📄 lcd15xx.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 : LCD15XX.C
Purpose : Driver for LCDs using Seiko Epson SED15XX controllers
The current version supports up to 4 LCD controllers in
(almost) any hardware configuration. The following
derivatives are currently supported:
Epson SED1560
Epson SED1565 132*65 BW
Epson SED1566 132*49 BW (untested due to lack of hardware)
Epson SED1567 132*33 BW (untested due to lack of hardware)
Epson SED1568 132*55 BW (untested due to lack of hardware)
Epson SED1569 132*53 BW (untested due to lack of hardware)
Epson SED1575 132*200 BW
Samsung KS0108B
Hitachi HD61202
Other Epson LCD controllers are very similar and could
be covered by this driver as well, but are not
currently supported.
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
2.02e 020716 JE a) Support for KS0108B & HD61202 added
2.02d 020715 JE a) Reworked to work with 2 LCD-controllers
2.02c 020204 JE a) Hardwareinterface routines renamed:
...DATA -> ...A1, ...CMD -> ...A0
2.02b 010706 JE a) BUGFIXES: DrawBitLine1BPP_NoSwap
2.02a 010402 RS a) LCD_GetDevCaps removed from driver
(now LCD.c)
2.02 010329 JE a) Completely revised, tested without mirror & swap
2.00 001107 RS a) New driver interface V2.00 used
1.32.01 000321 RS a) BUGFIX: LCD__ClearVRam: aCAdr set to LCD_SEGS_MAX-1
b) BUGFIX: Flush: DataR_Cache = DataW_Cache inserted
JE c) BUGFIX: ASSIGN_PIXEL_FAST now takes account
of LCD_DRAWMODE_XOR
d) BUGFIX: DrawBitLine1BPP_NoSwap XORMODE now works
e) BUGFIX: DrawBitLine1BPP_NoSwap clipping now works
f) BUGFIX: FindByte: -LCD_FIRSTSEG0 removed
g) BUGFIX: LCD_RefreshSection: -LCD_FIRSTSEG0 removed
h) LCD_DrawBit now checks number of colors
1.32.00 990930 RS a) LCD_Init now returns an int
b) bit changed -> Bit in order to vaoid problems
with IAR compilers
1.31.06 990926 RS a) Code is generated now only if LCD_CONTROLLER
is in the range of 1500 - 1599, allowing to
compile all LCD drivers with a project, making
the selection in the config file.
b) Config defaults added
1.31.05 990922 RS/BB a) Number of Segments for 1575 changed from 168
to 200. 200 is correct because the controller
has RAM for 200 segments, even thou just 168
segment lines
b) Transparency support for bitmaps in
DrawBitLine1BPP_Swap added
1.31.04 990810 RS a) LCD__ClearVRam: Cut and paste error elimiated
(Relevant only in 4 controller system)
b) Transparency problem in DrawBitLine1BPP_Swap
eliminated
c) CALCXY: LCD_FIRSTSEG had been subtracted,
but had already been subtracted before. Could
lead to a an offset in the memory area used as
video RAM if LCD_FIRSTSEG<x> != 0.
Fixed.
d) FlushCache-routine simplified for easier
maintanance using a macro
e) Bugfix in FlushCache-routine --- untested
due to lack of hardware !
1.31.03 990720 RS a) Compile problem in single-controller system
(CurController) fixed
b) GotoYPlus1(void) Prototype: Parameterlist:
() replaced by (void) to avoid comiler warning
1.31.02 990713 RS a) All (global/static) variables are initialized in
LCD_Init. This turned out to be necessary as not
all systems comply with ANSI-"C" and automatically
initialize these variables with 0.
1.31.01 990712 RS a) Cache locking bug for systems with seg/Com lookup
tables fixed. Cache writeout accelerated.
1.31.00 990712 RS a) FindByte made leaner and converted to a macro
for 2 controller systems, resulting in improved
performance
b) Internal DrawLine /DrawBitmap routines
improved for higher performance and better
readability
c) Inline versions of SetPixel/ClrPixel created, as
well as fast versions of ASSIGN_PIXEL
(again: for better performance !)
1.30.03 990709 RS a) Structural changes leading to clearer
structure and higher performance
b) FindByte Optimization for 2-Controller system
c) Bugfix: One of the previous optimizations
could lead to a duplicated byte in video memory
when LCD_DrawByte was called fo very
narrow bitmaps. Fixed.
1.30.02 990708 RS a) ReadData optimized if all bytes are
in Cache (macro, no switch statement)
1.30.01 990707 RS a) Add. Optimization in FindByte
1.30.00 990707 RS a) Various optimizations impemented, esp.
if translation (lookup) table for COMs is
activated
1.21.02 990617 RS a) Macro bug (created in 1.21.01) cleaned up
b) Page 8 of all controllers cleared during
init in order to make sure that the COMS
signal can be used and the data for it is
cleared to 0
c) Problem with segment table fixed ...
If used, the segments were moved by LCD_FIRSTSEG<X>
1.21.01 990615 RS a) Some more macros generated in order to
keep the driver easy to maintain
b) Com-offset is now subtracted from Cache<X>
index (in order to avoid potential bounds
problem): e.g.:
Cache0[Page][Col] --> Cache0[Page][Col-LCD_FIRSTSEG0]
1.21.00 990615 RS a) When using segment/com lookup tables,
the macro-values
LCD_NUM_COMS0, LCD_NUM_COMS0
LCD_NUM_COMS1, LCD_NUM_COMS1 (controller 1)
Have to be defined.
Add. configuration checking added.
1.20.02 990614 RS a) LCD_Init did not clear VMem for 3. and 4.
controller. Fixed.
configuration switches eliminated
1.20.01 990614 RS a) Problem with certain combination of
configuration switches eliminated
1.20.00 990614 RS a) Optional segment and com translation tables
supported. This turned out to be necessary
as with some LCDs the COM/SEG lines are
completely mixed up. The translation tables
have to be defined in a seperate file
(sample supplied in LCDTable.c) in
order to make sure that the code in this
driver does not have to be changed.
1.10.00 990505 RS a) Optional support for Cache locking added.
It now requires the add. configuration switch
LCD_SUPPORT_CACHECONTROL
1.04.00 990420 AW/RS a) Support for 1560 added.
1.03.03 990322 RS a) Bitmaps have not been properly cut off at the
end of the clipping region. Fixed
b) Clipping for horizontal/vert. lines
implemented
1.03.02 990319 RS a) When writing bitmaps in XOR-Mode, the LCD
cache was not automatically flushed.
Fixed.
1.03.01 990319 RS a) (Kuennemann) If multiple LCD-controllers had
been used in a horizontal array (different
SEG lines with SEG<X> > 0) the page
calculation did not take the SEG<X> value
into account. Fixed.
b) (Kuennemann)
LCD_Init(): VRAM of controller2/3 was not
cleared in a 3 or 4 controller system.
Fixed.
c) LCD_SetInverse / LCD_ClrInverse:
These routines did not write the command to
all LCD-controllers, but only to the first
one. Fixed.
1.03.00 990317 RS a) XOR Mode implemented for all configurations
b) DrawVLine accelerated
1.02.03 990218 RS a) (Kuennemann) If multiple LCD-controllers had
been used in a vertical array (different
COM lines with COM<X> > 0) the page
calculation did not take the COM<X> value
into account. Fixed.
b) Driver should now also work with 4
controllers. However, this configuration is
still untested. The #error is taken out.
1.02.02 990217 RS a) LCD_GetVisPage, LCD_GetSelPage added
1.02.01 990216 RS a) LCD_GetPixel implemented
b) Support for GetDeviceCaps added
c) Support for Drawmode can now be disabled via
config switch
1.02.00 990212 RS a) Include file string.h put back in in order to
be able to completly reset the LCD, including
clearing the cache
b) LCD_Refresh implemented
c) Support for physical bitmaps added
d) Support for LCD_REVERSE added
e) Support for Write-thru cache added
1.01.01 990203 RS a) Include file string.h no longer needed,
taken out
1.01.00 990203 RS a) Cache no longer filled with 0 using memset
(We trust the compiler to do the job for us.)
1.00.02 990202 RS Support for up to 4 controllers implemented
1.00.01 990128 RS Changes in header-configuration as discussed
with BB
1.00 990118 RS First release for up to 2 LCD controllers *
----------------------------------------------------------------------
Known problems or limitations with current version
----------------------------------------------------------------------
Due to the change to interface version 2.0,
The draw bitline routines has been temp. disabled
The routines:
LCD_L0_SetPixelIndex
LCD_L0_XorPixel
LCD_L0_GetPixelIndex
need to be proberly implemented
----------------------------------------------------------------------
Possible optimizations
----------------------------------------------------------------------
---------------------------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/100 == 15) \
|| (LCD_CONTROLLER == 0713) \
|| (LCD_CONTROLLER == 108) \
|| (LCD_CONTROLLER == 61202) \
) \
&& (LCD_CONTROLLER/100 != 0x15E05 ) \
&& (!defined(WIN32) | defined(LCD_SIMCONTROLLER))
/*
*********************************************************
* *
* Compiler specific settings *
* *
*********************************************************
*/
#ifdef WIN32 /* Avoid warnings in MS-compiler */
#pragma warning(disable : 4244) // warning C4244: '=' : conversion from 'long ' to 'unsigned char ', possible loss of data
#pragma warning(disable : 4761) // warning C4761: integral size mismatch in argument; conversion supplied
#pragma warning(disable : 4305) // warning C4305: '=' : truncation from 'const int ' to ...
#endif
#ifndef LCD_DISPLAY_INDEX
#define LCD_DISPLAY_INDEX 0
#endif
/*********************************************************************
*
* Map hardware macros
*
**********************************************************************
*/
/* mapping for multi-display configuration */
#if (LCD_NUM_DISPLAYS > 1)
#if (LCD_DISPLAY_INDEX == 0) /* First display in a multi-display configuration */
#define LCD_WRITE_A0 LCD_WRITE_A0_0
#define LCD_WRITE_A1 LCD_WRITE_A1_0
#define LCD_WRITE_A0C1 LCD_WRITE_A0C1_0
#define LCD_WRITE_A1C1 LCD_WRITE_A1C1_0
#define LCD_WRITE_A0C2 LCD_WRITE_A0C2_0
#define LCD_WRITE_A1C2 LCD_WRITE_A1C2_0
#define LCD_WRITE_A0C3 LCD_WRITE_A0C3_0
#define LCD_WRITE_A1C3 LCD_WRITE_A1C3_0
#define LCD_READ_A0 LCD_READ_A0_0
#define LCD_READ_A0 LCD_READ_A0_0
#define LCD_READ_A0C1 LCD_READ_A0C1_0
#define LCD_READ_A0C1 LCD_READ_A0C1_0
#define LCD_READ_A0C2 LCD_READ_A0C2_0
#define LCD_READ_A0C2 LCD_READ_A0C2_0
#define LCD_READ_A0C3 LCD_READ_A0C3_0
#define LCD_READ_A0C3 LCD_READ_A0C3_0
#elif (LCD_DISPLAY_INDEX == 1) /* Second display in a multi-display configuration */
#define LCD_WRITE_A0 LCD_WRITE_A0_1
#define LCD_WRITE_A1 LCD_WRITE_A1_1
#define LCD_WRITE_A0C1 LCD_WRITE_A0C1_1
#define LCD_WRITE_A1C1 LCD_WRITE_A1C1_1
#define LCD_WRITE_A0C2 LCD_WRITE_A0C2_1
#define LCD_WRITE_A1C2 LCD_WRITE_A1C2_1
#define LCD_WRITE_A0C3 LCD_WRITE_A0C3_1
#define LCD_WRITE_A1C3 LCD_WRITE_A1C3_1
#define LCD_READ_A0 LCD_READ_A0_1
#define LCD_READ_A0 LCD_READ_A0_1
#define LCD_READ_A0C1 LCD_READ_A0C1_1
#define LCD_READ_A0C1 LCD_READ_A0C1_1
#define LCD_READ_A0C2 LCD_READ_A0C2_1
#define LCD_READ_A0C2 LCD_READ_A0C2_1
#define LCD_READ_A0C3 LCD_READ_A0C3_1
#define LCD_READ_A0C3 LCD_READ_A0C3_1
#else
#error This many displays not yet supported !
#endif
#endif
/* Command definitions in dependence of selected LCD-controller */
#if (LCD_CONTROLLER/100 == 15) || (LCD_CONTROLLER == 0713)
#define SET_PAGE0(Page) LCD_WriteSingleCommand0(0xb0 + Page)
#define SET_CADR0(Col) LCD_WriteDoubleCommand0(0x10 + (Col >> 4), 0x00 + (Col & 0xf))
#define CMD_LCD_ON 0xaf
#define CMD_LCD_OFF 0xae
#define WAIT0()
#define WAIT1()
#define WAIT2()
#define WAIT3()
#elif (LCD_CONTROLLER == 108) || (LCD_CONTROLLER == 61202)
static int _Status;
#define SET_PAGE0(Page) LCD_WriteSingleCommand0(0xb8 + Page);
#define SET_CADR0(Col) LCD_WriteSingleCommand0(0x40 + Col);
#if (LCD_NUM_CONTROLLERS > 1)
#define SET_PAGE1(Page) LCD_WriteSingleCommand1(0xb8 + Page);
#define SET_CADR1(Col) LCD_WriteSingleCommand1(0x40 + Col);
#endif
#define CMD_LCD_ON 0x3f
#define CMD_LCD_OFF 0x3e
#define WAIT0() do { LCD_READ_A0(_Status); } while (_Status & 0x80);
#define WAIT1() do { LCD_READ_A0C1(_Status); } while (_Status & 0x80);
#define WAIT2() do { LCD_READ_A0C2(_Status); } while (_Status & 0x80);
#define WAIT3() do { LCD_READ_A0C3(_Status); } while (_Status & 0x80);
#else
#error LCD-controller not supported!
#endif
#ifdef WIN32 /* SEGGER internal simulation */
void SIM_WriteA1C0(U8 Data);
void SIM_WriteA0C0(U8 cmd);
U8 SIM_ReadA0C0(void);
U8 SIM_ReadA1C0(void);
#define WRITE_DATA0(Data) SIM_WriteA1C0(Data)
#define WRITE_CMD0(cmd) SIM_WriteA0C0(cmd)
#define READ_DATA0(Data) Data = SIM_ReadA1C0()
#define READ_CMD0(cmd) cmd = SIM_ReadA0C0()
#define INIT_CONTROLLER()
#if LCD_NUM_CONTROLLERS > 1
void SIM_WriteA1C1(U8 Data);
void SIM_WriteA0C1(U8 cmd);
U8 SIM_ReadA0C1(void);
U8 SIM_ReadA1C1(void);
#define WRITE_DATA1(Data) SIM_WriteA1C1(Data)
#define WRITE_CMD1(cmd) SIM_WriteA0C1(cmd)
#define READ_DATA1(Data) Data = SIM_ReadA1C1()
#define READ_CMD1(cmd) cmd = SIM_ReadA0C1()
#endif
#if LCD_NUM_CONTROLLERS > 2
void SIM_WriteA1C2(U8 Data);
void SIM_WriteA0C2(U8 cmd);
U8 SIM_ReadA0C2(void);
U8 SIM_ReadA1C2(void);
#define WRITE_DATA2(Data) SIM_WriteA1C2(Data)
#define WRITE_CMD2(cmd) SIM_WriteA0C2(cmd)
#define READ_DATA2(Data) Data = SIM_ReadA1C2()
#define READ_CMD2(cmd) cmd = SIM_ReadA0C2()
#endif
#if LCD_NUM_CONTROLLERS > 3
void SIM_WriteA1C3(U8 Data);
void SIM_WriteA0C3(U8 cmd);
U8 SIM_ReadA0C3(void);
U8 SIM_ReadA1C3(void);
#define WRITE_DATA3(Data) SIM_WriteA1C3(Data)
#define WRITE_CMD3(cmd) SIM_WriteA0C3(cmd)
#define READ_DATA3(Data) Data = SIM_ReadA1C3()
#define READ_CMD3(cmd) cmd = SIM_ReadA0C3()
#endif
#else
#define WRITE_CMD0(cmd) WAIT0(); LCD_WRITE_A0(cmd)
#define WRITE_DATA0(Data) WAIT0(); LCD_WRITE_A1(Data)
#define READ_DATA0(Data) WAIT0(); LCD_READ_A1(Data)
#define READ_CMD0(cmd) WAIT0(); LCD_READ_A0(cmd)
#define INIT_CONTROLLER LCD_INIT_CONTROLLER
#if LCD_NUM_CONTROLLERS > 1
#define WRITE_CMD1(cmd) WAIT1(); LCD_WRITE_A0C1(cmd)
#define WRITE_DATA1(Data) WAIT1(); LCD_WRITE_A1C1(Data)
#define READ_DATA1(Data) WAIT1(); LCD_READ_A1C1(Data)
#define READ_CMD1(cmd) WAIT1(); LCD_READ_A0C1(cmd)
#endif
#if LCD_NUM_CONTROLLERS > 2
#define WRITE_CMD2(cmd) WAIT(2); LCD_WRITE_A0C2(cmd)
#define WRITE_DATA2(Data) WAIT(2); LCD_WRITE_A1C2(Data)
#define READ_DATA2(Data) WAIT(2); LCD_READ_A1C2(Data)
#define READ_CMD2(cmd) WAIT(2); LCD_READ_A0C2(cmd)
#endif
#if LCD_NUM_CONTROLLERS > 3
#define WRITE_CMD3(cmd) WAIT(3); LCD_WRITE_A0C3(cmd)
#define WRITE_DATA3(Data) WAIT(3); LCD_WRITE_A1C3(Data)
#define READ_DATA3(Data) WAIT(3); LCD_READ_A1C3(Data)
#define READ_CMD3(cmd) WAIT(3); LCD_READ_A0C3(cmd)
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -