mirror of
https://gitee.com/Polarix/simplegui.git
synced 2025-06-18 14:07:53 +00:00
1.增加VirtualSDK的灰度显示支持
2.废弃SGUI_COLOR枚举,将SGUI_COLOR_TRANS调整至-1,SGUI_COLOR_FRGCLR弃用,SGUI_COLOR_BKGCLR保留转为宏定义 3.切换SGUI_COLOR为SGUI_INT16,使其能够保存256阶灰度的情况下同时支持负数的透明色 4.修复绘制圆形中的一些问题 5.调整基础绘图中与灰度显示不兼容的部分 6.修改基础绘图示例,增加灰度显示示例
This commit is contained in:
parent
39563bec4b
commit
3030207e10
@ -1,4 +1,4 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/** Copyright. **/
|
/** Copyright. **/
|
||||||
/** FileName: RTCNotice.c **/
|
/** FileName: RTCNotice.c **/
|
||||||
/** Author: Polarix **/
|
/** Author: Polarix **/
|
||||||
@ -65,10 +65,17 @@ HMI_ENGINE_RESULT HMI_DemoBasic_RefreshScreen(SGUI_SCR_DEV* pstDeviceIF, const v
|
|||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
SGUI_Basic_DrawLine(pstDeviceIF, 0, 10, 96, 10, SGUI_COLOR_FRGCLR);
|
SGUI_Basic_DrawRectangle(pstDeviceIF, 5, 16, 40, 40, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS);
|
||||||
SGUI_Basic_DrawRectangle(pstDeviceIF, 5, 5, 50, 50, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS);
|
SGUI_Basic_DrawCircle(pstDeviceIF, 30, 30, 12, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR);
|
||||||
SGUI_Basic_DrawCircle(pstDeviceIF, 32, 32, 20, SGUI_COLOR_FRGCLR, SGUI_COLOR_FRGCLR);
|
SGUI_Basic_DrawCircle(pstDeviceIF, 96, 40, 20, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS);
|
||||||
SGUI_Basic_DrawCircle(pstDeviceIF, 96, 32, 20, SGUI_COLOR_FRGCLR, SGUI_COLOR_TRANS);
|
|
||||||
|
// GrayScale Demos
|
||||||
|
SGUI_Basic_DrawLine(pstDeviceIF, 0, 2, 50, 2, 0x02);
|
||||||
|
SGUI_Basic_DrawLine(pstDeviceIF, 0, 4, 60, 4, 0x04);
|
||||||
|
SGUI_Basic_DrawLine(pstDeviceIF, 0, 6, 70, 6, 0x06);
|
||||||
|
SGUI_Basic_DrawLine(pstDeviceIF, 0, 8, 80, 8, 0x08);
|
||||||
|
SGUI_Basic_DrawLine(pstDeviceIF, 0, 10, 90, 10, 0x0B);
|
||||||
|
SGUI_Basic_DrawLine(pstDeviceIF, 0, 12, 100, 12, 0x0E);
|
||||||
return HMI_RET_NORMAL;
|
return HMI_RET_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "DemoProc.h"
|
#include "DemoProc.h"
|
||||||
|
|
||||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||||
|
#include "Common.h"
|
||||||
#include "SDKInterface.h"
|
#include "SDKInterface.h"
|
||||||
#include "SGUI_FontResource.h"
|
#include "SGUI_FontResource.h"
|
||||||
#else
|
#else
|
||||||
@ -82,8 +83,9 @@ HMI_ENGINE_RESULT InitializeHMIEngineObj(void)
|
|||||||
SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT));
|
SGUI_SystemIF_MemorySet(&g_stDemoEngine, 0x00, sizeof(HMI_ENGINE_OBJECT));
|
||||||
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
#ifdef _SIMPLE_GUI_IN_VIRTUAL_SDK_
|
||||||
/* Initialize display size. */
|
/* Initialize display size. */
|
||||||
g_stDeviceInterface.stSize.iWidth = 128;
|
g_stDeviceInterface.stSize.iWidth = PARAM_DEFAULT_PIXEL_NUM_H;
|
||||||
g_stDeviceInterface.stSize.iHeight = 64;
|
g_stDeviceInterface.stSize.iHeight = PARAM_DEFAULT_PIXEL_NUM_V;
|
||||||
|
g_stDeviceInterface.uiDepthBits = PARAM_DEFAULT_PIXEL_DEPTH;
|
||||||
/* Initialize interface object. */
|
/* Initialize interface object. */
|
||||||
g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel;
|
g_stDeviceInterface.fnSetPixel = SGUI_SDK_SetPixel;
|
||||||
g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel;
|
g_stDeviceInterface.fnGetPixel = SGUI_SDK_GetPixel;
|
||||||
|
@ -61,6 +61,15 @@ typedef SGUI_UINT32 SGUI_ROM_ADDRESS;
|
|||||||
#define SGUI_FALSE (0)
|
#define SGUI_FALSE (0)
|
||||||
#define SGUI_TRUE (!SGUI_FALSE)
|
#define SGUI_TRUE (!SGUI_FALSE)
|
||||||
|
|
||||||
|
#define SGUI_COLOR_TRANS (-1)
|
||||||
|
/******
|
||||||
|
* Deprecated!
|
||||||
|
* Prepared to delete this guy!
|
||||||
|
* DO NOT USE THIS MACRO ANY MORE!
|
||||||
|
*/
|
||||||
|
#define SGUI_COLOR_FRGCLR (0x0A)
|
||||||
|
#define SGUI_COLOR_BKGCLR (0)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
SGUI_INT iX;
|
SGUI_INT iX;
|
||||||
@ -87,12 +96,7 @@ typedef struct
|
|||||||
SGUI_INT iMax;
|
SGUI_INT iMax;
|
||||||
}SGUI_RANGE;
|
}SGUI_RANGE;
|
||||||
|
|
||||||
typedef enum
|
typedef SGUI_INT16 SGUI_COLOR ;
|
||||||
{
|
|
||||||
SGUI_COLOR_BKGCLR = 0,
|
|
||||||
SGUI_COLOR_FRGCLR = 1,
|
|
||||||
SGUI_COLOR_TRANS = 2,
|
|
||||||
}SGUI_COLOR;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -127,6 +131,8 @@ typedef struct
|
|||||||
{
|
{
|
||||||
//Screen display area size in pixel.
|
//Screen display area size in pixel.
|
||||||
SGUI_AREA_SIZE stSize;
|
SGUI_AREA_SIZE stSize;
|
||||||
|
// Screen display pixel depth in bit count(eg. 4(bits) means 16 grayscale)
|
||||||
|
SGUI_UINT8 uiDepthBits;
|
||||||
//Bitmap data buffer.
|
//Bitmap data buffer.
|
||||||
SGUI_BYTE arrBmpDataBuffer[SGUI_BMP_DATA_BUFFER_SIZE];
|
SGUI_BYTE arrBmpDataBuffer[SGUI_BMP_DATA_BUFFER_SIZE];
|
||||||
//Engine & device initialize function.
|
//Engine & device initialize function.
|
||||||
|
@ -41,13 +41,9 @@ void SGUI_Basic_DrawPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiCoordinateX, SG
|
|||||||
{
|
{
|
||||||
/* Action function is unspecified, no actions. */
|
/* Action function is unspecified, no actions. */
|
||||||
}
|
}
|
||||||
else if(SGUI_COLOR_FRGCLR == eColor)
|
else
|
||||||
{
|
{
|
||||||
pstDeviceIF->fnSetPixel(uiCoordinateX, uiCoordinateY, 1);
|
pstDeviceIF->fnSetPixel(uiCoordinateX,uiCoordinateY,eColor);
|
||||||
}
|
|
||||||
else if(SGUI_COLOR_BKGCLR == eColor)
|
|
||||||
{
|
|
||||||
pstDeviceIF->fnSetPixel(uiCoordinateX, uiCoordinateY, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,13 +64,11 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiCoordinate
|
|||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
SGUI_COLOR eColor;
|
SGUI_COLOR eColor;
|
||||||
SGUI_UINT uiPixValue;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
eColor = SGUI_COLOR_BKGCLR;
|
eColor = SGUI_COLOR_BKGCLR;
|
||||||
uiPixValue = 0;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
@ -87,15 +81,7 @@ SGUI_COLOR SGUI_Basic_GetPoint(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiCoordinate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiPixValue = pstDeviceIF->fnGetPixel(uiCoordinateX, uiCoordinateY);
|
eColor = pstDeviceIF->fnGetPixel(uiCoordinateX, uiCoordinateY);
|
||||||
if(0 == uiPixValue)
|
|
||||||
{
|
|
||||||
eColor = SGUI_COLOR_BKGCLR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
eColor = SGUI_COLOR_FRGCLR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,15 +426,16 @@ void SGUI_Basic_DrawCircle(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiCx, SGUI_UINT
|
|||||||
// Fill the circle
|
// Fill the circle
|
||||||
if((uiRadius > 1) && (eFillColor != SGUI_COLOR_TRANS) && (uiPosXOffset_Old != uiPosXOffset))
|
if((uiRadius > 1) && (eFillColor != SGUI_COLOR_TRANS) && (uiPosXOffset_Old != uiPosXOffset))
|
||||||
{
|
{
|
||||||
|
|
||||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx-uiPosXOffset, uiCy-uiYOffset+1, uiCx-uiPosXOffset, uiCy+uiYOffset-1, eFillColor);
|
SGUI_Basic_DrawLine(pstDeviceIF, uiCx-uiPosXOffset, uiCy-uiYOffset+1, uiCx-uiPosXOffset, uiCy+uiYOffset-1, eFillColor);
|
||||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx+uiPosXOffset, uiCy-uiYOffset+1, uiCx+uiPosXOffset, uiCy+uiYOffset-1, eFillColor);
|
SGUI_Basic_DrawLine(pstDeviceIF, uiCx+uiPosXOffset, uiCy-uiYOffset+1, uiCx+uiPosXOffset, uiCy+uiYOffset-1, eFillColor);
|
||||||
uiPosXOffset_Old = uiPosXOffset;
|
uiPosXOffset_Old = uiPosXOffset;
|
||||||
}
|
}
|
||||||
|
if ((uiRadius > 1) && (eFillColor != SGUI_COLOR_TRANS) && (uiYOffset_Old != uiYOffset))
|
||||||
|
{
|
||||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx-uiYOffset, uiCy-uiPosXOffset+1, uiCx-uiYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
SGUI_Basic_DrawLine(pstDeviceIF, uiCx-uiYOffset, uiCy-uiPosXOffset+1, uiCx-uiYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
||||||
SGUI_Basic_DrawLine(pstDeviceIF, uiCx+uiYOffset, uiCy-uiPosXOffset+1, uiCx+uiYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
SGUI_Basic_DrawLine(pstDeviceIF, uiCx+uiYOffset, uiCy-uiPosXOffset+1, uiCx+uiYOffset, uiCy+uiPosXOffset-1, eFillColor);
|
||||||
uiYOffset_Old = uiYOffset;
|
uiYOffset_Old = uiYOffset;
|
||||||
|
}
|
||||||
// Draw edge.
|
// Draw edge.
|
||||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiCx+uiPosXOffset, uiCy+uiYOffset, eEdgeColor);
|
SGUI_Basic_DrawPoint(pstDeviceIF, uiCx+uiPosXOffset, uiCy+uiYOffset, eEdgeColor);
|
||||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiCx-uiPosXOffset, uiCy+uiYOffset, eEdgeColor);
|
SGUI_Basic_DrawPoint(pstDeviceIF, uiCx-uiPosXOffset, uiCy+uiYOffset, eEdgeColor);
|
||||||
@ -490,6 +477,8 @@ void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiStartX,
|
|||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
SGUI_UINT i_W, i_H;
|
SGUI_UINT i_W, i_H;
|
||||||
|
SGUI_COLOR clsOriginColor;
|
||||||
|
SGUI_UINT16 uiDepthTotal=1<<pstDeviceIF->uiDepthBits;
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Process */
|
/* Process */
|
||||||
@ -498,14 +487,8 @@ void SGUI_Basic_ReverseBlockColor(SGUI_SCR_DEV* pstDeviceIF, SGUI_UINT uiStartX,
|
|||||||
{
|
{
|
||||||
for(i_H=0; i_H<uiHeight; i_H++)
|
for(i_H=0; i_H<uiHeight; i_H++)
|
||||||
{
|
{
|
||||||
if(SGUI_Basic_GetPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H) == SGUI_COLOR_FRGCLR)
|
clsOriginColor=SGUI_Basic_GetPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H);
|
||||||
{
|
SGUI_Basic_DrawPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H, uiDepthTotal-clsOriginColor);
|
||||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H, SGUI_COLOR_BKGCLR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SGUI_Basic_DrawPoint(pstDeviceIF, uiStartX+i_W, uiStartY+i_H, SGUI_COLOR_FRGCLR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
# SimpleGUI
|
# Simple(Gray)GUI
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
**注意:当前项目正在经历从单色屏幕到灰度屏支持的变更,可能存在意想不到的Bug,如您需要在项目中使用SimpleGUI,请移步[SimpleGUI](https://gitee.com/Polarix/simplegui)官方仓库!**
|
||||||
|
|
||||||
#### 简介
|
#### 简介
|
||||||
SimpleGUI是一款针对单色显示屏设计的GUI接口库。
|
SimpleGUI是一款针对单色显示屏设计的GUI接口库。
|
||||||
>
|
>
|
||||||
|
@ -28,12 +28,20 @@
|
|||||||
#define LCD_COLOR_OBJ_PIX (0xFF258562)
|
#define LCD_COLOR_OBJ_PIX (0xFF258562)
|
||||||
#define LCD_COLOR_OBJ_BKG (0xFF2BEEDE)
|
#define LCD_COLOR_OBJ_BKG (0xFF2BEEDE)
|
||||||
#define LCD_COLOR_OBJ_GRID (0xFF38E3D0)
|
#define LCD_COLOR_OBJ_GRID (0xFF38E3D0)
|
||||||
|
// White LCD
|
||||||
|
/*
|
||||||
|
#define LCD_COLOR_OBJ_PIX (0xFFFFFFFF)
|
||||||
|
#define LCD_COLOR_OBJ_BKG (0x00000000)
|
||||||
|
#define LCD_COLOR_OBJ_GRID (0xFFCC1209)
|
||||||
|
*/
|
||||||
|
|
||||||
#define PARAM_DEFAULT_PIXEL_NUM_H (128)
|
#define PARAM_DEFAULT_PIXEL_NUM_H (128)
|
||||||
#define PARAM_DEFAULT_PIXEL_NUM_V (64)
|
#define PARAM_DEFAULT_PIXEL_NUM_V (64)
|
||||||
#define PARAM_DEFAULT_PANEL_BORDER_WIDTH (8)
|
#define PARAM_DEFAULT_PANEL_BORDER_WIDTH (8)
|
||||||
#define PARAM_DEFAULT_PIXEL_WIDTH (3)
|
#define PARAM_DEFAULT_PIXEL_WIDTH (3)
|
||||||
#define PARAM_DEFAULT_PIXEL_HEIGHT (3)
|
#define PARAM_DEFAULT_PIXEL_HEIGHT (3)
|
||||||
|
#define PARAM_DEFAULT_PIXEL_DEPTH_BITS (4)
|
||||||
|
#define PARAM_DEFAULT_PIXEL_DEPTH (1<<PARAM_DEFAULT_PIXEL_DEPTH_BITS)
|
||||||
#define PARAM_DEFAULT_GRID_ENABLE (true)
|
#define PARAM_DEFAULT_GRID_ENABLE (true)
|
||||||
#define PARAM_DEFAULT_GRID_DISABLE (false)
|
#define PARAM_DEFAULT_GRID_DISABLE (false)
|
||||||
|
|
||||||
@ -46,6 +54,7 @@ typedef struct
|
|||||||
size_t VerticalPixelNumber;
|
size_t VerticalPixelNumber;
|
||||||
size_t PixelUnitWidth;
|
size_t PixelUnitWidth;
|
||||||
size_t PixelUnitHeight;
|
size_t PixelUnitHeight;
|
||||||
|
int PixelUnitDepth;
|
||||||
size_t BorderWidth;
|
size_t BorderWidth;
|
||||||
bool EnableGrid;
|
bool EnableGrid;
|
||||||
unsigned int PanelColor;
|
unsigned int PanelColor;
|
||||||
|
@ -27,5 +27,6 @@ void SetLCDPanelParameter(PixelPanelParameter* pstParameter)
|
|||||||
pstParameter->PanelColor = LCD_COLOR_OBJ_BKG;
|
pstParameter->PanelColor = LCD_COLOR_OBJ_BKG;
|
||||||
pstParameter->PixelColor = LCD_COLOR_OBJ_PIX;
|
pstParameter->PixelColor = LCD_COLOR_OBJ_PIX;
|
||||||
pstParameter->GridColor = LCD_COLOR_OBJ_GRID;
|
pstParameter->GridColor = LCD_COLOR_OBJ_GRID;
|
||||||
|
pstParameter->PixelUnitDepth = PARAM_DEFAULT_PIXEL_DEPTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ class wxLCD: public wxLCDBase
|
|||||||
private:
|
private:
|
||||||
wxColour m_clsPixelHColour;
|
wxColour m_clsPixelHColour;
|
||||||
wxColour m_clsPixelLColour;
|
wxColour m_clsPixelLColour;
|
||||||
|
wxColour* m_clsPixelPalette;
|
||||||
|
int m_iPixelDepth;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ class wxLCD: public wxLCDBase
|
|||||||
void CleanScreen(void);
|
void CleanScreen(void);
|
||||||
void SetPanelColour(const wxColour& clsPanelColour, bool bRefreshNow = true);
|
void SetPanelColour(const wxColour& clsPanelColour, bool bRefreshNow = true);
|
||||||
void SetPixelColour(const wxColour& clsPixelColour, bool bRefreshNow = true);
|
void SetPixelColour(const wxColour& clsPixelColour, bool bRefreshNow = true);
|
||||||
|
void SetPixelDepth(const int depth);
|
||||||
|
|
||||||
// Prepare to remove.
|
// Prepare to remove.
|
||||||
void SetParameter(PixelPanelParameter* pstPanelParameter);
|
void SetParameter(PixelPanelParameter* pstPanelParameter);
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
//= Include files. =//
|
//= Include files. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
#include "wxLCD.h"
|
#include "wxLCD.h"
|
||||||
|
#include "SGUI_Typedef.h"
|
||||||
|
#include <math.h>
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
//= Function define. =//
|
//= Function define. =//
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
@ -17,6 +18,7 @@ wxLCDBase(pclsParent, iWinID, clsPosition, clsSizeInPixel)
|
|||||||
{
|
{
|
||||||
m_clsPixelLColour.Set(0x00000000);
|
m_clsPixelLColour.Set(0x00000000);
|
||||||
m_clsPixelHColour.Set(0x00000000);
|
m_clsPixelHColour.Set(0x00000000);
|
||||||
|
m_clsPixelPalette=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLCD::~wxLCD(void)
|
wxLCD::~wxLCD(void)
|
||||||
@ -56,32 +58,111 @@ void wxLCD::SetPixelColour(const wxColour& clsPixelColour, bool bRefreshNow)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxLCD::SetPixelDepth(const int depth)
|
||||||
|
{
|
||||||
|
this->m_iPixelDepth=depth;
|
||||||
|
if(this->m_clsPixelPalette != NULL)
|
||||||
|
{
|
||||||
|
free(m_clsPixelPalette);
|
||||||
|
m_clsPixelPalette=NULL;
|
||||||
|
}
|
||||||
|
// Generate a scaled Palette bettween the BackgroundColor and PixelColor
|
||||||
|
m_clsPixelPalette = new wxColor[depth];
|
||||||
|
unsigned char ucRH=this->m_clsPixelHColour.Red();
|
||||||
|
unsigned char ucGH=this->m_clsPixelHColour.Green();
|
||||||
|
unsigned char ucBH=this->m_clsPixelHColour.Blue();
|
||||||
|
|
||||||
|
unsigned char ucRL=m_clsPixelLColour.Red();
|
||||||
|
unsigned char ucGL=m_clsPixelLColour.Green();
|
||||||
|
unsigned char ucBL=m_clsPixelLColour.Blue();
|
||||||
|
|
||||||
|
double dbRDiff=(ucRH-ucRL)*1.0/depth;
|
||||||
|
double dbGDiff=(ucGH-ucGL)*1.0/depth;
|
||||||
|
double dbBDiff=(ucBH-ucBL)*1.0/depth;
|
||||||
|
|
||||||
|
double dbR=(int)ucRL*1.0;
|
||||||
|
double dbG=(int)ucGL*1.0;
|
||||||
|
double dbB=(int)ucBL*1.0;
|
||||||
|
|
||||||
|
for(int i=0; i<depth; i++)
|
||||||
|
{
|
||||||
|
dbR+=dbRDiff;
|
||||||
|
dbG+=dbGDiff;
|
||||||
|
dbB+=dbBDiff;
|
||||||
|
m_clsPixelPalette[i]=wxColor((unsigned char)floor(dbR+0.5),(unsigned char)floor(dbG+0.5),(unsigned char)floor(dbB+0.5));
|
||||||
|
}
|
||||||
|
}
|
||||||
int wxLCD::GetPixel(const int iX, const int iY)
|
int wxLCD::GetPixel(const int iX, const int iY)
|
||||||
{
|
{
|
||||||
int iReturn;
|
int iReturn=-1;
|
||||||
|
int iLeft=0;
|
||||||
|
int iRight=m_iPixelDepth-1;
|
||||||
|
int iMid=(iLeft+iRight)/2;
|
||||||
|
wxColor clsLeftColor,clsRightColor;
|
||||||
|
wxColor clsTargetColor=GetPixelUnitColor(iX, iY);
|
||||||
|
wxColor clsMidColor;
|
||||||
|
|
||||||
if(WX_LCD_PIX_RGB(GetPixelUnitColor(iX, iY)) == WX_LCD_PIX_RGB(m_clsPixelHColour.GetRGBA()))
|
while(iLeft<iRight)
|
||||||
{
|
{
|
||||||
iReturn = 1;
|
iMid=(iLeft+iRight)/2;
|
||||||
}
|
clsLeftColor=m_clsPixelPalette[iLeft];
|
||||||
else
|
clsMidColor=m_clsPixelPalette[iMid];
|
||||||
|
clsRightColor=m_clsPixelPalette[iRight];
|
||||||
|
// use Red to search
|
||||||
|
if((clsLeftColor.Red()<=clsTargetColor.Red() && clsTargetColor.Red()<clsMidColor.Red()) ||
|
||||||
|
(clsLeftColor.Red()>=clsTargetColor.Red() && clsTargetColor.Red()>clsMidColor.Red()))
|
||||||
{
|
{
|
||||||
iReturn = 0;
|
iRight=iMid-1;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
else if((clsRightColor.Red()>=clsTargetColor.Red() && clsTargetColor.Red()>clsMidColor.Red())||
|
||||||
|
(clsRightColor.Red()<=clsTargetColor.Red() && clsTargetColor.Red()<clsMidColor.Red()))
|
||||||
|
{
|
||||||
|
iLeft=iMid+1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// use Green to search
|
||||||
|
if((clsLeftColor.Green()<=clsTargetColor.Green() && clsTargetColor.Green()<clsMidColor.Green()) ||
|
||||||
|
(clsLeftColor.Green()>=clsTargetColor.Green() && clsTargetColor.Green()>clsMidColor.Green()))
|
||||||
|
{
|
||||||
|
iRight=iMid-1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if((clsRightColor.Green()>=clsTargetColor.Green() && clsTargetColor.Green()>clsMidColor.Green())||
|
||||||
|
(clsRightColor.Green()<=clsTargetColor.Green() && clsTargetColor.Green()<clsMidColor.Green()))
|
||||||
|
{
|
||||||
|
iLeft=iMid+1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// use Blue to search
|
||||||
|
if((clsLeftColor.Blue()<=clsTargetColor.Blue() && clsTargetColor.Blue()<clsMidColor.Blue()) ||
|
||||||
|
(clsLeftColor.Blue()>=clsTargetColor.Blue() && clsTargetColor.Blue()>clsMidColor.Blue()))
|
||||||
|
{
|
||||||
|
iRight=iMid-1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if((clsRightColor.Blue()>=clsTargetColor.Blue() && clsTargetColor.Blue()>clsMidColor.Blue())||
|
||||||
|
(clsRightColor.Blue()<=clsTargetColor.Blue() && clsTargetColor.Blue()<clsMidColor.Blue()))
|
||||||
|
{
|
||||||
|
iLeft=iMid+1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// iMid is the target color
|
||||||
|
iReturn=iMid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(iReturn==-1 && iLeft==iRight)
|
||||||
|
iReturn=iLeft;
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLCD::SetPixel(const int iX, const int iY, const int iValue)
|
void wxLCD::SetPixel(const int iX, const int iY, const int iValue)
|
||||||
{
|
{
|
||||||
if(1 == iValue)
|
int iCheckedValue;
|
||||||
{
|
iCheckedValue = SGUI_MIN_OF(iValue,m_iPixelDepth-1);
|
||||||
SetPixelUnitColor(iX, iY, m_clsPixelHColour);
|
iCheckedValue = SGUI_MAX_OF(iCheckedValue,0);
|
||||||
}
|
|
||||||
else
|
SetPixelUnitColor(iX,iY,m_clsPixelPalette[iCheckedValue]);
|
||||||
{
|
|
||||||
SetPixelUnitColor(iX, iY, m_clsPixelLColour);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxLCD::CleanScreen(void)
|
void wxLCD::CleanScreen(void)
|
||||||
@ -101,6 +182,7 @@ void wxLCD::SetParameter(PixelPanelParameter* pstPanelParameter)
|
|||||||
SetPixelColour(wxColor(pstPanelParameter->PixelColor), false);
|
SetPixelColour(wxColor(pstPanelParameter->PixelColor), false);
|
||||||
SetPanelColour(wxColor(pstPanelParameter->PanelColor), false);
|
SetPanelColour(wxColor(pstPanelParameter->PanelColor), false);
|
||||||
SetGridColor(wxColor(pstPanelParameter->GridColor));
|
SetGridColor(wxColor(pstPanelParameter->GridColor));
|
||||||
|
SetPixelDepth(pstPanelParameter->PixelUnitDepth);
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,9 @@
|
|||||||
<Unit filename="../../../DemoProc/src/Basic.c">
|
<Unit filename="../../../DemoProc/src/Basic.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
<Unit filename="../../../DemoProc/src/Curve.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
<Unit filename="../../../DemoProc/src/DemoProc.c">
|
<Unit filename="../../../DemoProc/src/DemoProc.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
Loading…
Reference in New Issue
Block a user