1、键盘C语言程序word版查看文章在DSP2812上的键盘C+程序#include main.hclass SystemObj System;class TimerObj Timer;class LcdObj Lcd;class KeyboardObj Keyboard;int main(void) Lcd.SetDisplayPos(0, 0);/汉字定位到上行左端 Lcd.Display(汉字显示演示12); Lcd.SetDisplayPos(1, 0);/汉字定位到上行左端 Lcd.Display(汉字显示演示34); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端
2、 Lcd.Display(汉字显示演示56); Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(汉字显示演示78); EALLOW;/ PieCtrlRegs.PIEACK.all = 0xFFFF;/PIEACK_GROUP1; PieCtrlRegs.PIEACK.bit.ACK7 = 1; EDIS; EINT; / Enable Global interrupt INTM ERTM; / Enable Global realtime interrupt DBGM for(;) asm( nop); / Reset the watchdog
3、counter KickDog(); #include keyboard.hKeyboardObj:KeyboardObj(void) Init();void KeyboardObj:Init(void) for (int i = 0; i = KeyboardPushTimes) if (KeyCount = KeyboardPushTimes)/短压键 / System.BeepOn(); (:Keyboard.*KeyboardCommandTab1Count)(); if (KeyCount = KeyboardLongPushTimes)/长压键 (:Keyboard.*Keyboa
4、rdCommandTab2Count)(); KeyCount = KeyboardPushTimes; else/无键压下 if (KeyCount 0)/以前有键压下 if (KeyCount KeyboardPushTimes) KeyCount = KeyboardPushTimes; else KeyCount -;/放键计数 if (KeyCount = 0)/键释放 System.BeepOff(); (:Keyboard.*KeyboardCommandTab0Count)(); else KeyCount = 0; PressCountCount = KeyCount; Co
5、unt +; Count %= KeyboardNumbers;unsigned char KeyboardObj:Scan(void)volatile unsigned char KeyVal = 0; Count %= KeyboardNumbers; KeyVal = LedKeyRegs; switch (Count) case 0: if (!(KeyVal & ConstKEY1) KeyVal = Count + 1; break; case 1: if (!(KeyVal & ConstKEY2) KeyVal = Count + 1; break; case 2: if (!
6、(KeyVal & ConstKEY3) KeyVal = Count + 1; break; case 3: if (!(KeyVal & ConstKEY4) KeyVal = Count + 1; break; case 4: if (!(KeyVal & ConstKEY5) KeyVal = Count + 1; break; case 5: if (!(KeyVal & ConstKEY6) KeyVal = Count + 1; break; case 6: if (!(KeyVal & ConstKEY7) KeyVal = Count + 1; break; case 7:
7、if (!(KeyVal & ConstKEY8) KeyVal = Count + 1; break; return KeyVal;/KEY1放键事件处理void KeyboardObj:Key01(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(KEY1键释放事件);/KEY2放键事件处理void KeyboardObj:Key02(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(KEY2键释放事件);/KEY3放键事件处理void KeyboardObj:Key03(voi
8、d) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(KEY3键释放事件);/KEY4放键事件处理void KeyboardObj:Key04(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(KEY4键释放事件);/KEY5放键事件处理void KeyboardObj:Key05(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(KEY5键释放事件);/KEY6放键事件处理void KeyboardObj:Key06(void) Lcd
9、.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(KEY6键释放事件);/KEY7放键事件处理void KeyboardObj:Key07(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(KEY7键释放事件);/KEY8放键事件处理void KeyboardObj:Key08(void) Lcd.SetDisplayPos(3, 0);/汉字定位到上行左端 Lcd.Display(KEY8键释放事件);/KEY1压键事件处理void KeyboardObj:Key11(void)/特别注意菜农的组合
10、键用法,可以看出零耗时键盘的非典之处 if (PressCount7 = KeyboardPushTimes)/KEY8已先压下 Key8_Key1();/执行KEY8_KEY1组合键事件 else / System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY1键单击事件); /KEY2压键事件处理void KeyboardObj:Key12(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY2键单击事件);/KEY3压键
11、事件处理void KeyboardObj:Key13(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY3键单击事件);/KEY4压键事件处理void KeyboardObj:Key14(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY4键单击事件);/KEY5压键事件处理void KeyboardObj:Key15(void) System.BeepOn(); Lcd.SetDisplayPos(2,
12、 0);/汉字定位到上行左端 Lcd.Display(KEY5键单击事件);/KEY6压键事件处理void KeyboardObj:Key16(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY6键单击事件);/KEY7压键事件处理void KeyboardObj:Key17(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY7键单击事件);/KEY8压键事件处理void KeyboardObj:Key1
13、8(void)/特别注意菜农的组合键用法,可以看出零耗时键盘的非典之处 if (PressCount0 = KeyboardPushTimes)/KEY1已先压下 Key1_Key8();/执行KEY1_KEY8组合键事件 else / System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY8键单击事件); /KEY1长压键事件处理void KeyboardObj:Key21(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(
14、KEY1键长压事件);/KEY2长压键事件处理void KeyboardObj:Key22(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY2键长压事件);/KEY3长压键事件处理void KeyboardObj:Key23(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY3键长压事件);/KEY4长压键事件处理void KeyboardObj:Key24(void) System.BeepOn();
15、 Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY4键长压事件);/KEY5长压键事件处理void KeyboardObj:Key25(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY5键长压事件);/KEY6长压键事件处理void KeyboardObj:Key26(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY6键长压事件);/KEY7长压键事
16、件处理void KeyboardObj:Key27(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY7键长压事件);/KEY8长压键事件处理void KeyboardObj:Key28(void) System.BeepOn(); Lcd.SetDisplayPos(2, 0);/汉字定位到上行左端 Lcd.Display(KEY8键长压事件);/KEY1-KEY8组合键事件处理void KeyboardObj:Key1_Key8(void) Lcd.SetDisplayPos(1, 0);/汉字定位到上行左端 Lcd.Display(KEY1KEY8键事件);/KEY8-KEY1组合键事件处理void KeyboardObj:Key8_Key1(void) Lcd.SetDisplayPos(1, 0);/汉字定位到上行左端 Lcd.Display(KEY8KEY1键事件);类别:Dsp | | 添加到搜藏 | 分享到i贴吧 | 浏览(247) | 评论(0) 上一篇:DSP281x_Adc.h修改以便访问下一篇:DSP2812串口波特率正确和良好的.最近读者:欢迎您的下载,资料仅供参考!
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1