📄 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
//#define LCMDW (*((volatile unsigned char *)0xE0028010))
//#define LCMCW (*((volatile unsigned char *)0xE0028010))
//For SED1335
#define DIR245 (1<<22)
#define WR (1<<23)
#define RD (1<<24)
#define CE (1<<25)
#define RESET (1<<25)
#define CD (1<<24)
#define DIR245H IO0SET|=DIR245
#define DIR245L IO0CLR|=DIR245
#define WRH IO0SET|=WR
#define WRL IO0CLR|=WR
#define RDH IO0SET|=RD
#define RDL IO0CLR|=RD
#define CEH IO0SET|=CE
#define CEL IO0CLR|=CE
#define RESETH IO1SET|=RESET
#define RESETL IO1CLR|=RESET
#define CDH IO1SET|=CD
#define CDL IO1CLR|=CD
//#define RESET P125
//#define CE P124
#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;DIR245H
#define LcdNormal RESETH;RDH;WRH
#define SetData CDL
#define SetCmd CDH
#define SetRead DIR245L;RDL
#define ClrRead RDH;DIR245H
#define SetWrite WRL
#define ClrWrite WRH
#define WriteData SetData;SetWrite
#define WriteCmd SetCmd;SetWrite
#define ReadData IO1DIR &= 0xff00ffff;SetCmd;SetRead
#define ReadStatus IO1DIR &= 0xff00ffff;SetData;SetRead
#define WriteOK ClrWrite
#define ReadOK ClrRead;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:清除
*/
//SED1335指令集
#define LC_SYSTEM_SET 0x40
#define LC_SLEEP_IN 0x53
#define LC_DISP_ON 0x59
#define LC_DISP_OFF 0x58
#define LC_SCROLL 0x44
#define LC_CSRFORM 0x5D
#define LC_CGRAM_ADR 0x5C
#define LC_CSRDIR1 0x4C
#define LC_CSRDIR2 0x4D
#define LC_CSRDIR3 0x4E
#define LC_CSRDIR4 0x4F
#define LC_HDOT_SCR 0x5A
#define LC_OVLAY 0x5B
#define LC_CSRW 0x46
#define LC_CSRR 0x47
#define LC_MWRITE 0x42
#define LC_MREAD 0x43
/* 定义LCM像素数宏 */
#define GUI_LCM_XMAX 320 // 定义液晶x轴的像素数 *
#define GUI_LCM_YMAX 240 // 定义液晶y轴的像素数 *
#define XTAL 10000000
// ASCII 字模宽度及高度定义
#define ASC_CHR_WIDTH 8
#define ASC_CHR_HEIGHT 12
// ASCII 字模,显示为8*16
typedef struct _tagCursor
{
uint16 xx;
uint16 yy;
uchar cs;
}tagCursor,*LPtagCursor;
extern uchar gCurRow;
extern uchar gCurCol;
extern uchar const *MenuIndex[5];
extern const uchar uPowArr[];
extern uchar FBpos[];
extern uchar gCurLayer;
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 uLayer,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);
void delay_nus(unsigned int t);
//void delay_ms(void);
void delay_ms(unsigned int time);
void delay_nms(unsigned int t);
void LCDWriteCmd(unsigned char byte);
void LCDWriteData(unsigned char byte);
unsigned char LCDReadData(void);
unsigned char LCDReadStatus(void);
void ClrSCR(char Layer);
void LCD_Init(void);
void TextLocate(char x, char y);
void Cursor(char cursor);
void DEC_Num_Disp(char X,char Y,unsigned int Num,char Bit);
void PointNum_Disp(char X,char Y,unsigned int Num,char Bit,char Point);
void LCDWriteString(char X,char Y,char *ptr);
void UseTxtFill(char x1, char y1, char x2, char y2, char FillMode);
void GraphicLocate(int X, char Y);
void LCDDisplay_bmp(int x,char y,int length,char Width,const char *dat);
void GPix(int x, char y, char state);
void GBox(int x1, char y1, int x2, char y2,char state);
void TextBox(int x, char y, int length,char state);
void GLine(int x1, char y1, int x2, char y2,char state);
void GPART(int x1, char y1, int x2, char y2, char FillMode);
unsigned char LCDCheckBusy(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -