⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd6642x.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
                      *                                                       *
                      *********************************************************
              */
              
              #define LCD_MSB_SHIFT       (8-LCD_LSB_SHIFT)
              
              /* Define number of used coms/segments per controller */
              #define LCD_NUM_SEGS0 (LCD_LASTSEG0-LCD_FIRSTSEG0+1)
              #define LCD_NUM_COMS0 (LCD_LASTCOM0-LCD_FIRSTCOM0+1)
              #if (LCD_NUM_CONTROLLERS >1)
                #define LCD_NUM_SEGS1 (LCD_LASTSEG1-LCD_FIRSTSEG1+1)
                #define LCD_NUM_COMS1 (LCD_LASTCOM1-LCD_FIRSTCOM1+1)
C51 COMPILER V8.05a   LCD6642X                                                             04/11/2008 14:19:24 PAGE 6   

              #endif
              
              /* Define total number of used coms/segments */
              #if (LCD_NUM_CONTROLLERS ==1)
                #define LCD_NUM_SEGS LCD_NUM_SEGS0
                #define LCD_NUM_COMS LCD_NUM_COMS0
              #elif (LCD_NUM_CONTROLLERS ==2)
                #define LCD_NUM_SEGS (LCD_NUM_SEGS0+LCD_NUM_SEGS1)
                #define LCD_NUM_COMS (LCD_NUM_COMS0+LCD_NUM_COMS1)
              #endif
              
              #define LCD_MEMSIZE ((LCD_BITSPERPIXEL*LCD_VXSIZE/LCD_BUSWIDTH)*(LCD_VYSIZE+LCD_NUM_EMPTY_LINES))
              
              #define LCD_NUM_PAGES (LCD_NUM_COMS+7)/8
              
              /*
                      *********************************************************
                      *                                                       *
                      *      Configuration switch checking                    *
                      *                                                       *
                      *********************************************************
              
              Please be aware that not all configuration errors can be captured !
              
              */
              
              /* Check number of controllers */
              #if ((LCD_NUM_CONTROLLERS >1) || (LCD_NUM_CONTROLLERS <0))
                #error "More than 1 controller not supported by this driver"
              #endif
              
              #if (!defined(LCD_INIT_R00)) | (!defined(LCD_INIT_R01))
                #error You have to define init values in the configuration for Registers 0,1
                       /* Drivers needs to know as these values can not be read back ! */
              #endif
              
              
              /*********************************************************************
              *
              *           Static variables
              *
              **********************************************************************
              */
              
              static struct {
                U8 ConReg0;
                U8 ConReg1;
                U8 x,y;
                #if LCD_CACHE
                  U8 aaVMem[MAX_COMS][MAX_SEGS/4];  /* video memory */
                #endif
              } aState[LCD_NUM_CONTROLLERS];
              
              /*
                      *********************************************************
                      *                                                       *
                      *              Macros, standard                         *
                      *                                                       *
                      *********************************************************
              
              These macros can be found in any LCD-driver as they serve purposes
              that can be found in any class of LCD-driver.
C51 COMPILER V8.05a   LCD6642X                                                             04/11/2008 14:19:24 PAGE 7   

              */
              
              #if (!LCD_SWAP_XY) && (!LCD_MIRROR_X) && (!LCD_MIRROR_Y)
                #define LOG2PHYS(x,y) x,y
              #elif (!LCD_SWAP_XY) && (!LCD_MIRROR_X) && (LCD_MIRROR_Y)
                #define LOG2PHYS(x,y) x,LCD_YSIZE_PHYS-1-(y)
              #elif (!LCD_SWAP_XY) && (LCD_MIRROR_X) && (!LCD_MIRROR_Y)
                #define LOG2PHYS(x,y) LCD_XSIZE_PHYS-1-(x),y
              #elif (!LCD_SWAP_XY) && (LCD_MIRROR_X) && (LCD_MIRROR_Y)
                #define LOG2PHYS(x,y) LCD_XSIZE_PHYS-1-(x),LCD_YSIZE_PHYS-1-(y)
              #elif (LCD_SWAP_XY) && (!LCD_MIRROR_X) && (!LCD_MIRROR_Y)
                #define LOG2PHYS(x,y) y,x
              #elif (LCD_SWAP_XY) && (LCD_MIRROR_X) && (!LCD_MIRROR_Y)
                #define LOG2PHYS(x,y) y,LCD_XSIZE-1-(x)
              #elif (LCD_SWAP_XY) && (!LCD_MIRROR_X) && (LCD_MIRROR_Y)
                #define LOG2PHYS(x,y) LCD_YSIZE-1-(y),x
              #elif (LCD_SWAP_XY) && (LCD_MIRROR_X) && (LCD_MIRROR_Y)
                #define LOG2PHYS(x,y) LCD_YSIZE-1-(y),LCD_XSIZE-1-(x)
              #else
                #error unsupported configuration
              #endif
              
              /*
                      *********************************************************
                      *                                                       *
                      *       Macros for internal use                         *
                      *                                                       *
                      *********************************************************
              */
              
              #if (LCD_SUPPORT_COMTRANS)
                #if (LCD_MIRROR_Y)
                  #error LCD_MIRROR_Y not supported with COMTrans !
                #endif
                #if (LCD_MIRROR_X)
                  #error LCD_MIRROR_X not supported with COMTrans !
                #endif
              #endif
              
              #define XORPIXEL_DATA(x, y,c)  XorPixel_Data(x,y,c)
              
              #if (!LCD_SUPPORT_COMTRANS && !LCD_SUPPORT_SEGTRANS)
                #define SETPIXEL(x, y, c)  _SetPixel(x, y, c)
                #define GETPIXEL(x, y)     _GetPixel(x,y)
                #define XORPIXEL(x, y)     XorPixel(x,y)
                #define XORPIXEL_DATA(x, y,c)  XorPixel_Data(x,y,c)
              #elif (LCD_SUPPORT_COMTRANS && !LCD_SUPPORT_SEGTRANS)
                #if (!LCD_SWAP_XY)
                  #define SETPIXEL(x, y, c)  _SetPixel(x,LCD__aLine2Com0[y], c)
                  #define GETPIXEL(x, y)     _GetPixel(x,LCD__aLine2Com0[y])
                  #define XORPIXEL(x, y)      XorPixel(x,LCD__aLine2Com0[y])
                #else
                  #define SETPIXEL(x, y, c)  _SetPixel(y,LCD__aLine2Com0[x], c)
                  #define GETPIXEL(x, y)     _GetPixel(y,LCD__aLine2Com0[x])
                  #define XORPIXEL(x, y)      XorPixel(y,LCD__aLine2Com0[x])
                #endif
              #elif (!LCD_SUPPORT_COMTRANS && LCD_SUPPORT_SEGTRANS)
                #if (!LCD_SWAP_XY)
                  #define SETPIXEL(x, y, c)  _SetPixel(LCD__aRow2Seg0[x],y, c)
                  #define GETPIXEL(x, y)     _GetPixel(LCD__aRow2Seg0[x],y)
                  #define XORPIXEL(x, y)      XorPixel(LCD__aRow2Seg0[x],y)
                #else
