⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyboard_lcd.lst

📁 TS12864液晶驱动
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.02   KEYBOARD_LCD                                                          07/26/2008 19:16:15 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE KEYBOARD_LCD
OBJECT MODULE PLACED IN Keyboard_LCD.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe Keyboard_LCD.c DB OE BR

line level    source

   1          #include "Keyboard_LCD.h"
   2          
   3          //sbit led=P1^6;
   4          
   5          #define ZERO                    0
   6          #define ONE                             1
   7          #define TWO                             2
   8          #define THREE                   3
   9          #define FOUR                    4
  10          #define FIVE                    5
  11          #define SIX                             6
  12          #define SEVEN                   7
  13          #define EIGHT                   8
  14          #define NIGHT                   9
  15          #define XXXX                    0xF0F0
  16          
  17          #define INIT_SCREEN             11
  18          #define TRIG_WORD               12
  19          #define TRIG_CH                 13
  20          #define TRIG_DELAY              14
  21          #define THRESHOLD               15
  22          #define RETURN_TURE             16
  23          #define RETURN_FALSE    17
  24          
  25          unsigned char xdata trig_word[8] = {0,1,1,0,0,1,0,0};                       //触发字
  26          unsigned char trig_ch = 0x00;                                                                   //3级触发时的触发通道
  27          unsigned char thresholdW;                                                                               //门限电压
  28          unsigned char trig_delay = 0; 
  29          
  30          struct getMessage
  31          {
  32                  unsigned int prevValue;
  33                  unsigned int thisValue;
  34          }trigWord,trigCh,trigDelay,threshold;
  35          
  36          struct keyCheck
  37          {
  38                  unsigned char prevKey;
  39                  unsigned char thisKey;
  40          }key;
  41          
  42          struct screenMode
  43          {
  44                  unsigned char prevMode;
  45                  unsigned char thisMode;
  46                  unsigned char exitOrNo;
  47          }screenMode,showMode;
  48          
  49          void GetKeyValue() interrupt 1
  50          {
  51   1              unsigned int keyValue;
  52   1              unsigned char tempMode;
  53   1              TR0=0;
  54   1              TF0=0;
  55   1              keyValue=uart_keyboard();
C51 COMPILER V8.02   KEYBOARD_LCD                                                          07/26/2008 19:16:15 PAGE 2   

  56   1              switch(keyValue)
  57   1              {
  58   2              case 0x0008:    //zero
  59   2              case 0x0004:    //one
  60   2              case 0x0040:    //two           
  61   2              case 0x0400:    //three
  62   2              case 0x0002:    //four                  
  63   2              case 0x0020:    //five
  64   2              case 0x0200:    //six                   
  65   2              case 0x0001:    //seven                 
  66   2              case 0x0010:    //eight
  67   2              case 0x0100:    //night
  68   2                                      switch(keyValue)
  69   2                                      {
  70   3                                      case 0x0008:    if(key.thisKey!=ZERO)
  71   3                                                                              key.thisKey=ZERO;
  72   3                                                                      break;                          //zero
  73   3                                      case 0x0004:    if(key.thisKey!=ONE)
  74   3                                                                              key.thisKey=ONE;
  75   3                                                                      break;                          //one
  76   3                                      case 0x0040:    if(key.thisKey!=TWO)
  77   3                                                                              key.thisKey=TWO;
  78   3                                                                      break;                          //two           
  79   3                                      case 0x0400:    if(key.thisKey!=THREE)
  80   3                                                                              key.thisKey=THREE;
  81   3                                                                      break;                          //three
  82   3                                      case 0x0002:    if(key.thisKey!=FOUR)
  83   3                                                                              key.thisKey=FOUR;
  84   3                                                                      break;                          //four                  
  85   3                                      case 0x0020:    if(key.thisKey!=FIVE)
  86   3                                                                              key.thisKey=FIVE;
  87   3                                                                      break;                          //five
  88   3                                      case 0x0200:    if(key.thisKey!=SIX)
  89   3                                                                              key.thisKey=SIX;
  90   3                                                                      break;                          //six                   
  91   3                                      case 0x0001:    if(key.thisKey!=SEVEN)
  92   3                                                                              key.thisKey=SEVEN;
  93   3                                                                      break;                          //seven                 
  94   3                                      case 0x0010:    if(key.thisKey!=EIGHT)
  95   3                                                                              key.thisKey=EIGHT;
  96   3                                                                      break;                          //eight
  97   3                                      case 0x0100:    if(key.thisKey!=NIGHT)
  98   3                                                                              key.thisKey=NIGHT;
  99   3                                                                      break;                          //night
 100   3                                      default:
 101   3                                                                      key.thisKey=XXXX;
 102   3                                      }
 103   2                                      if(key.thisKey!=key.prevKey && key.thisKey!=XXXX)
 104   2                                      {
 105   3                                              key.prevKey=key.thisKey;
 106   3                                              if(screenMode.thisMode==INIT_SCREEN)
 107   3                                              {//此时不在编辑状态,可在此加入更多功能
 108   4                                              }
 109   3                                              else if(screenMode.thisMode==TRIG_WORD)
 110   3                                              {                               
 111   4                                                      if(key.thisKey==1 || key.thisKey==0)
 112   4                                                              trigWord.prevValue=(trigWord.prevValue<<1)|key.thisKey;
 113   4                                              }
 114   3                                              else if(screenMode.thisMode==TRIG_CH)
 115   3                                              {
 116   4                                                      if(key.thisKey==1 || key.thisKey==0)
 117   4                                                              trigCh.prevValue=(trigCh.prevValue<<1)|key.thisKey;
C51 COMPILER V8.02   KEYBOARD_LCD                                                          07/26/2008 19:16:15 PAGE 3   

 118   4                                              }
 119   3                                              else if(screenMode.thisMode==TRIG_DELAY)
 120   3                                              {
 121   4                                                      trigDelay.prevValue=trigDelay.prevValue*10+key.thisKey;
 122   4                                              }
 123   3                                              else if(screenMode.thisMode==THRESHOLD)
 124   3                                              {
 125   4                                                      threshold.prevValue=threshold.prevValue*10+key.thisKey;
 126   4                                              }
 127   3                                              delayX10ms(40);
 128   3                                      }
 129   2                                      break;
 130   2              case 0x0080:
 131   2                                      screenMode.exitOrNo=RETURN_TURE;
 132   2                                      break;
 133   2              case 0x0800:            //取消返回,不修改任何数据
 134   2                                      if(screenMode.thisMode!=INIT_SCREEN)
 135   2                                      {
 136   3                                              tempMode=screenMode.thisMode;
 137   3                                              screenMode.thisMode=screenMode.prevMode;
 138   3                                              screenMode.prevMode=tempMode;
 139   3                                      }
 140   2                                      break;
 141   2              case 0x1000:if(key.thisKey!=TRIG_WORD)
 142   2                                      {
 143   3                                              key.thisKey=TRIG_WORD;
 144   3                                              if(screenMode.thisMode==INIT_SCREEN)
 145   3                                              {                                       
 146   4                                                      screenMode.prevMode=screenMode.thisMode;
 147   4                                                      screenMode.thisMode=TRIG_WORD;
 148   4                                      
 149   4                                                      trigWord.prevValue=0;
 150   4                                              }
 151   3                                              else if(screenMode.thisMode==TRIG_WORD)
 152   3                                              {
 153   4                                                      if(trigWord.prevValue!=0)
 154   4                                                              trigWord.thisValue=trigWord.prevValue;
 155   4      
 156   4                                                      screenMode.prevMode=screenMode.thisMode;
 157   4                                                      screenMode.thisMode=INIT_SCREEN;
 158   4                                              }
 159   3                                      }
 160   2                                      break;
 161   2              case 0x2000:if(key.thisKey!=TRIG_CH)
 162   2                                      {
 163   3                                              key.thisKey=TRIG_CH;
 164   3                                              if(screenMode.thisMode==INIT_SCREEN)
 165   3                                              {                                       
 166   4                                                      screenMode.prevMode=screenMode.thisMode;
 167   4                                                      screenMode.thisMode=TRIG_CH;
 168   4                                      
 169   4                                                      trigCh.prevValue=0;
 170   4                                              }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -