?? tirnec.c.svn-base
字號:
/**
* This code and information is part of Trident DPTV API (TDAPI)
*
* Copyright (C) Trident Multimedia Technologies (Shanghai) Co., Ltd.
* 2002 - 2003 All rights reserved.
*
* This file provides functions for TV or demoboard remote controller.
*
* Revision:
* 03/04/2004 Modify RC5 part(decode & repeat) by Max and Joy
* 04/18/2003 Added repeat key support by Archie
* 08/01/2002 Created by Rick, York, Joy and Archie
*
*/
#include "tdefs.h"
#include "tio.h"
#include "tutils.h"
#include "tvkey.h"
#include "tRemote.h"
#include "ioctrl.h"
#include "thilevel.h"
#include "ttimer.h"
#include "tvdebug.h"
//#define _IR_DEBUG_
Byte Factory_Data[4];
/*remote flag*/
static Byte s_ucRemoteFlag = 0;
#ifdef _IR_DEBUG_
Byte IR_DATA[50];
Byte IR_Index ;
#endif
/*dy
const Byte KeyCodeFactory[][2] =
{
{0x01, COMMAND_M},
{0x08, COMMAND_BUSOFF},
};
*/
/*the following two global variables are used by remote routines*/
static Void tdRemoteCodeDetect(Byte ucRemoteCode);
static Gdata struct tagRemoteData
{
Byte ucRemoteBackup; /*store the first code of system or data*/
Byte ucRemoteTemp; /*store the temporary value of a code,tdRemoteCodeDetect was call 8 times to generate a code*/
Byte ucRemoteShift; /*used to count shift times and generate s_RemoteData.ucRemoteTemp*/
Byte ucSCheckSum;
Byte ucDCheckSum;
Byte ucPreviousCountVal; /*timer count value of last time*/
Byte ucSystemCode;
Byte ucRemoteCode;
Byte ucOffset;
Byte ucKeyNum;
} s_RemoteData;
extern GBool t_bNewKey;
extern GBool t_bRemoteKey;
extern Gdata Byte ucAutoOffTimer;
static GByte s_ucTimeOutCount = 0;
#ifdef _IR_DEBUG_
Byte uc;
#endif
static Void tdIRNEC1msTimer(Void)
{
if (t_RemoteData.wCount == t_RemoteData.wFirstDelay)
{
#ifdef _NEW_REPEATKEY_FUNC_
tdSetFastRepeatKeyFlag(_FALSE_);
tdSetSlowRepeatKeyFlag(_FALSE_);
#endif
tdSetKeyStatusUpFlag(_FALSE_);
tdAddVirtualKey(s_RemoteData.ucRemoteCode/* | _VK_STATUS_DOWN_*/);
t_RemoteData.wCount--;
ucAutoOffTimer = 0;
#ifdef _IR_DEBUG_
tvDebugPrint("Send none-repeat code!\n");
tvDebugPrint1("s_ucRemoteFlag = 0x%x\n", s_ucRemoteFlag);
tvDebugPrint1("s_RemoteData.ucRemoteCode = 0x%x\n", s_RemoteData.ucRemoteCode);
#endif
//set g_KeyInfo.bRemoteKeyDown flag
g_KeyInfo.bRemoteKeyDown = _TRUE_;
//set g_KeyInfo.bRepeatKeyDown flag
g_KeyInfo.bRepeatKeyDown = _FALSE_;
//clear s_ucTimeOutCount
s_ucTimeOutCount = 0;
}
else
{
if (t_RemoteData.wCount)
{
t_RemoteData.wCount--;
if (tdTestValBitTrue(s_ucRemoteFlag, _RF_NEC_REPEAT_) && tdTestValBitTrue(s_ucRemoteFlag, _RF_NEC_LEADERCODE_))
{
//set g_KeyInfo.bRemoteKeyDown flag
//g_KeyInfo.bRemoteKeyDown = _TRUE_;
//clear s_ucTimeOutCount
//s_ucTimeOutCount = 0;
if (t_RemoteData.wCount == 0)
{
#ifdef _NEW_REPEATKEY_FUNC_
if(g_KeyInfo.bFastRepeatKeyEnable||g_KeyInfo.bSlowRepeatKeyEnable)
{
#ifdef _IR_DEBUG_
Printf("Sent repeat code!\n",12);
Printf("s_ucRemoteFlag = 0x%x\n", s_ucRemoteFlag);
#endif
tdAddVirtualKey(s_RemoteData.ucRemoteCode /*| _VK_STATUS_DOWN_*/);
g_KeyInfo.bRepeatKeyDown = _TRUE_;
}
#else
tdAddVirtualKey(s_RemoteData.ucRemoteCode /*| _VK_STATUS_DOWN_*/);
#endif
tdClearValBit(s_ucRemoteFlag, _RF_NEC_LEADERCODE_);
if(g_KeyInfo.bSlowRepeatKeyEnable)
t_RemoteData.wCount = t_RemoteData.wRepeatDelay*4 - 1;
else
t_RemoteData.wCount = t_RemoteData.wRepeatDelay - 1;
}
return; //end
}
}
//detect whether key is released up
if (s_ucTimeOutCount != 0xFF)
s_ucTimeOutCount++;
else
return;
if (s_ucTimeOutCount > t_RemoteData.wRepeatDelay) //nomatter last key is _FIRSTKEY_ or _REPEATKEY_
{
if (g_KeyInfo.bRemoteKeyDown)
{
if (g_KeyInfo.bRepeatKeyDown) //clear repeat key in fifo
tdClearKeyInFIFO((FifoHandle)t_VirtualKeyBuffer, s_RemoteData.ucRemoteCode);
g_KeyInfo.bRemoteKeyDown = _FALSE_;
g_KeyInfo.bRepeatKeyDown = _FALSE_;
s_ucTimeOutCount = 0xFF; //don't +1 again
#ifdef _IR_DEBUG_
tvDebugPrint("Before tdClearPreviousKey\n");
for (uc = 0; uc < VIRTUALKEYBUFFERSIZE ; uc++)
tvDebugPrint2("t_VirtualKeyBuffer[%d] = %d\n", uc, t_VirtualKeyBuffer[uc]);
#endif
if (g_KeyInfo.bKeyStatusUpEnable)
{
tdAddVirtualKey(s_RemoteData.ucRemoteCode | _VK_STATUS_UP_);
tdSetKeyStatusUpFlag(_FALSE_);
}
s_RemoteData.ucRemoteCode = _VK_NONE_;
tdSetFastRepeatKeyFlag(_FALSE_); //to prevent adding repeat key after user obstructs RC for a while when press repeat key
tdSetSlowRepeatKeyFlag(_FALSE_);
//clear REPEAT and LEADERCODE flag
tdClearValBit(s_ucRemoteFlag, _RF_NEC_REPEAT_ | _RF_NEC_LEADERCODE_);
#ifdef _IR_DEBUG_
tvDebugPrint("After tdClearPreviousKey\n");
for (uc = 0; uc < VIRTUALKEYBUFFERSIZE ; uc++)
tvDebugPrint2("t_VirtualKeyBuffer[%d] = %d\n", uc, t_VirtualKeyBuffer[uc]);
#endif
}
}
}
}
static Byte tdGetTimeInterval(Byte ucCurrentCountVal)
{
/* when the INT0 interrupt the timer interrupt service */
if (!ucCurrentCountVal)
ucCurrentCountVal = tdLoadInitTimerCount();
#ifdef _TIMERCOUNT_DOWN_
if (ucCurrentCountVal < s_RemoteData.ucPreviousCountVal)
ucCurrentCountVal = s_RemoteData.ucPreviousCountVal - ucCurrentCountVal;
else
ucCurrentCountVal = s_RemoteData.ucPreviousCountVal + tdGetTimerBInterval() - ucCurrentCountVal;
#else
if (ucCurrentCountVal >= s_RemoteData.ucPreviousCountVal)
ucCurrentCountVal = ucCurrentCountVal - s_RemoteData.ucPreviousCountVal;
else
ucCurrentCountVal = ucCurrentCountVal + tdGetTimerBInterval() - s_RemoteData.ucPreviousCountVal;
#endif
return ucCurrentCountVal;
}
Bool ucselect = _TRUE_;
IWord ucCurrentCountValtemp1,ucCurrentCountValtemp2;
//Word ucRemotecodetest[100];
//static BYTE ucRemotetestIndex = 0;
static Void tdIRNECService(Void)
{
IByte ucRemoteCode;
IWord ucCurrentCountVal;
/* ucCurrentCountVal = tdGetTimerBCurrentCount();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -