?? smg19264a_z_exsample_c51.c
字號(hào):
//SMG19264A標(biāo)準(zhǔn)圖形點(diǎn)陣型液晶顯示模塊的演示程序[C51編程語(yǔ)言][MCS51總線接口方式]
//應(yīng)用產(chǎn)品: SMG19264A標(biāo)準(zhǔn)圖形點(diǎn)陣型液晶顯示模塊
// 本演示程序適用于SMG19264A液晶顯示模塊與MCS51系列單片機(jī)采用MCS51總線的
//硬件連線方式。
// 本演示程序包括KS0108B兼容芯片的MCS51總線接口子程序集,KS0108B兼容芯片的19264
//液晶顯示模塊的基本子程序,19264系列繪圖子程序集,19264系列圖形子程序集,19264系列
//精簡(jiǎn)中英文字庫(kù)子程序集,以及SMG19264A系列標(biāo)準(zhǔn)圖形點(diǎn)陣型液晶顯示的演示子程序.
// 本演示的內(nèi)容為,在192列X64行的點(diǎn)陣液晶顯示屏上清屏,圖片演示,英文字符串演示,
//中文字符串演示,反白顯示字符串,繪制矩形,寫點(diǎn),繪制直線,全屏顯示.
//-------------------------------------------------------------------------------
//創(chuàng)建日期: 2009.08.31
//軟件環(huán)境: VW For Windows
//硬件環(huán)境: AT89C52 MCU,MCS-51系列 MCU,etc.
//創(chuàng)建人: 褚建軍(chujianjun@sunman.cn),譚超(tanchao@sunman.cn).
//技術(shù)支持: 電話(0731-84167806,84167807),傳真(0731-84167807),網(wǎng)址(www.sunman.cn)
//版權(quán)信息: 長(zhǎng)沙太陽(yáng)人電子有限公司版權(quán)所有,轉(zhuǎn)載請(qǐng)指明出處.
//參考網(wǎng)頁(yè): http:/www.sunman.cn/lcm/product/SMG19264A.html
//-------------------------------------------------------------------------------
#include <reg51.h>
#include <intrins.h>
//以下為演示程序的函數(shù)定義
void exsample(void); //演示程序
void exdelay(void); //演示延時(shí)子程序
void putchar(unsigned int c); //定位寫字符子程序
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 setlcdvoltage(unsigned char vol); //LCD電壓設(shè)置
void lcdwd(unsigned char d); //送圖形數(shù)據(jù)子程序
unsigned char lcdrd(void); //讀圖形數(shù)據(jù)子程序
void lcdwc(unsigned char c); //送指令子程序
void lcdwaitidle(void); //忙檢測(cè)子程序
void lcdwd1(unsigned char d); //送圖形數(shù)據(jù)子程序
unsigned char lcdrd1(void); //讀圖形數(shù)據(jù)子程序
void lcdwc1(unsigned char c); //送指令子程序
void lcdwaitidle1(void); //忙檢測(cè)子程序
void lcdwd2(unsigned char d); //送圖形數(shù)據(jù)子程序
unsigned char lcdrd2(void); //讀圖形數(shù)據(jù)子程序
void lcdwc2(unsigned char c); //送指令子程序
void lcdwaitidle2(void); //忙檢測(cè)子程序
void lcdwd3(unsigned char d); //送圖形數(shù)據(jù)子程序
unsigned char lcdrd3(void); //讀圖形數(shù)據(jù)子程序
void lcdwc3(unsigned char c); //送指令子程序
void lcdwaitidle3(void); //忙檢測(cè)子程序
//-------------------------------------------------------------------------------
//SMG19264A產(chǎn)品引腳說(shuō)明及演示連線
//PIN1: DB7 [Data I/O]-----------------------------P0.7
//PIN2: DB6 [Data I/O]-----------------------------P0.6
//PIN3: DB5 [Data I/O]-----------------------------P0.5
//PIN4: DB4 [Data I/O]-----------------------------P0.4
//PIN5: DB3 [Data I/O]-----------------------------P0.3
//PIN6: DB2 [Data I/O]-----------------------------P0.2
//PIN7: DB1 [Data I/O]-----------------------------P0.1
//PIN8: DB0 [Data I/O]-----------------------------P0.0
//PIN9: E [使能信號(hào)輸入 高有效]------------------見使用說(shuō)明書
//PIN10:RW [讀寫信號(hào)選擇端 1:讀操作 0:寫操作]-----P2.3
//PIN11:RS [數(shù)據(jù)/命令選擇端 1:數(shù)據(jù) 0:命令]--------P2.0
//PIN12:Vo [LCD偏壓輸入]--------------------------見使用說(shuō)明書
//PIN13:VDD [電源正極]-----------------------------+5V
//PIN14:VSS [電源地]-------------------------------VSS
//PIN15:CSA [片選A信號(hào)輸入]------------------------P2.2
//PIN16:CSB [片選B信號(hào)輸入]------------------------P2.1
//PIN17:RST [復(fù)位信號(hào)輸入(H:正常工作,L:復(fù)位)]-----VDD
//PIN18:VEE [LCD驅(qū)動(dòng)負(fù)壓輸出(-10V)]----------------見使用說(shuō)明書
//PIN19:LED+ [背光源正極]---------------------------見使用說(shuō)明書
//PIN20:LED- [背光源負(fù)極]---------------------------見使用說(shuō)明書
//注:8031的晶振頻率為12MHz.
//請(qǐng)參見http://download.sunman.cn/lcm/product/1/SMG19264A.pdf
//-------------------------------------------------------------------------------
//以下為產(chǎn)品接口引腳在演示程序中的預(yù)定義
//用戶在編寫應(yīng)用程序時(shí),需按自己的實(shí)際硬件連線來(lái)重新定義
//以下CS(P2.7)=1
//RW(P2.3) CSA(P2.2) CSB(P2.1) RS(P2.0)
unsigned char xdata LCDC1RREG _at_ 0x8800;//地址RW=1,CSA=0,CSB=0,RS=0
unsigned char xdata LCDC1WREG _at_ 0x8000;//地址RW=0,CSA=0,CSB=0,RS=0
unsigned char xdata LCDC2RREG _at_ 0x8C00;//地址RW=1,CSA=1,CSB=0,RS=0
unsigned char xdata LCDC2WREG _at_ 0x8400;//地址RW=0,CSA=1,CSB=0,RS=0
unsigned char xdata LCDC3RREG _at_ 0x8A00;//地址RW=1,CSA=0,CSB=1,RS=0
unsigned char xdata LCDC3WREG _at_ 0x8200;//地址RW=0,CSA=0,CSB=1,RS=0
unsigned char xdata LCDD1RREG _at_ 0x8900;//地址RW=1,CSA=0,CSB=0,RS=1
unsigned char xdata LCDD1WREG _at_ 0x8100;//地址RW=0,CSA=0,CSB=0,RS=1
unsigned char xdata LCDD2RREG _at_ 0x8D00;//地址RW=1,CSA=1,CSB=0,RS=1
unsigned char xdata LCDD2WREG _at_ 0x8500;//地址RW=0,CSA=1,CSB=0,RS=1
unsigned char xdata LCDD3RREG _at_ 0x8B00;//地址RW=1,CSA=0,CSB=1,RS=1
unsigned char xdata LCDD3WREG _at_ 0x8300;//地址RW=0,CSA=0,CSB=1,RS=1
//-------------------------------------------------------------------------------
//以下XPOS,YPOS變量用于指示當(dāng)前操作點(diǎn)的位置的預(yù)定義
//用戶在編寫應(yīng)用程序時(shí),需按自己的實(shí)際軟件程序需要來(lái)重新定義
unsigned char XPOS; //列方向LCD點(diǎn)陣位置指針
unsigned char YPOS; //行方向LCD點(diǎn)陣位置指針
bit CharImageReverse; //字符及圖形的反顯控制,0(正常顯示),1(反顯)
#define XDOTS 192 //圖形空間X方向大小
#define YDOTS 64 //圖形空間X方向大小
//-------------------------------------------------------------------------------
//以下為精簡(jiǎn)版中英文字庫(kù)
//實(shí)際使用時(shí)請(qǐng)包含由Sunman精簡(jiǎn)版中英文字符庫(kù)代碼生成器.exe自動(dòng)生成的charlib.c文
//文件來(lái)替換該部分
#define ENGLISHCHARNUMBER 5 //精簡(jiǎn)版英文字符庫(kù)中的英文字符的個(gè)數(shù)
#define CHINESECHARNUMBER 5 //精簡(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 int code EnglishCode[]={
0x41, //字符001:[A]
0x4d, //字符002:[M]
0x4e, //字符003:[N]
0x53, //字符004:[S]
0x55 //字符005:[U]
};
unsigned int code ChineseCode[]={
0xb5e7, //字符001:[電]
0xc8cb, //字符002:[人]
0xccab, //字符003:[太]
0xd1f4, //字符004:[陽(yáng)]
0xd7d3 //字符005:[子]
};
unsigned char code EnglishCharDot[]={
0x00,0x20,0x00,0x3c,0xc0,0x23,0x38,0x02, //字符001:[A]
0xe0,0x02,0x00,0x27,0x00,0x38,0x00,0x00,
0x08,0x20,0xf8,0x3f,0xf8,0x00,0x00,0x3f, //字符002:[M]
0xf8,0x00,0xf8,0x3f,0x08,0x20,0x00,0x00,
0x08,0x20,0xf8,0x3f,0x30,0x20,0xc0,0x00, //字符003:[N]
0x00,0x07,0x08,0x18,0xf8,0x3f,0x00,0x00,
0x00,0x00,0x70,0x38,0x88,0x20,0x08,0x21, //字符004:[S]
0x08,0x21,0x08,0x22,0x38,0x1c,0x00,0x00,
0x08,0x00,0xf8,0x1f,0x08,0x20,0x00,0x20, //字符005:[U]
0x00,0x20,0x08,0x20,0xf8,0x1f,0x00,0x00
};
unsigned char code ChineseCharDot[]={
0x00,0x00,0x00,0x00,0xf8,0x0f,0x48,0x04, //字符001:[電]
0x48,0x04,0x48,0x04,0x48,0x04,0xff,0x3f,
0x48,0x44,0x48,0x44,0x48,0x44,0x48,0x44,
0xf8,0x4f,0x00,0x40,0x00,0x70,0x00,0x00,
0x00,0x00,0x00,0x40,0x00,0x20,0x00,0x10, //字符002:[人]
0x00,0x0c,0x00,0x03,0xc0,0x00,0x3f,0x00,
0xc2,0x01,0x00,0x06,0x00,0x0c,0x00,0x18,
0x00,0x30,0x00,0x60,0x00,0x20,0x00,0x00,
0x00,0x00,0x10,0x80,0x10,0x40,0x10,0x20, //字符003:[太]
0x10,0x10,0x10,0x0c,0x10,0x03,0xff,0x08,
0x10,0x71,0x10,0x22,0x10,0x04,0x10,0x18,
0x10,0x30,0x10,0xe0,0x10,0x40,0x00,0x00,
0x00,0x00,0xfe,0xff,0x02,0x04,0x22,0x08, //字符004:[陽(yáng)]
0x5a,0x04,0x86,0x03,0x00,0x00,0xfe,0x3f,
0x42,0x10,0x42,0x10,0x42,0x10,0x42,0x10,
0x42,0x10,0xfe,0x3f,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x01,0x02,0x01,0x02,0x01, //字符005:[子]
0x02,0x01,0x02,0x41,0x02,0x81,0xe2,0x7f,
0x12,0x01,0x0a,0x01,0x06,0x01,0x02,0x01,
0x00,0x01,0x80,0x01,0x00,0x01,0x00,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,0xf0,0x0f,0x00,
0x00,0xfe,0x7f,0x00,
0x80,0x0f,0xf6,0x01,
0xc0,0x03,0xc6,0x03,
0xe0,0x70,0x0e,0x07,
0x70,0x7c,0x3e,0x0e,
0x38,0x7f,0xfe,0x1c,
0x9c,0x7f,0xfe,0x39,
0xcc,0x7f,0xfe,0x33,
0xce,0x7f,0xfe,0x73,
0xe6,0x7f,0xfe,0x67,
0xe6,0x07,0xe0,0x67,
0xf3,0x07,0xe0,0xcf,
0xf3,0xcf,0xff,0xcf,
0x73,0x9e,0xff,0xcf,
0x33,0x3c,0xff,0xcf,
0x33,0x3c,0xff,0xcf,
0x73,0x9e,0xff,0xcf,
0xf3,0xcf,0xff,0xcf,
0xf3,0x07,0xe0,0xcf,
0xe6,0x07,0xe0,0x67,
0xe6,0x7f,0xfe,0x67,
0xce,0x7f,0xfe,0x73,
0xcc,0x7f,0xfe,0x33,
0x9c,0x7f,0xfe,0x39,
0x38,0x7f,0xfe,0x1c,
0x70,0x7c,0x3e,0x0e,
0xe0,0x70,0x0e,0x07,
0xc0,0x63,0xc0,0x03,
0x80,0x6f,0xf0,0x01,
0x00,0xfe,0x7f,0x00,
0x00,0xf0,0x0f,0x00
};
//-------------------------------------------------------------------------------
void main(void)
{ while(1)
{ lcdreset(); //初始化液晶顯示控制器
exsample(); //演示程序
}
}
void exsample(void) //演示程序
{
//0.演示前的準(zhǔn)備,將LCD液晶顯示全部清空
CharImageReverse=0; //反顯關(guān)閉
lcdfill(0); //清屏
//1.圖片測(cè)試: 在(40,16)位置顯示32點(diǎn)陣SUNMAN圖標(biāo)
XPOS=40;
YPOS=16;
putimage(Img_sunman_32); //寫數(shù)據(jù)到當(dāng)前LCDRAM地址中
exdelay(); //延時(shí)約600mS
//2.字符串測(cè)試: 在(88,16)位置顯示"SUNMAN"字符串.
XPOS=88;
YPOS=16;
putstr("SUNMAN");
exdelay(); //延時(shí)約600mS
//3.字符串測(cè)試: 在(72,32)位置顯示"太陽(yáng)人電子"字符串.
XPOS=72;
YPOS=32;
putstr("太陽(yáng)人電子");
exdelay(); //延時(shí)約600mS
//4.反顯測(cè)試: 在(72,32)位置反顯"太陽(yáng)人電子"字符串.
XPOS=72;
YPOS=32;
CharImageReverse=1;
putstr("太陽(yáng)人電子");
CharImageReverse=0;
exdelay(); //延時(shí)約600mS
//5.繪圖測(cè)試: RECT(6,14)-(186,50),畫矩形.
rect(6,14,186,50,1);
exdelay(); //延時(shí)約600mS
//6.繪圖測(cè)試: POINT(6,52),畫點(diǎn).
XPOS=6;
YPOS=52;
point(1);
exdelay(); //延時(shí)約600mS
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -