📄 lcdslin.c
字号:
/*
*********************************************************************************************************
* 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 : LCDSLin.C
Purpose : Driver for LCDs using simple bus interface
Currently supported controllers:
Toshiba T6963
Epson SED1330
Epson SED1335
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
2.00g 020319 JE a) Macro changed to fix NC30-error
2.00f 020204 JE a) Hardwareinterface routines renamed:
...DATA -> ...A0, ...CMD -> ...A1
2.00e 011112 JE a) LCD_INIT_CONTROLLER added to be able to
execute LCD_X_Init during init
2.00d 010926 JE a) Support for LCD_SWAP_XY added
2.00c 010706 JE a) Bugfix in DrawBitLine1BPP
2.00b 010402 RS a) LCD_GetDevCaps removed from driver
(now LCD.c)
2.00a 008026 RS a) Simulation interface changed
2.00 000525 JE a) Interface changed
1.02c 000509 JE a) Simple bus interface changed for SED133x
b) Small changes in DrawBitLine1BPP
c) Cache initialisation to SED133x added
1.02b 000508 JE a) Simple bus interface changed for T6963
1.02a 000426 JE a) Transparent mode in DrawBitLine1BPP changed
b) Dummy LCD_L0_SetLUTEntry inserted
1.02 000426 RS a) Changes for new LCD-driver interface V1.30
1.00a 000410 JE a) LCD_GetDevCap changed
b) LCD_GetpCapFunc deleted
c) LCD_DrawBitMap changed
d) Definition for aColorIndex changed
1.00 000407 JE First release
---------------------------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.
----------------------------------------------------------------------
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 == 6963) || (LCD_CONTROLLER == 1330) || (LCD_CONTROLLER == 1335) \
&& (!defined(WIN32) | defined(LCD_SIMCONTROLLER))
/*
********************************************************************
* *
* Conversion table
* *
********************************************************************
*/
static const LCD_PIXELINDEX LCD_ConversionTable[2] = {0, 1};
/*
*********************************************************
* *
* Defaults for configuration *
* *
*********************************************************
*/
#ifndef LCD_OPTIMIZE
#define LCD_OPTIMIZE (1)
#endif
#ifndef LCD_CHECKBUSY
#define LCD_CHECKBUSY (1)
#endif
#ifndef LCD_INIT
#define LCD_INIT()
#endif
#ifndef LCD_WATCHDOG_TRIGGERCNT
#define LCD_WATCHDOG_TRIGGERCNT (0)
#endif
#ifndef LCD_KICK_WATCHDOG
#define LCD_KICK_WATCHDOG()
#endif
#ifndef LCD_CACHE
#define LCD_CACHE (1)
#endif
#ifndef LCD_SUPPORT_REFRESH
#define LCD_SUPPORT_REFRESH LCD_CACHE
#endif
#ifndef LCD_REVERSEMODE_SUPPORT
#define LCD_REVERSEMODE_SUPPORT (0)
#endif
#ifndef LCD_SUPPORT_VERIFY
#define LCD_SUPPORT_VERIFY (0)
#endif
/* Switch for support of multiple pages.
Only available with certain LCD-controllers */
#ifndef LCD_SUPPORT_PAGING
#define LCD_SUPPORT_PAGING (0)
#endif
#ifndef LCD_SCHEDULE_CNT
#define LCD_SCHEDULE_CNT (0)
#endif
#ifndef LCD_NUM_CONTROLLERS
#define LCD_NUM_CONTROLLERS (1)
#endif
#ifndef LCD_SUPPORT_CHECKINIT
#define LCD_SUPPORT_CHECKINIT (0)
#endif
/* Switch support for the LCD_CopyRect function of the driver */
#ifndef LCD_SUPPORT_COPYRECT
#define LCD_SUPPORT_COPYRECT (1)
#endif
#ifndef LCD_INIT_CONTROLLER
#define LCD_INIT_CONTROLLER()
#endif
/*
*********************************************************
* *
* Internal types *
* *
*********************************************************
*/
#if LCD_BITSPERPIXEL == 1
#define PIXELCOLOR U8
#else
#error LCD_BITSPERPIXEL != 1 not supported
#endif
/*
*********************************************************
* *
* Configuration switch checking *
* *
*********************************************************
Please be aware that not all configuration errors can be captured !
*/
/* Check number of controllers */
#if (LCD_NUM_CONTROLLERS != 1)
#error "Only 1 controller supported by this driver"
#endif
/*
*********************************************************
*
* Defines for simulation
*
*********************************************************
*/
#ifdef WIN32
#undef LCD_WRITE_A0
#undef LCD_WRITE_A1
#undef LCD_READ_A0
#undef LCD_READ_A1
void SIM_WriteA1C0(U8 Data);
void SIM_WriteA0C0(U8 cmd);
U8 SIM_ReadA1C0(void);
U8 SIM_ReadA0C0(void);
#define LCD_WRITE_A1(Data) SIM_WriteA1C0(Data)
#define LCD_WRITE_A0(cmd) SIM_WriteA0C0(cmd)
#define LCD_READ_A1() SIM_ReadA1C0()
#define LCD_READ_A0() SIM_ReadA0C0()
#endif
/*
*********************************************************
* *
* Standard variables for driver *
* *
*********************************************************
*/
static U8 Cache[((LCD_XSIZE_PHYS+7)>>3)*LCD_YSIZE_PHYS];
#if LCD_WATCHDOG_TRIGGERCNT
int WatchdogTriggerCnt;
#endif
#if LCD_SUPPORT_VERIFY
static int ErrCnt;
static int ErrStat;
#endif
/*
*********************************************************
* *
* 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
/*
*********************************************************
* *
* 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
#if (!LCD_SUPPORT_COMTRANS && !LCD_SUPPORT_SEGTRANS)
#if (!LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY)
#define SETPIXEL(x, y, c) _SetPixel(x, y, c)
#define GETPIXEL(x, y) _GetPixel(x,y)
#define XORPIXEL(x, y) XorPixel(x,y)
#elif (!LCD_MIRROR_X && !LCD_MIRROR_Y && LCD_SWAP_XY)
#define SETPIXEL(x, y, c) _SetPixel(y, x, c)
#define GETPIXEL(x, y) _GetPixel(y, x)
#define XORPIXEL(x, y) XorPixel(y, x)
#elif (!LCD_MIRROR_X && LCD_MIRROR_Y && !LCD_SWAP_XY)
#define SETPIXEL(x, y, c) _SetPixel(x, LCD_YSIZE-1-(y), c)
#define GETPIXEL(x, y) _GetPixel(x, LCD_YSIZE-1-(y))
#define XORPIXEL(x, y) XorPixel (x, LCD_YSIZE-1-(y))
#elif (!LCD_MIRROR_X && LCD_MIRROR_Y && LCD_SWAP_XY)
#define SETPIXEL(x, y, c) _SetPixel(LCD_YSIZE-1-(y), x, c)
#define GETPIXEL(x, y) _GetPixel(LCD_YSIZE-1-(y), x)
#define XORPIXEL(x, y) XorPixel(LCD_YSIZE-1-(y), x)
#elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY)
#define SETPIXEL(x, y, c) _SetPixel(LCD_XSIZE-1-(x), y, c)
#define GETPIXEL(x, y) _GetPixel(LCD_XSIZE-1-(x), y)
#define XORPIXEL(x, y) XorPixel (LCD_XSIZE-1-(x), y)
#elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && LCD_SWAP_XY)
#define SETPIXEL(x, y, c) _SetPixel(LCD_YSIZE-1-(y), x, c)
#define GETPIXEL(x, y) _GetPixel(LCD_YSIZE-1-(y), x)
#define XORPIXEL(x, y) XorPixel(LCD_YSIZE-1-(y), x)
#elif ( LCD_MIRROR_X && LCD_MIRROR_Y && !LCD_SWAP_XY)
#define SETPIXEL(x, y, c) _SetPixel(LCD_XSIZE-1-(x), LCD_YSIZE-1-(y), c)
#define GETPIXEL(x, y) _GetPixel(LCD_XSIZE-1-(x), LCD_YSIZE-1-(y))
#define XORPIXEL(x, y) XorPixel (LCD_XSIZE-1-(x), LCD_YSIZE-1-(y))
#elif ( LCD_MIRROR_X && LCD_MIRROR_Y && LCD_SWAP_XY)
#error This combination of mirroring/swapping not yet supported
#endif
#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
#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
#define XY2OFF(x,y) ((x>>3)+y*((LCD_XSIZE_PHYS+7)>>3))
#define BKCOLOR LCD_BKCOLORINDEX
#define COLOR LCD_COLORINDEX
/*
*********************************************************
* *
* ID translation table *
* *
*********************************************************
This table contains 0, 1, 2, ... and serves as translation table for DDBs
*/
static const U8 TransId[] = { 0,1 };
/*
*********************************************************
* *
* LCD Access *
* *
*********************************************************
*/
int LCD_Adr;
#if (!LCD_CHECKBUSY)
#define LCD_WAIT()
#endif
static U8 result; /* Possibly needed for access macro */
/*
*********************************************************
* *
* LCD Access Controller SED133x *
* *
*********************************************************
*/
#if (LCD_CONTROLLER == 1330) \
||(LCD_CONTROLLER == 1335)
/* Remap ...A0, ...A1 -> ...CMD, ...DATA */
#define LCD_READCMD0 LCD_READ_A0
#define LCD_READDATA0 LCD_READ_A1
#define LCD_WRITECMD0 LCD_WRITE_A1
#define LCD_WRITEDATA0 LCD_WRITE_A0
#ifndef LCD_EXTENDED_WAIT
#define LCD_EXTENDED_WAIT 1
#endif
#ifndef LCD_WAIT
#define LCD_WAIT() \
while (!(LCD_READCMD0()&0x40)); \
while ( LCD_READCMD0()&0x40) ;
#endif
#if LCD_EXTENDED_WAIT
#define LCD_WRITECMD(cmd) { LCD_WAIT(); LCD_WRITECMD0(cmd); }
#define LCD_WRITEDATA(Data) { LCD_WAIT(); LCD_WRITEDATA0(Data);}
#else
#define LCD_WRITECMD(cmd) { LCD_WRITECMD0(cmd); }
#define LCD_WRITEDATA(Data) { LCD_WRITEDATA0(Data);}
#endif
#define GSTART (0x0)
#if (LCD_YSIZE_PHYS >128)
#define TSTART 30000
#else
#define TSTART 7000
#endif
static void LCD_SetSystem(void) {
LCD_WRITECMD (0x40);
LCD_WRITEDATA(0x30); /* P1 */
LCD_WRITEDATA(0x87); /* P2 : FX : hor. char size-1 */
LCD_WRITEDATA(0x7); /* P3 : FY : ver. char size-1 (not imp.) */
LCD_WRITEDATA(((LCD_XSIZE_PHYS+7)>>3)-1); /* P4 : Characters per row */
LCD_WRITEDATA(0x4a); /* P5 : Timing charcters per row */
LCD_WRITEDATA(LCD_YSIZE_PHYS-1); /* P6 : Number of lines per screen */
LCD_WRITEDATA((LCD_XSIZE_PHYS+7)>>3); /* P7 : Address pitch low */
LCD_WRITEDATA(0x00); /* P8 : Address pitch high */
}
static void LCD_SetScroll(int Adr) {
LCD_WRITECMD(0x44);
LCD_WRITEDATA(TSTART&255); /* address of screen 1 (text) */
LCD_WRITEDATA(TSTART>>8);
LCD_WRITEDATA((LCD_YSIZE_PHYS)-1);
LCD_WRITEDATA(Adr); /* address of screen 2 (graphic) */
LCD_WRITEDATA(Adr>>8);
LCD_WRITEDATA((LCD_YSIZE_PHYS)-1);
}
static void LCD_SetAdr(int Off) {
LCD_Adr=Off;
#if (!LCD_EXTENDED_WAIT)
LCD_WAIT();
#endif
LCD_WRITECMD (0x46);
LCD_WRITEDATA(Off&255);
LCD_WRITEDATA(Off>>8);
}
#define LCD_SETADR(Off) LCD_SetAdr(Off)
static void LCD_Write1(char Byte) {
#if (!LCD_EXTENDED_WAIT)
LCD_WAIT();
#endif
LCD_WRITECMD (0x42);
LCD_WRITEDATA(Byte);
LCD_Adr++;
}
#define LCD_WRITE1(Byte) LCD_Write1(Byte)
/* LCD_L0_ReInit */
void LCD_L0_ReInit(void) {
int i;
LCD_INIT_CONTROLLER();
LCD_SetSystem();
LCD_SetScroll(GSTART) ;
LCD_WRITECMD (0x4c); /* Set cursor move direction */
LCD_WRITECMD (0x5a); /* HDOT SCR : Set horiz. scroll position */
LCD_WRITEDATA(0);
LCD_WRITECMD (0x5b); /* OVLAY */
LCD_WRITEDATA(1);
/* Clear display memory */
LCD_SETADR(0);
LCD_WRITECMD (0x42);
#if (LCD_YSIZE_PHYS >128)
for (i=0; i<32000; i++)
#else
for (i=0; i<8000; i++)
#endif
LCD_WRITEDATA(0);
#if (LCD_REVERSE)
LCD_SETADR(GSTART);
LCD_WRITECMD (0x42);
for (i=GSTART; i<GSTART+((LCD_XSIZE_PHYS+7)>>3)*LCD_YSIZE_PHYS; i++)
LCD_WRITEDATA(0xff);
#endif
if(COLOR)
memset(Cache,0xff,sizeof(Cache));
else
memset(Cache,0x0,sizeof(Cache));
LCD_WRITECMD (0x59); /* Display on */
LCD_WRITEDATA(0x14); /* All screens on, curosr off */
}
/* LCD_FirstInit */
static void LCD_FirstInit(void) {
LCD_L0_ReInit();
}
#endif /* SED133x */
/*
*********************************************************
* *
* LCD Access Controller T6963 *
* *
*********************************************************
*/
#if (LCD_CONTROLLER == 6963)
/* Remap ...A0, ...A1 -> ...CMD, ...DATA */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -