嵌入式实验三人机交互接口-键盘操作实验_第1页
嵌入式实验三人机交互接口-键盘操作实验_第2页
嵌入式实验三人机交互接口-键盘操作实验_第3页
嵌入式实验三人机交互接口-键盘操作实验_第4页
嵌入式实验三人机交互接口-键盘操作实验_第5页
已阅读5页,还剩70页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验报告课程名称嵌入式系统设计实验仪器清华同方辰源嵌入式系统实验箱实验名称实验三:人机交互接口-键盘操作实验系别计算机学院专业计算机科学与技术班级/学号学生姓名实验日期成绩指导教师实验三:人机交互接口-键盘操作实验实验问题答复键盘的工作原理是什么?答:键盘分独立式键盘与矩阵式键盘。独立式键盘:在由单片机组成的测控系统及智能化仪器中,用的最多的是独立式键盘。这种键盘具有硬件与软件相对简单的特点,其缺点是按键数量较多时,要占用大量口线。当按键没按下时,CPU对应的I/O接口由于内部有上拉电阻,其输入为高电平;当某键被按下后,对应的I/O接口变为低电平。只要在程序中判断I/O接口的状态,即可知道哪个键处于闭合状态。矩阵式键盘:矩阵式键盘使用于按键数量较多的场合,它由行线与列线组成,按键位于行、列的交叉点上。一个3*3的行列结构可以构成一个有9个按键的键盘。同理,一个4*4的行列可以构成一个16按键的键盘。很明显,在按键数量较多的场合,与独立式键盘相比,矩阵式键盘要节省很多I/0接口。键盘按键识别方法分扫描法语线反转法。扫描法:扫描法有行扫描和列扫描两种,无论采用哪种,无论采用哪种,其效果是一样的,只是在程序中的处理方法有所区别。下面以列扫描法为例来介绍扫描法识别按键的方法。首先在键处理程序中将P1.4-P1.7依次按位变低,P1.4-P1.7在某一时刻只有一个为低。在某一位为低时读行线,根据行线的状态即可判断出哪一个按键被按下。如2号键按下,当列线P1.5为低时,读回的行线状态中P1.0被拉低,由此可知K2键被按下。一般在扫描法中分两步处理按键,首先是判断有无键按下,如行线有一个为低,那么有键按下。当判断有键按下时,使列线依次变低,读行线,进而判断出具体哪个键被按下。线反转法:扫描法是逐行或逐列扫描查询,当被按下的键处于最后一列时,要经过屡次扫描才能最后获得此按键所处的行列值。而线反转法那么显的简练,无论被按的键处于哪列,均可经过两步即能获得此按键所在的行列值。

首先将行线P1.0-P1.3作为输入线,列线P1.4-P1.7作为输出线,并且输出线输出全为低电平,读行线状态,那么行线中电平为低的是按键所在的行。然后将列线作为输入线,行线作为输出线,并将输出线输出为低电平,读列线状态,那么列线是电平为低的是按键所在的列。综合上述两步结果,确定按键所在的行和列,从而识别出所按下的键。

