嵌入式实验三人机交互接口-键盘操作实验
更新时间:2024-03-03 10:44:01 阅读量: 综合文库 文档下载
实 验 报 告
指导教师
课程名称 实验仪器 实验名称 系 别 专 业 班级/学号学生姓名 实验日期 成 绩
嵌入式系统设计
清华同方辰源嵌入式系统实验箱 实验三:人机交互接口-键盘操作实验 计算机学院
计算机科学与技术
实验三:人机交互接口-键盘操作实验
一、实验问题回答
(1)键盘的工作原理是什么?
答:键盘分独立式键盘与矩阵式键盘。 独立式键盘:
在由单片机组成的测控系统及智能化仪器中,用的最多的是独立式键盘。这种键盘具有硬件与软件相对简单的特点,其缺点是按键数量较多时,要占用大量口线。
当按键没按下时,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键。
(2)键盘等其他外部设备与CPU之间如何协调工作?
答:cpu通过I/O接口和外部设备进行数据交换。cpu通过接口对外设进行控制的方式有以下几种:程序查询方式、中断处理方式、DMA传送方式。
(3)在实验报告中对键盘中断服务程序进行逐行注释,理解计算机是如何接收键盘输入的。
答:
void GPIO_PORT_D_ISR(void)
{ unsigned char ucKey; //定义一个unsigned char类型的变量 ucKey unsigned long ulStatus; //定义一个unsigned long 类型的变量 ulStatus ulStatus = 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+1 ucValue = ucValue<<1;//ucValue左移一位 i++; if(i==4)//如果发生四次中断 { i=0;//i置0
Event_Key=1;//Event_Key置一,代表按键信息已传给cpu oledkey[1]='\\0';给oledKey[1]赋值\\0 if((ucValue>>4)<10)//如果ucValue右移四位后小于10 oledkey[0] = (ucValue>>4) + 48;//则oledkey[0]右移四位后加48 else oledkey[0] = (ucValue>>4) - 10 + 'A';//否则ucValue右移四位减10加A } } }
(4)根据实验思考,如果有两个不同的中断需要响应时,应该如何设计程序?
答: while(1)
{ if(Event_key)//中断1发生的标志 { Event_key=0; ?. ? } if(Event) //中断2发生的标志 { Event = 0; ? ? } }
(5)按下几个键后屏幕中出现多个字符怎么办?如何只显示一个?
答:发生一次按键中断后调用一次函数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) { Event 2= 0; …… } if(Event3) { Event 3= 0; …… } if(Event4) { Event 4= 0; …… } }
二、实验目的和效果 实验目的:
(1)了解键盘工作原理和使用方法 (2)深入学习、理解、掌握中断使用方法
实验效果:
三、实验内容和步骤
实验内容:
(1)默认在在OLED屏幕上分行显示自己的学号、姓名,如“2010011001”、“zhangsan”。
思路:RIT128x96x4StringDraw直接显示。
(2)按下键盘的任意键,在OLED屏幕正中显示该键字符,如“0”、“A”等。
思路:通过oledkey得到键盘的值,利用RIT128x96x4StringDraw显示在屏幕上。
(3)按下键盘的偶数键时,在OLED屏幕上显示“Now Show Char!”提示信息,并在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)在相应位置显示字符图形。
(4)按下键盘的奇数键时,在OLED屏幕上显示“Now Reset Speed!”提示信息,在OLED屏幕上显示实验二的效果,即根据自己分配的阈值和移动路线上对字符进行移动,并根据按下的键值,确定频率的快慢,按“1”、“3”、“5”、“7”、“9”、“B”、“D”、“F”由慢到快(速度可以逐个递增2倍或5倍)。
思路:通过switch语句进行判断,当键盘值为上述字符时调用Reset_Counter_Speed(x)设置字符的不同移动速度。
(5)根据自己的想法,选用一个按键,在OLED屏幕上显示与上面不同的效果。
思路:一朵花从花盆中长出花茎、叶子、花朵。通过不同的按键长出花的不同部分。
实验步骤:
(一)Keil开发环境中对项目Project配置 见实验一(一)步骤 (二)嵌入式C程序开发 (1)加载必要程序
本次实验提供了几个源程序rit128x96x4.h,rit128x96x4.c,startup.s,都压在work3_code.zip中,与实验一(二)(1)步骤类似。
(2)新建主函数程序,并加载到项目中
新建一个文件,保存为main.c,把main.c也加载到项目中,与实验一(二)(2)步骤类似。 本次实验需要增加以下头文件 #include
#include
本次实验显示的内容实验(二)已完成,故可在实验(二)基础上进一步开发。
(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_RISING_EDGE);
GPIO_PIN_7,
注意:其中,GPIO_PORTC用于传输按下的键值,GPIO_PORTD用于向CPU发起中断请求。
(3)--(2)设置全局变量oledkey用于保存键盘输入的按键 char oledkey[2];
(3)--(3)设计实现并注册键盘中断处理函数
键盘每次按键都会触发四次中断,中断信号源为GPIO Port D,修改startup.s中GPIO Port D项对应的中断服务处理函数,与实验(二)设置中断流程类似,这里不再重复。
键盘中断处理函数示例如下:
int i=0; // i定义为全局变量,因为只有1根线GPIO_PIN_4与CPU相联,所以一个按键(16种,4bit表示)需要四次中断才能传给CPU。
unsigned char ucValue=0x00; //ucValue定义为全局变量,该值存储输入的按键值的中间结果。
/*中断服务函数ISR*/ void GPIO_PORT_D_ISR(void) {
unsigned char ucKey;
unsigned long ulStatus;
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; else
oledkey[0] = (ucValue>>4) - 10 + 'A'; } }
#include
#include \int Event=0; int Event_Key=0; int count1=0; char oledkey[2]; int i=0; int z=56; unsigned char ucValue=0x00; unsigned char buf01[] = //开放的花 { 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 }; unsigned char buf02[] = { 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 };
unsigned char buf03[] = {
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 };
unsigned char buf04[] = {
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 };
unsigned char buf05[] = {
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 };
unsigned char buf06[] = {
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 };
unsigned char buf07[] = {
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 };
unsigned char buf08[] = {
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 };
unsigned char buf09[] = {
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 };
unsigned char buf010[] = {
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 };
unsigned char buf011[] = {
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 };
unsigned char buf012[] = {
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 };
unsigned char buf013[] = {
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 };
unsigned char buf015[] = {
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, };
unsigned char buf014[] = {
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 };
unsigned char buf016[] = {
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 };
unsigned char buf017[] = { 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 };
unsigned char buf018[] = { 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 };
unsigned char buf019[] = { 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 };
unsigned char buf020[] = { //花枝 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 }; unsigned char bufp1[] = {
0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff,
//花盆 huapen 0xff,0xff }; unsigned char bufp2[] = {
0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff }; unsigned char bufp3[] = {
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 }; unsigned char bufp4[] = {
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 }; unsigned char bufp5[] = {
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 }; unsigned char bufp6[] = {
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 }; unsigned char bufp7[] = {
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 }; unsigned char bufp8[] = {
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 }; unsigned char bufp9[] = {
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 }; unsigned char bufp10[] = {
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 }; unsigned char bufp11[] = {
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 }; unsigned char bufp12[] = {
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 }; unsigned char bufl1[] = //叶子 big leaf 8x6 {
0x00,0x00, 0x00,0x00, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char bufl2[] = {
0x00,0x00, 0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00,
0xff,0xff, 0x00,0x00, 0x00,0x00 }; unsigned char bufl3[] = {
0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0xff,0xff, 0x00,0x00 }; unsigned char bufl4[] = { 0x00,0x00, 0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0xff,0xff }; unsigned char bufl5[] = { 0x00,0x00, 0x00,0x00, 0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0xff,0xff }; unsigned char bufl6[] = { 0x00,0x00,
0x00,0x00, 0x00,0x00, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff }; unsigned char bufs1[] = //small leaf {
0x00,0x00, 0x00,0x00, 0xff,0xff, 0xff,0xff, 0x00,0x00, 0x00,0x00 }; unsigned char bufs2[] = {
0x00,0x00, 0xff,0xff, 0x00,0x00, 0x00,0x00, 0xff,0xff, 0x00,0x00 }; unsigned char bufs3[] = {
0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0xff,0xff }; unsigned char bufs4[] = {
0xff,0xff, 0xff,0xff, 0xff,0xff,
0xff,0xff, 0xff,0xff, 0x00,0x00 }; unsigned char buf1[] = {
0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff }; unsigned char buf2[] = {
0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf3[] = {
0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf4[] = {
0xff,0xff, 0xff,0xff, 0xff,0xff, 0xff,0xff, 0x00,0x00 }; unsigned char buf5[] = {
0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf6[] = {
0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf7[] = {
0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf1c[] = {
0xf4,0xf4, 0xf4,0xf4, 0xf4,0xf4, 0xf4,0xf4, 0xf4,0xf4 }; unsigned char buf2c[] = {
0xf6,0xf6, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf3c[] =
{
0xf8,0xf8, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf4c[] = {
0xfa,0xfa, 0xfa,0xfa, 0xfa,0xfa, 0xfa,0xfa, 0x00,0x00 }; unsigned char buf5c[] = {
0xfc,0xfc, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf6c[] = {
0xfe,0xfe, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 }; unsigned char buf7c[] = {
0xff,0xff, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00 };
unsigned char buf1a[] = {
0xff,0xff, 0xff }; unsigned char buf2a[] = {
0xff,0x00, 0x00 }; unsigned char buf3a[] = {
0xff,0x00, 0x00 }; unsigned char buf4a[] = {
0xff,0xff, 0x00 }; unsigned char buf5a[] = {
0xff,0x00, 0x00 };unsigned char buf6a[] = {
0xff,0x00, 0x00 }; unsigned char buf7a[] = {
0xff,0x00, 0x00 }; unsigned char buf9[] = {
0xff,0xff, 0xff };
unsigned char buf10[] = {
0xff,0xff, 0xff };
unsigned char buf11[] = {
0xff,0xff, 0xff }; //SysTick interrupt happens every XX ms void SysTick_Handler(void){ Event=1; } /*中断服务函数ISR*/ void GPIO_PORT_D_ISR(void) { unsigned char ucKey; unsigned long ulStatus; 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; else oledkey[0] = (ucValue>>4) - 10 + 'A'; } } }
void Reset_Counter_Speed(int x) {
SysTickIntDisable(); SysTickDisable(); SysTickPeriodSet(SysCtlClockGet() / x*100);//x为输入的参数,控制计数频率,值越大频率越快 SysTickEnable(); SysTickIntEnable(); RIT128x96x4StringDraw(\ }
void Draw_Char_F(int x){ RIT128x96x4StringDraw(\ RIT128x96x4ImageDraw(buf1, x, 30, 20, 1);//big F RIT128x96x4ImageDraw(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); }
void Draw_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); }
void Draw_o(){//画花枝 for(z=56;z<=74;z++){ RIT128x96x4ImageDraw(buf020, 0,z,104, 1); } } void Draw_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); } void Draw_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); } void Draw_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); }
void Draw_l(){ SysTickIntDisable(); SysTickDisable(); SysTickPeriodSet(SysCtlClockGet() / 500000);//x为输入的参数,控制计数频率,值越大频率越快 SysTickEnable(); SysTickIntEnable(); }
/*unsigned char buf0[50]{ for(i=0;i //int y2=0; //int count5=0; unsigned char buf[5]; unsigned char buff[5]; //unsigned char buf0[50]; int count=0; //int light=0; int i; int x=9; int v=1; int s=0; int s1=0; int t=10; //int v1=0; //x1=rand()?+5; //y1=rand()q+5; SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); RIT128x96x4Init(1000000); RIT128x96x4Clear(); //Setup and enables SysTick with interrupt(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(\ RIT128x96x4StringDraw(\ if(Event_Key){ //0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 RIT128x96x4Clear(); Event_Key=0; RIT128x96x4Clear(); sprintf(buff, \ 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; break; case '2': Draw_Char_F(16); Flag = 0; break; case '3': Reset_Counter_Speed(2); Flag = 0; break; case '4': Draw_Char_F(32); Flag = 0; break; case '5': Reset_Counter_Speed(4); Flag = 0; break; case '6': Draw_Char_F(48); Flag = 0; break; case '7': Reset_Counter_Speed(8); Flag = 0; break; case '8': Draw_Char_F(64); Flag = 0; break; case '9': Reset_Counter_Speed(16); Flag = 0; break; case 'A': Draw_Char_F(80); Flag = 0; break; case 'B': Reset_Counter_Speed(32); Flag = 0; break; case 'C': Draw_Char_F(96); Flag = 0; break; case 'D': Reset_Counter_Speed(64); Flag = 0; break; case 'E': Draw_Char_F(108); Flag = 0; break; case 'F': Reset_Counter_Speed(128); Flag = 0; break; /* case '0': Draw_f(); Flag = 0; break; case'1': Draw_l(); Flag = 0; break; case '2': Draw_o(); Flag = 0; break; case '3': Draw_w(); Flag = 0; break; case '4': Draw_e(); Flag = 0; break; case '5': Draw_r(); Flag = 0; break; default: break; */ } } if(Event) { RIT128x96x4StringDraw(\ RIT128x96x4StringDraw(\ RIT128x96x4Clear(); //x1=rand()?+5; //y1=rand()q+5; Event = 0; if(count>400) count = 0; else count++; //if(count1>49) count1=0; //else count1++; //if(v1>4) v1=0; //else v1++; //if(light>15) //light=0; //else //light++; /*for(i=0;i
正在阅读:
嵌入式实验三人机交互接口-键盘操作实验03-03
预拌再生混凝土全计算法配合比设计01-18
优易电商ERP操作手册(自有仓)12-04
定性研究与定量研究之比较12-29
高等职业学校新校区建设项目可行性研究报告06-19
司马迁发愤写史记教学设计04-09
秋天的儿童公园作文350字07-13
关于做好站址变动对比观测资料分析工作的通知(气测函〔2012〕27号文)12-08
Java软件设计基础07-17
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 实验
- 人机
- 嵌入式
- 交互
- 接口
- 键盘
- 操作
- 2015年高考地理二轮复习专题十一 自然资源与人类活动
- 人教版六年级数学下册第六单元整理和复习教案
- 《给排水管道工程技术》课程标准课件
- 小学五年级数学-北师版五年级数学体积与容积 精品
- 关于2016地理信息科技进步奖评选工作的通知 doc
- 《FLASH动画》教学大纲总结
- 高三世界地理复习《北美洲-美国》练习题 - 图文
- GSP质量管理体系汇编门店
- 西藏游注意事项
- 广东省创新杯说课大赛公共艺术类一等奖作品:中国民族民间舞教学
- 《西游记》竞赛题目100题
- 服务器实施方案
- 2017年大众创业与转型机遇公需课题目及答案汇总完整版
- 初中英语宾语从句试题
- 五升六奥数测试试卷
- (解析版)广东省广州市铁一中学、广外等三校高一下学期期末联考
- 2019学年中考地理会考复习专题三 七上 世界的地形、世界的居民训
- 2019最新八年级数学上册17特殊三角形17.3勾股定理2导学案无答案
- 2010年6月大学英语四级考试完型填空突破(25)
- 科技小论文-为什么白醋能显字