T6963C液晶顯示控制器的240128程序
//SMG240128A標(biāo)準(zhǔn)圖形點(diǎn)陣型液晶顯示模塊的擴(kuò)展演示程序[C51編程語(yǔ)言][MCS51總線接口方式]
//應(yīng)用產(chǎn)品: SMG240128A標(biāo)準(zhǔn)圖形點(diǎn)陣型液晶顯示模塊
// 本演示程序適用于SMG240128A液晶顯示模塊與MCS51系列單片機(jī)采用MCS51總線接口的
//硬件連線方式。
// 本演示程序包括T6963C兼容芯片的MCS51總線接口方式子程序集,T6963C兼容芯片的240128
//液晶顯示模塊的基本子程序,240128系列繪圖子程序集,240128系列圖形子程序集,240128系
//列精簡(jiǎn)中英文字庫(kù)子程序集,以及SMG240128系列標(biāo)準(zhǔn)圖形點(diǎn)陣型液晶顯示的擴(kuò)展演示子程序.
// 本演示的內(nèi)容為,在240列X128行的點(diǎn)陣液晶顯示屏上清屏,圖片演示,英文字符串演示,中文
//字符串演示,反白顯示字符串,繪制矩形,寫(xiě)點(diǎn),繪制直線,全屏顯示.
//-------------------------------------------------------------------------------
//軟件環(huán)境: VW For Windows
//硬件環(huán)境: AT89C52 MCU,MCS-51系列 MCU,etc.
//-------------------------------------------------------------------------------
#include
#include
//以下為演示程序的函數(shù)定義
void exsample(void); //演示程序
void exdelay(void); //演示延時(shí)子程序
void putchar(unsigned int c); //定位寫(xiě)字符子程序
void putstr(unsigned char code *s); //顯示字符串子程序,字符碼為0時(shí)退出
unsigned char code *getchinesecodepos(unsigned int ac);
unsigned char code *getenglishcodepos(unsigned char ac);
void putimage(unsigned char code *s); //顯示圖形子程序
void putsizeimage(unsigned char XSIZE,unsigned char YSIZE,unsigned char code *s);
//顯示指定大小的圖形子程序
void point(bit b);
void line(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,bit b);
void lineto(unsigned char x1,unsigned char y1,bit b);//繪制(XPOS,YPOS)-(X1,Y1)的直線
void rect(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,bit b);
void lcdfill(unsigned char d); //整屏顯示d代表的字節(jié)數(shù)據(jù)子程序
void lcdpos(void); //設(shè)置坐標(biāo)點(diǎn)(XPOS,YPOS)內(nèi)部RAM地址的子程序
void lcdreset(void); //液晶顯示控制器初始化子程序
void lcdwd(unsigned char d); //送圖形數(shù)據(jù)子程序
unsigned char lcdrd(void); //讀圖形數(shù)據(jù)子程序
void lcdwc(unsigned char c); //送指令子程序
void lcdwc2(unsigned char c,unsigned char d);//送2字節(jié)指令子程序
void lcdwc3(unsigned char c,unsigned char d1,unsigned char d2);//送3字節(jié)指令子程序
unsigned char lcdrdata(void); //讀數(shù)據(jù)子程序
void lcdwdata(unsigned char d); //送數(shù)據(jù)子程序
void lcdwaitidle(void); //忙檢測(cè)子程序
//-------------------------------------------------------------------------------
//SMG240128A產(chǎn)品引腳說(shuō)明及演示連線
//PIN1: FG [構(gòu)造地]-------------------VSS
//PIN2: VSS [電源地]-------------------VSS
//PIN3: VDD [電源正極]-----------------VDD(+5V)
//PIN4: Vo [LCD 偏壓輸入]-------------接10K的可調(diào)電阻2K電阻到VSS及VEE
// Vo=VEE時(shí)為顯示最深
//PIN5: WR [寫(xiě)信號(hào) 低有效]------------P3.6
//PIN6: RD [讀信號(hào) 低有效]------------P3.7
//PIN7: CE [使能信號(hào) 低有效]----------P2.1
//PIN8: CD [數(shù)據(jù)/命令選擇端(H/L)]---P2.0
//PIN9: NC [空腳]---------------------不連線
//PIN10:RST [復(fù)位端 低有效]------------VDD
//PIN11:D0 [Data I/O]-----------------P0.0
//PIN12:D1 [Data I/O]-----------------P0.1
//PIN13:D2 [Data I/O]-----------------P0.2
//PIN14:D3 [Data I/O]-----------------P0.3
//PIN15:D4 [Data I/O]-----------------P0.4
//PIN16:D5 [Data I/O]-----------------P0.5
//PIN17:D6 [Data I/O]-----------------P0.6
//PIN18:D7 [Data I/O]-----------------P0.7
//PIN19:FS [字體點(diǎn)陣]-----------------VSS
//PIN20:VEE [LCD負(fù)壓輸出]--------------提供液晶負(fù)電壓.
//PIN21:BLA [背光源正極]---------------見(jiàn)使用說(shuō)明書(shū).
//PIN22:BLK [背光源負(fù)極]---------------VSS
//注:8031的晶振頻率為12MHz.
//-------------------------------------------------------------------------------
//以下為外部地址在演示程序中的預(yù)定義
//用戶在編寫(xiě)應(yīng)用程序時(shí),需按自己的實(shí)際硬件連線來(lái)重新定義
unsigned char xdata LCDCREG _at_ 0x0100;//指令地址CE(P2.1)=0,C/D(P2.0)=1
unsigned char xdata LCDDREG _at_ 0x0000;//數(shù)據(jù)地址CE(P2.1)=0,C/D(P2.0)=0
//-------------------------------------------------------------------------------
//以下XPOS,YPOS變量用于指示當(dāng)前操作點(diǎn)的位置的預(yù)定義
//用戶在編寫(xiě)應(yīng)用程序時(shí),需按自己的實(shí)際軟件程序需要來(lái)重新定義
unsigned char XPOS; //列方向LCD點(diǎn)陣位置指針
unsigned char YPOS; //行方向LCD點(diǎn)陣位置指針
bit CharImageReverse; //字符及圖形的反顯控制,0(正常顯示),1(反顯)
#define XDOTS 240 //圖形空間X方向大小
#define YDOTS 128 //圖形空間X方向大小
//-------------------------------------------------------------------------------
//以下為精簡(jiǎn)版中英文字庫(kù)
//實(shí)際使用時(shí)請(qǐng)包含由Sunman精簡(jiǎn)版中英文字符庫(kù)代碼生成器.exe自動(dòng)生成的charlib.c文
//文件來(lái)替換該部分
//精簡(jiǎn)版中英文字符庫(kù)常量定義
#define ENGLISHCHARNUMBER 8 //精簡(jiǎn)版英文字符庫(kù)中的英文字符的個(gè)數(shù)
#define CHINESECHARNUMBER 11 //精簡(jiǎn)版中文字符庫(kù)中的中文字符的個(gè)數(shù)
#define ENGLISHCHARSIZE 8 //英文字符X方向顯示點(diǎn)的個(gè)數(shù)
#define CHINESECHARSIZE 16 //中文字符X方向及中英文字符Y方向顯示點(diǎn)的個(gè)數(shù)
#define ENGLISHCHARDOTSIZE 16 //單個(gè)英文字符點(diǎn)陣的字節(jié)數(shù)
#define CHINESECHARDOTSIZE 32 //單個(gè)中文字符點(diǎn)陣的字節(jié)數(shù)
unsigned char code EnglishCode[]={
0x2e, //字符001:[.]
0x41, //字符002:[A]
0x43, //字符003:[C]
0x4d, //字符004:[M]
0x4e, //字符005:[N]
0x53, //字符006:[S]
0x55, //字符007:[U]
0x57 //字符003:[W]
};
unsigned int code ChineseCode[]={
0xb3a4, //字符001:[長(zhǎng)]
0xb5e7, //字符002:[電]
0xb9ab, //字符003:[公]
0xc8cb, //字符004:[人]
0xc9b3, //字符005:[沙]
0xcbbe, //字符006:[司]
0xccab, //字符007:[太]
0xcfde, //字符008:[限]
0xd1f4, //字符009:[陽(yáng)]
0xd3d0, //字符010:[有]
0xd7d3 //字符011:[子]
};
unsigned char code EnglishCharDot[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //字符001:[.]
0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,
0x00,0x00,0x00,0x10,0x10,0x18,0x28,0x28, //字符002:[A]
0x24,0x3c,0x44,0x42,0x42,0xe7,0x00,0x00,
0x00,0x00,0x00,0x3e,0x42,0x42,0x80,0x80, //字符003:[C]
0x80,0x80,0x80,0x42,0x44,0x38,0x00,0x00,
0x00,0x00,0x00,0xee,0x6c,0x6c,0x6c,0x6c, //字符004:[M]
0x54,0x54,0x54,0x54,0x54,0xd6,0x00,0x00,
0x00,0x00,0x00,0xc7,0x62,0x62,0x52,0x52, //字符005:[N]
0x4a,0x4a,0x4a,0x46,0x46,0xe2,0x00,0x00,
0x00,0x00,0x00,0x3e,0x42,0x42,0x40,0x20, //字符006:[S]
0x18,0x04,0x02,0x42,0x42,0x7c,0x00,0x00,
0x00,0x00,0x00,0xe7,0x42,0x42,0x42,0x42, //字符007:[U]
0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00,
0x00,0x00,0x00,0xd6,0x92,0x92,0x92,0x92, //字符003:[W]
0xaa,0xaa,0x6c,0x44,0x44,0x44,0x00,0x00
};
unsigned char code ChineseCharDot[]={
0x08,0x00,0x08,0x10,0x08,0x20,0x08,0x40, //字符001:[長(zhǎng)]
0x09,0x80,0x0e,0x00,0x08,0x00,0xff,0xfe,
0x0a,0x00,0x09,0x00,0x08,0x80,0x08,0x40,
0x09,0x30,0x0a,0x1c,0x0c,0x08,0x08,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x3f,0xf8, //字符002:[電]
0x21,0x08,0x21,0x08,0x3f,0xf8,0x21,0x08,
0x21,0x08,0x21,0x08,0x3f,0xf8,0x21,0x08,
0x01,0x02,0x01,0x02,0x00,0xfe,0x00,0x00,
0x00,0x00,0x04,0x40,0x06,0x40,0x04,0x40, //字符003:[公]
0x08,0x20,0x08,0x10,0x10,0x18,0x22,0x0e,
0x43,0x04,0x02,0x00,0x04,0x20,0x08,0x10,
0x11,0xf8,0x3f,0x18,0x10,0x10,0x00,0x00,
0x01,0x00,0x01,0x80,0x01,0x00,0x01,0x00, //字符004:[人]
0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80,
0x04,0x80,0x04,0x40,0x08,0x60,0x08,0x30,
0x10,0x18,0x20,0x0e,0x40,0x04,0x00,0x00,
0x20,0x40,0x10,0x40,0x10,0x40,0x01,0x50, //字符005:[沙]
0x41,0x48,0x2a,0x44,0x0a,0x42,0x14,0x40,
0x10,0x44,0x20,0x44,0xe0,0x08,0x20,0x10,
0x20,0x20,0x20,0xc0,0x23,0x00,0x2c,0x00,
0x00,0x00,0x3f,0xfc,0x00,0x04,0x00,0x04, //字符006:[司]
0x7f,0xe4,0x00,0x04,0x00,0x04,0x3f,0xc4,
0x20,0x44,0x20,0x44,0x3f,0xc4,0x20,0x44,
0x20,0x04,0x00,0x14,0x00,0x08,0x00,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00, //字符007:[太]
0x7f,0xfe,0x01,0x00,0x01,0x00,0x01,0x00,
0x02,0x80,0x02,0x40,0x04,0x20,0x05,0x10,
0x08,0x98,0x10,0xcc,0x20,0x86,0x40,0x04,
0x00,0x00,0xfb,0xf8,0x92,0x08,0x93,0xf8, //字符008:[限]
0xa2,0x08,0xa2,0x08,0x93,0xf8,0x8a,0x80,
0x8a,0x48,0xaa,0x50,0x92,0x20,0x82,0x20,
0x82,0x10,0x82,0x8e,0x83,0x04,0x82,0x00,
0x00,0x00,0x7d,0xfc,0x45,0x04,0x49,0x04, //字符009:[陽(yáng)]
0x49,0x04,0x51,0x04,0x49,0xfc,0x45,0x04,
0x45,0x04,0x45,0x04,0x69,0x04,0x51,0x04,
0x41,0xfc,0x41,0x04,0x40,0x00,0x40,0x00,
0x01,0x00,0x01,0x00,0x7f,0xfe,0x02,0x00, //字符010:[有]
0x04,0x00,0x0f,0xf0,0x18,0x10,0x28,0x10,
0x4f,0xf0,0x88,0x10,0x08,0x10,0x0f,0xf0,
0x08,0x10,0x08,0x90,0x08,0x70,0x08,0x20,
0x00,0x00,0x3f,0xf0,0x00,0x20,0x00,0x40, //字符011:[子]
0x00,0x80,0x01,0x00,0x01,0x00,0x01,0x04,
0xff,0xfe,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00
};
//-------------------------------------------------------------------------------
//以下為圖片庫(kù)點(diǎn)陣代碼
//實(shí)際使用時(shí)請(qǐng)包含由SUNMAN圖形點(diǎn)陣代碼生成器.EXE自動(dòng)生成的imagelib.c文件來(lái)替換該
//部分
unsigned char code Img_sunman_32[]={32,32,
0x00,0x0f,0xf0,0x00,
0x00,0x7f,0xfe,0x00,
0x01,0xf0,0x0f,0x80,
0x03,0xc0,0x03,0xc0,
0x07,0x0f,0xf0,0xe0,
0x0e,0x3f,0xfc,0x70,
0x1c,0xfe,0x7f,0x38,
0x39,0xfc,0x3f,0x9c,
0x33,0xfc,0x3f,0xcc,
0x73,0xfe,0x7f,0xce,
0x67,0xff,0xff,0xe6,
0x67,0xe7,0xe7,0xe6,
0xcf,0xe3,0xc7,0xf3,
0xcf,0xe1,0x87,0xff,
0xcf,0xe4,0x27,0xff,
0xc0,0x06,0x60,0x03,
0xc0,0x07,0xe0,0x03,
0xff,0xe7,0xe7,0xf3,
0xff,0xe7,0xe7,0xf3,
0xcf,0xe7,0xe7,0xf3,
0x67,0xe7,0xe7,0xe6,
0x67,0xff,0xff,0xe6,
0x73,0xff,0xff,0xce,
0x33,0xff,0xff,0xcc,
0x39,0xff,0xff,0x9c,
0x1c,0xff,0xff,0x38,
0x0e,0x3f,0xfc,0x70,
0x07,0x0f,0xf0,0xe0,
0x03,0xc0,0x03,0xc0,
0x01,0xf0,0x0f,0x80,
0x00,0x7f,0xfe,0x00,
0x00,0x0f,0xf0,0x00
};
//-------------------------------------------------------------------------------