📄 lcd07x1.lst
字号:
*/
#if (LCD_FIXEDPALETTE==0)
static const LCD_COLOR PhysColors[] = {
#if (LCD_REVERSE)
#if (LCD_BITSPERPIXEL == 1) /* black/white */
0xffffff, 0x000000
#elif (LCD_BITSPERPIXEL == 2) /* 4 gray scales */
0xffffff, 0xaaaaaa, 0x555555, 0x000000
#endif
#else
#if (LCD_BITSPERPIXEL == 1) /* black/white */
0x000000, 0xffffff
#elif (LCD_BITSPERPIXEL == 2) /* 4 gray scales */
0x000000, 0x555555, 0xaaaaaa, 0xffffff
#endif
#endif
};
#endif
/*
*********************************************************
* *
* LCD_SetPaletteEntry *
* *
*********************************************************
*/
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color) {
Pos=Pos;
color=color;
}
/*
*********************************************************
* *
* ID translation table *
* *
*********************************************************
This table contains 0, 1, 2, ... and serves as translation table for DDBs
*/
#define INTS(Base) Base+0,Base+1,Base+2,Base+3,Base+4,Base+5, \
Base+6,Base+7,Base+8,Base+9,Base+10,Base+11, \
Base+12,Base+13,Base+14,Base+15
static const PIXELCOLOR TransId[] = {
INTS(0*16)
C51 COMPILER V8.05a LCD07X1 04/11/2008 14:19:22 PAGE 11
};
/*
********************************************************************
* *
* Hardware access, register level *
* *
* Write Page / Column *
* *
********************************************************************
The following routines are used for all access to the
LCD-controller(s).
*/
static U8 PageCache, ColCache; /* Page / column of cache byte */
/*
*****************************************
* *
* Set Column routines *
* *
*****************************************
These routines set the page-register of their respective
LCD-controller. Note that page is not what you might imagine,
but is a section of the controllers internal video RAM.
For details, please refer to the datasheet.
*/
#define SETCOL(col) { \
if (ColCache != col) { \
U8 temp_NewCol = 0x0+(col&15); /* Set low nibble */ \
LCD_WRITECMD(temp_NewCol); /* Send low nibble */ \
temp_NewCol = 0x10+(col>>4); /* Set high nibble */ \
LCD_WRITECMD(temp_NewCol); /* Send high nibble */ \
ColCache = col; \
} \
}
void SetCol(U8 col) {
SETCOL(col);
}
#define SETCOL_IF_NEEDED(c) { if (c != ColCache) SETCOL(c); }
/*
*****************************************
* *
* Set Page routines *
* *
*****************************************
These routines set the page-register of their respective
LCD-controller. Note that page is not what you might imagine,
but is a section of the controllers internal video RAM.
For details, please refer to the datasheet.
C51 COMPILER V8.05a LCD07X1 04/11/2008 14:19:22 PAGE 12
*/
#define SETPAGE(p) { \
U8 temp_NewPage; \
if (PageCache != p) { \
PageCache = p; \
temp_NewPage = 0xb0+ PageCache; \
LCD_WRITECMD(temp_NewPage); \
} \
}
#define SETPAGE_IF_NEEDED(p) { if (p != PageCache) SETPAGE(p); }
void SetPage(U8 p) {
SETPAGE(p);
}
#define WRITE_VMEM_PAIR(page, col, ptr) { \
if (!CacheLocked) { \
SETPAGE_IF_NEEDED(page); \
SETCOL_IF_NEEDED(col); \
LCD_WRITEMDATA(ptr,2); \
ColCache++; \
} else { \
aCacheDirty[page] = CacheStat=1; \
} \
}
/*
*********************************************************
* *
* Internal set pixel routines *
* *
*********************************************************
*/
static void _SetPixel(int x, int y, PIXELCOLOR c) {
U8 page = (y+LCD_FIRSTSEG0)>>3;
U8 mask = 1<<((y+LCD_FIRSTSEG0)&7);
U8 aData[2];
U8* pCache = &Cache[page][x][0];
/* Read data from cache into 2 byte array */
aData[0] = *pCache;
aData[1] = *(pCache+1);
/* Write Data into array */
if (c&(1<<1))
aData[0] |= mask;
else
aData[0] &= ~mask;
if (c&(1<<0))
aData[1] |= mask;
else
aData[1] &= ~mask;
/* Check if we need to write */
if ((*pCache == aData[0]) && (*(pCache+1) == aData[1]))
return;
/* Write modified data back into cache */
*pCache = aData[0];
*(pCache+1) = aData[1];
/* Write data from cache into 2 byte array */
C51 COMPILER V8.05a LCD07X1 04/11/2008 14:19:22 PAGE 13
WRITE_VMEM_PAIR(page, x, &aData[0]);
}
static PIXELCOLOR _GetPixel(int x, int y) {
PIXELCOLOR col=0;
U8 page = (y+LCD_FIRSTSEG0)>>3;
U8 mask = 1<<((y+LCD_FIRSTSEG0)&7);
if (Cache[page][x][0] & mask)
col|=(1<<1);
if (Cache[page][x][1] & mask)
col|=(1<<0);
return col;
}
static void XorPixel (int x, int y) {
PIXELCOLOR Index = _GetPixel(x,y);
_SetPixel(x,y, LCD_NUM_COLORS-1-Index);
}
static void XorPixel_Data(int x, int y, PIXELCOLOR c) {
PIXELCOLOR Index = _GetPixel(x,y);
_SetPixel(x,y,Index^c);
}
/*
*********************************************************
* *
* LCD_GetPixelIndex *
* *
*********************************************************
*/
unsigned LCD_L0_GetPixelIndex(int x, int y) {
return GETPIXEL(x,y);
/*return _GetPixel(x,y);*/
}
/*
*********************************************************
* *
* LCD_L0_XorPixel *
* *
*********************************************************
Purpose: This routine is called by emWin. It writes 1 pixel into the
display.
*/
void LCD_L0_XorPixel(int x, int y) {
XORPIXEL(x, y);
}
/*
*********************************************************
* *
* LCD_L0_SetPixelIndex *
* *
*********************************************************
Purpose: This routine is called by emWin. It writes 1 pixel into the
display.
C51 COMPILER V8.05a LCD07X1 04/11/2008 14:19:22 PAGE 14
*/
void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex) {
SETPIXEL(x, y, ColorIndex);
}
/*
*********************************************************
* *
* LCD_L0_DrawHLine unoptimized *
* *
*********************************************************
*/
void LCD_L0_DrawHLine (int x0, int y, int x1) {
LCD_KICK_WATCHDOG();
if (LCD_DrawMode & LCD_DRAWMODE_XOR) {
while (x0 <= x1) {
XORPIXEL(x0, y);
x0++;
}
} else {
while (x0 <= x1) {
SETPIXEL(x0, y, COLOR);
x0++;
}
}
}
/*
*********************************************************
* *
* LCD_L0_DrawVLine no optimization *
* *
*********************************************************
*/
void LCD_L0_DrawVLine (int x, int y0, int y1) {
LCD_KICK_WATCHDOG();
if (LCD_DrawMode & LCD_DRAWMODE_XOR) {
while (y0 <= y1) {
XORPIXEL(x, y0);
y0++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -