嵌入式實(shí)驗(yàn)三人機(jī)交互接口-鍵盤操作實(shí)驗(yàn)_第1頁
嵌入式實(shí)驗(yàn)三人機(jī)交互接口-鍵盤操作實(shí)驗(yàn)_第2頁
嵌入式實(shí)驗(yàn)三人機(jī)交互接口-鍵盤操作實(shí)驗(yàn)_第3頁
嵌入式實(shí)驗(yàn)三人機(jī)交互接口-鍵盤操作實(shí)驗(yàn)_第4頁
嵌入式實(shí)驗(yàn)三人機(jī)交互接口-鍵盤操作實(shí)驗(yàn)_第5頁
已閱讀5頁,還剩70頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

實(shí)驗(yàn)報告課程名稱嵌入式系統(tǒng)設(shè)計實(shí)驗(yàn)儀器清華同方辰源嵌入式系統(tǒng)實(shí)驗(yàn)箱實(shí)驗(yàn)名稱實(shí)驗(yàn)三:人機(jī)交互接口-鍵盤操作實(shí)驗(yàn)系別計算機(jī)學(xué)院專業(yè)計算機(jī)科學(xué)與技術(shù)班級/學(xué)號學(xué)生姓名實(shí)驗(yàn)日期成績指導(dǎo)教師實(shí)驗(yàn)三:人機(jī)交互接口-鍵盤操作實(shí)驗(yàn)實(shí)驗(yàn)問題答復(fù)鍵盤的工作原理是什么?答:鍵盤分獨(dú)立式鍵盤與矩陣式鍵盤。獨(dú)立式鍵盤:在由單片機(jī)組成的測控系統(tǒng)及智能化儀器中,用的最多的是獨(dú)立式鍵盤。這種鍵盤具有硬件與軟件相對簡單的特點(diǎn),其缺點(diǎn)是按鍵數(shù)量較多時,要占用大量口線。當(dāng)按鍵沒按下時,CPU對應(yīng)的I/O接口由于內(nèi)部有上拉電阻,其輸入為高電平;當(dāng)某鍵被按下后,對應(yīng)的I/O接口變?yōu)榈碗娖?。只要在程序中判斷I/O接口的狀態(tài),即可知道哪個鍵處于閉合狀態(tài)。矩陣式鍵盤:矩陣式鍵盤使用于按鍵數(shù)量較多的場合,它由行線與列線組成,按鍵位于行、列的交叉點(diǎn)上。一個3*3的行列結(jié)構(gòu)可以構(gòu)成一個有9個按鍵的鍵盤。同理,一個4*4的行列可以構(gòu)成一個16按鍵的鍵盤。很明顯,在按鍵數(shù)量較多的場合,與獨(dú)立式鍵盤相比,矩陣式鍵盤要節(jié)省很多I/0接口。鍵盤按鍵識別方法分掃描法語線反轉(zhuǎn)法。掃描法:掃描法有行掃描和列掃描兩種,無論采用哪種,無論采用哪種,其效果是一樣的,只是在程序中的處理方法有所區(qū)別。下面以列掃描法為例來介紹掃描法識別按鍵的方法。首先在鍵處理程序中將P1.4-P1.7依次按位變低,P1.4-P1.7在某一時刻只有一個為低。在某一位為低時讀行線,根據(jù)行線的狀態(tài)即可判斷出哪一個按鍵被按下。如2號鍵按下,當(dāng)列線P1.5為低時,讀回的行線狀態(tài)中P1.0被拉低,由此可知K2鍵被按下。一般在掃描法中分兩步處理按鍵,首先是判斷有無鍵按下,如行線有一個為低,那么有鍵按下。當(dāng)判斷有鍵按下時,使列線依次變低,讀行線,進(jìn)而判斷出具體哪個鍵被按下。線反轉(zhuǎn)法:掃描法是逐行或逐列掃描查詢,當(dāng)被按下的鍵處于最后一列時,要經(jīng)過屢次掃描才能最后獲得此按鍵所處的行列值。而線反轉(zhuǎn)法那么顯的簡練,無論被按的鍵處于哪列,均可經(jīng)過兩步即能獲得此按鍵所在的行列值。

