📄 keyremo.lst
字号:
483 1 #ifdef DEBUG_KEYREMO
if (key_in >= 0x10)
dPrintf("\r\nKeyIn ADC Value is: 0x%2x", (WORD)key_in );
//return (0);
#endif
488 1
C51 COMPILER V7.50 KEYREMO 04/01/2008 15:02:11 PAGE 9
489 1 if ( key_in < 0x10 )
490 1 return( 0 );
491 1 else if ( key_in < 0x33 )
492 1 return( INPUTSOURCEKEY );
493 1 else if ( key_in < 0x5a )
494 1 return( RIGHTKEY );
495 1 else if ( key_in < 0x80 )
496 1 return( UPKEY );
497 1 else if ( key_in < 0xa0 )
498 1 return( MENUKEY );
499 1 else if ( key_in < 0xcc )
500 1 return( DOWNKEY );
501 1 else if ( key_in < 0xf5 )
502 1 return( LEFTKEY );
503 1 else
504 1 return( POWERKEY );
505 1
506 1 }
507 #endif
508
509 //=============================================================================
510 // Get Key
511 //=============================================================================
512 BYTE GetKey(BYTE repeat)
513 {
514 1 #ifdef INTERNAL_MCU
515 1 BYTE i;
516 1 i = repeat;
517 1 i = ReadKey();
518 1 if ( i == 0 ) {
519 2 RepeatKey = 0;
520 2 Key = 0;
521 2 KeyReady = 0;
522 2 keytic = 0;
523 2 return (0);
524 2 }
525 1 if ( Key == 0 ) { // first pressed?
526 2 Key = i;
527 2 keytic++;
528 2 return (i);
529 2 }
530 1 else if ( i != Key) { // same key pressed check for repeat function
531 2 RepeatKey = 0;
532 2 KeyReady = 0;
533 2 keytic = 0;
534 2 return (0);
535 2 }
536 1 else {
537 2 keytic++;
538 2 if ( keytic < 30 ) {
539 3 return (0);
540 3 }
541 2 else {
542 3 RepeatKey = 1;
543 3 KeyReady = 1;
544 3 keytic = 24;
545 3 return (i);
546 3 }
547 2 }
548 1 #else
bit ready;
C51 COMPILER V7.50 KEYREMO 04/01/2008 15:02:11 PAGE 10
ready = KeyReady;
KeyReady = 0;
if( !ready ) return 0;
if( repeat ) return Key;
if( !RepeatKey ) return Key;
return 0;
#endif
560 1 }
561
562
563 //=============================================================================
564 // CheckRemo
565 //=============================================================================
566 #ifdef REMO_RC5
567
568 BYTE IsRemoDataReady(BYTE *DataCode, BYTE *AutoKey)
569 {
570 1 bit togglebit;
571 1 static bit LastToggle=0;
572 1 static BYTE AutoWait=0;
573 1
574 1 BYTE _RemoSystemCode, _RemoDataCode, _RemoDataReady;
575 1
576 1 if( !RemoDataReady ) return 0;
577 1
578 1 _RemoDataReady = RemoDataReady;
579 1 _RemoDataCode = RemoDataCode;
580 1 _RemoSystemCode = RemoSystemCode;
581 1
582 1 *AutoKey = 0;
583 1
584 1 EnableRemoconInt();
585 1
586 1 #ifdef DEBUG_KEYREMO
dPrintf("\r\n(CheckRemo)R-S:%02x, R-D:%02x", (WORD)_RemoSystemCode, (WORD)_RemoDataCode);
#endif
589 1
590 1 if( (_RemoSystemCode & 0xc0) != 0xc0 ) return 0;
591 1 if( (_RemoSystemCode & 0x1f) != REMO_CUSTOM ) return 0;
592 1
593 1 togglebit = LastToggle;
594 1 if( _RemoSystemCode & 0x20 ) LastToggle = 1;
595 1 else LastToggle = 0;
596 1
597 1 #ifdef DEBUG_KEYREMO
dPrintf("**** %d %d ", (WORD)LastToggle, (WORD)_RemoDataReady);
#endif
600 1
601 1 if( LastToggle != togglebit ) { // new key
602 2 AutoWait = 0;
603 2 }
604 1 else if( AutoWait>=4 ) { // auto key
605 2 AutoWait++;
606 2 if( AutoWait>=6 ) {
607 3 AutoWait = 4;
608 3 *AutoKey = 1;
609 3 }
610 2 else return 0;
611 2 }
612 1 else { // wait auto key
C51 COMPILER V7.50 KEYREMO 04/01/2008 15:02:11 PAGE 11
613 2 AutoWait++;
614 2 return 0;
615 2 }
616 1
617 1 #ifdef DEBUG_KEYREMO
if( *AutoKey ) {
dPuts(" ---> AutoKey ");
}
else {
dPuts(" ---> New Key ");
}
#endif
625 1
626 1 *DataCode = _RemoDataCode;
627 1 return 1;
628 1 }
629
630 #elif defined REMO_NEC
extern DATA BYTE RemoData[4];
BYTE IsRemoDataReady(BYTE *DataCode, BYTE *AutoKey)
{
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
C51 COMPILER V7.50 KEYREMO 04/01/2008 15:02:11 PAGE 12
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;
}
#endif // REMO_NEC
698
699 BYTE CheckRemo(void)
700 {
701 1 BYTE AutoKey, ret=1, _RemoDataCode;
702 1
703 1 if( IsRemoDataReady(&_RemoDataCode, &AutoKey) ) {
704 2 ret = ActionRemo( _RemoDataCode, (BYTE)AutoKey) ;
705 2 }
706 1
707 1 return ret;
708 1 }
709
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1308 ----
CONSTANT SIZE = 167 ----
XDATA SIZE = ---- ----
PDATA SIZE = 1 14
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = 1 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -