keyremo.lst

来自「显示屏驱动源代码」· LST 代码 · 共 800 行 · 第 1/3 页

LST
800
字号
                      if ( i<0x10 ) return (0);
                      key_in = i;
                      min = i; max = i;
                      for ( j=0; j<17; j++ ) {
                              i = GetLAD0();
                              if ( i<0x10 ) return (0);
                              key_in += i;
                              if ( i < min ) min = i;
                              else if ( i > max ) max = i;
                      }
                      key_in -= min;
                      key_in -= max;
              
                      key_in >>= 4;   // divide by 16
              
                      #ifdef DEBUG_KEYREMO
                      if (key_in >= 0x10)
                      dPrintf("\r\nKeyIn ADC Value is: 0x%2x", (WORD)key_in );
                      //return (0);
                      #endif
              
                      if ( key_in < 0x10 )
                              return( 0 );
                      else if ( key_in < 0x33 )
                              return( INPUTSOURCEKEY );
                      else if ( key_in < 0x5a )
                              return( RIGHTKEY );
                      else if ( key_in < 0x80 )
                              return( UPKEY );
                      else if ( key_in < 0xa0 )
                              return( MENUKEY );
                      else if ( key_in < 0xcc )
                              return( DOWNKEY );
                      else if ( key_in < 0xf5 )
                              return( LEFTKEY );
                      else
                              return( POWERKEY );
              
              }
              #endif
 549          
 550          //=============================================================================
C51 COMPILER V7.06   KEYREMO                                                               02/21/2008 14:00:26 PAGE 10  

 551          //              Get Key 
 552          //=============================================================================
 553          BYTE GetKey(BYTE repeat)
 554          {
 555   1      #ifdef INTERNAL_MCU
              BYTE    i;
                      i = repeat;
                      i = ReadKey();
                      if ( i == 0 ) {
                              RepeatKey = 0;
                              Key = 0;
                              KeyReady = 0;
                              keytic = 0;
                              return (0);
                      }
                      if ( Key == 0 ) {                       // first pressed?
                              Key = i;
                              keytic++;
                              return (i);
                      }
                      else if ( i != Key) {           // same key pressed check for repeat function
                              RepeatKey = 0;
                              KeyReady = 0;
                              keytic = 0;
                              return (0);
                      }
                      else {
                              keytic++;
                              if ( keytic < 30 ) {
                                      return (0);
                              }
                              else {
                                      RepeatKey = 1;
                                      KeyReady = 1;
                                      keytic = 24;
                                      return (i);
                              }
                      }
              #else
 590   1      bit ready;
 591   1      
 592   1              ready = KeyReady;
 593   1              KeyReady = 0;
 594   1      
 595   1              if( !ready ) return 0;
 596   1              if( repeat ) return Key;
 597   1              if( !RepeatKey ) return Key;
 598   1      
 599   1              return 0;
 600   1      #endif
 601   1      }
 602          
 603          
 604          //=============================================================================
 605          //              CheckRemo
 606          //=============================================================================
 607          #ifdef REMO_RC5
 608          
 609          BYTE IsRemoDataReady(BYTE *DataCode, BYTE *AutoKey)
 610          {
 611   1              bit togglebit;
 612   1              static bit      LastToggle=0;
C51 COMPILER V7.06   KEYREMO                                                               02/21/2008 14:00:26 PAGE 11  

 613   1              static BYTE AutoWait=0;
 614   1      
 615   1              BYTE _RemoSystemCode, _RemoDataCode, _RemoDataReady;
 616   1      
 617   1              if( !RemoDataReady ) return 0;
 618   1      
 619   1              _RemoDataReady = RemoDataReady;
 620   1              _RemoDataCode = RemoDataCode;
 621   1              _RemoSystemCode = RemoSystemCode;
 622   1      
 623   1              *AutoKey = 0;
 624   1      
 625   1              EnableRemoconInt();
 626   1      
 627   1              #ifdef DEBUG_KEYREMO
                      dPrintf("\r\n(CheckRemo)R-S:%02x, R-D:%02x", (WORD)_RemoSystemCode, (WORD)_RemoDataCode);
                      #endif
 630   1      
 631   1              if( (_RemoSystemCode & 0xc0) != 0xc0 ) return 0;
 632   1              if( (_RemoSystemCode & 0x1f) != REMO_CUSTOM ) return 0;
 633   1      
 634   1              togglebit = LastToggle;
 635   1              if( _RemoSystemCode & 0x20 ) LastToggle = 1;
 636   1              else LastToggle = 0;
 637   1      
 638   1              #ifdef DEBUG_KEYREMO
                      dPrintf("**** %d  %d ", (WORD)LastToggle, (WORD)_RemoDataReady);
                      #endif
 641   1      
 642   1              if( LastToggle != togglebit ) {                 // new key
 643   2                      AutoWait =  0;
 644   2              }
 645   1              else if( AutoWait>=4 ) {                                // auto key
 646   2                      AutoWait++;
 647   2                      if( AutoWait>=6 ) {
 648   3                              AutoWait = 4;
 649   3                              *AutoKey = 1;
 650   3                      }
 651   2                      else return 0;
 652   2              }
 653   1              else {                                                                  // wait auto key
 654   2                      AutoWait++;
 655   2                      return 0;
 656   2              }
 657   1              
 658   1              #ifdef DEBUG_KEYREMO
                      if( *AutoKey ) {
                              dPuts(" ---> AutoKey ");
                      }
                      else {
                              dPuts(" ---> New Key ");
                      }
                      #endif
 666   1      
 667   1              *DataCode = _RemoDataCode;
 668   1              return 1;
 669   1      }
 670          
 671          #elif defined REMO_NEC
              extern DATA             BYTE     RemoData[4];
              
              BYTE IsRemoDataReady(BYTE *DataCode, BYTE *AutoKey)
