“(SKU:RB-05L003)LCD12864點(diǎn)陣液晶擴(kuò)展板”的版本間的差異
來(lái)自ALSROBOT WiKi
(→?應(yīng)用例程) |
|||
第41行: | 第41行: | ||
* PIN20 ----LED- ,背光 -,一般接GND。 | * PIN20 ----LED- ,背光 -,一般接GND。 | ||
==應(yīng)用例程== | ==應(yīng)用例程== | ||
+ | ===示例代碼=== | ||
+ | <pre style='color:blue'>/************************************************************ | ||
+ | 機(jī)器人基地 RobotBase www.robatbase.cn | ||
+ | 目 的: 12864LCD_Parallel功能測(cè)試實(shí)驗(yàn)例程 | ||
+ | 目標(biāo)系統(tǒng): Carduino Mega168/Arduino Mega168/Mega328/Mega1280控制器 | ||
+ | 應(yīng)用軟件: Arduino 0023 | ||
+ | 功能描述: 顯示完整字符 | ||
+ | 發(fā)布時(shí)間: 2015-01-28 | ||
+ | 說(shuō) 明: 若用于商業(yè)用途,請(qǐng)保留此段文字或注明代碼來(lái)源 | ||
+ | 哈爾濱奧松機(jī)器人科技有限公司保留所有版權(quán) | ||
+ | ************************************************************/ | ||
+ | #include "PIC.h" | ||
+ | int RS = 2; | ||
+ | int RW = 3; | ||
+ | int E = 4; | ||
+ | //DB should be an unseparated group of pins | ||
+ | unsigned char DB[] = { | ||
+ | 6,7,8,9,10,11,12,13}; //wire these to DB6~13 on LCD. | ||
+ | //基本指令集預(yù)定義 | ||
+ | #define LCD_DATA 1 //數(shù)據(jù)位 | ||
+ | #define LCD_COMMAND 0 //命令位 | ||
+ | #define LCD_CLEAR_SCREEN 0x01 //清屏 | ||
+ | #define LCD_ADDRESS_RESET 0x02 //地址歸零 | ||
+ | #define LCD_BASIC_FUNCTION 0x30 //基本指令集 | ||
+ | #define LCD_EXTEND_FUNCTION 0x34 //擴(kuò)充指令集 | ||
+ | |||
+ | //擴(kuò)展指令集預(yù)定義 | ||
+ | #define LCD_AWAIT_MODE 0x01 //待命模式 | ||
+ | #define LCD_ROLLADDRESS_ON 0x03 //允許輸入垂直卷動(dòng)地址 | ||
+ | #define LCD_IRAMADDRESS_ON 0x02 //允許輸入IRAM地址 | ||
+ | #define LCD_SLEEP_MODE 0x08 //進(jìn)入睡眠模式 | ||
+ | #define LCD_NO_SLEEP_MODE 0x0c //脫離睡眠模式 | ||
+ | #define LCD_GRAPH_ON 0x36 //打開(kāi)繪圖模式 | ||
+ | #define LCD_GRAPH_OFF 0x34 //關(guān)閉繪圖模式 | ||
+ | void setup() | ||
+ | { | ||
+ | LCD_Init(); | ||
+ | LCD_ClearRam(); | ||
+ | // lcd.LCD_DisplayStrings_WithAddress(0x90,"ST7920 testing... processing"); | ||
+ | // pinMode(13,OUTPUT); | ||
+ | } | ||
+ | void loop() | ||
+ | { | ||
+ | LCD_DisplayStrings_WithAddress(0x80," Welcome to "); | ||
+ | LCD_DisplayStrings_WithAddress(0x90,"www.robotbase.cn"); | ||
+ | LCD_DisplayStrings_WithAddress(0x88,"LCD 12864 Module"); | ||
+ | LCD_DisplayStrings_WithAddress(0x98,"ST7920 testing.."); | ||
+ | delay(5000); | ||
+ | LCD_ClearRam(); | ||
+ | chsDisplay_16bit(0x80, 0xb4f2);//打 | ||
+ | chsDisplay_16bit(0x81, 0xd4ec);//造 | ||
+ | chsDisplay_16bit(0x82, 0xb9fa);//國(guó) | ||
+ | chsDisplay_16bit(0x83, 0xc4da);//內(nèi) | ||
+ | chsDisplay_16bit(0x84, 0xcde2);//外 | ||
+ | chsDisplay_16bit(0x85, 0xd7ee);//最 | ||
+ | chsDisplay_16bit(0x86, 0xb4f3);//大 | ||
+ | chsDisplay_16bit(0x90, 0xbbfa);//機(jī) | ||
+ | chsDisplay_16bit(0x91, 0xc6f7);//器 | ||
+ | chsDisplay_16bit(0x92, 0xc8cb);//人 | ||
+ | chsDisplay_16bit(0x93, 0xc5e4);//配 | ||
+ | chsDisplay_16bit(0x94, 0xbcfe);//件 | ||
+ | chsDisplay_16bit(0x95, 0xc9cc);//商 | ||
+ | chsDisplay_16bit(0x96, 0xb3c7);//城 | ||
+ | chsDisplay_16bit(0x88, 0xb8fc);//更 | ||
+ | chsDisplay_16bit(0x89, 0xb6e0);//多 | ||
+ | chsDisplay_16bit(0x8a, 0xd7ca);//資 | ||
+ | chsDisplay_16bit(0x8b, 0xd1b6);//訊 | ||
+ | chsDisplay_16bit(0x8c, 0xc7eb);//請(qǐng) | ||
+ | chsDisplay_16bit(0x8d, 0xb5c7);//登 | ||
+ | chsDisplay_16bit(0x8e, 0xc2bc);//錄 | ||
+ | LCD_DisplayStrings_WithAddress(0x98,"www.robotbase.cn"); | ||
+ | delay(5000); | ||
+ | LCD_ClearRam(); | ||
+ | LCD_ImgDisplay_from_flash(logo); | ||
+ | delay(5000); | ||
+ | LCD_ClearRam(); | ||
+ | LCD_ImgDisplay_from_flash(QQ); | ||
+ | delay(5000); | ||
+ | LCD_ClearRam(); | ||
+ | } | ||
+ | void LCD_Init(void) | ||
+ | { | ||
+ | pinMode(E,OUTPUT); | ||
+ | pinMode(RS,OUTPUT); | ||
+ | pinMode(RW,OUTPUT); | ||
+ | pinMode(6,OUTPUT); | ||
+ | pinMode(7,OUTPUT); | ||
+ | pinMode(8,OUTPUT); | ||
+ | pinMode(9,OUTPUT); | ||
+ | pinMode(10,OUTPUT); | ||
+ | pinMode(11,OUTPUT); | ||
+ | pinMode(12,OUTPUT); | ||
+ | pinMode(13,OUTPUT); | ||
+ | delay(100); | ||
+ | LCD_Write(0,0x30); //基本指令動(dòng)作 | ||
+ | LCD_Write(0,0x02); //地址歸位 | ||
+ | LCD_Write(0,0x0C); //開(kāi)顯示,關(guān)游標(biāo) | ||
+ | LCD_Write(0,0x01);//清屏,地址指針指向00H | ||
+ | LCD_Write(0,0x06); //光標(biāo)的移動(dòng)方向 | ||
+ | LCD_Write(0,0x80); //設(shè)定顯示的起始地址 | ||
+ | } | ||
+ | void LCD_Write( unsigned char Data_Command , unsigned char uc_Content ) | ||
+ | { | ||
+ | digitalWrite(RW,LOW); //RW = 0; //寫(xiě)模式 | ||
+ | if(Data_Command) | ||
+ | { | ||
+ | digitalWrite(RS,HIGH); //RS = 1; //數(shù)據(jù) | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | digitalWrite(RS,LOW); //RS = 0; //指令 | ||
+ | } | ||
+ | |||
+ | unsigned char i; | ||
+ | for (i=DB[0]; i <= DB[7]; i++) | ||
+ | { | ||
+ | digitalWrite(i,uc_Content & 0x01); | ||
+ | uc_Content >>= 1; | ||
+ | }//發(fā)送數(shù)據(jù) | ||
+ | digitalWrite(E,HIGH); //E = 1; | ||
+ | delay(5); //延時(shí) | ||
+ | digitalWrite(E,LOW); //E = 0; | ||
+ | } | ||
+ | void LCD_ClearRam(void) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令集 | ||
+ | LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏 | ||
+ | } | ||
+ | void LCD_DDRAM_AddressSet(unsigned char ucDDramAdd) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令集 | ||
+ | LCD_Write(LCD_COMMAND,ucDDramAdd); //設(shè)定DDRAM地址到地址計(jì)數(shù)器AC | ||
+ | } | ||
+ | void LCD_CGRAM_AddressSet(unsigned char ucCGramAdd) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令集 | ||
+ | LCD_Write(LCD_COMMAND,ucCGramAdd); //設(shè)定CGRAM地址到地址計(jì)數(shù)器AC | ||
+ | } | ||
+ | void LCD_GDRAM_AddressSet(unsigned char ucGDramAdd) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_EXTEND_FUNCTION); //擴(kuò)展指令集 | ||
+ | LCD_Write(LCD_COMMAND,ucGDramAdd); | ||
+ | } | ||
+ | void chsDisplay_8bit(unsigned char ucAdd, unsigned char code) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令動(dòng)作 | ||
+ | LCD_DDRAM_AddressSet(ucAdd); | ||
+ | LCD_Write(LCD_DATA, code); | ||
+ | } | ||
+ | void chsDisplay_16bit(unsigned char ucAdd, unsigned int code) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令動(dòng)作 | ||
+ | LCD_DDRAM_AddressSet(ucAdd); | ||
+ | unsigned char temp; | ||
+ | delay(2); | ||
+ | temp = (code&0xFF00)>>8; | ||
+ | LCD_Write(1,temp); | ||
+ | |||
+ | temp = code&0x00FF; | ||
+ | LCD_Write(1,temp); | ||
+ | } | ||
+ | void LCD_DisplayStrings_WithAddress(unsigned char ucAdd,const char *p) | ||
+ | { | ||
+ | unsigned char length; | ||
+ | length = strlen(p); | ||
+ | LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令動(dòng)作 | ||
+ | LCD_DDRAM_AddressSet(ucAdd); | ||
+ | for( ; length ; length -- ) | ||
+ | LCD_Write(LCD_DATA, *(p++)); | ||
+ | } | ||
+ | void LCD_GraphModeSet(unsigned char Select) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_EXTEND_FUNCTION); //擴(kuò)展指令集 | ||
+ | if(Select) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_GRAPH_ON); //打開(kāi)繪圖模式 | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,LCD_GRAPH_OFF); //關(guān)閉繪圖模式 | ||
+ | } | ||
+ | } | ||
+ | void LCD_ImgDisplay(unsigned char *img) | ||
+ | { | ||
+ | unsigned char i,j; | ||
+ | LCD_GraphModeSet(0x00); //先關(guān)閉圖形顯示功能 | ||
+ | for(j=0;j<32;j++) | ||
+ | { | ||
+ | for(i=0;i<8;i++) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,0x80+j); //設(shè)定垂直坐標(biāo) | ||
+ | LCD_Write(LCD_COMMAND,0x80+i); //設(shè)定水平坐標(biāo) | ||
+ | LCD_Write(LCD_DATA,img[j*16+i*2]); //放入數(shù)據(jù)高字節(jié) | ||
+ | LCD_Write(LCD_DATA,img[j*16+i*2+1]); //放入數(shù)據(jù)低字節(jié) | ||
+ | } | ||
+ | } | ||
+ | for(j=32;j<64;j++) | ||
+ | { | ||
+ | for(i=0;i<8;i++) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,0x80+j-32); | ||
+ | LCD_Write(LCD_COMMAND,0x88+i); | ||
+ | LCD_Write(LCD_DATA,img[j*16+i*2]); | ||
+ | LCD_Write(LCD_DATA,img[j*16+i*2+1]); | ||
+ | } | ||
+ | } | ||
+ | LCD_GraphModeSet(0x01);//最后打開(kāi)圖形顯示功能 | ||
+ | } | ||
+ | void LCD_ImgDisplay_from_flash(unsigned char *img) | ||
+ | { | ||
+ | unsigned char *data = img; | ||
+ | unsigned char i,j; | ||
+ | LCD_GraphModeSet(0x00); | ||
+ | |||
+ | for(i=0;i<32;i++) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,0x80|i); | ||
+ | LCD_Write(LCD_COMMAND,0x80); | ||
+ | for(j=0;j<16;j++) | ||
+ | { | ||
+ | LCD_Write(LCD_DATA,pgm_read_byte(data++)); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | for(i=0;i<32;i++) | ||
+ | { | ||
+ | LCD_Write(LCD_COMMAND,0x80|i); | ||
+ | LCD_Write(LCD_COMMAND,0x88); | ||
+ | for(j=0;j<16;j++) | ||
+ | { | ||
+ | LCD_Write(LCD_DATA,pgm_read_byte(data++)); | ||
+ | } | ||
+ | } | ||
+ | LCD_GraphModeSet(0x01); | ||
+ | LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); | ||
+ | }</pre> | ||
+ | ===程序效果=== | ||
字跡顯示清晰 | 字跡顯示清晰 | ||
[[文件:RB-05L0031.jpg|500px|縮略圖|居中]] | [[文件:RB-05L0031.jpg|500px|縮略圖|居中]] | ||
? | + | ||
? | + | ||
==產(chǎn)品相關(guān)推薦== | ==產(chǎn)品相關(guān)推薦== | ||
購(gòu)買(mǎi)地址:[http://lifestyle201.com/goods-128.html LCD12864點(diǎn)陣液晶擴(kuò)展板] | 購(gòu)買(mǎi)地址:[http://lifestyle201.com/goods-128.html LCD12864點(diǎn)陣液晶擴(kuò)展板] |
2015年6月12日 (五) 15:41的版本
目錄 |
產(chǎn)品概述
2014年最新推出的12864液晶板采用的是帶漢字庫(kù)圖形點(diǎn)陣液晶顯示模塊,具有串行和并行接口,背光控制開(kāi)關(guān)(串行與并行模式均可使用),對(duì)比度調(diào)節(jié)旋鈕,板上集成IDC6插座和IDC14插座,可通過(guò)套件中附送的專(zhuān)用連接線(xiàn)與Arduino傳感器擴(kuò)展板連接,無(wú)需再買(mǎi)相關(guān)轉(zhuǎn)接板,通過(guò)我們提供的例子程序,您可以用Arduino控制器做控制完成顯示8192個(gè)中文漢字(16X16點(diǎn)陣)、128個(gè)字符(8X16點(diǎn)陣)和圖形顯示(128X64點(diǎn)陣)功能,輕松制作Arduino互動(dòng)顯示器最佳選擇。
規(guī)格參數(shù)
- 電源電壓:VDD+3.3V~+5.5V(內(nèi)置升壓電路,無(wú)需負(fù)壓)
- 控制器:ST7920
- 點(diǎn)陣個(gè)數(shù):128列×64行
- 顯示顏色:藍(lán)底白字
- 可視角度:170度
- LCD類(lèi)型:STN
- 控制接口:8位或4位并行和3位串行
- LED背光:藍(lán)色
- 軟件功能:光標(biāo)顯示、畫(huà)面移位、自定義字符、反白顯示、睡眠模式等
- 邏輯工作電壓(VDD):4.5~5.5V
- 電源地(GND):0V
- 工作溫度:-20℃~70℃
- 存儲(chǔ)溫度:-30℃~80℃
- 模塊尺寸:93×70×22mm
- 視域尺寸:73×39mm
使用方法
工作于并行模式時(shí)的引腳定義:
- PIN1------ GND 電源接入 -, 一般接0V。
- PIN2------電源接入 +, 一般接5V。
- PIN3------對(duì)比度調(diào)整端,VDD和GND接可調(diào)電阻兩端,中間抽頭接至V0。
- PIN4------RS 指令/數(shù)據(jù)選擇
- PIN5------R/W 讀寫(xiě)選擇
- PIN6------E,信號(hào)使能
- PIN7------D0,數(shù)據(jù)位0
- PIN8------D1,數(shù)據(jù)位1
- PIN9------D2,數(shù)據(jù)位2
- PIN10-----D3,數(shù)據(jù)位3
- PIN11-----D4,數(shù)據(jù)位4
- PIN12-----D5,數(shù)據(jù)位5
- PIN13-----D6,數(shù)據(jù)位6
- PIN14-----D7,數(shù)據(jù)位7
- PIN15-----PSB 并行:PSB=1,可以接VCC; 串行:PSB=0,一般接GND
- PIN16 ----NC,不連接
- PIN17-----~RST,模塊復(fù)位,可不連接
- PIN18 ----NC,不連接
- PIN19 ----LED+ ,背光 +,一般接5V。
- PIN20 ----LED- ,背光 -,一般接GND。
應(yīng)用例程
示例代碼
/************************************************************ 機(jī)器人基地 RobotBase www.robatbase.cn 目 的: 12864LCD_Parallel功能測(cè)試實(shí)驗(yàn)例程 目標(biāo)系統(tǒng): Carduino Mega168/Arduino Mega168/Mega328/Mega1280控制器 應(yīng)用軟件: Arduino 0023 功能描述: 顯示完整字符 發(fā)布時(shí)間: 2015-01-28 說(shuō) 明: 若用于商業(yè)用途,請(qǐng)保留此段文字或注明代碼來(lái)源 哈爾濱奧松機(jī)器人科技有限公司保留所有版權(quán) ************************************************************/ #include "PIC.h" int RS = 2; int RW = 3; int E = 4; //DB should be an unseparated group of pins unsigned char DB[] = { 6,7,8,9,10,11,12,13}; //wire these to DB6~13 on LCD. //基本指令集預(yù)定義 #define LCD_DATA 1 //數(shù)據(jù)位 #define LCD_COMMAND 0 //命令位 #define LCD_CLEAR_SCREEN 0x01 //清屏 #define LCD_ADDRESS_RESET 0x02 //地址歸零 #define LCD_BASIC_FUNCTION 0x30 //基本指令集 #define LCD_EXTEND_FUNCTION 0x34 //擴(kuò)充指令集 //擴(kuò)展指令集預(yù)定義 #define LCD_AWAIT_MODE 0x01 //待命模式 #define LCD_ROLLADDRESS_ON 0x03 //允許輸入垂直卷動(dòng)地址 #define LCD_IRAMADDRESS_ON 0x02 //允許輸入IRAM地址 #define LCD_SLEEP_MODE 0x08 //進(jìn)入睡眠模式 #define LCD_NO_SLEEP_MODE 0x0c //脫離睡眠模式 #define LCD_GRAPH_ON 0x36 //打開(kāi)繪圖模式 #define LCD_GRAPH_OFF 0x34 //關(guān)閉繪圖模式 void setup() { LCD_Init(); LCD_ClearRam(); // lcd.LCD_DisplayStrings_WithAddress(0x90,"ST7920 testing... processing"); // pinMode(13,OUTPUT); } void loop() { LCD_DisplayStrings_WithAddress(0x80," Welcome to "); LCD_DisplayStrings_WithAddress(0x90,"www.robotbase.cn"); LCD_DisplayStrings_WithAddress(0x88,"LCD 12864 Module"); LCD_DisplayStrings_WithAddress(0x98,"ST7920 testing.."); delay(5000); LCD_ClearRam(); chsDisplay_16bit(0x80, 0xb4f2);//打 chsDisplay_16bit(0x81, 0xd4ec);//造 chsDisplay_16bit(0x82, 0xb9fa);//國(guó) chsDisplay_16bit(0x83, 0xc4da);//內(nèi) chsDisplay_16bit(0x84, 0xcde2);//外 chsDisplay_16bit(0x85, 0xd7ee);//最 chsDisplay_16bit(0x86, 0xb4f3);//大 chsDisplay_16bit(0x90, 0xbbfa);//機(jī) chsDisplay_16bit(0x91, 0xc6f7);//器 chsDisplay_16bit(0x92, 0xc8cb);//人 chsDisplay_16bit(0x93, 0xc5e4);//配 chsDisplay_16bit(0x94, 0xbcfe);//件 chsDisplay_16bit(0x95, 0xc9cc);//商 chsDisplay_16bit(0x96, 0xb3c7);//城 chsDisplay_16bit(0x88, 0xb8fc);//更 chsDisplay_16bit(0x89, 0xb6e0);//多 chsDisplay_16bit(0x8a, 0xd7ca);//資 chsDisplay_16bit(0x8b, 0xd1b6);//訊 chsDisplay_16bit(0x8c, 0xc7eb);//請(qǐng) chsDisplay_16bit(0x8d, 0xb5c7);//登 chsDisplay_16bit(0x8e, 0xc2bc);//錄 LCD_DisplayStrings_WithAddress(0x98,"www.robotbase.cn"); delay(5000); LCD_ClearRam(); LCD_ImgDisplay_from_flash(logo); delay(5000); LCD_ClearRam(); LCD_ImgDisplay_from_flash(QQ); delay(5000); LCD_ClearRam(); } void LCD_Init(void) { pinMode(E,OUTPUT); pinMode(RS,OUTPUT); pinMode(RW,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(8,OUTPUT); pinMode(9,OUTPUT); pinMode(10,OUTPUT); pinMode(11,OUTPUT); pinMode(12,OUTPUT); pinMode(13,OUTPUT); delay(100); LCD_Write(0,0x30); //基本指令動(dòng)作 LCD_Write(0,0x02); //地址歸位 LCD_Write(0,0x0C); //開(kāi)顯示,關(guān)游標(biāo) LCD_Write(0,0x01);//清屏,地址指針指向00H LCD_Write(0,0x06); //光標(biāo)的移動(dòng)方向 LCD_Write(0,0x80); //設(shè)定顯示的起始地址 } void LCD_Write( unsigned char Data_Command , unsigned char uc_Content ) { digitalWrite(RW,LOW); //RW = 0; //寫(xiě)模式 if(Data_Command) { digitalWrite(RS,HIGH); //RS = 1; //數(shù)據(jù) } else { digitalWrite(RS,LOW); //RS = 0; //指令 } unsigned char i; for (i=DB[0]; i <= DB[7]; i++) { digitalWrite(i,uc_Content & 0x01); uc_Content >>= 1; }//發(fā)送數(shù)據(jù) digitalWrite(E,HIGH); //E = 1; delay(5); //延時(shí) digitalWrite(E,LOW); //E = 0; } void LCD_ClearRam(void) { LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令集 LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏 } void LCD_DDRAM_AddressSet(unsigned char ucDDramAdd) { LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令集 LCD_Write(LCD_COMMAND,ucDDramAdd); //設(shè)定DDRAM地址到地址計(jì)數(shù)器AC } void LCD_CGRAM_AddressSet(unsigned char ucCGramAdd) { LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令集 LCD_Write(LCD_COMMAND,ucCGramAdd); //設(shè)定CGRAM地址到地址計(jì)數(shù)器AC } void LCD_GDRAM_AddressSet(unsigned char ucGDramAdd) { LCD_Write(LCD_COMMAND,LCD_EXTEND_FUNCTION); //擴(kuò)展指令集 LCD_Write(LCD_COMMAND,ucGDramAdd); } void chsDisplay_8bit(unsigned char ucAdd, unsigned char code) { LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令動(dòng)作 LCD_DDRAM_AddressSet(ucAdd); LCD_Write(LCD_DATA, code); } void chsDisplay_16bit(unsigned char ucAdd, unsigned int code) { LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令動(dòng)作 LCD_DDRAM_AddressSet(ucAdd); unsigned char temp; delay(2); temp = (code&0xFF00)>>8; LCD_Write(1,temp); temp = code&0x00FF; LCD_Write(1,temp); } void LCD_DisplayStrings_WithAddress(unsigned char ucAdd,const char *p) { unsigned char length; length = strlen(p); LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); //基本指令動(dòng)作 LCD_DDRAM_AddressSet(ucAdd); for( ; length ; length -- ) LCD_Write(LCD_DATA, *(p++)); } void LCD_GraphModeSet(unsigned char Select) { LCD_Write(LCD_COMMAND,LCD_EXTEND_FUNCTION); //擴(kuò)展指令集 if(Select) { LCD_Write(LCD_COMMAND,LCD_GRAPH_ON); //打開(kāi)繪圖模式 } else { LCD_Write(LCD_COMMAND,LCD_GRAPH_OFF); //關(guān)閉繪圖模式 } } void LCD_ImgDisplay(unsigned char *img) { unsigned char i,j; LCD_GraphModeSet(0x00); //先關(guān)閉圖形顯示功能 for(j=0;j<32;j++) { for(i=0;i<8;i++) { LCD_Write(LCD_COMMAND,0x80+j); //設(shè)定垂直坐標(biāo) LCD_Write(LCD_COMMAND,0x80+i); //設(shè)定水平坐標(biāo) LCD_Write(LCD_DATA,img[j*16+i*2]); //放入數(shù)據(jù)高字節(jié) LCD_Write(LCD_DATA,img[j*16+i*2+1]); //放入數(shù)據(jù)低字節(jié) } } for(j=32;j<64;j++) { for(i=0;i<8;i++) { LCD_Write(LCD_COMMAND,0x80+j-32); LCD_Write(LCD_COMMAND,0x88+i); LCD_Write(LCD_DATA,img[j*16+i*2]); LCD_Write(LCD_DATA,img[j*16+i*2+1]); } } LCD_GraphModeSet(0x01);//最后打開(kāi)圖形顯示功能 } void LCD_ImgDisplay_from_flash(unsigned char *img) { unsigned char *data = img; unsigned char i,j; LCD_GraphModeSet(0x00); for(i=0;i<32;i++) { LCD_Write(LCD_COMMAND,0x80|i); LCD_Write(LCD_COMMAND,0x80); for(j=0;j<16;j++) { LCD_Write(LCD_DATA,pgm_read_byte(data++)); } } for(i=0;i<32;i++) { LCD_Write(LCD_COMMAND,0x80|i); LCD_Write(LCD_COMMAND,0x88); for(j=0;j<16;j++) { LCD_Write(LCD_DATA,pgm_read_byte(data++)); } } LCD_GraphModeSet(0x01); LCD_Write(LCD_COMMAND,LCD_BASIC_FUNCTION); }
程序效果
字跡顯示清晰
產(chǎn)品相關(guān)推薦
購(gòu)買(mǎi)地址:LCD12864點(diǎn)陣液晶擴(kuò)展板