假设10号键被按下,在第一步P1.3-P1.0全为低电平时,读P1.4-P1.7的值,那么P1.5为低电平;在第二步P1.4-P1.7输出全为低电平时,读P1.3-P1.0时,P1.2为低电平。由此可判断第3行第2列有键被按下,此键就是K10键。键盘等其他外部设备与CPU之间如何协调工作?答:cpu通过I/O接口和外部设备进行数据交换。cpu通过接口对外设进行控制的方式有以下几种:程序查询方式、中断处理方式、DMA传送方式。在实验报告中对键盘中断效劳程序进行逐行注释,理解计算机是如何接收键盘输入的。答:voidGPIO_PORT_D_ISR(void){unsignedcharucKey;//定义一个unsignedchar类型的变量ucKeyunsignedlongulStatus;//定义一个unsignedlong类型的变量ulStatusulStatus=GPIOPinIntStatus(GPIO_PORTD_BASE,true);//读取中断状态GPIOPinIntClear(GPIO_PORTD_BASE,ulStatus);//清空读取到的中断if(ulStatus&GPIO_PIN_7)//如果GPIO_PIN_7中断状态有效{ucKey=GPIOPinRead(GPIO_PORTC_BASE,GPIO_PIN_4);//读取管脚ucKey=ucKey>>1;//ucKey右移一位ucValue=ucValue+ucKey;//ucValue+1ucValue=ucValue<<1;//ucValue左移一位i++;if(i==4)//如果发生四次中断{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}}}根据实验思考,如果有两个不同的中断需要响应时,应该如何设计程序?答:while(1){if(Event_key)//中断1发生的标志{Event_key=0;….…}if(Event)//中断2发生的标志{Event=0;……}}按下几个键后屏幕中出现多个字符怎么办?如何只显示一个?答:发生一次按键中断后调用一次函数RIT128x96x4Clear();。〔6〕因为本次实验需要响应两个中断,需要对主函数的死循环做以下改动。while(1){if(Event_key){Event_key=0;….…}if(Event){Event=0;……}}思考:这样设计的目的和作用是什么?要是系统需要响应4个不同的中断又如何设计?答:目的是使各个中断的处理不受影响。如果需要响应4个不同的中断那么需要定义四个全局变量〔值为0或1〕来标记每个中断。例如如下:while(1){if(Event1){Event1=0;….…}if(Event2){Event2=0;……}if(Event3){Event3=0;……}if(Event4){Event4=0;……}}实验目的和效果实验目的:〔1〕了解键盘工作原理和使用方法〔2〕深入学习、理解、掌握中断使用方法实验效果:三、实验内容和步骤实验内容:默认在在OLED屏幕上分行显示自己的学号、姓名,如“2023011001〞、“zhangsan〞。思路:RIT128x96x4StringDraw直接显示。按下键盘的任意键,在OLED屏幕正中显示该键字符,如“0〞、“A〞等。思路:通过oledkey得到键盘的值,利用RIT128x96x4StringDraw显示在屏幕上。按下键盘的偶数键时,在OLED屏幕上显示“NowShowChar!〞提示信息,并在OLED屏幕上显示实验一的字符,并根据按下的键值,确定字符的位置,按“0〞、“2〞、“4〞、“6〞、“8〞、“A〞、“C〞、“E〞分别在最左端,距左端1/8屏幕宽度处、距左端2/8屏幕宽度处、距左端3/8屏幕宽度处、距左端1/2屏幕宽度处、距右端3/8屏幕宽度处、距右端2/8屏幕宽度处、距右端1/8屏幕宽度处、最右端显示。要保证字符可以全部显示。思路:通过switch语句进行判断,当键盘值为上述字符时调用Draw_Char_F(ulx)在相应位置显示字符图形。按下键盘的奇数键时,在OLED屏幕上显示“NowResetSpeed!〞提示信息,在OLED屏幕上显示实验二的效果,即根据自己分配的阈值和移动路线上对字符进行移动,并根据按下的键值,确定频率的快慢,按“1〞、“3〞、“5〞、“7〞、“9〞、“B〞、“D〞、“F〞由慢到快〔速度可以逐个递增2倍或5倍〕。思路:通过switch语句进行判断,当键盘值为上述字符时调用Reset_Counter_Speed(x)设置字符的不同移动速度。根据自己的想法,选用一个按键,在OLED屏幕上显示与上面不同的效果。思路:一朵花从花盆中长出花茎、叶子、花朵。通过不同的按键长出花的不同局部。实验步骤:〔一〕Keil开发环境中对工程Project配置见实验一〔一〕步骤〔二〕嵌入式C程序开发〔1〕加载必要程序本次实验提供了几个源程序rit128x96x4.h,rit128x96x4.c,startup.s,都压在work3_code.zip中,与实验一〔二〕〔1〕步骤类似。〔2〕新建主函数程序,并加载到工程中新建一个文件,保存为main.c,把main.c也加载到工程中,与实验一〔二〕〔2〕步骤类似。本次实验需要增加以下头文件#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"本次实验显示的内容实验〔二〕已完成,故可在实验〔二〕根底上进一步开发。〔3〕利用中断,接收键盘输入〔3〕--〔1〕在主函数中开启键盘中断,例如如下:/*使能外设GPIO*/SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);/*设置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发起中断请求。〔3〕--〔2〕设置全局变量oledkey用于保存键盘输入的按键charoledkey[2];〔3〕--〔3〕设计实现并注册键盘中断处理函数键盘每次按键都会触发四次中断,中断信号源为GPIOPortD,修改startup.s中GPIOPortD项对应的中断效劳处理函数,与实验〔二〕设置中断流程类似,这里不再重复。键盘中断处理函数例如如下:inti=0;//i定义为全局变量,因为只有1根线GPIO_PIN_4与CPU相联,所以一个按键〔16种,4bit表示〕需要四次中断才能传给CPU。unsignedcharucValue=0x00;//ucValue定义为全局变量,该值存储输入的按键值的中间结果。/*中断效劳函数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';}}}该程序就可以根据键盘中断信号获取键盘输入值,并通过并行转串行转换,将该值存放在oledkey[0]中。〔4〕修改主函数,实现本次实验要求的功能本次实验通过不同键盘控制不同显示,但显示内容实验〔二〕都已完成,故可在实验〔二〕根底上继续深入开发,完成实验〔三〕。〔4〕--〔1〕通过一个全局变量值控制按键后的处理在主函数的while死循环中,应该添加对按键后的处理程序,方法类似于实验〔二〕中对SysTick中断的处理,即设置一个全局变量Event_key,通过在中断效劳程序中设其值为1,主程序死循环中设其值为0来实现。思考一下,应该在中断效劳程序voidGPIO_PORT_D_ISR(void)中的哪个位置设置Event_key为1。提示:一个按键发起四次中断,通过全局变量i计数,到第四次时才表示接收完毕,在此处设置Event_key为1。〔4〕--〔2〕主函数死循环流程因为本次实验需要响应两个中断,需要对主函数的死循环做以下改动。while(1){if(Event_key){Event_key=0;….…}if(Event){Event=0;……}}思考:实验问题6:这样设计的目的和作用是什么?要是系统需要响应4个不同的中断又如何设计?〔4〕--〔3〕发生一次键盘按键后,中断效劳程序完成后,全局变量oledkey[0]中保存的即是输入字符,根据该字符值和实验要求,设计程序。例如如下: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〕偶数时,在不同位置显示字符Draw_Char_H即是画出字符,本例画的是H字符,因为根据输入字符来确定显示位置,因此位置信息作为该函数参数传入,根据要求设计实现该函数。〔4〕--〔5〕奇数时,设置计数器计数频率Reset_Counter_Speed函数完成重新设置计数器的计数频率,其程序流程为关中断---重设中断周期---开中断。例如如下:voidReset_Counter_Speed(){SysTickIntDisable();SysTickDisable();SysTickPeriodSet(SysCtlClockGet()/x);//x为输入的参数,控制计数频率,值越大频率越快SysTickEnable();SysTickIntEnable();}〔4〕--〔6〕完成实验根据实验要求,补齐switch语句。〔5〕编译、连接,生成可执行程序文件〔编译〕〔链接〕〔6〕反复〔3〕--〔5〕步骤,直到完成如果中间出现错误,修改代码,一直到无错,生成最后程序。〔三〕硬件连接见实验〔一〕〔三〕步骤。〔四〕联调见实验〔一〕〔四〕步骤。实验代码:〔实验代码过长,放在实验报告最后〕实验总结与收获附:实验代码#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;}/*中断效劳函数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为输入的参数,控制计数频率,值越大频率越快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为输入的参数,控制计数频率,值越大频率越快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();*//*使能外设GPIO*/SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);/*设置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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论