C51 COMPILER V7.06   KEYREMO                                                               02/21/2008 14:00:26 PAGE 12  

              {
                      static BYTE AutoWait=0;
                      static IDATA BYTE LastDataCode=0xff;
                      static IDATA BYTE repeatcnt=0;
                      BYTE ret =0 ;
              
                      *AutoKey = 0;
                      switch ( RemoDataReady ) {
              
                      case 0: return 0;
              
                      case 1:
                              #ifdef DEBUG_KEYREMO
                              dPrintf("\r\nNEC RemoData = %02x %02x %02x %02x", (WORD)RemoData[0], (WORD)RemoData[1], (WORD)RemoData[2
             -], (WORD)RemoData[3] );
                              #endif
                              if( (RemoData[0]==REMO_CUSTOM1) && (RemoData[1]==REMO_CUSTOM2 ) && (RemoData[2]+RemoData[3])==0xff ) {
                                      RemoDataCode = RemoData[2];
                                      LastDataCode = RemoDataCode;
                                      AutoWait = 0;
                                      *AutoKey = 0;
                                      repeatcnt = 0;
                              }
                              else {
                                      RemoDataCode = 0xff;
                                      LastDataCode = 0xff;
              
                                      EnableRemoconInt();             //
                                      return 0;
                              }
                              break;
              
                      case 2:
                              AutoWait++;
                              if( AutoWait>=6 ) {
                                      RemoDataCode = LastDataCode;
                                      repeatcnt++;
                                      if( repeatcnt>=5 ) {
                                              AutoWait = 5;
                                      }
                                      else
                                              AutoWait = 4;
              
                                      *AutoKey = 1;
                              }
                              else {
                                      EnableRemoconInt();             //
                                      return 0;
                              }
                              break;
              
                      }
              
                      EnableRemoconInt();             ////LJY052902
                      if( RemoDataCode==0xff )        return 0;
              
                      #ifdef DEBUG_KEYREMO
                      dPrintf("(R-D:%02x)  ", (WORD)RemoDataCode);
                      #endif
              
                      *DataCode = RemoDataCode;
                      return 1;
C51 COMPILER V7.06   KEYREMO                                                               02/21/2008 14:00:26 PAGE 13  

              }
              
              #endif  // REMO_NEC
 739          
 740          BYTE CheckRemo(void)
 741          {
 742   1              BYTE AutoKey, ret=1, _RemoDataCode;
 743   1      
 744   1              if( IsRemoDataReady(&_RemoDataCode, &AutoKey) ) {
 745   2                      ret = ActionRemo( _RemoDataCode, (BYTE)AutoKey) ;
 746   2              }
 747   1      
 748   1              return ret;
 749   1      }
 750          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    822    ----
   CONSTANT SIZE    =    167    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =      1      13
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1       2
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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