首先將行線P1.0-P1.3作為輸入線,列線P1.4-P1.7作為輸出線,并且輸出線輸出全為低電平,讀行線狀態(tài),那么行線中電平為低的是按鍵所在的行。然后將列線作為輸入線,行線作為輸出線,并將輸出線輸出為低電平,讀列線狀態(tài),那么列線是電平為低的是按鍵所在的列。綜合上述兩步結(jié)果,確定按鍵所在的行和列,從而識別出所按下的鍵。

假設(shè)10號鍵被按下,在第一步P1.3-P1.0全為低電平時,讀P1.4-P1.7的值,那么P1.5為低電平;在第二步P1.4-P1.7輸出全為低電平時,讀P1.3-P1.0時,P1.2為低電平。由此可判斷第3行第2列有鍵被按下,此鍵就是K10鍵。鍵盤等其他外部設(shè)備與CPU之間如何協(xié)調(diào)工作?答:cpu通過I/O接口和外部設(shè)備進(jìn)行數(shù)據(jù)交換。cpu通過接口對外設(shè)進(jìn)行控制的方式有以下幾種:程序查詢方式、中斷處理方式、DMA傳送方式。在實(shí)驗(yàn)報告中對鍵盤中斷效勞程序進(jìn)行逐行注釋,理解計算機(jī)是如何接收鍵盤輸入的。答:voidGPIO_PORT_D_ISR(void){unsignedcharucKey;//定義一個unsignedchar類型的變量ucKeyunsignedlongulStatus;//定義一個unsignedlong類型的變量ulStatusulStatus=GPIOPinIntStatus(GPIO_PORTD_BASE,true);//讀取中斷狀態(tài)GPIOPinIntClear(GPIO_PORTD_BASE,ulStatus);//清空讀取到的中斷if(ulStatus&GPIO_PIN_7)//如果GPIO_PIN_7中斷狀態(tài)有效{ucKey=GPIOPinRead(GPIO_PORTC_BASE,GPIO_PIN_4);//讀取管腳ucKey=ucKey>>1;//ucKey右移一位ucValue=ucValue+ucKey;//ucValue+1ucValue=ucValue<<1;//ucValue左移一位i++;if(i==4)//如果發(fā)生四次中斷{i=0;//i置0Event_Key=1;//Event_Key置一,代表按鍵信息已傳給cpuoledkey[1]='\0';給oledKey[1]賦值\0if((ucValue>>4)<10)//如果ucValue右移四位后小于10oledkey[0]=(ucValue>>4)+48;//那么oledkey[0]右移四位后加48elseoledkey[0]=(ucValue>>4)-10+'A';//否那么ucValue右移四位減10加A}}}根據(jù)實(shí)驗(yàn)思考,如果有兩個不同的中斷需要響應(yīng)時,應(yīng)該如何設(shè)計程序?答:while(1){if(Event_key)//中斷1發(fā)生的標(biāo)志{Event_key=0;….…}if(Event)//中斷2發(fā)生的標(biāo)志{Event=0;……}}按下幾個鍵后屏幕中出現(xiàn)多個字符怎么辦?如何只顯示一個?答:發(fā)生一次按鍵中斷后調(diào)用一次函數(shù)RIT128x96x4Clear();?!?〕因?yàn)楸敬螌?shí)驗(yàn)需要響應(yīng)兩個中斷,需要對主函數(shù)的死循環(huán)做以下改動。while(1){if(Event_key){Event_key=0;….…}if(Event){Event=0;……}}思考:這樣設(shè)計的目的和作用是什么?要是系統(tǒng)需要響應(yīng)4個不同的中斷又如何設(shè)計?答:目的是使各個中斷的處理不受影響。如果需要響應(yīng)4個不同的中斷那么需要定義四個全局變量〔值為0或1〕來標(biāo)記每個中斷。例如如下:while(1){if(Event1){Event1=0;….…}if(Event2){Event2=0;……}if(Event3){Event3=0;……}if(Event4){Event4=0;……}}實(shí)驗(yàn)?zāi)康暮托Ч麑?shí)驗(yàn)?zāi)康模骸?〕了解鍵盤工作原理和使用方法〔2〕深入學(xué)習(xí)、理解、掌握中斷使用方法實(shí)驗(yàn)效果:三、實(shí)驗(yàn)內(nèi)容和步驟實(shí)驗(yàn)內(nèi)容:默認(rèn)在在OLED屏幕上分行顯示自己的學(xué)號、姓名,如“2023011001〞、“zhangsan〞。思路:RIT128x96x4StringDraw直接顯示。按下鍵盤的任意鍵,在OLED屏幕正中顯示該鍵字符,如“0〞、“A〞等。思路:通過oledkey得到鍵盤的值,利用RIT128x96x4StringDraw顯示在屏幕上。按下鍵盤的偶數(shù)鍵時,在OLED屏幕上顯示“NowShowChar!〞提示信息,并在OLED屏幕上顯示實(shí)驗(yàn)一的字符,并根據(jù)按下的鍵值,確定字符的位置,按“0〞、“2〞、“4〞、“6〞、“8〞、“A〞、“C〞、“E〞分別在最左端,距左端1/8屏幕寬度處、距左端2/8屏幕寬度處、距左端3/8屏幕寬度處、距左端1/2屏幕寬度處、距右端3/8屏幕寬度處、距右端2/8屏幕寬度處、距右端1/8屏幕寬度處、最右端顯示。要保證字符可以全部顯示。思路:通過switch語句進(jìn)行判斷,當(dāng)鍵盤值為上述字符時調(diào)用Draw_Char_F(ulx)在相應(yīng)位置顯示字符圖形。按下鍵盤的奇數(shù)鍵時,在OLED屏幕上顯示“NowResetSpeed!〞提示信息,在OLED屏幕上顯示實(shí)驗(yàn)二的效果,即根據(jù)自己分配的閾值和移動路線上對字符進(jìn)行移動,并根據(jù)按下的鍵值,確定頻率的快慢,按“1〞、“3〞、“5〞、“7〞、“9〞、“B〞、“D〞、“F〞由慢到快〔速度可以逐個遞增2倍或5倍〕。思路:通過switch語句進(jìn)行判斷,當(dāng)鍵盤值為上述字符時調(diào)用Reset_Counter_Speed(x)設(shè)置字符的不同移動速度。根據(jù)自己的想法,選用一個按鍵,在OLED屏幕上顯示與上面不同的效果。思路:一朵花從花盆中長出花莖、葉子、花朵。通過不同的按鍵長出花的不同局部。實(shí)驗(yàn)步驟:〔一〕Keil開發(fā)環(huán)境中對工程Project配置見實(shí)驗(yàn)一〔一〕步驟〔二〕嵌入式C程序開發(fā)〔1〕加載必要程序本次實(shí)驗(yàn)提供了幾個源程序rit128x96x4.h,rit128x96x4.c,startup.s,都壓在work3_code.zip中,與實(shí)驗(yàn)一〔二〕〔1〕步驟類似?!?〕新建主函數(shù)程序,并加載到工程中新建一個文件,保存為main.c,把main.c也加載到工程中,與實(shí)驗(yàn)一〔二〕〔2〕步驟類似。本次實(shí)驗(yàn)需要增加以下頭文件#include<stdio.h>#include<LM3Sxxxx.H>#include<hw_ints.h>#include<hw_memmap.h>#include<hw_types.h>#include<gpio.h>#include<interrupt.h>#include<sysctl.h>#include"rit128x96x4.h"本次實(shí)驗(yàn)顯示的內(nèi)容實(shí)驗(yàn)〔二〕已完成,故可在實(shí)驗(yàn)〔二〕根底上進(jìn)一步開發(fā)?!?〕利用中斷,接收鍵盤輸入〔3〕--〔1〕在主函數(shù)中開啟鍵盤中斷,例如如下:/*使能外設(shè)GPIO*/SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);/*設(shè)置GPIO為輸入*/GPIOPinTypeGPIOInput(GPIO_PORTD_BASE,GPIO_PIN_7);GPIOPinTypeGPIOInput(GPIO_PORTC_BASE,GPIO_PIN_4);/*使能中斷*/IntEnable(INT_GPIOD);IntMasterEnable();GPIOPinIntEnable(GPIO_PORTD_BASE,GPIO_PIN_7);GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_7,GPIO_RISING_EDGE);注意:其中,GPIO_PORTC用于傳輸按下的鍵值,GPIO_PORTD用于向CPU發(fā)起中斷請求?!?〕--〔2〕設(shè)置全局變量oledkey用于保存鍵盤輸入的按鍵charoledkey[2];〔3〕--〔3〕設(shè)計實(shí)現(xiàn)并注冊鍵盤中斷處理函數(shù)鍵盤每次按鍵都會觸發(fā)四次中斷,中斷信號源為GPIOPortD,修改startup.s中GPIOPortD項(xiàng)對應(yīng)的中斷效勞處理函數(shù),與實(shí)驗(yàn)〔二〕設(shè)置中斷流程類似,這里不再重復(fù)。鍵盤中斷處理函數(shù)例如如下:inti=0;//i定義為全局變量,因?yàn)橹挥?根線GPIO_PIN_4與CPU相聯(lián),所以一個按鍵〔16種,4bit表示〕需要四次中斷才能傳給CPU。unsignedcharucValue=0x00;//ucValue定義為全局變量,該值存儲輸入的按鍵值的中間結(jié)果。/*中斷效勞函數(shù)ISR*/voidGPIO_PORT_D_ISR(void){unsignedcharucKey;unsignedlongulStatus;ulStatus=GPIOPinIntStatus(GPIO_PORTD_BASE,true);GPIOPinIntClear(GPIO_PORTD_BASE,ulStatus);if(ulStatus&GPIO_PIN_7){ucKey=GPIOPinRead(GPIO_PORTC_BASE,GPIO_PIN_4);ucKey=ucKey>>1;ucValue=ucValue+ucKey;ucValue=ucValue<<1;i++;if(i==4){i=0;oledkey[1]='\0';if((ucValue>>4)<10)oledkey[0]=(ucValue>>4)+48;elseoledkey[0]=(ucValue>>4)-10+'A';}}}該程序就可以根據(jù)鍵盤中斷信號獲取鍵盤輸入值,并通過并行轉(zhuǎn)串行轉(zhuǎn)換,將該值存放在oledkey[0]中。〔4〕修改主函數(shù),實(shí)現(xiàn)本次實(shí)驗(yàn)要求的功能本次實(shí)驗(yàn)通過不同鍵盤控制不同顯示,但顯示內(nèi)容實(shí)驗(yàn)〔二〕都已完成,故可在實(shí)驗(yàn)〔二〕根底上繼續(xù)深入開發(fā),完成實(shí)驗(yàn)〔三〕。〔4〕--〔1〕通過一個全局變量值控制按鍵后的處理在主函數(shù)的while死循環(huán)中,應(yīng)該添加對按鍵后的處理程序,方法類似于實(shí)驗(yàn)〔二〕中對SysTick中斷的處理,即設(shè)置一個全局變量Event_key,通過在中斷效勞程序中設(shè)其值為1,主程序死循環(huán)中設(shè)其值為0來實(shí)現(xiàn)。思考一下,應(yīng)該在中斷效勞程序voidGPIO_PORT_D_ISR(void)中的哪個位置設(shè)置Event_key為1。提示:一個按鍵發(fā)起四次中斷,通過全局變量i計數(shù),到第四次時才表示接收完畢,在此處設(shè)置Event_key為1?!?〕--〔2〕主函數(shù)死循環(huán)流程因?yàn)楸敬螌?shí)驗(yàn)需要響應(yīng)兩個中斷,需要對主函數(shù)的死循環(huán)做以下改動。while(1){if(Event_key){Event_key=0;….…}if(Event){Event=0;……}}思考:實(shí)驗(yàn)問題6:這樣設(shè)計的目的和作用是什么?要是系統(tǒng)需要響應(yīng)4個不同的中斷又如何設(shè)計?〔4〕--〔3〕發(fā)生一次鍵盤按鍵后,中斷效勞程序完成后,全局變量oledkey[0]中保存的即是輸入字符,根據(jù)該字符值和實(shí)驗(yàn)要求,設(shè)計程序。例如如下:switch(oledkey[0]){case'0':Draw_Char_H(0);Flag=0;break;case'1':Reset_Counter_Speed(1);break;case'2':Draw_Char_H(25);break;case'3':Reset_Counter_Speed(2);break;default:break;}〔4〕--〔4〕偶數(shù)時,在不同位置顯示字符Draw_Char_H即是畫出字符,本例畫的是H字符,因?yàn)楦鶕?jù)輸入字符來確定顯示位置,因此位置信息作為該函數(shù)參數(shù)傳入,根據(jù)要求設(shè)計實(shí)現(xiàn)該函數(shù)?!?〕--〔5〕奇數(shù)時,設(shè)置計數(shù)器計數(shù)頻率Reset_Counter_Speed函數(shù)完成重新設(shè)置計數(shù)器的計數(shù)頻率,其程序流程為關(guān)中斷---重設(shè)中斷周期---開中斷。例如如下:voidReset_Counter_Speed(){SysTickIntDisable();SysTickDisable();SysTickPeriodSet(SysCtlClockGet()/x);//x為輸入的參數(shù),控制計數(shù)頻率,值越大頻率越快SysTickEnable();SysTickIntEnable();}〔4〕--〔6〕完成實(shí)驗(yàn)根據(jù)實(shí)驗(yàn)要求,補(bǔ)齊switch語句?!?〕編譯、連接,生成可執(zhí)行程序文件〔編譯〕〔鏈接〕〔6〕反復(fù)〔3〕--〔5〕步驟,直到完成如果中間出現(xiàn)錯誤,修改代碼,一直到無錯,生成最后程序。〔三〕硬件連接見實(shí)驗(yàn)〔一〕〔三〕步驟?!菜摹陈?lián)調(diào)見實(shí)驗(yàn)〔一〕〔四〕步驟。實(shí)驗(yàn)代碼:〔實(shí)驗(yàn)代碼過長,放在實(shí)驗(yàn)報告最后〕實(shí)驗(yàn)總結(jié)與收獲附:實(shí)驗(yàn)代碼#include<stdio.h>#include<LM3Sxxxx.H>#include<hw_ints.h>#include<hw_memmap.h>#include<hw_types.h>#include<gpio.h>#include<interrupt.h>#include<sysctl.h>#include"rit128x96x4.h"intEvent=0;intEvent_Key=0;intcount1=0;charoledkey[2];inti=0;intz=56;unsignedcharucValue=0x00;unsignedcharbuf01[]=//開放的花{0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf02[]={0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00};unsignedcharbuf03[]={0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00};unsignedcharbuf04[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf05[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf06[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf07[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf08[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf09[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf010[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf011[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf012[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf013[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf015[]={0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,};unsignedcharbuf014[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbuf016[]={0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00};unsignedcharbuf017[]={0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf018[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf019[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf020[]={//花枝0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufp1[]=//花盆huapen{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};unsignedcharbufp2[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};unsignedcharbufp3[]={0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00};unsignedcharbufp4[]={0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00};unsignedcharbufp5[]={0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufp6[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufp7[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufp8[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufp9[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufp10[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufp11[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufp12[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufl1[]=//葉子bigleaf8x6{0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbufl2[]={0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00};unsignedcharbufl3[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00};unsignedcharbufl4[]={0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbufl5[]={0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbufl6[]={0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};unsignedcharbufs1[]=//smallleaf{0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00};unsignedcharbufs2[]={0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00};unsignedcharbufs3[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff};unsignedcharbufs4[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00};unsignedcharbuf1[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};unsignedcharbuf2[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf3[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf4[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00};unsignedcharbuf5[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf6[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf7[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf1c[]={0xf4,0xf4,0xf4,0xf4,0xf4,0xf4,0xf4,0xf4,0xf4,0xf4};unsignedcharbuf2c[]={0xf6,0xf6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf3c[]={0xf8,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf4c[]={0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0x00,0x00};unsignedcharbuf5c[]={0xfc,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf6c[]={0xfe,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf7c[]={0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};unsignedcharbuf1a[]={0xff,0xff,0xff};unsignedcharbuf2a[]={0xff,0x00,0x00};unsignedcharbuf3a[]={0xff,0x00,0x00};unsignedcharbuf4a[]={0xff,0xff,0x00};unsignedcharbuf5a[]={0xff,0x00,0x00};unsignedcharbuf6a[]={0xff,0x00,0x00};unsignedcharbuf7a[]={0xff,0x00,0x00};unsignedcharbuf9[]={0xff,0xff,0xff};unsignedcharbuf10[]={0xff,0xff,0xff};unsignedcharbuf11[]={0xff,0xff,0xff};//SysTickinterrupthappenseveryXXmsvoidSysTick_Handler(void){Event=1;}/*中斷效勞函數(shù)ISR*/voidGPIO_PORT_D_ISR(void){unsignedcharucKey;unsignedlongulStatus;ulStatus=GPIOPinIntStatus(GPIO_PORTD_BASE,true);GPIOPinIntClear(GPIO_PORTD_BASE,ulStatus);if(ulStatus&GPIO_PIN_7){ucKey=GPIOPinRead(GPIO_PORTC_BASE,GPIO_PIN_4);ucKey=ucKey>>1;ucValue=ucValue+ucKey;ucValue=ucValue<<1;i++;if(i==4){i=0;Event_Key=1;oledkey[1]='\0';if((ucValue>>4)<10)oledkey[0]=(ucValue>>4)+48;elseoledkey[0]=(ucValue>>4)-10+'A';}}}voidReset_Counter_Speed(intx){SysTickIntDisable();SysTickDisable();SysTickPeriodSet(SysCtlClockGet()/x*100);//x為輸入的參數(shù),控制計數(shù)頻率,值越大頻率越快SysTickEnable();SysTickIntEnable();RIT128x96x4StringDraw("NowResetSpeed!",0,80,15);}voidDraw_Char_F(intx){RIT128x96x4StringDraw("NowResetSpeed!",0,80,15);RIT128x96x4ImageDraw(buf1,x,30,20,1);//bigFRIT128x96x4ImageDraw(buf2,x,32,20,1);RIT128x96x4ImageDraw(buf3,x,34,20,1);RIT128x96x4ImageDraw(buf4,x,36,20,1);RIT128x96x4ImageDraw(buf5,x,38,20,1);RIT128x96x4ImageDraw(buf6,x,40,20,1);}voidDraw_f(){//畫花盆RIT128x96x4ImageDraw(bufp1,0,74,104,1);RIT128x96x4ImageDraw(bufp2,0,75,104,1);RIT128x96x4ImageDraw(bufp3,0,76,104,1);RIT128x96x4ImageDraw(bufp4,0,77,104,1);RIT128x96x4ImageDraw(bufp5,0,78,104,1);RIT128x96x4ImageDraw(bufp6,0,79,104,1);RIT128x96x4ImageDraw(bufp7,0,80,104,1);RIT128x96x4ImageDraw(bufp8,0,81,104,1);RIT128x96x4ImageDraw(bufp9,0,82,104,1);RIT128x96x4ImageDraw(bufp10,0,83,104,1);RIT128x96x4ImageDraw(bufp11,0,84,104,1);RIT128x96x4ImageDraw(bufp12,0,85,104,1);}voidDraw_o(){//畫花枝for(z=56;z<=74;z++){RIT128x96x4ImageDraw(buf020,0,z,104,1);}}voidDraw_w(){RIT128x96x4ImageDraw(bufs1,52,65,24,1);RIT128x96x4ImageDraw(bufs1,52,66,24,1);RIT128x96x4ImageDraw(bufs1,52,67,24,1);RIT128x96x4ImageDraw(bufs1,52,68,24,1);}voidDraw_e(){RIT128x96x4ImageDraw(bufl1,18,60,32,1);RIT128x96x4ImageDraw(bufl2,18,61,32,1);RIT128x96x4ImageDraw(bufl3,18,62,32,1);RIT128x96x4ImageDraw(bufl4,18,63,32,1);RIT128x96x4ImageDraw(bufl5,18,64,32,1);RIT128x96x4ImageDraw(bufl6,18,65,32,1);}voidDraw_r(){RIT128x96x4ImageDraw(buf01,0,18,104,1);RIT128x96x4ImageDraw(buf02,0,20,104,1);RIT128x96x4ImageDraw(buf03,0,22,104,1);RIT128x96x4ImageDraw(buf04,0,24,104,1);RIT128x96x4ImageDraw(buf05,0,26,104,1);RIT128x96x4ImageDraw(buf06,0,28,104,1);RIT128x96x4ImageDraw(buf07,0,30,104,1);RIT128x96x4ImageDraw(buf08,0,32,104,1);RIT128x96x4ImageDraw(buf09,0,34,104,1);RIT128x96x4ImageDraw(buf010,0,36,104,1);RIT128x96x4ImageDraw(buf011,0,38,104,1);RIT128x96x4ImageDraw(buf012,0,40,104,1);RIT128x96x4ImageDraw(buf013,0,42,104,1);RIT128x96x4ImageDraw(buf014,0,44,104,1);RIT128x96x4ImageDraw(buf015,0,46,104,1);RIT128x96x4ImageDraw(buf016,0,48,104,1);RIT128x96x4ImageDraw(buf017,0,50,104,1);RIT128x96x4ImageDraw(buf018,0,52,104,1);RIT128x96x4ImageDraw(buf019,0,54,104,1);}voidDraw_l(){SysTickIntDisable();SysTickDisable();SysTickPeriodSet(SysCtlClockGet()/500000);//x為輸入的參數(shù),控制計數(shù)頻率,值越大頻率越快SysTickEnable();SysTickIntEnable();}/*unsignedcharbuf0[50]{for(i=0;i<count1;i++)buf[i]=0xff;for(i=count1;i<50;i++)buf[i]=0x00;};*/intmain(){intFlag=1;//intx2=0;//inty2=0;//intcount5=0;unsignedcharbuf[5];unsignedcharbuff[5];//unsignedcharbuf0[50];intcount=0;//intlight=0;inti;intx=9;intv=1;ints=0;ints1=0;intt=10;//intv1=0;//x1=rand()%96+5;//y1=rand()%71+5;SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_8MHZ);RIT128x96x4Init(1000000);RIT128x96x4Clear();//SetupandenablesSysTickwithinterrupt(100HZ)//SysTickPeriodSet(10);/*SysTickPeriodSet(SysCtlClockGet()/100000);SysTickEnable();SysTickIntEnable();*//*使能外設(shè)GPIO*/SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);/*設(shè)置GPIO為輸入*/GPIOPinTypeGPIOInput(GPIO_PORTD_BASE,GPIO_PIN_7);GPIOPinTypeGPIOInput(GPIO_PORTC_BASE,GPIO_PIN_4);/*使能中斷*/IntEnable(INT_GPIOD);IntMasterEnable();GPIOPinIntEnable(GPIO_PORTD_BASE,GPIO_PIN_7);GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_7,GPIO_RISING_EDGE);while(1){RIT128x96x4StringDraw("2023011111",0,6,15);RIT128x96x4StringDraw("admin",0,20,15);if(Event_Key){//0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000RIT128x96x4Clear();Event_Key=0;RIT128x96x4Clear();sprintf(buff,"%i",oledkey[0]);RIT128x96x4StringDraw(oledkey,60,60,15);switch(oledkey[0]){case'0':Draw_Char_F(0);Flag=0;break;case'1':Reset_Counter_Speed(1);Flag=0

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論