C51 COMPILER V8.05a   LCD6642X                                                             04/11/2008 14:19:24 PAGE 8   

                  #define SETPIXEL(x, y, c)  _SetPixel(LCD__aRow2Seg0[y],x, c)
                  #define GETPIXEL(x, y)     _GetPixel(LCD__aRow2Seg0[y],x)
                  #define XORPIXEL(x, y)      XorPixel(LCD__aRow2Seg0[y],x)
                #endif
              #elif (LCD_SUPPORT_COMTRANS && LCD_SUPPORT_SEGTRANS)
                #if (!LCD_SWAP_XY)
                  #define SETPIXEL(x, y, c)  _SetPixel(LCD__aRow2Seg0[x],LCD__aLine2Com0[y], c)
                  #define GETPIXEL(x, y)     _GetPixel(LCD__aRow2Seg0[x],LCD__aLine2Com0[y])
                  #define XORPIXEL(x, y)      XorPixel(LCD__aRow2Seg0[x],LCD__aLine2Com0[y])
                #else
                  #define SETPIXEL(x, y, c)  _SetPixel(LCD__aRow2Seg0[y],LCD__aLine2Com0[x], c)
                  #define GETPIXEL(x, y)     _GetPixel(LCD__aRow2Seg0[y],LCD__aLine2Com0[x])
                  #define XORPIXEL(x, y)      XorPixel(LCD__aRow2Seg0[y],LCD__aLine2Com0[x])
                #endif
              #else
                #error This combination of switches not yet supported
              #endif
              
              /*
                      *********************************************************
                      *                                                       *
                      *       Next pixel routines                             *
                      *                                                       *
                      *********************************************************
              */
              
              
              /*
                      *********************************************************
                      *                                                       *
                      *                   LCD_SetPaletteEntry                 *
                      *                                                       *
                      *********************************************************
              
              */
              
              void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color) {
                Pos=Pos;
                color=color;
              }
              
              /*
              ********************************************************************
              *
              *           Hardware access routines
              *
              ********************************************************************
              */
              
              /* Write into controller 0 */
              void LCD_WriteReg0(int Reg, U8 Data) {
                LCD_WRITE_REG00(Reg);
                LCD_WRITE_REG01(Data);
              }
              
              #if LCD_NUM_CONTROLLERS > 1
              void LCD_WriteReg1(int Reg, U8 Data) {
                LCD_WRITE_REG10(Reg);
                LCD_WRITE_REG11(Data);
              }
              #endif
              
