新手上路
- 积分
- 39
- 金钱
- 39
- 注册时间
- 2015-3-18
- 在线时间
- 3 小时
|

楼主 |
发表于 2015-12-29 15:50:00
|
显示全部楼层
本帖最后由 guobo123 于 2015-12-29 15:52 编辑
#include "LCD_Private.h" /* private modul definitions & config */
#include "GUI_Private.h"
#include "GUIDebug.h"
#include "lcdx.h"
int LCD_L0_Init(void)
{
NT5510_Initializtion();
return 0;
}
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR Color)
{
GUI_USE_PARA(Pos);
GUI_USE_PARA(Color);
}
void LCD_L0_SetOrg(int x, int y)
{
GUI_USE_PARA(x);
GUI_USE_PARA(y);
}
void LCD_L0_SetPixelIndex(int x, int y, int PixelIndex)
{
LCD_DrawPoint1(x,y,PixelIndex);
}
void LCD_L0_DrawHLine (int x0, int y, int x1)
{
GUI_Line(x0,y,x1,y,LCD_COLORINDEX);//这个参数有问题,这是ucgui源码里面定义的
}
void LCD_L0_DrawVLine (int x, int y0, int y1)
{
GUI_Line(x,y0,x,y1,LCD_COLORINDEX);
}
void LCD_L0_FillRect(int x0, int y0, int x1, int y1)
{
#if !LCD_SWAP_XY
for (; y0 <= y1; y0++)
{
LCD_L0_DrawHLine(x0,y0, x1);
}
#else
for (; x0 <= x1; x0++)
{
LCD_L0_DrawVLine(x0,y0, y1);
}
#endif
}
static void _DrawBitLine1BPP(int x, int y, U8 const GUI_UNI_PTR *p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
LCD_PIXELINDEX Index0 = *(pTrans+0);
LCD_PIXELINDEX Index1 = *(pTrans+1);
x += Diff;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
do {
LCD_L0_SetPixelIndex(x++, y, (*p & (0x80 >> Diff)) ? Index1 : Index0);
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
case LCD_DRAWMODE_TRANS:
do {
if (*p & (0x80 >> Diff))
LCD_L0_SetPixelIndex(x, y, Index1);
x++;
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
case LCD_DRAWMODE_XOR:;
do {
if (*p & (0x80 >> Diff)) {
int Pixel = LCD_L0_GetPixelIndex(x, y);
LCD_L0_SetPixelIndex(x, y, LCD_NUM_COLORS - 1 - Pixel);
}
x++;
if (++Diff == 8) {
Diff = 0;
p++;
}
} while (--xsize);
break;
}
}
/*******************************
*
* Draw Bitmap 2 BPP
*/
#if (LCD_MAX_LOG_COLORS > 2)
static void _DrawBitLine2BPP(int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX Pixels = *p;
int CurrentPixel = Diff;
x += Diff;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
if (pTrans) {
do {
int Shift = (3 - CurrentPixel) << 1;
int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
LCD_L0_SetPixelIndex(x++, y, PixelIndex);
if (++CurrentPixel == 4) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
} else {
do {
int Shift = (3 - CurrentPixel) << 1;
int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
LCD_L0_SetPixelIndex(x++, y, Index);
if (++CurrentPixel == 4) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
}
break;
case LCD_DRAWMODE_TRANS:
if (pTrans) {
do {
int Shift = (3 - CurrentPixel) << 1;
int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
if (Index) {
LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
LCD_L0_SetPixelIndex(x, y, PixelIndex);
}
x++;
if (++CurrentPixel == 4) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
} else {
do {
int Shift = (3 - CurrentPixel) << 1;
int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
if (Index) {
LCD_L0_SetPixelIndex(x, y, Index);
}
x++;
if (++CurrentPixel == 4) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
}
break;
}
}
#endif
/*******************************
*
* Draw Bitmap 4 BPP
*/
#if (LCD_MAX_LOG_COLORS > 4)
static void _DrawBitLine4BPP(int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX Pixels = *p;
int CurrentPixel = Diff;
x += Diff;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
if (pTrans) {
do {
int Shift = (1 - CurrentPixel) << 2;
int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
LCD_L0_SetPixelIndex(x++, y, PixelIndex);
if (++CurrentPixel == 2) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
} else {
do {
int Shift = (1 - CurrentPixel) << 2;
int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
LCD_L0_SetPixelIndex(x++, y, Index);
if (++CurrentPixel == 2) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
}
break;
case LCD_DRAWMODE_TRANS:
if (pTrans) {
do {
int Shift = (1 - CurrentPixel) << 2;
int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
if (Index) {
LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
LCD_L0_SetPixelIndex(x, y, PixelIndex);
}
x++;
if (++CurrentPixel == 2) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
} else {
do {
int Shift = (1 - CurrentPixel) << 2;
int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
if (Index) {
LCD_L0_SetPixelIndex(x, y, Index);
}
x++;
if (++CurrentPixel == 2) {
CurrentPixel = 0;
Pixels = *(++p);
}
} while (--xsize);
}
break;
}
}
#endif
/*******************************
*
* Draw Bitmap 8 BPP
*/
#if (LCD_MAX_LOG_COLORS > 16)
static void _DrawBitLine8BPP(int x, int y, U8 const GUI_UNI_PTR * p, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX Pixel;
switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
case 0:
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
LCD_L0_SetPixelIndex(x, y, *p);
}
}
break;
case LCD_DRAWMODE_TRANS:
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
if (Pixel) {
LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
}
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
Pixel = *p;
if (Pixel) {
LCD_L0_SetPixelIndex(x, y, Pixel);
}
}
}
break;
}
}
#endif
/*******************************
*
* Draw Bitmap 16 BPP
*/
#if (LCD_BITSPERPIXEL > 8)
static void DrawBitLine16BPP(int x, int y, U16 const GUI_UNI_PTR * p, int xsize, const LCD_PIXELINDEX * pTrans) {
LCD_PIXELINDEX pixel;
if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) == 0) {
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
LCD_L0_SetPixelIndex(x, y, *(pTrans + pixel));
}
} else {
for (;xsize > 0; xsize--, x++, p++) {
LCD_L0_SetPixelIndex(x, y, *p);
}
}
} else {
if (pTrans) {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
if (pixel) {
LCD_L0_SetPixelIndex(x, y, *(pTrans + pixel));
}
}
} else {
for (; xsize > 0; xsize--, x++, p++) {
pixel = *p;
if (pixel) {
LCD_L0_SetPixelIndex(x, y, pixel);
}
}
}
}
}
#endif
void LCD_L0_DrawBitmap (int x0, int y0,
int xsize, int ysize,
int BitsPerPixel,
int BytesPerLine,
const U8* pData, int Diff,
const LCD_PIXELINDEX* pTrans)
{
int i;
/* Use _DrawBitLineXBPP */
for (i=0; i<ysize; i++) {
switch (BitsPerPixel) {
case 1:
_DrawBitLine1BPP(x0, i + y0, pData, Diff, xsize, pTrans);
break;
#if (LCD_MAX_LOG_COLORS > 2)
case 2:
_DrawBitLine2BPP(x0, i + y0, pData, Diff, xsize, pTrans);
break;
#endif // ×÷Õß:ÄaÔöo£
#if (LCD_MAX_LOG_COLORS > 4)
case 4:
_DrawBitLine4BPP(x0, i + y0, pData, Diff, xsize, pTrans);
break;
#endif
#if (LCD_MAX_LOG_COLORS > 16)
case 8:
_DrawBitLine8BPP(x0, i + y0, pData, xsize, pTrans);
break;
#endif
#if (LCD_BITSPERPIXEL > 8)
case 16:
DrawBitLine16BPP(x0, i + y0, (const U16 *)pData, xsize, pTrans);
break;
#endif
}
pData += BytesPerLine;
}
}
void LCD_L0_On(void)
{
#ifdef LCD_ON
LCD_ON();
#endif
}
void LCD_Off (void) {
#ifdef LCD_OFF
LCD_OFF();
#endif
}
void LCD_L0_XorPixel(int x, int y)
{
LCD_PIXELINDEX PixelIndex = LCD_ReadPoint( x,y);
LCD_DrawPoint1(x, y, LCD_NUM_COLORS - PixelIndex - 1);
}
unsigned int LCD_L0_GetPixelIndex(int x, int y)
{
return LCD_ReadPoint( x,y);
}
|
|