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

📄 lcd15xx.c

📁 lpc2478+ucosII+ucgui源码
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif
#if (LCD_NUM_COMS < LCD_YSIZE_P)
  #error Please check com setup of controller 0 and X/YSIZE !!!
#endif

/*
  ********************************************************************
  *                                                                  *
  *       Standard variables for driver                              *
  *                                                                  *
  ********************************************************************
*/

#define BKCOLOR LCD_BKCOLORINDEX
#define   COLOR LCD_COLORINDEX

static LCD_RECT ClipRect;
#if LCD_SUPPORT_VERIFY
  static int ErrCnt;
  static int ErrStat;
#endif

/*
        *****************************************
        *                                       *
        *   Memory areas for caching (optional) *
        *                                       *
        *****************************************

The cache stores only the bytes actually used in every controller.
This is also the reason why different arrays are used for every
controller.
*/

#if LCD_CACHE
  /* Handle controller #0 */
  #define NUM_COMS0   (LCD_LASTCOM0-LCD_FIRSTCOM0+1)
  #define NUM_PAGES0  ((NUM_COMS0+7)/8)
  #define NUM_COLS0    (LCD_LASTSEG0-LCD_FIRSTSEG0+1)
  static U8 Cache0[NUM_PAGES0][NUM_COLS0];
/* Check configuration a bit to capture the worst mistakes ...  */
  #if (NUM_COLS0<LCD_NUM_SEGS0)
    #error Configuration error ! Please check LCD_LASTSEG0, LCD_FIRSTSEG0
  #endif
  #if (NUM_COMS0<LCD_NUM_COMS0)
    #error Configuration error ! Please check LCD_LASTCOM0, LCD_FIRSTCOM0
  #endif
  /* Handle controller #1 */
  #if (LCD_NUM_CONTROLLERS >1)
    #define NUM_COMS1   (LCD_LASTCOM1-LCD_FIRSTCOM1+1)
    #define NUM_PAGES1  ((NUM_COMS1+7)/8)
    #define NUM_COLS1    (LCD_LASTSEG1-LCD_FIRSTSEG1+1)
    static U8 Cache1[NUM_PAGES1][NUM_COLS1];
/* Check configuration a bit to capture the worst mistakes ...  */
    #if (NUM_COLS1<LCD_NUM_SEGS1)
      #error Configuration error ! Please check LCD_LASTSEG1, LCD_FIRSTSEG1
    #endif
    #if (NUM_COMS1<LCD_NUM_COMS1)
      #error Configuration error ! Please check LCD_LASTCOM1, LCD_FIRSTCOM1
    #endif
  #endif
  /* Handle controller #2 */
  #if (LCD_NUM_CONTROLLERS >2)
    #define NUM_PAGES2  ((LCD_LASTCOM2-LCD_FIRSTCOM2+1+7)/8)
    #define NUM_COLS2    (LCD_LASTSEG2-LCD_FIRSTSEG2+1)
    static U8 Cache2[NUM_PAGES2][NUM_COLS2];
  #endif
  /* Handle controller #3 */
  #if (LCD_NUM_CONTROLLERS >3)
    #define NUM_PAGES3  ((LCD_LASTCOM3-LCD_FIRSTCOM3+1+7)/8)
    #define NUM_COLS3    (LCD_LASTSEG3-LCD_FIRSTSEG3+1)
    static U8 Cache3[NUM_PAGES3][NUM_COLS3];
  #endif
#endif

/*
  ********************************************************************
  *                                                                  *
  *                Write Cache variables                             *
  *                                                                  *
  ********************************************************************
*/

#if  LCD_SUPPORT_CACHECONTROL
  static char CacheStat   =0;     /* 0: No changes */
  static char CacheLocked =0;     /* 0: Not locked */
  static U8   aaCacheDirtyTag0[NUM_PAGES0][(NUM_COLS0+7)/8];
  #if (LCD_NUM_CONTROLLERS >1)
    static U8   aaCacheDirtyTag1[NUM_PAGES1][(NUM_COLS1+7)/8];
  #endif
  #if (LCD_NUM_CONTROLLERS >2)
    static U8   aaCacheDirtyTag2[NUM_PAGES2][(NUM_COLS2+7)/8];
  #endif
  #if (LCD_NUM_CONTROLLERS >3)
    static U8   aaCacheDirtyTag3[NUM_PAGES3][(NUM_COLS3+7)/8];
  #endif
#endif

/*
  ********************************************************************
  *                                                                  *
  *                  Hardware access, low level                      *
  *                                                                  *
  *           Write Command/Data, Reset                              *
  *           Read  Command/data if possible (LCD readable)          *
  *                                                                  *
  ********************************************************************

  The following routines are used for all access to the
  LCD-controller(s).
*/

/* This macro can be used to check how much time is used up
   for management and how much for hardware access */
#ifdef LCD_TESTSPEED
  #undef  WRITE_DATA0
  #undef  WRITE_CMD0
  #undef  WRITE_DATA1
  #undef  WRITE_CMD1
  #define WRITE_DATA0(p0)
  #define WRITE_CMD0(p0)
  #define WRITE_DATA1(p0)
  #define WRITE_CMD1(p0)
#endif


        /****************************************
        *                                       *
        *        Write Data                     *
        *                                       *
        ****************************************/

static void LCD_WriteData0(char Data) {
  LCD_LOCK();
  WRITE_DATA0(Data);
  LCD_UNLOCK();
}

#if (LCD_NUM_CONTROLLERS >1)
static void LCD_WriteData1(char Data) {
  LCD_LOCK();
  WRITE_DATA1(Data);
  LCD_UNLOCK();
}
#endif

#if (LCD_NUM_CONTROLLERS >2)
static void LCD_WriteData2(char Data) {
  LCD_LOCK();
  LCD_WRITEDATA2(Data);
  LCD_UNLOCK();
}
#endif

#if (LCD_NUM_CONTROLLERS >3)
static void LCD_WriteData3(char Data) {
  LCD_LOCK();
  LCD_WRITEDATA3(Data);
  LCD_UNLOCK();
}
#endif

        /****************************************
        *                                       *
        *        Write single command           *
        *                                       *
        ****************************************/

static void LCD_WriteSingleCommand0(char cmd) {
  LCD_LOCK();
  WRITE_CMD0(cmd);
  LCD_UNLOCK();
}

#if (LCD_NUM_CONTROLLERS >1)
static void LCD_WriteSingleCommand1(char cmd) {
  LCD_LOCK();
  WRITE_CMD1(cmd);
  LCD_UNLOCK();
}
#endif
#if (LCD_NUM_CONTROLLERS >2)
static void LCD_WriteSingleCommand2(char cmd) {
  LCD_LOCK();
  LCD_WRITECMD2(cmd);
  LCD_UNLOCK();
}
#endif
#if (LCD_NUM_CONTROLLERS >3)
static void LCD_WriteSingleCommand3(char cmd) {
  LCD_LOCK();
  LCD_WRITECMD3(cmd);
  LCD_UNLOCK();
}
#endif

        /****************************************
        *                                       *
        *        Write double command           *
        *                                       *
        ****************************************/

static void LCD_WriteDoubleCommand0(char P1, char P2) {
  LCD_LOCK();
  WRITE_CMD0(P1);
  WRITE_CMD0(P2);
  LCD_UNLOCK();
}
#if (LCD_NUM_CONTROLLERS >1)
static void LCD_WriteDoubleCommand1(char P1, char P2) {
  LCD_LOCK();
  WRITE_CMD1(P1);
  WRITE_CMD1(P2);
  LCD_UNLOCK();
}
#endif
#if (LCD_NUM_CONTROLLERS >2)
static void LCD_WriteDoubleCommand2(char P1, char P2) {
  LCD_LOCK();
  LCD_WRITECMD2(P1);
  LCD_WRITECMD2(P2);
  LCD_UNLOCK();
}
#endif
#if (LCD_NUM_CONTROLLERS >3)
static void LCD_WriteDoubleCommand3(char P1, char P2) {
  LCD_LOCK();
  LCD_WRITECMD3(P1);
  LCD_WRITECMD3(P2);
  LCD_UNLOCK();
}
#endif

        /****************************************
        *                                       *
        *          Read data                    *
        *                                       *
        ****************************************/

#if LCD_READABLE
static U8 LCD_ReadData0(void) {
  U8 r;
  LCD_LOCK();
  READ_DATA0(r);
  LCD_UNLOCK();
  return r;
}
#if (LCD_NUM_CONTROLLERS >1)
static U8 LCD_ReadData1(void) {
  U8 r;
  LCD_LOCK();
  READ_DATA1(r);
  LCD_UNLOCK();
  return r;
}
#endif
#if (LCD_NUM_CONTROLLERS >2)
static U8 LCD_ReadData2(void) {
  U8 r;
  LCD_LOCK();
  READ_DATA2(r);
  LCD_UNLOCK();
  return r;
}
#endif
#if (LCD_NUM_CONTROLLERS >3)
static U8 LCD_ReadData3(void) {
  U8 r;
  LCD_LOCK();
  READ_DATA3(r);
  LCD_UNLOCK();
  return r;
}
#endif
#endif

        /****************************************
        *                                       *
        *          Read command (status)        *
        *                                       *
        ****************************************/

#if LCD_READABLE
static U8 LCD_ReadCmd0(void) {
  U8 r;
  LCD_LOCK();
  READ_CMD0(r);
  LCD_UNLOCK();
  return r;
}
#if (LCD_NUM_CONTROLLERS >1)
static U8 LCD_ReadCmd1(void) {
  U8 r;
  LCD_LOCK();
  READ_CMD1(r);
  LCD_UNLOCK();
  return r;
}
#endif
#if (LCD_NUM_CONTROLLERS >2)
static U8 LCD_ReadCmd2(void) {
  U8 r;
  LCD_LOCK();
  READ_CMD2(r);
  LCD_UNLOCK();
  return r;
}
#endif
#if (LCD_NUM_CONTROLLERS >3)
static U8 LCD_ReadCmd3(void) {
  U8 r;
  LCD_LOCK();
  READ_CMD3(r);
  LCD_UNLOCK();
  return r;
}
#endif
#endif

/*
        ****************************************
        *                                      *
        *     Write to  all controllers        *
        *                                      *
        ****************************************

Some commands should be written to all controllers at the same time.
(Commands used in the init-sequence, or display on/off).
With a multi-controller LCD it can come in handy to have a routine to
write to all of them at once.
*/

#if (LCD_NUM_CONTROLLERS ==1)
  #define LCD_WriteSingleCommandAll LCD_WriteSingleCommand0
#else
  void LCD_WriteSingleCommandAll(char cmd) {
    LCD_WriteSingleCommand0(cmd);
    LCD_WriteSingleCommand1(cmd);
    #if (LCD_NUM_CONTROLLERS >2)
      LCD_WriteSingleCommand2(cmd);
    #endif
    #if (LCD_NUM_CONTROLLERS >3)
      LCD_WriteSingleCommand3(cmd);
    #endif
  }
#endif

/*
  ********************************************************************
  *                                                                  *
  *                  Hardware access, register level                 *
  *                                                                  *
  *           Write Page / Column                                    *
  *                                                                  *
  ********************************************************************

 The following routines are used for all access to the
 LCD-controller(s).

*/
#if (LCD_NUM_CONTROLLERS > 1)
  static U8 CurController;    /* Currently selected controller. All
                                 hardware operations are executed on
                                 this particular controller. It is
                                 more efficient to have a global
                                 variable than to pass this value as
                                 parameter many times. And in a low 
                                 level driver as this one, the
                                 priority of efficiency is top of
                                 the list.  */
#endif
static U8* pCacheByte;
static U8 aPage[LCD_NUM_CONTROLLERS];   /* Current page of
                                           LCD controller(s) */
static U8 aCAdr[LCD_NUM_CONTROLLERS];   /* Current column adr
                                           of LCD controller(s) */
static U8 Page, Col;            /* Page / column of cache byte */
static U8 DataW_Dirty;          /* Set (1) bits are dirty */
static U8 DataW_Cache;          /* Data to be written
                                  (not all bits may be valid !) */
static U8 DataR_Valid;
static U8 DataR_Cache;

/* The coordinates of the cache byte. We save current X,Y as well
   as Y0/Y1 (min/max) in Y-direction. Note that on this level we
   always talk about physical coordinates ! */
static int DataCacheX=-1;   /* x-adr. of currently cached byte.
                               If it is <0 it is sure invalid ! */
static int DataCacheY;
static int DataCacheY0;

⌨️ 快捷键说明

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