C51 COMPILER V8.05a   LCD6642X                                                             04/11/2008 14:19:24 PAGE 9   

              /*
                ********************************************************************
                *                                                                  *
                *                  Hardware access, register level                 *
                *                                                                  *
                *           Write Page / Column                                    *
                *                                                                  *
                ********************************************************************
              
               The following routines are used for all access to the
               LCD-controller(s).
              
              */
              
              #define SET_X_INCREMENT()                    \
                aState[0].ConReg1 = (LCD_INIT_R01) | ( 2); \
                LCD_WriteReg0( 1, aState[0].ConReg1)
              
              #define SET_Y_INCREMENT()                    \
                aState[0].ConReg1 = (LCD_INIT_R01) & (~2); \
                LCD_WriteReg0( 1, aState[0].ConReg1)
              
              #define SET_X0(xNew) \
                if (aState[0].x != xNew) \
                { LCD_WRITE_REG00(2); LCD_WRITE_REG01(xNew); aState[0].x = xNew; }
              
              #define SET_Y0(yNew) \
                if (aState[0].y != yNew) \
                { LCD_WRITE_REG00(3); LCD_WRITE_REG01(yNew); aState[0].y = yNew; }
              
              #define EXEC_INCREMENT()        \
                if (aState[0].ConReg1 & 1<<1) \
                  aState[0].x++;              \
                else                          \
                  aState[0].y++
              
              #if LCD_CACHE
                #define WRITE_VMEM0(Data) {     \
                  aState[0].aaVMem[aState[0].y][aState[0].x] = Data; \
                  LCD_WRITE_REG00(4);           \
                  LCD_WRITE_REG01(Data);        \
                  EXEC_INCREMENT();             \
                }
              #else
                #define WRITE_VMEM0(Data) {     \
                  LCD_WRITE_REG00(4);           \
                  LCD_WRITE_REG01(Data);        \
                  EXEC_INCREMENT();             \
                }
              #endif
              
              #if LCD_CACHE
                #define READ_VMEM0(Data)  {     \
                  Data = aState[0].aaVMem[aState[0].y][aState[0].x]; \
                }
              #else
                #define READ_VMEM0(Data)  {     \
                  LCD_WRITE_REG00(4);           \
                  LCD_READ_REG01(Data);         \
                  LCD_READ_REG01(Data);         \
                }
              #endif
C51 COMPILER V8.05a   LCD6642X                                                             04/11/2008 14:19:24 PAGE 10  

              
              /*
                      *********************************************************
                      *                                                       *
                      *       Internal set pixel routines                     *
                      *                                                       *
                      *********************************************************
              */
              
              static U8 aAndMask[4] = {255-(3<<6), 255-(3<<4), 255-(3<<2), 255-(3<<0)};
              
              static void _SetPixel0_Phys(int x, int y, PIXELCOLOR c) {
                U8 Data;
                int xByte = x>>2;
                int Pos = x&3;
                #if LCD_CACHE ==0
                  SET_X0(xByte);
                  SET_Y0(y);
                  READ_VMEM0(Data);
                  Data &= aAndMask[Pos];
                  Data |= c<<(6-(Pos<<1));
                  WRITE_VMEM0(Data);
                #else
                  U8* pData = &aState[0].aaVMem[y][xByte];
                  Data = *pData & aAndMask[Pos];
                  Data |= c<<(6-(Pos<<1));
                  if (Data != *pData) {
                    SET_X0(xByte);
                    SET_Y0(y);
                    WRITE_VMEM0(Data);
                  }
                #endif
              }
              
              #define _SetPixel(x,y,c)     _SetPixel0_Phys(LOG2PHYS((x-LCD_XORG0),(y-LCD_YORG0)), c)
              
              static PIXELCOLOR _GetPixel0(int x, int y) {
                int xByte = x>>2;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -