📄 lcddrv.h
字号:
#ifndef _LCDDRV_H_
#define _LCDDRV_H_
// T6963C 端口定义
/*
//For C51
#define LCMDW XBYTE[0x5000] // 数据口
#define LCMCW XBYTE[0x5002] // 命令口
#define CD P023
#define RD P024
#define WR P025
*/
//For LPC2100
#define LCMDW PORT1C
#define LCMCW PORT1C
/*
//For LPC2100
#define CD (1<<23)
#define RD (1<<24)
#define WR (1<<25)
#define RESET P125
#define CE P124
*/
//For TDJSD
#define CD (1<<15)
#define RD (1<<14)
#define WR (1<<13)
#define RESET (1<<11)
#define CE (1<<12)
//#define RESET P011
//#define CE P012
#define CDH IO0SET|=CD
#define CDL IO0CLR|=CD
#define RDH IO0SET|=RD
#define RDL IO0CLR|=RD
#define WRH IO0SET|=WR
#define WRL IO0CLR|=WR
#define RESETH IO0SET|=RESET
#define RESETL IO0CLR|=RESET
#define CEH IO0SET|=CE
#define CEL IO0CLR|=CE
//For TDJSD
//#define LCDDIR P010
//#define LCDIN LCDDIR = HIGH
//#define LCDOUT LCDDIR = LOW
#define LDIR (1<<10)
#define LCDIN IO0CLR|=LDIR
#define LCDOUT IO0SET|=LDIR
#define DB0 P116
#define DB1 P117
#define DB2 P118
#define DB3 P119
#define DB4 P120
#define DB5 P121
#define DB6 P122
#define DB7 P123
#define LcdEnable CEL
#define LcdDisable CEH
#define LcdReset RESETL;RDH;WRH;LCDOUT
#define LcdNormal RESETH;RDH;WRH;LCDOUT
#define SetData CDL
#define SetCmd CDH
#define SetRead RDL
#define ClrRead RDH
#define SetWrite WRL
#define ClrWrite WRH
#define WriteData LCDOUT;SetData;SetWrite
#define WriteCmd LCDOUT;SetCmd;SetWrite
#define ReadData IO1DIR &= 0xff00ffff;LCDIN;SetData;SetRead
#define ReadStatus IO1DIR &= 0xff00ffff;LCDIN;SetCmd;SetRead
#define WriteOK ClrWrite
#define ReadOK ClrRead;LCDOUT;IO1DIR |= 0x00ff0000
// T6963C 命令定义
#define LC_CUR_POS 0x21 // 光标位置设置
#define LC_CGR_POS 0x22 // CGRAM偏置地址设置
#define LC_ADD_POS 0x24 // 地址指针位置
#define LC_TXT_STP 0x40 // 文本区首址
#define LC_TXT_WID 0x41 // 文本区宽度
#define LC_GRH_STP 0x42 // 图形区首址
#define LC_GRH_WID 0x43 // 图形区宽度
#define LC_MOD_OR 0x80 // 显示方式:逻辑“或”
#define LC_MOD_XOR 0x81 // 显示方式:逻辑“异或”
#define LC_MOD_AND 0x82 // 显示方式:逻辑“与”
#define LC_MOD_TCH 0x83 // 显示方式:文本特征
#define LC_DIS_SW 0x90 // 显示开关:D0=1/0:光标闪烁启用/禁用;
// D1=1/0:光标显示启用/禁用;
// D2=1/0:文本显示启用/禁用;
// D3=1/0:图形显示启用/禁用;
#define LC_CUR_SHP 0xA0 // 光标形状选择:0xA0-0xA7表示光标占的行数
#define LC_AUT_WR 0xB0 // 自动写设置
#define LC_AUT_RD 0xB1 // 自动读设置
#define LC_AUT_OVR 0xB2 // 自动读/写结束
#define LC_INC_WR 0xC0 // 数据一次写,地址加1
#define LC_INC_RD 0xC1 // 数据一次读,地址加1
#define LC_DEC_WR 0xC2 // 数据一次写,地址减1
#define LC_DEC_RD 0xC3 // 数据一次读,地址减1
#define LC_NOC_WR 0xC4 // 数据一次写,地址不变
#define LC_NOC_RD 0xC5 // 数据一次读,地址不变
#define LC_SCN_RD 0xE0 // 屏读
#define LC_SCN_CP 0xE8 // 屏拷贝
#define LC_BIT_OP 0xF0 // 位操作:D0-D2:定义D0-D7位;D3:1置位;0:清除
// ASCII 字模宽度及高度定义
#define ASC_CHR_WIDTH 8
#define ASC_CHR_HEIGHT 12
#define GH_Addr 0x2000
// ASCII 字模,显示为8*16
extern uchar gCurRow;
extern uchar gCurCol;
extern uint8 gCurMode;
extern uchar const *MenuIndex[5];
extern const uchar uPowArr[];
extern uchar FBpos[];
uchar fnGetRow(void);
uchar fnGetCol(void);
uchar fnST01(void); // 状态位STA1,STA0判断(读写指令和读写数据)
uchar fnST2(void); // 状态位ST2判断(数据自动读状态)
uchar fnST3(void); // 状态位ST3判断(数据自动写状态)
uchar fnST6(void); // 状态位ST6判断(屏读/屏拷贝状态)
uchar fnPR1(uchar uCmd,uchar uPar1,uchar uPar2); // 写双参数的指令
uchar fnPR11(uchar uCmd,uchar uPar1); // 写单参数的指令
uchar fnPR12(uchar uCmd); // 写无参数的指令
uchar fnPR13(uchar uData); // 写数据
uchar fnPR14(uchar uData); // 写数据
uchar fnPR2(void); // 读数据
void fnSetPos(uchar urow, uchar ucol);
void cursor(uchar uRow, uchar uCol);
void cls(void);
char fnLCMInit(void);
void FunBlock(uchar X,uchar Y,uchar width,uchar height);
uchar dprintf(char *fmt, ...);
void ReadLcd(void);
void DispBMP(uchar Xs, uchar Ys, uchar Xw, uchar Yh,const uchar *BMPdata);
uchar cprintf(uchar *fmt);
uchar tcprintf(uchar *fmt);
#define LCM_TEXT gCurMode = 1;fnSetPos(0,0);fnPR12(LC_DIS_SW | 0x04);
#define LCM_GRAPH gCurMode = 0;fnSetPos(0,0);fnPR12(LC_DIS_SW | 0x08);
#define LCM_GT gCurMode = 0;fnSetPos(0,0);fnPR12(LC_DIS_SW | 0x0c);
#define LCM_CURSOR_ON gCurMode = 1;fnSetPos(0,0);fnPR12(LC_DIS_SW | 0x06);
#define LCM_CURSOR_BLINK gCurMode = 1;fnSetPos(0,0);fnPR12(LC_DIS_SW | 0x07);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -