第十六节:矩阵键盘的组合按键触发。(中)

  1. if((uiKeyStatus&0x0200)==0x0200)  //说明10号键没有被按下来  
  2.                   {  
  3.              uiKeyTimeCnt[9]=0;  
  4.              ucKeyLock[9]=0;  
  5.                   }  
  6.                   else if(ucKeyLock[9]==0)  
  7.                   {  
  8.                      uiKeyTimeCnt[9]++;  
  9.                          if(uiKeyTimeCnt[9]>const_key_time)  
  10.                          {  
  11.                             uiKeyTimeCnt[9]=0;  
  12.                             ucKeyLock[9]=1; //自锁按键,防止不断触发  
  13.                             ucKeySec=10;   //被触发10号键  
  14.                          }  
  15.                   }  
  16.   
  17.               if((uiKeyStatus&0x0400)==0x0400)  //说明11号键没有被按下来  
  18.                   {  
  19.              uiKeyTimeCnt[10]=0;  
  20.              ucKeyLock[10]=0;  
  21.                   }  
  22.                   else if(ucKeyLock[10]==0)  
  23.                   {  
  24.                      uiKeyTimeCnt[10]++;  
  25.                          if(uiKeyTimeCnt[10]>const_key_time)  
  26.                          {  
  27.                             uiKeyTimeCnt[10]=0;  
  28.                             ucKeyLock[10]=1; //自锁按键,防止不断触发  
  29.                             ucKeySec=11;   //被触发11号键  
  30.                          }  
  31.                   }  
  32.   
  33.               if((uiKeyStatus&0x0800)==0x0800)  //说明12号键没有被按下来  
  34.                   {  
  35.              uiKeyTimeCnt[11]=0;  
  36.              ucKeyLock[11]=0;  
  37.                   }  
  38.                   else if(ucKeyLock[11]==0)  
  39.                   {  
  40.                      uiKeyTimeCnt[11]++;  
  41.                          if(uiKeyTimeCnt[11]>const_key_time)  
  42.                          {  
  43.                             uiKeyTimeCnt[11]=0;  
  44.                             ucKeyLock[11]=1; //自锁按键,防止不断触发  
  45.                             ucKeySec=12;   //被触发12号键  
  46.                          }  
  47.                   }  
  48.   
  49.               if((uiKeyStatus&0x0800)==0x0800)  //说明12号键没有被按下来  
  50.                   {  
  51.              uiKeyTimeCnt[11]=0;  
  52.              ucKeyLock[11]=0;  
  53.                   }  
  54.                   else if(ucKeyLock[11]==0)  
  55.                   {  
  56.                      uiKeyTimeCnt[11]++;  
  57.                          if(uiKeyTimeCnt[11]>const_key_time)  
  58.                          {  
  59.                             uiKeyTimeCnt[11]=0;  
  60.                             ucKeyLock[11]=1; //自锁按键,防止不断触发  
  61.                             ucKeySec=12;   //被触发12号键  
  62.                          }  
  63.                   }  
  64.   
  65.               if((uiKeyStatus&0x1000)==0x1000)  //说明13号键没有被按下来  
  66.                   {  
  67.              uiKeyTimeCnt[12]=0;  
  68.              ucKeyLock[12]=0;  
  69.                   }  
  70.                   else if(ucKeyLock[12]==0)  
  71.                   {  
  72.                      uiKeyTimeCnt[12]++;  
  73.                          if(uiKeyTimeCnt[12]>const_key_time)  
  74.                          {  
  75.                             uiKeyTimeCnt[12]=0;  
  76.                             ucKeyLock[12]=1; //自锁按键,防止不断触发  
  77.                             ucKeySec=13;   //被触发13号键  
  78.                          }  
  79.                   }  
  80.   
  81.   
  82.               if((uiKeyStatus&0x2000)==0x2000)  //说明14号键没有被按下来  
  83.                   {  
  84.              uiKeyTimeCnt[13]=0;  
  85.              ucKeyLock[13]=0;  
  86.                   }  
  87.                   else if(ucKeyLock[13]==0)  
  88.                   {  
  89.                      uiKeyTimeCnt[13]++;  
  90.                          if(uiKeyTimeCnt[13]>const_key_time)  
  91.                          {  
  92.                             uiKeyTimeCnt[13]=0;  
  93.                             ucKeyLock[13]=1; //自锁按键,防止不断触发  
  94.                             ucKeySec=14;   //被触发14号键  
  95.                          }  
  96.                   }  
  97.   
  98.               if((uiKeyStatus&0x4000)==0x4000)  //说明15号键没有被按下来  
  99.                   {  
  100.              uiKeyTimeCnt[14]=0;  
  101.              ucKeyLock[14]=0;  
  102.                   }  
  103.                   else if(ucKeyLock[14]==0)  
  104.                   {  
  105.                      uiKeyTimeCnt[14]++;  
  106.                          if(uiKeyTimeCnt[14]>const_key_time)  
  107.                          {  
  108.                             uiKeyTimeCnt[14]=0;  
  109.                             ucKeyLock[14]=1; //自锁按键,防止不断触发  
  110.                             ucKeySec=15;   //被触发15号键  
  111.                          }  
  112.                   }  
  113.   
  114.               if((uiKeyStatus&0x8000)==0x8000)  //说明16号键没有被按下来  
  115.                   {  
  116.              uiKeyTimeCnt[15]=0;  
  117.              ucKeyLock[15]=0;  
  118.                   }  
  119.                   else if(ucKeyLock[15]==0)  
  120.                   {  
  121.                      uiKeyTimeCnt[15]++;  
  122.                          if(uiKeyTimeCnt[15]>const_key_time)  
  123.                          {  
  124.                             uiKeyTimeCnt[15]=0;  
  125.                             ucKeyLock[15]=1; //自锁按键,防止不断触发  
  126.                             ucKeySec=16;   //被触发16号键  
  127.                          }  
  128.                   }  
  129.   
  130.   
  131.               if((uiKeyStatus&0x8001)==0x0000)  //S1和S16的组合键盘被按下。  
  132.                   {  
  133.              if(ucKeyLock_01_16==0)  
  134.                          {  
  135.                              uiKeyTimeCnt_01_16++;  
  136.                                  if(uiKeyTimeCnt_01_16>const_key_time_comb)  
  137.                                  {  
  138.                                     uiKeyTimeCnt_01_16=0;  
  139.                                         ucKeyLock_01_16=1;  
  140.                                         ucKeySec=17;   //被触发17号组合键                             
  141.                                  }  
  142.                                
  143.                          }  
  144.                   }  
  145.                   else   
  146.                   {  
  147.              uiKeyTimeCnt_01_16=0; //S1和S16组合按键去抖动延时计数器  
  148.              ucKeyLock_01_16=0; //S1和S16组合按键触发后自锁的变量标志  
  149.                   }  
  150.   
  151.   
  152.               if((uiKeyStatus&0x1008)==0x0000)  //S4和S13的组合键盘被按下。  
  153.                   {  
  154.              if(ucKeyLock_04_13==0)  
  155.                          {  
  156.                              uiKeyTimeCnt_04_13++;  
  157.                                  if(uiKeyTimeCnt_04_13>const_key_time_comb)  
  158.                                  {  
  159.                                     uiKeyTimeCnt_04_13=0;  
  160.                                         ucKeyLock_04_13=1;  
  161.                                         ucKeySec=18;   //被触发18号组合键                             
  162.                                  }  
  163.                                
  164.                          }  
  165.                   }  
  166.                   else   
  167.                   {  
  168.              uiKeyTimeCnt_04_13=0; //S4和S13组合按键去抖动延时计数器  
  169.              ucKeyLock_04_13=0; //S4和S13组合按键触发后自锁的变量标志  
  170.                   }  
  171.   
  172.           uiKeyStatus=0xffff;   //及时恢复状态,方便下一次扫描  
  173.                   ucKeyStep=1;  //返回到第一个运行步骤重新开始扫描  
  174.               break;  
  175.   
  176.   }  
  177.   
  178.   
  179. }  
  180.   
  181.   
  182. void key_service() //第三区 按键服务的应用程序  
  183. {  
  184.   switch(ucKeySec) //按键服务状态切换  
  185.   {  
  186.     case 1:// 1号键 对应朱兆祺学习板的S1键  
  187.   
  188.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  189.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  190.           break;          
  191.     case 2:// 2号键 对应朱兆祺学习板的S2键  
  192.   
  193.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  194.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  195.           break;       
  196.     case 3:// 3号键 对应朱兆祺学习板的S3键  
  197.   
  198.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  199.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  200.           break;            
  201.     case 4:// 4号键 对应朱兆祺学习板的S4键  
  202.   
  203.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  204.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  205.           break;     
  206.     case 5:// 5号键 对应朱兆祺学习板的S5键  
  207.   
  208.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  209.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  210.           break;     
  211.     case 6:// 6号键 对应朱兆祺学习板的S6键  
  212.   
  213.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  214.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  215.           break;     
  216.     case 7:// 7号键 对应朱兆祺学习板的S7键  
  217.   
  218.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  219.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  220.           break;     
  221.     case 8:// 8号键 对应朱兆祺学习板的S8键  
  222.   
  223.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  224.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  225.           break;     
  226.     case 9:// 9号键 对应朱兆祺学习板的S9键  
  227.   
  228.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  229.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  230.           break;     
  231.     case 10:// 10号键 对应朱兆祺学习板的S10键  
  232.   
  233.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  234.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  235.           break;     
  236.     case 11:// 11号键 对应朱兆祺学习板的S11键  
  237.   
  238.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  239.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  240.           break;     
  241.     case 12:// 12号键 对应朱兆祺学习板的S12键  
  242.   
  243.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  244.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  245.           break;     
  246.     case 13:// 13号键 对应朱兆祺学习板的S13键  
  247.   
  248.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  249.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  250.           break;     
  251.     case 14:// 14号键 对应朱兆祺学习板的S14键  
  252.   
  253.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  254.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  255.           break;     
  256.     case 15:// 15号键 对应朱兆祺学习板的S15键  
  257.   
  258.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  259.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  260.           break;     
  261.     case 16:// 16号键 对应朱兆祺学习板的S16键  
  262.   
  263.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  264.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  265.           break;     
  266.   
  267.     case 17:// 17号组合键 对应朱兆祺学习板的S1和S16键的组合按键  
  268.   
  269.           led_dr=1; //LED灯亮  
  270.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  271.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  272.           break;     
  273.   
  274.     case 18:// 18号组合键 对应朱兆祺学习板的S4和S13键的组合按键  
  275.   
  276.           led_dr=0; //LED灯灭  
  277.           uiVoiceCnt=const_voice_short; //按键声音触发,滴一声就停。  
  278.           ucKeySec=0;  //响应按键服务处理程序后,按键编号清零,避免一致触发  
  279.           break;     
  280.   }                  
  281. }  
  282.   
  283.   
  284.   
  285.  

(上http://www.eeskill.com/group/topic_scan/id/467

(下http://www.eeskill.com/group/topic_scan/id/492

永不止步步 发表于11-20 14:22 浏览65535次
分享到:

已有0条评论

暂时还没有回复哟,快来抢沙发吧

添加一条新评论

只有登录用户才能评论,请先登录注册哦!

话题作者

永不止步步
金币:67417个|学分:363741个
立即注册
畅学电子网,带你进入电子开发学习世界
专业电子工程技术学习交流社区,加入畅学一起充电加油吧!

x

畅学电子网订阅号