版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
作者:鄒運(yùn)懷LCD、OLED模塊開(kāi)發(fā)CONTENTS01LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA63150702OLED模塊開(kāi)發(fā)1.LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507反射型、全透型、半透型正性、負(fù)性顯示單色屏、4級(jí)灰度屏、8級(jí)灰度屏、16級(jí)灰度屏、256級(jí)灰度屏、16色屏、256色偽彩色屏、TFT真彩色屏電阻式觸摸屏、表面聲波觸摸屏、電容式觸摸屏、紅外線觸摸屏筆段式、字符型、圖形點(diǎn)陣式液晶顯示器,簡(jiǎn)稱LCD,是使用了“液晶”作為材料的顯示器1.LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507筆段式LCD共端和位段端都不能簡(jiǎn)單給出高低電平就能點(diǎn)亮,因此需要專用的位段式液晶驅(qū)動(dòng)芯片(或者單片機(jī)內(nèi)部集成LCD驅(qū)動(dòng)模塊)1.LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507筆段式LCD引腳號(hào)插口名I/O功能描述1CSI片選輸入,接一上拉電阻。當(dāng)/CS為高電平,讀寫(xiě)HT1621的數(shù)據(jù)和命令無(wú)效,串行接口電路復(fù)位;當(dāng)/CS為低電平和作為輸入時(shí),讀寫(xiě)HT1621的數(shù)據(jù)和命令有效。2RDIREAD脈沖輸入,接一上拉電阻。在/RD信號(hào)的下降沿,HT1621內(nèi)存的數(shù)據(jù)被讀到DATA線上,主控制芯片可以在下一個(gè)上升沿時(shí)鎖存這些數(shù)據(jù)。3/RWIWRITE脈沖輸入,接一上拉電阻。在/RW信號(hào)的上升沿,DATA線上的數(shù)據(jù)寫(xiě)到HT1621.4DATAI/O外接上拉電阻的串行數(shù)據(jù)輸入和輸出。5VSSI負(fù)電源;地。76OSCIOSCOIOOSCI和OSCO外接一個(gè)32.768KHz晶振用于產(chǎn)生系統(tǒng)時(shí)鐘;若用另一個(gè)外部時(shí)鐘源,應(yīng)接在OSCI上;若用片內(nèi)RC震蕩器,OSCI和OSCO應(yīng)懸空。8VLCDILCD電源輸入。9VDDI正電源。10/IRQO時(shí)基或看門(mén)狗定時(shí)器溢出標(biāo)志,NMOS開(kāi)漏輸出。11,12BZ,/BZO聲音頻率輸出。13~16COM0~COM3OLCD公共輸出口。17~48SEG0~SEG31OLCD段輸出口。1.LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA6315071621驅(qū)動(dòng)LCD程序開(kāi)發(fā)1使用供應(yīng)商提供的模塊程序2根據(jù)頭文件提供的函數(shù)聲明,即可編寫(xiě)1.LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA6315071621驅(qū)動(dòng)LCD程序開(kāi)發(fā)頭文件#include<STC15.H>//1621引腳定義#defineRW_1621P14#defineCS_1621P15#defineDATA_1621P13#defineread_data0xc0//讀數(shù)據(jù)模式#definewrite_data0xa0//寫(xiě)數(shù)據(jù)模式#definewrite_code0x80//寫(xiě)命令模式#100#definesys_en0x01//啟動(dòng)1621系統(tǒng)振蕩器00000001-x#defineLCD_off0x02//關(guān)閉LCD偏壓器#defineLCD_on0x03//開(kāi)啟LCD偏壓器#definetime_dis0x04//禁止時(shí)基準(zhǔn)輸出#definewdt_dis0x05//禁止WDT暫停標(biāo)記輸出#definetime_en0x06//允許時(shí)基準(zhǔn)輸出#definewdt_en0x07//允許WDT暫停標(biāo)記輸出#definetone_off0x08//蜂鳴器輸出禁止#definetone_on0x09//蜂鳴器輸出允許#defineclr_timer0x0c//清除時(shí)其發(fā)生器內(nèi)容#defineclr_wdt0x0e//清除WDT內(nèi)容#definextal_32k0x14//外32K晶振#defineRC_256K0x18//內(nèi)部RC振蕩器作為時(shí)鐘#defineext_RC0x1c//外部RC作為時(shí)鐘#definebias_4com0x28//4com輸出#defineirq_en0x88//允許IRQ輸出#definef10xa0//時(shí)基/WDT時(shí)鐘輸出1HZvoid_delay(unsignedintx);voidcms1621_init(void);voidcms1621_diver(unsignedcharcont,unsignedchartemp);對(duì)使用的相關(guān)端口進(jìn)行了定義,程序員要按照硬件電路設(shè)計(jì)0102申明相關(guān)函數(shù)1.LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA6315071621驅(qū)動(dòng)LCD程序開(kāi)發(fā)初始化函數(shù)調(diào)用1621的初始化函數(shù)voidMCU_init(void){
unsignedchari=0; P1=0x00; P1M0=0x00; P1M1=0x00; P3=0x00; P3M0=0xC0; P3M1=0x00; P5=0x00; P5M0=0x20; P5M1=0x00; LED1=LEDON; LED2=LEDOFF; cms1621_init(); AUXR|=0x80; //定時(shí)器時(shí)鐘1T模式 TMOD&=0xF0; //設(shè)置定時(shí)器模式 TL0=0x9A; //設(shè)置定時(shí)初值 TH0=0xFA; //設(shè)置定時(shí)初值 TF0=0; //清除TF0標(biāo)志 TR0=1; //定時(shí)器0開(kāi)始計(jì)時(shí) ET0=1; EA=1;}1.LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA6315071621驅(qū)動(dòng)LCD程序開(kāi)發(fā)LCD顯示函數(shù)按照顯示內(nèi)容與1621通信傳遞顯示數(shù)據(jù)voidDsp_LCD(void){ unsignedchari;
for(i=0;i<8;i++)dsp_buf2[i]=0;
//顯示驅(qū)動(dòng)把顯示緩沖的內(nèi)容送入顯示
dsp_numerical_1(Dsp_Num[0]); dsp_numerical_2(Dsp_Num[1]); dsp_numerical_3(Dsp_Num[2]); dsp_numerical_4(Dsp_Num[3]);
for(i=0;i<8;i++) dsp_buf[i]=dsp_buf2[i]; CS_1621=0; _delay(20);
cms1621_diver(3,write_data);
cms1621_diver(6,0);
for(i=0;i<5;i++)
cms1621_diver(8,dsp_buf[i]);//dsp_buf[i] for(i=0;i<8;i++)
cms1621_diver(8,0); for(i=0;i<3;i++) cms1621_diver(8,dsp_buf[i+5]); CS_1621=1; }1.LCD模塊e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507字符式LCD顯示字符式LCD往往自帶驅(qū)動(dòng)芯片,液晶可以和控制芯片直接連接編號(hào)符號(hào)引腳說(shuō)明編號(hào)符號(hào)引腳說(shuō)明1VSS電源地9D2數(shù)據(jù)2VDD電源正極10D3數(shù)據(jù)3VL液晶顯示偏壓11D4數(shù)據(jù)4RS數(shù)據(jù)/命令選擇12D5數(shù)據(jù)5R/W讀/寫(xiě)選擇13D6數(shù)據(jù)6E使能信號(hào)14D7數(shù)據(jù)7D0數(shù)據(jù)15BLA背光源正極8D1數(shù)據(jù)16BLK背光源負(fù)極LCD16022.OLED模塊開(kāi)發(fā)e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507有機(jī)發(fā)光二極管(OLED)自發(fā)光、廣視角、高對(duì)比度、較低耗電、極高反應(yīng)速度一般通過(guò)I2C或者SPI與嵌入式控制芯片連接通信,也可以和普通I/O相連2.OLED模塊開(kāi)發(fā)e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507名稱用途GND電源地VCC電源正(3~5.5V)D0(SCLK)OLED的D0腳,在SP或IIC通信中為時(shí)鐘引腳D1(SDA)OLED的D1腳,在SPI或IIC通信中為數(shù)據(jù)引腳RESOLED的RES#腳,用來(lái)復(fù)位(低電平復(fù)位)DCOLED的D/C#E腳,數(shù)據(jù)和命令控制引腳CSOLED的CS#腳,也就是片選引腳7PINOLED128642.OLED模塊開(kāi)發(fā)e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA6315071使用OLED供應(yīng)商提供的模塊程序2根據(jù)頭文件提供的函數(shù)聲明,即可編寫(xiě)2.OLED模塊開(kāi)發(fā)e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507#ifndefSSD1306_H#defineSSD1306_H#include"STC8A8K64D4.h"#include<string.h>#include<stdlib.h>//數(shù)據(jù)類型簡(jiǎn)化宏定義#ifndefuint8#defineuint8unsignedchar#endif#ifndefuint16#defineuint16unsignedint#endif#ifndefuint32#defineuint32unsignedlongint#endif/*OLEDI/O端口定義*/#defineOLED_SCLKP14//SCL#defineOLED_SDINP13//SDA#defineOLED_RSTP12//RES#defineOLED_DCP11//DC#defineOLED_CSP10//CS/*OLEDCommand端口操作*/#defineOLED_CS_Clr()OLED_CS=0#defineOLED_CS_Set()OLED_CS=1#defineOLED_RST_Clr()OLED_RST=0#defineOLED_RST_Set()OLED_RST=1#defineOLED_DC_Clr()OLED_DC=0#defineOLED_DC_Set()OLED_DC=1#defineOLED_SCLK_Clr()OLED_SCLK=0#defineOLED_SCLK_Set()OLED_SCLK=1#defineOLED_SDIN_Clr()OLED_SDIN=0#defineOLED_SDIN_Set()OLED_SDIN=1對(duì)常見(jiàn)數(shù)據(jù)類型如unsignedchar進(jìn)行了簡(jiǎn)寫(xiě)的宏定義,進(jìn)一步提高了代碼可讀性010203對(duì)相關(guān)端口操作進(jìn)行了宏定義對(duì)OLED使用的相關(guān)端口進(jìn)行了定義,程序員要按照硬件電路設(shè)計(jì)對(duì)相應(yīng)端口宏定義2.OLED模塊開(kāi)發(fā)e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507/*OLEDPixel*/#defineWIDTH128#defineHEIGHT64#definePAGES8/*OLEDBrightness*/#defineBRIGHTNESS_MIN1#defineBRIGHTNESS_MAX25/*OLEDDriver*/voidOLED_Init(void);//初始化voidOLED_Write_Command(uint8dat);//寫(xiě)命令voidOLED_Clear(void);//清除緩存內(nèi)容voidOLED_Display(void);//將緩存內(nèi)容顯示到屏幕上voidOLED_Set_Pos(uint8x,uint8y);
//設(shè)置內(nèi)存位置x:0-127,y:0-63voidOLED_WR_Byte(uint8dat,uint8cmd);//寫(xiě)數(shù)據(jù)voidOLED_DrawChar(uint8x,uint8y,uint8chr);//繪制字符至緩存voidOLED_DrawString(uint8*p);
//繪制字符串至緩存voidOLED_DrawNum(uint32num,uint8len);
//繪制數(shù)字至緩存voidOLED_DrwCHS_16x16(uint8chs_no);
//繪制16x16漢字至緩存voidOLED_DrawPixel(uint8x,uint8y);
//繪制一個(gè)像素至緩存voidOLED_DrawHLine(uint8x,uint8y,uint8w);//繪制水平線至緩存voidOLED_DrawVLine(uint8x,uint8y,uint8w);//繪制垂直線至緩存voidOLED_DrawLine(uint8x0,uint8y0,uint8x1,uint8y1);//繪制兩點(diǎn)線段voidOLED_DrawBMP(uint8x0,uint8y0,uint8x1,uint8y1,uint8*BMP,uint16len);//繪制圖片至緩存voidOLED_SetFontWidth(uint8w);//設(shè)置ASCII字符寬度voidOLED_Reverse(biti);//反顯i=0正常顯示i=1反顯voidOLED_Overlap(biti);//繪圖模式i=0覆蓋i=1疊加voidDelay50ms();
//延時(shí)函數(shù)#endif聲明了模塊函數(shù)2.OLED模塊開(kāi)發(fā)e7d195523061f1c01ef2b70529884c179423570dbaad84926380ABC1F97BAEF0C8FC051856578EAB7874501A1FFE158C4981707381814BCC4D9A8E3554438DEE4FBCF5A5B4D2A8B0989AB57E8BAC65EB4C7ADE47CB0CAEE0501E4A226B4263409BF6D490A639D9B9ED09071C131A40B4F721A3CABF56865E37DAC04C7C9B262B2670CBBEB096AEE5D9F6218CBA631507#include<STC8A8K64D4.h>#include<ssd1306.h>#include<bmp.h>/*********常量定義區(qū)********/voidMCU_init(void);voidmain(){/****初始化區(qū)****/unsignedchari=0,j=0;MCU_init();/******主循環(huán)*******/while(1){for(i=0;i<=10;i++)
{OLED_Set_Pos(8,30)
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 戶外廣告牌投放合作期限合同
- 全方位行銷(xiāo)策劃合同
- 車(chē)庫(kù)租賃合同示例
- 電腦耗材采購(gòu)合同
- 全面會(huì)議策劃服務(wù)協(xié)議
- 租房協(xié)議書(shū)簡(jiǎn)單版
- 綠植租擺服務(wù)合同
- 房屋買(mǎi)賣(mài)合同中介模式
- 融資服務(wù)合作協(xié)議
- 工程合同的勞務(wù)分包協(xié)議
- 螺旋體和支原體課件整理
- 最新數(shù)字媒體藝術(shù)概論課件
- 水資源復(fù)習(xí)資料
- 地產(chǎn)結(jié)算復(fù)審方案
- 化療后骨髓抑制的觀察及護(hù)理考核試題與答案
- 非政府組織管理課件大全
- 木門(mén)安裝說(shuō)明指導(dǎo)書(shū)指導(dǎo)手冊(cè)圖文介紹(附圖)
- 外科護(hù)理學(xué)全套課件
- 工程經(jīng)濟(jì)學(xué)完整版課件全套ppt教程
- 華海醫(yī)藥智慧園區(qū)方案
- 高中日語(yǔ) 授受關(guān)系 課件
評(píng)論
0/150
提交評(píng)論