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

📄 lcd6642x.c

📁 lpc2478+ucosII+ucgui源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*
*********************************************************************************************************
*                                                uC/GUI
*                        Universal graphic software for embedded applications
*
*                       (c) Copyright 2002, Micrium Inc., Weston, FL
*                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
*              礐/GUI is protected by international copyright laws. Knowledge of the
*              source code may not be used to write a similar product. This file may
*              only be used in accordance with a license and should not be redistributed
*              in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File        : 
Purpose     : 
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
1.04f   020204 JE     a) Hardwareinterface routines renamed:
                         ...REG01 -> ...A1, ...REG00 -> ...A0
1.04e   010706 JE     a) Bugfixes in DrawBitLine1BPP_Swap
1.04d   010627 JE     a) Bugfix in DrawBitLine1BPP_Swap
1.04c   010420 JE     a) Defaults for config switches added
1.04b   010418 JE     a) Accelerations of DrawVLine changed 
                         for using with cache
                      b) LCD_L0_DrawBitmap changed
1.04a   010417 RS     a) DrawVLine for "Philips mode" accelerated
1.04    010411 JE     a) 2bpp bitmaps accelerated
                      b) 1bpp bitmaps accelerated
1.02    010406 JE     a) Use of cache completed
                      b) DrawVLine optimized
1.00    010401 RS     a) Major work ...
0.02    010314 JE     a) REORG0 changed
                      b) _GetPixel0 & _GetPixel0 changed
                      c) Superfluous macro definitions SETPIXEL, ... deleted
                      d) PHYS_... new to handle rotation
0.01    010313 JE     a) Initialisation changed
0.00    001019 RS     Start of development
---------------------------LIST OF CONFIG SWITCHES--------------------
The following is a list of additional configuration switches for this
driver. These switches might not be listed in the manual, because
the manual mainly covers the general config switches which are
supported by all drivers.
----------------------------------------------------------------------
define ----------------------Explanation------------------------------
LCD_OPTIMIZE                 Controls the use of optimized routines.
LCD_CACHE                    If active cache is used
----------------------------------------------------------------------
Known problems or limitations with current version
----------------------------------------------------------------------
none
---------------------------END-OF-HEADER------------------------------
*/

#include <string.h>             /* for memset */
#include <stddef.h>           /* needed for definition of NULL */
#include "LCD_Private.h"      /* private modul definitions & config */
#include "GUI_Private.h"
#include "GUIDebug.h"
#include "LCD_0.h"            /* Defines for first display */

#if   ((LCD_CONTROLLER == 66420) | (LCD_CONTROLLER == 66421)) \
      && (!defined(WIN32) | defined(LCD_SIMCONTROLLER))



/*
  ********************************************************************
  *
  *                  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 LCD_PIXELINDEX aID[] = {
  INTS(0),
  #if LCD_MAX_LOG_COLORS > 0x10
    INTS(0x10),
  #endif
  #if LCD_MAX_LOG_COLORS > 0x20
    INTS(0x20),
    INTS(0x30),
  #endif
  #if LCD_MAX_LOG_COLORS > 0x40
    INTS(0x40),
    INTS(0x50),
    INTS(0x60),
    INTS(0x70),
  #endif
  #if LCD_MAX_LOG_COLORS > 0x80
    INTS(0x80),
    INTS(0x90),
    INTS(0xa0),
    INTS(0xb0),
    INTS(0xc0),
    INTS(0xd0),
    INTS(0xe0),
    INTS(0xf0)
  #endif
};

/*
        *********************************************************
        *                                                       *
        *           Defaults for configuration                  *
        *                                                       *
        *********************************************************
*/

#ifndef LCD_XORG0
  #define LCD_XORG0     (0)     /* leftmost position covered by this controller */
#endif

#ifndef LCD_YORG0
  #define LCD_YORG0     (0)     /* topmost position covered by this controller */
#endif

#ifndef LCD_STATIC
  #define LCD_STATIC static
#endif

#ifndef LCD_CACHE
  #define  LCD_CACHE (0)
#endif

#ifndef LCD_FIRSTSEG0
  #define LCD_FIRSTSEG0   (0)     /* Contr.0: first segment line used */
#endif

#ifndef LCD_LASTSEG0
  #define LCD_LASTSEG0    (LCD_XSIZE_PHYS-1)    /* Contr.0: last segment line used */
#endif

#ifndef LCD_FIRSTCOM0
  #define LCD_FIRSTCOM0   (0)     /* Contr.0: first com line used */
#endif

#ifndef LCD_LASTCOM0
  #define LCD_LASTCOM0    (LCD_YSIZE_PHYS-1)     /* Contr.0: last com line used */
#endif

#ifndef LCD_NUM_CONTROLLERS
  #define LCD_NUM_CONTROLLERS           (1)
#endif

#ifndef LCD_SUPPORT_CHECKINIT
  #define LCD_SUPPORT_CHECKINIT         (0)
#endif

#ifndef LCD_OPTIMIZE
  #define LCD_OPTIMIZE                (1)
#endif

/*      *********************************************************
        *                                                       *
        *              Controller dependend values              *
        *                                                       *
        *********************************************************
*/

#define MAX_REGS   18
#if (LCD_CONTROLLER == 66420)
  #define MAX_SEGS   160
  #define MAX_COMS   80
#elif (LCD_CONTROLLER == 66421)
  #define MAX_SEGS   160
  #define MAX_COMS   100
#endif

/*
        *********************************************************
        *                                                       *
        *           Compiler specific settings                  *
        *                                                       *
        *********************************************************
*/

#ifdef WIN32   /* Avoid warnings in MS-compiler */
  #pragma warning(disable : 4761)  // warning C4761: integral size mismatch in argument; conversion supplied
#endif

/*
        *********************************************************
        *
        *           Defines for simulation
        *
        *********************************************************
*/

#ifdef WIN32
  U8 SIM_Read00(void);
  U8 SIM_Read01(void);
  U8 SIM_Read10(void);
  U8 SIM_Read11(void);
  void SIM_Write00(U8 Data);
  void SIM_Write01(U8 Data);
  void SIM_Write10(U8 Data);
  void SIM_Write11(U8 Data);
/* Write data */
  #undef  LCD_WRITE_A0
  #define LCD_WRITE_A0(Data) SIM_Write00(Data)
  #undef  LCD_WRITE_A1
  #define LCD_WRITE_A1(Data) SIM_Write01(Data)
  #if LCD_NUM_CONTROLLERS > 1
    #undef  LCD_WRITE_A0C1
    #define LCD_WRITE_A0C1(Data) SIM_Write10(Data)
    #undef  LCD_WRITE_A1C1
    #define LCD_WRITE_A1C1(Data) SIM_Write11(Data)
  #endif  /* LCD_NUM_CONTROLLERS > 1 */
/* Read data */
  #undef  LCD_READ_A0
  #define LCD_READ_A0(Data) Data = SIM_Read00()
  #undef  LCD_READ_A1
  #define LCD_READ_A1(Data) Data = SIM_Read01()
  #if LCD_NUM_CONTROLLERS > 1
    #undef  LCD_READ_A0C0
    #define LCD_READ_A0C0(Data) Data = SIM_Read10()
    #undef  LCD_READ_A1C0
    #define LCD_READ_A1C0(Data) Data = SIM_Read11()
  #endif  /* LCD_NUM_CONTROLLERS > 1 */
#endif

/*
        *********************************************************
        *
        *          Remap ...A0, ...A1 -> ...CMD, ...DATA
        *
        *********************************************************
*/

#define LCD_WRITE_REG00 LCD_WRITE_A0
#define LCD_WRITE_REG01 LCD_WRITE_A1
#define LCD_READ_REG00  LCD_READ_A0
#define LCD_READ_REG01  LCD_READ_A1
#if LCD_NUM_CONTROLLERS > 1
  #define LCD_WRITE_REG10 LCD_WRITE_A0C1
  #define LCD_WRITE_REG11 LCD_WRITE_A1C1
  #define LCD_READ_REG10  LCD_READ_A0C1
  #define LCD_READ_REG11  LCD_READ_A1C1
#endif

/*
        *********************************************************
        *                                                       *
        *          Internal types                               *
        *                                                       *
        *********************************************************
*/

#define PIXELCOLOR U8
#define BKCOLOR LCD_BKCOLORINDEX
#define   COLOR LCD_COLORINDEX

/*
        *********************************************************
        *                                                       *
        *          Support for Segment/COMLUTs                  *
        *                                                       *
        *********************************************************
*/

/* For compatibility with older configs, define defaults */
#ifndef LCD_SUPPORT_COMTRANS
  #define LCD_SUPPORT_COMTRANS 0
#endif
#ifndef LCD_SUPPORT_SEGTRANS
  #define LCD_SUPPORT_SEGTRANS 0
#endif

#if LCD_SUPPORT_COMTRANS
  extern LCD_TYPE_COMTRANS LCD__aLine2Com0[LCD_LASTCOM0-LCD_FIRSTCOM0+1];
#endif

#if LCD_SUPPORT_SEGTRANS
  extern LCD_TYPE_SEGTRANS LCD__aRow2Seg0[LCD_LASTSEG0-LCD_FIRSTSEG0+1];
#endif

/*
        *********************************************************
        *                                                       *
        *           Macro calculations                          *
        *                                                       *
        *********************************************************
*/

#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)
#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.
*/

#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
    #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

⌨️ 快捷键说明

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