📄 lcd13xx.c
字号:
{
U16 c;
READ_MEM(Off,c);
c ^= 0xff;
WRITE_MEM(Off,c);
}
}
else {
for (;Rem>=4;Off+=4,Rem-=4)
{
WRITE_MEM(Off,COLOR);
WRITE_MEM(Off+1,COLOR);
WRITE_MEM(Off+2,COLOR);
WRITE_MEM(Off+3,COLOR);
}
for (; (--Rem)>=0; Off++)
{
WRITE_MEM(Off,COLOR);
}
}
}
#undef X0
}
/*
*********************************************************
* *
* LCD_L0_DrawHLine optimized *
* *
* 8 bit bus, 4 bpp *
* *
*********************************************************
*/
#elif (LCD_OPTIMIZE) \
&& (!LCD_SWAP_XY) \
&& (!LCD_MIRROR_Y) \
&& (LCD_BUSWIDTH==8) \
&& (!defined (LCD_LUT_SEG)) \
&& (LCD_BITSPERPIXEL == 4)
void LCD_L0_DrawHLine (int x0, int y, int x1)
{
#if LCD_MIRROR_X
#define X0 (LCD_XSIZE-1-(x1))
#else
#define X0 x0
#endif
if (x0>x1) return;
{
register tOff Off;
register int Rem;
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
{
for (; (x0&1) &&(x0<=x1); x0++)
{
XORPIXEL(x0, y);
}
for (; ((x1&1)!=1)&&(x0<=x1); x1--)
{
XORPIXEL(x1, y);
}
Off = XY2OFF(X0,y);
Rem = (x1-x0+2)>>1;
for (; Rem--; Off++)
{
U16 c;
READ_MEM(Off,c);
c ^= 0xff;
WRITE_MEM(Off,c);
}
}
else {
U8 col = COLOR+(COLOR<<4);
/* Draw pixels left of fill area */
for (; (x0&1) && (x0<=x1); x0++)
{
SETPIXEL(x0, y, COLOR);
}
/* Draw pixels right of fill area */
for (; ((x1+1)&1)&&(x0<=x1); x1--)
{
SETPIXEL(x1, y, COLOR);
}
Off = XY2OFF(X0,y);
Rem = (x1-x0+2)>>1;
for (; Rem--; Off++)
{
WRITE_MEM(Off,col);
}
}
}
#undef X0
}
/*
*********************************************************
* *
* LCD_L0_DrawHLine optimized *
* *
* 8 bit bus, 1 bpp *
* *
*********************************************************
*/
#elif (LCD_OPTIMIZE) \
&& (!LCD_SWAP_XY) \
&& (!LCD_MIRROR_Y) \
&& (!LCD_MIRROR_X) \
&& (LCD_BUSWIDTH==8) \
&& (!defined (LCD_LUT_SEG)) \
&& (LCD_BITSPERPIXEL == 1)
void LCD_L0_DrawHLine (int x0, int y, int x1)
{
register tOff Off = XY2OFF(x0,y);
int iByte = x0>>3;
int Byte1 = x1>>3;
U8 Mask = 0xff >> (x0&7);
U8 EndMask = 0xff80 >> (x1&7);
U8 Data;
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
{
for (; iByte<Byte1; iByte++)
{
READ_MEM(Off,Data);
Data ^= Mask;
WRITE_MEM(Off,Data);
Mask = 0xff;
Off++;
}
Mask &= EndMask;
READ_MEM(Off,Data);
Data ^= Mask;
WRITE_MEM(Off,Data);
}
else { /* Clear pixels in line */
int NumBytes = Byte1-iByte;
if (COLOR==0)
{
if (NumBytes)
{
READ_MEM(Off,Data);
Data &= (~Mask);
WRITE_MEM(Off,Data);
Off++; NumBytes--;
/* Fill bytes in 2 loops for speed reasons ... */
for (; NumBytes>=4; NumBytes-=4, Off+=4)
{
WRITE_MEM(Off,0);
WRITE_MEM(Off+1,0);
WRITE_MEM(Off+2,0);
WRITE_MEM(Off+3,0);
}
for (; NumBytes; NumBytes--, Off++)
{
WRITE_MEM(Off,0);
}
Mask = 0xff;
}
Mask &= EndMask;
READ_MEM(Off,Data);
Data &= ~Mask;
WRITE_MEM(Off,Data);
}
else { /* Set pixels in line */
if (NumBytes)
{
READ_MEM(Off,Data);
Data |= Mask;
WRITE_MEM(Off,Data);
Off++; NumBytes--;
/* Fill bytes in 2 loops for speed reasons ... */
for (; NumBytes>=4; NumBytes-=4, Off+=4)
{
WRITE_MEM(Off, 0xff);
WRITE_MEM(Off+1,0xff);
WRITE_MEM(Off+2,0xff);
WRITE_MEM(Off+3,0xff);
}
for (; NumBytes; NumBytes--, Off++)
{
WRITE_MEM(Off,0xff);
}
Mask = 0xff;
}
Mask &= EndMask;
READ_MEM(Off,Data);
Data |= Mask;
WRITE_MEM(Off,Data);
}
}
}
/*
*********************************************************
* *
* LCD_L0_DrawHLine unoptimized *
* *
*********************************************************
*/
#else /* Unoptimized variant */
void LCD_L0_DrawHLine (int x0, int y, int x1)
{
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
{
while (x0 <= x1)
{
XORPIXEL(x0, y);
x0++;
}
}
else {
while (x0 <= x1)
{
SETPIXEL(x0, y, COLOR);
x0++;
}
}
}
#endif
/********************************************************
* *
* LCD_L0_DrawVLine optimized *
* *
* 16 bit bus, using BITBLT *
* *
*********************************************************
*/
#if (LCD_USE_BITBLT) \
&& (!LCD_SWAP_XY) \
&& (LCD_BUSWIDTH==16) \
&& (!defined (LCD_LUT_COM)) \
&& (!defined (LCD_LUT_SEG)) \
&& ((LCD_CONTROLLER == 1356)||(LCD_CONTROLLER == 13806))
void LCD_L0_DrawVLine (int x, int y0, int y1)
{
#if LCD_MIRROR_X
#define X0 (LCD_XSIZE-1-(x))
#else
#define X0 x
#endif
#if LCD_MIRROR_Y
#define Y0 (LCD_YSIZE-1-(y1))
#define Y1 (LCD_YSIZE-1-(y0))
#else
#define Y0 y0
#define Y1 y1
#endif
if (y0>y1) return;
LCD_FillRectBB(X0,Y0,X0,Y1);
#undef X0
#undef Y0
#undef Y1
}
/********************************************************
* *
* LCD_L0_DrawVLine optimized *
* *
* 8 bit bus, 4 bpp, SWAP_XY, MIRROR_Y *
* *
*********************************************************
*/
#elif (LCD_OPTIMIZE) \
&& (LCD_SWAP_XY) \
&& (LCD_MIRROR_Y) \
&& (LCD_BUSWIDTH==8) \
&& (!defined (LCD_LUT_COM)) \
&& (!defined (LCD_LUT_SEG)) \
&& (LCD_BITSPERPIXEL == 4)
void LCD_L0_DrawVLine (int x, int y0, int y1)
{
#if !LCD_MIRROR_X
int y_P = x;
#else
int y_P = (LCD_XSIZE-1-(x1));
#endif
#if !LCD_MIRROR_Y
int x0_P = y0;
int x1_P = y1;
#else
int x0_P = (LCD_YSIZE-1-(y1));
int x1_P = (LCD_YSIZE-1-(y0));
#endif
register tOff Off = XY2OFF(x0_P, y_P);
register int Rem;
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
{
if (x0_P & 3)
{
while (x0_P <= x1_P)
{
XorPixel(x0_P++, y_P);
}
}
if ((x1_P + 1) & 3)
{
while (x1_P >= x0_P)
{
XorPixel(x1_P--, y_P);
}
}
Rem = (x1_P - x0_P + 1) >> 1;
for (; Rem-- > 0; Off++)
{
U8 Contents;
READ_MEM(Off,Contents);
Contents ^= 0xff;
WRITE_MEM(Off,Contents);
}
}
else {
U8 col = COLOR+(COLOR<<4);
if (x0_P & 3)
{
while (x0_P <= x1_P)
{
_SetPixel(x0_P++, y_P, COLOR);
}
}
if ((x1_P + 1) & 3)
{
while (x1_P >= x0_P)
{
_SetPixel(x1_P--, y_P, COLOR);
}
}
Rem = (x1_P - x0_P + 1) >> 1;
for (; Rem-- > 0; Off++)
{
WRITE_MEM(Off,col);
}
}
#if 0
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
{
//for (; y0<=y1; y0++) XORPIXEL(x0, y0);
}
else {
U8 col = COLOR+(COLOR<<4);
/* Draw pixels left of fill area */
for (; (x0_P&1) && (x0_P<=x1_P); x0_P++)
{
_SetPixel(x0_P, y_P, COLOR);
}
/* Draw pixels right of fill area */
for (; ((x1_P+1)&1)&&(x0_P<=x1_P); x1_P--)
{
_SetPixel(x0_P, y_P, COLOR);
}
Rem = (x1_P+1-x0_P)>>1;
for (; Rem--; Off++)
{
WRITE_MEM(Off,col);
}
}
#endif
}
/*
*********************************************************
* *
* LCD_L0_DrawVLine optimized *
* *
* 16 bit bus, 4 bpp, SWAP_XY *
* *
*********************************************************
*/
#elif (LCD_OPTIMIZE) \
&& (LCD_SWAP_XY) \
&& (!defined (LCD_LUT_COM)) \
&& (!defined (LCD_LUT_SEG)) \
&& (LCD_BITSPERPIXEL == 4) \
&& (LCD_BUSWIDTH==16)
void LCD_L0_DrawVLine (int x, int y0, int y1)
{
int y_P = x;
#if (!LCD_MIRROR_Y) && (!LCD_MIRROR_X)
int x0_P = y0;
int x1_P = y1;
#else
int x0_P = (LCD_YSIZE-1-(y1));
int x1_P = (LCD_YSIZE-1-(y0));
#endif
register tOff Off;
register int Rem;
if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
{
if (x0_P & 3)
while ((x0_P <= x1_P) && (x0_P & 3))
{
XorPixel(x0_P++, y_P);
}
if ((x1_P + 1) & 3)
{
while ((x1_P >= x0_P) && ((x1_P + 1) & 3))
{
XorPixel(x1_P--, y_P);
}
}
Off = XY2OFF(x0_P, y_P);
Rem = (x1_P - x0_P + 3) >> 2;
for (; Rem-- > 0; Off++)
{
U16 Contents;
Contents = LCD_READ_MEM(Off);
Contents ^= 0xffff;
LCD_WRITE_MEM(Off,Contents);
}
}
else {
U16 col = COLOR+(COLOR<<4)+(COLOR<<8)+(COLOR<<12);
if (x0_P & 3)
{
while ((x0_P <= x1_P) && (x0_P & 3))
{
_SetPixel(x0_P++, y_P, COLOR);
}
}
if ((x1_P + 1) & 3)
{
while ((x1_P >= x0_P) && ((x1_P + 1) & 3))
{
_SetPixel(x1_P--, y_P, COLOR);
}
}
Off = XY2OFF(x0_P, y_P);
Rem = (x1_P - x0_P + 3) >> 2;
for (; Rem-- > 0; Off++)
{
LCD_WRITE_MEM(Off,col);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -