?? lcd15xx.c
字號:
DataR_Valid= 0xff; /* All bits are valid. */
#if (LCD_NUM_CONTROLLERS == 1)
DataR_Cache= ReadVMem0();
#else
switch (CurController) {
case 0:
DataR_Cache= ReadVMem0(); break;
case 1:
DataR_Cache= ReadVMem1(); break;
#if (LCD_NUM_CONTROLLERS >2)
case 2:
DataR_Cache= ReadVMem2(); break;
#endif
#if (LCD_NUM_CONTROLLERS >3)
case 3:
DataR_Cache= ReadVMem3(); break;
#endif
}
#endif /* LCD_NUM_CONTROLLERS == 1 */
}
#endif
#if (LCD_NUM_CONTROLLERS > 1)
typedef void (tWriteVMem)(void);
tWriteVMem* aWriteVMemX[] = {
WriteVMem0,WriteVMem1
#if (LCD_NUM_CONTROLLERS >2)
,WriteVMem2
#endif
#if (LCD_NUM_CONTROLLERS >3)
,WriteVMem3
#endif
};
#endif
static void Flush(void) {
/* Nothing to write ? Then we are done !*/
if (DataW_Dirty==0)
return;
/* All bits are dirty ? Then write`em all, dont read !!*/
if (DataW_Dirty!=0xff) {
/* Only some are dirty ... We have to read the byte ! */
if (!DataR_Valid) {
ReadData(); /* Get current byte in our cache */
}
DataW_Cache &= DataW_Dirty;
DataW_Cache |= DataR_Cache & (~DataW_Dirty);
}
DataR_Cache = DataW_Cache;
#if (LCD_NUM_CONTROLLERS == 1)
WriteVMem0();
#else
aWriteVMemX[CurController]();
#endif
DataW_Dirty = 0; /* No more bits to write */
}
/*
*****************************************
* *
* Find Byte *
* *
*****************************************
Due to the setup options reg. the area of the display which is covered
by one LCD-controller and the fact that different display controllers
can controll arbitrary areas of the display as defined in the
config-file, It can be a tricky job to find out which display
controller is concerned, where in the video memory of that particular
controller the byte is located and how many bits are left (i.e. what
the minimal and maximal physical y-position is).
Note that this job is a lot easier in a single controller system,
where the entire routine could be placed in a macro.
*/
#if (LCD_SUPPORT_SEGTRANS==0)
#define CALCCOL(Con) Col = DataCacheX-LCD_XORG##Con
#else
#define CALCCOL(Con) Col = LCD__aRow2Seg##Con[DataCacheX-LCD_XORG##Con]
#endif
#if (LCD_SUPPORT_COMTRANS==0)
#define CALCY(Con) \
DataCacheY0 = DataCacheY &(~7); \
DataCacheY1 = DataCacheY0+ 7; \
Page = (DataCacheY0-LCD_YORG##Con)>>3
#else
#define CALCY(Con) \
DataCacheY1 = DataCacheY0 = DataCacheY; \
{ \
int Com = LCD__aLine2Com##Con[DataCacheY-LCD_YORG##Con]; \
Page = Com>>3; \
DataCacheYBit0 = DataCacheY-(Com&7); \
}
#endif
#define IF_INLEFT(Con) if (DataCacheX >= LCD_XORG##Con)
#define IF_INRIGHT(Con) if (DataCacheX <= LCD_XORG##Con+LCD_NUM_SEGS##Con-1)
#define IF_INTOP(Con) if (DataCacheY >= LCD_YORG##Con)
#define IF_INBOTTOM(Con) if (DataCacheY <= LCD_YORG##Con+LCD_NUM_COMS##Con-1)
#define IF_INAREA(Con) \
IF_INRIGHT(Con) \
IF_INLEFT(Con) \
IF_INTOP(Con) \
IF_INBOTTOM(Con)
#define CALCXY(Con) \
CALCCOL(Con); \
CALCY(Con); \
pCacheByte = &Cache##Con[Page][Col]; \
CurController = Con;
/* This is an optimization for a single controller system */
#if (LCD_NUM_CONTROLLERS == 1)
#define FindByte() \
CALCCOL(0); CALCY(0); pCacheByte = &Cache0[Page][Col];
/* CALCCOL(0); CALCY(0); pCacheByte = &Cache0[Page][Col-LCD_FIRSTSEG0];*/
#endif
/* This is an optimization for a 2 controller system */
#if (LCD_NUM_CONTROLLERS == 2)
#if (LCD_XORG0==LCD_XORG1)
#undef IF_INAREA
#if (LCD_YORG0 == LCD_YORG)
#define IF_INAREA(Con) IF_INBOTTOM(Con)
#else
#define IF_INAREA(Con) IF_INTOP(Con)
#endif
#define FindByte() IF_INAREA(0) { CALCXY(0); } else { CALCXY(1); }
#endif
#endif
/* The actual routine ... */
#ifndef FindByte
static void FindByte(void) {
#if (LCD_NUM_CONTROLLERS > 1)
/* Check if controller 0 is concerned */
IF_INAREA(0)
{
CALCXY(0);
return;
}
/* Check if controller 1 is concerned, but only
in a system with more than 2 controllers */
#if (LCD_NUM_CONTROLLERS > 2)
IF_INAREA(1)
#endif
{
CALCXY(1);
return;
}
/* Check if controller 2 is concerned */
#if (LCD_NUM_CONTROLLERS > 3)
#if (LCD_NUM_CONTROLLERS > 3)
IF_INAREA(2)
#endif
{
CALCXY(2);
return;
}
#endif
/* Check if controller 3 is concerned */
#if (LCD_NUM_CONTROLLERS >3)
#if (LCD_NUM_CONTROLLERS >4)
IF_INAREA(3)
#endif
{
CALCXY(3);
return;
}
#endif
/* This should never happen ! */
#endif
}
#endif
/*
*****************************************
* *
* Set new Position *
* *
*****************************************
*/
static void Goto(void) {
U8* pCacheByteTemp[2];
U8 PageTemp[2];
U8 ColTemp[2];
#if (LCD_NUM_CONTROLLERS > 1)
U8 CurControllerTemp[2];
#endif
DataR_Valid=0; /* No info about what's in the data byte */
if (DataW_Dirty == 0) {
FindByte();
return;
}
/* Save the current values because FindByte will overwrite them */
pCacheByteTemp[0] = pCacheByte;
PageTemp[0] = Page;
ColTemp[0] = Col;
#if (LCD_NUM_CONTROLLERS > 1)
CurControllerTemp[0] = CurController;
#endif
FindByte();
if (pCacheByteTemp[0] != pCacheByte) {
/* Save the new values */
pCacheByteTemp[1] = pCacheByte;
PageTemp[1] = Page;
ColTemp[1] = Col;
#if (LCD_NUM_CONTROLLERS > 1)
CurControllerTemp[1] = CurController;
#endif
/* Restore the old values for writing */
pCacheByte = pCacheByteTemp[0];
Page = PageTemp[0];
Col = ColTemp[0];
#if (LCD_NUM_CONTROLLERS > 1)
CurController = CurControllerTemp[0];
#endif
Flush();
/* Restore the new (current) values */
pCacheByte = pCacheByteTemp[1];
Page = PageTemp[1];
Col = ColTemp[1];
DataR_Valid=0; /* We have no more info about what's in the data byte */
#if (LCD_NUM_CONTROLLERS > 1)
CurController = CurControllerTemp[1];
#endif
}
}
/*
*****************************************
* *
* Set X and Y- Position *
* *
*****************************************
Check if we already have the right byte in the buffer.
This works only if COM-Lines are straight, otherwise it is just
a waste of CPU-time.
*/
#if (LCD_SUPPORT_COMTRANS)
#define GotoXY(x,y) \
DataCacheY = y; \
DataCacheX = x; \
Goto()
#else
static void GotoXY(int x, int y) {
DataCacheY = y;
if ((x == DataCacheX) &&
(y >= DataCacheY0) && (y <= DataCacheY1))
{
return;
}
DataCacheX = x;
Goto();
}
#endif
/*
*****************************************
* *
* Set Y- Position *
* *
*****************************************
*/
#if (!LCD_SUPPORT_COMTRANS) /* Only used if COMs are straight ! */
static void GotoY(int y) {
/* Check if we already have the right byte in the buffer.
This works only if COM-Lines are straight, otherwise it is just
a waste of CPU-time.
*/
DataCacheY = y;
if ((y >= DataCacheY0) && (y <= DataCacheY1))
return;
Goto();
}
#endif
#if (LCD_SUPPORT_COMTRANS)
#define GotoYPlus1() \
DataCacheY++; \
Goto()
#else
static void GotoYPlus1(void) {
DataCacheY++;
if ((DataCacheY >= DataCacheY0) && (DataCacheY <= DataCacheY1))
return;
Goto();
}
#endif
/*
********************************************************************
* *
* Drawing routines, internal *
* *
********************************************************************
*/
static const U8 Bit2Mask[] = { 1,2,4,8,16,32,64,128 };
/*
*****************************************
* *
* Xor pixel *
* *
*****************************************
*/
/*
static void XORPIXEL() {
U8 HWMask;
LOADDATA();
HWMask = Bit2Mask[DataCacheY-DataCacheYBit0];
DataW_Dirty |= HWMask;
DataW_Cache ^= HWMask;
}
*/
#define XORPIXEL() { \
U8 HWMask;\
LOADDATA(); /* For XOR operations, the byte needs to be loaded */ \
HWMask = Bit2Mask[DataCacheY-DataCacheYBit0];\
DataW_Dirty |= HWMask;\
DataW_Cache ^= HWMask;\
}
static void XorPixel(void) {
XORPIXEL();
}
/*
*****************************************
* *
* Set pixel, internal drawing *
* *
*****************************************
*/
/*
static void SETPIXEL() {
U8 HWMask;
HWMask = Bit2Mask[DataCacheY-DataCacheYBit0];
DataW_Dirty |= HWMask;
DataW_Cache |= HWMask;
}
*/
#define SETPIXEL() { \
U8 HWMask; \
HWMask = Bit2Mask[DataCacheY-DataCacheYBit0]; \
DataW_Dirty |= HWMask; \
DataW_Cache |= HWMask; \
}
static void SetPixel(void) {
SETPIXEL();
}
/*
*********************************************************
* *
* 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) {
GotoXY(x,y);
LOADDATA();
XORPIXEL();
}
/*
*****************************************
* *
* Clear pixel *
* *
*****************************************
*/
/*
static v
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -