




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.查看文章 在DSP2812上的键盘C+程序#include "main.h"class SystemObj System;class TimerObj Timer;class LcdObj Lcd;class KeyboardObj Keyboard;int main(void) Lcd.SetDisplayPos(0, 0);/汉字定位到上行左端 Lcd.Display("汉字显示演示12"); L
2、cd.SetDisplayPos(1, 0);/汉字定位到上行左端 Lcd.Display("汉字显示演示34"); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("汉字显示演示56"); Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Di
3、splay("汉字显示演示78"); EALLOW;/ PieCtrlRegs.PIEACK.all = 0xFFFF;/PIEACK_GROUP1; PieCtrlRegs.PIEACK.bit.ACK7 = 1; EDIS; EINT; / Enabl
4、e Global interrupt INTM ERTM; / Enable Global realtime interrupt DBGM for(;) asm(" nop"); / Reset the watchdog counter
5、60; KickDog(); #include "keyboard.h"KeyboardObj:KeyboardObj(void) Init();void KeyboardObj:Init(void) for (int i = 0; i < sizeof(PressCount); i +)
6、60; PressCounti = 0; Count = 0;void KeyboardObj:Exec(void)typedef void (KeyboardObj:*FunctionPtr)(void);/函数指针static const FunctionPtr KeyboardCommandTab3KeyboardNumbers =
7、160; &KeyboardObj:Key01, &KeyboardObj:Key02, &KeyboardObj:Key03, &KeyboardObj:Key04,
8、160; &KeyboardObj:Key05, &KeyboardObj:Key06, &KeyboardObj:Key07, &KeyboardObj:Key08 ,/放键表
9、60; &KeyboardObj:Key11, &KeyboardObj:Key12, &KeyboardObj:Key13, &KeyboardObj:Key14,
10、160; &KeyboardObj:Key15, &KeyboardObj:Key16, &KeyboardObj:Key17, &KeyboardObj:Key18
11、60; ,/短压表 &KeyboardObj:Key21, &KeyboardObj:Key22, &KeyboardObj:Key23, &
12、amp;KeyboardObj:Key24, &KeyboardObj:Key25, &KeyboardObj:Key26, &KeyboardObj:Key27, &Keyboard
13、Obj:Key28 /长压表;unsigned char KeyCount; Count %= KeyboardNumbers; KeyCount = PressCountCount;/取压键次数 if (Scan() = Count + 1)/有键压下 Key
14、Count +;/压键计数 if (KeyCount >= KeyboardPushTimes) if (KeyCount = KeyboardPushTimes)/短压键
15、 / System.BeepOn(); (:Keyboard.*KeyboardCommandTab1Cou
16、nt)(); if (KeyCount = KeyboardLongPushTimes)/长压键
17、0; (:Keyboard.*KeyboardCommandTab2Count)(); KeyCount = KeyboardPushTimes;
18、; else/无键压下 if (KeyCount > 0)/以前有键压下
19、0; if (KeyCount > KeyboardPushTimes) KeyCount = Ke
20、yboardPushTimes; else &
21、#160; KeyCount -;/放键计数 if (KeyCount = 0)/键释放
22、60; System.BeepOff(); (:Keyboard.*KeyboardCommandTab0Count)();
23、0; else
24、160; KeyCount = 0; PressCountCount = KeyCount; Count +;
25、160; Count %= KeyboardNumbers;unsigned char KeyboardObj:Scan(void)volatile unsigned char KeyVal = 0; Count %= KeyboardNumbers; KeyVal = LedKeyRegs; switch (Count)
26、; case 0: if (!(KeyVal & ConstKEY1) KeyVal = Coun
27、t + 1; break; case 1: if (!(KeyVal
28、& ConstKEY2) KeyVal = Count + 1;
29、0; break; case 2: if (!(KeyVal & ConstKEY3)
30、 KeyVal = Count + 1; break;
31、160; case 3: if (!(KeyVal & ConstKEY4) KeyVal = Count +
32、 1; break; case 4: if (!(KeyVal &am
33、p; ConstKEY5) KeyVal = Count + 1; &
34、#160; break; case 5: if (!(KeyVal & ConstKEY6)
35、60; KeyVal = Count + 1; break;
36、; case 6: if (!(KeyVal & ConstKEY7) KeyVal = Count + 1;
37、 break; case 7: if (!(KeyVal &
38、ConstKEY8) KeyVal = Count + 1;
39、0; break; return KeyVal;/KEY1放键事件处理void KeyboardObj:Key01(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display("KEY1键释放事件");/KEY2放键事件处理void KeyboardObj
40、:Key02(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display("KEY2键释放事件");/KEY3放键事件处理void KeyboardObj:Key03(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display("KEY3键释放事件");/KEY4放键事件处理
41、void KeyboardObj:Key04(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display("KEY4键释放事件");/KEY5放键事件处理void KeyboardObj:Key05(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display("KEY5键释放事件&qu
42、ot;);/KEY6放键事件处理void KeyboardObj:Key06(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display("KEY6键释放事件");/KEY7放键事件处理void KeyboardObj:Key07(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(&q
43、uot;KEY7键释放事件");/KEY8放键事件处理void KeyboardObj:Key08(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display("KEY8键释放事件");/KEY1压键事件处理void KeyboardObj:Key11(void)/特别注意菜农的组合键用法,可以看出"零耗时键盘"的非典之处 if (PressCount7 &
44、gt;= KeyboardPushTimes)/KEY8已先压下 Key8_Key1();/执行KEY8_KEY1组合键事件 else / System.BeepOn();
45、160; Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("KEY1键单击事件"); /KEY2压键事件处理void KeyboardObj:Key12(void) System.BeepOn();
46、 Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("KEY2键单击事件");/KEY3压键事件处理void KeyboardObj:Key13(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display
47、("KEY3键单击事件");/KEY4压键事件处理void KeyboardObj:Key14(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("KEY4键单击事件");/KEY5压键事件处理void KeyboardObj:Key15(void)
48、160; System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("KEY5键单击事件");/KEY6压键事件处理void KeyboardObj:Key16(void) System.BeepOn(); Lcd.SetDisplayPos(2
49、, 0);/汉字定位到上行左端 Lcd.Display("KEY6键单击事件");/KEY7压键事件处理void KeyboardObj:Key17(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("KEY7键单击事件");/KEY8压键事
50、件处理void KeyboardObj:Key18(void)/特别注意菜农的组合键用法,可以看出"零耗时键盘"的非典之处 if (PressCount0 >= KeyboardPushTimes)/KEY1已先压下 Key1_Key8();/执行KEY1_KEY8组合键事件 el
51、se / System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("KEY8键单击事件");
52、0; /KEY1长压键事件处理void KeyboardObj:Key21(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("KEY1键长压事件");/KEY2长压键事件处理void KeyboardObj:Key22(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display("KEY2键长压事件");/KEY3长压键事件处理void KeyboardObj:Key23(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年医师执业资格考试试题及答案
- 2025年企业管理人员考试题及答案
- 2025年生物医学工程职业资格考试卷及答案
- 知识产权授权及教育培训课程开发合同
- 高效商标续展代理服务合同模板
- 萌宠生活馆宠物训练学校加盟授权合同
- 抖音平台用户数据删除与个人信息保护协议
- 高端制造业全球供应链股权投资合作备忘录
- 网络游戏角色动作捕捉与动作库建设合作协议
- 留学咨询机构文书保密及授权使用合同
- 智慧火电厂综合安防解决方案
- 《历史研究》格式-20210720155944
- 高中化学人教版必修第一册课件2.2.1氯气的性质
- XX医院抗菌药物临床应用监督管理机制+预警机制
- 少数民族佤族民俗文化科普介绍
- 2024-2030年中国浆纸行业市场发展分析及发展前景预测研究报告
- 2024年湖南省长沙市中考地理试卷真题(含答案解析)
- 2《归去来兮辞并序》公开课一等奖创新教学设计统编版高中语文选择性必修下册
- 法理斗争1全文
- 2024年青岛东鼎产业发展集团招聘笔试冲刺题(带答案解析)
- NB-T 11074-2023 高压开关类设备操作机构 湿热环境耐久性评价
评论
0/150
提交评论