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

📄 key.lst

📁 一个LCD TV的源程序, 用的是realtek的IC
💻 LST
字号:
C51 COMPILER V7.07   KEY                                                                   09/26/2006 08:56:42 PAGE 1   


C51 COMPILER V7.07, COMPILATION OF MODULE KEY
OBJECT MODULE PLACED IN Key.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Key.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          
   2          
   3          /*******************************************************************************/
   4          //  Function.c
   5          //  Copyright (c) HIMAX, Inc. All rights reserved.
   6          //  Edit by Taylor Chen
   7          /*******************************************************************************/
   8          #include "intrins.h"
   9          #include "MCU_IO.h"
  10          #include "COMMON.H"
  11          #include "Key.H"
  12          #include "MAIN.H"
  13          #include "i2c_control.h"
  14          #include "HX8824.h"
  15          #include "OSD.h"
  16          #include "rs232.h"
  17          
  18          bdata unsigned char bkeycodeA; // now state
  19          sbit bup            = bkeycodeA^7;
  20          sbit bdown              = bkeycodeA^6;
  21          sbit bleft          = bkeycodeA^5;
  22          sbit bright         = bkeycodeA^4;
  23          sbit bpower         = bkeycodeA^3;
  24          sbit bISP           = bkeycodeA^2;
  25          sbit bburnin        = bkeycodeA^1;
  26          bdata unsigned char bkeycodeB; // previous state
  27          sbit bpup           = bkeycodeB^7;
  28          sbit bpdown         = bkeycodeB^6;
  29          sbit bpleft         = bkeycodeB^5;
  30          sbit bpright        = bkeycodeB^4;
  31          sbit bppower        = bkeycodeB^3;
  32          sbit bpISP          = bkeycodeB^2;
  33          sbit bpburnin       = bkeycodeB^1;
  34          bdata unsigned char bkeycodeC;
  35          sbit bkey_fast      = bkeycodeC^7;
  36          sbit bkeypress      = bkeycodeC^6;
  37          sbit bosdtimeout    = bkeycodeC^5;
  38          sbit bpage_enter    = bkeycodeC^4;
  39          sbit bbrg_con_hot   = bkeycodeC^3;
  40          sbit bout_range_saving = bkeycodeC^2;
  41          
  42          
  43          
  44          idata unsigned char RepeatKeyCounter, KeyTimerCounter, Counter, Second;
  45          
  46          
  47          /* -------------------------------------------------------------------
  48            Name    : Key_Snap
  49            Purpose :
  50            Passed  :
  51            Returns :
  52            Notes   :
  53            ------------------------------------------------------------------- */
  54          BYTE Key_Snap(void)
  55          {
C51 COMPILER V7.07   KEY                                                                   09/26/2006 08:56:42 PAGE 2   

  56   1        BYTE Previous = 0x00, Now = 0xff;
  57   1      
  58   1        do{
  59   2          Previous = (P1 & 0x1F);  // "0" : active
  60   2          DelayX1ms(3);
  61   2          Now = (P1 & 0x1F);
  62   2          }while(Previous!=Now); // wait signal stable
  63   1      
  64   1        return (~Now & 0x1F);
  65   1      
  66   1      }
  67          /* -------------------------------------------------------------------
  68            Name    : Get_Key
  69            Purpose :
  70            Passed  :
  71            Returns :
  72            Notes   :
  73            ------------------------------------------------------------------- */
  74          void Get_Key(void)
  75          {
  76   1        Byte Key_Value, TotalKeyPress;
  77   1      
  78   1        bkeycodeA = 0;
  79   1        Key_Value = Key_Snap();
  80   1        if(Key_Value == 0x01)
  81   1          bpower = 1;
  82   1        if(Key_Value == 0x02)
  83   1          bright = 1;
  84   1        if(Key_Value == 0x04)
  85   1          bleft = 1;
  86   1        if(Key_Value == 0x08)
  87   1          bup = 1;
  88   1        if(Key_Value == 0x10)
  89   1          bdown = 1;
  90   1        if(Key_Value == 0x18)
  91   1          bISP = 1;
  92   1        if(Key_Value == 0x11)
  93   1          bBurnInMode = 1;
  94   1        if(Key_Value == 0x03)
  95   1          bSwitchInput = 1;
  96   1      
  97   1                                                       
  98   1      // Puts_UART("in getkey loop");HexTobyStr(Panel_Type);Puts_UART(byStr);Puts_UART("\r\n");
  99   1        TotalKeyPress = (Byte)bpower + (Byte)bright + (Byte)bup + (Byte)bdown + (Byte)bleft + (Byte)bright;
 100   1      /*
 101   1        if(TotalKeyPress == 1)
 102   1          Print_String(5, 2, 0x00, 0x07, "1");
 103   1        else if(TotalKeyPress > 1)
 104   1          Print_String(5, 2, 0x00, 0x07, "2");
 105   1        else if(TotalKeyPress < 1)
 106   1          Print_String(5, 2, 0x00, 0x07, "0");
 107   1      */
 108   1      
 109   1        if(bkeycodeA == 0)               // no key be pressed
 110   1        {
 111   2          bkeycodeB = RepeatKeyCounter = bkeypress = bkey_fast = 0;
 112   2          //Print_String(5, 2, 0x00, 0x07, "0");
 113   2        }
 114   1        else                             // key pressed
 115   1        {
 116   2          Second = 0;
 117   2          if(bkeycodeA == bkeycodeB)      // key stable
C51 COMPILER V7.07   KEY                                                                   09/26/2006 08:56:42 PAGE 3   

 118   2          {
 119   3            if(bleft || bright)           // accerlate left, right key only
 120   3            {
 121   4              RepeatKeyCounter++;
 122   4              if(RepeatKeyCounter > 60)
 123   4              {
 124   5                bkey_fast = 1;
 125   5                RepeatKeyCounter = 60;
 126   5              }
 127   4            }
 128   3          }
 129   2          else                            // key not stable
 130   2          {
 131   3              RepeatKeyCounter = bkey_fast = 0;
 132   3          }
 133   2          if(bkeypress)
 134   2          {
 135   3            bkeycodeA = 0;                // set as no key be pressed, means release key and read again
 136   3          }
 137   2          else
 138   2          {
 139   3            KeyTimerCounter = 0;
 140   3            bkeypress = 1;
 141   3            bkeycodeB = bkeycodeA;
 142   3          }
 143   2        }
 144   1      }
 145          
 146          /* -------------------------------------------------------------------
 147            Name    : Key_Proc
 148            Purpose :
 149            Passed  :
 150            Returns :
 151            Notes   :
 152            ------------------------------------------------------------------- */
 153          void Key_Proc()
 154          {
 155   1      #if TV
                      Byte i, j;
              #endif
 158   1          if(bISP)
 159   1          {
 160   2              LEDG = LEDR = 1;
 161   2              BootFromLDROM();
 162   2          }    
 163   1          Puts_UART("in keyproc loop = ");HexTobyStr(bBurnInMode);Puts_UART(byStr);Puts_UART("\r\n");
 164   1      
 165   1          if(bBurnInMode)
 166   1          {                              
 167   2              Puts_UART("in burn in mode loop = ");HexTobyStr(Panel_Type);Puts_UART(byStr);Puts_UART("\r\n");
 168   2              if(bpower)
 169   2                  if((I2CReadByte(HX8824_ADDR, HX8824_TEST_PATTERN) & 0x0F) < 0x0F )
 170   2                              {
 171   3                      I2CWriteByte(HX8824_ADDR, HX8824_TEST_PATTERN, I2CReadByte(HX8824_ADDR, HX8824_TEST_PATTER
             -N) + 1);
 172   3                      Puts_UART("pattern +1 = ");HexTobyStr(Panel_Type);Puts_UART(byStr);Puts_UART("\r\n");
 173   3                              }
 174   2                  else if((I2CReadByte(HX8824_ADDR, HX8824_TEST_PATTERN) & 0x0F) == 0x0F)
 175   2                              {
 176   3                      I2CWriteByte(HX8824_ADDR, HX8824_TEST_PATTERN, I2CReadByte(HX8824_ADDR, HX8824_TEST_PATTER
             -N) & 0xF0);
 177   3                                      Puts_UART("pattern +1 = ");HexTobyStr(Panel_Type);Puts_UART(byStr);Puts_UART("\r\n");
C51 COMPILER V7.07   KEY                                                                   09/26/2006 08:56:42 PAGE 4   

 178   3                              }
 179   2          }
 180   1      /*  // ************  for 

⌨️ 快捷键说明

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