📄 panelkey_to_ir.c
字号:
#include "reg51.h"
#include "intrins.h"
#include "panelkey_to_ir.h"
#include "global.h"
//#define IR_16MHZ
code unsigned int IR_Code_Tbl[10]=
{
0xe41b, //IR_ROOT_MENU 0x20
0xeb14, //IR_UP 0x21
0xe817, //IR_DOWN 0x22
0xea15, //IR_LEFT 0x23
0xe916, //IR_RIGHT 0x24
0xe51a, //IR_PLAY_ENTER 0x25
0xb649, //IR_STOP 0x26
0xfc03, //IR_EJECT 0x27
0xaf50, //IR_PREV 0x28
0xae51, //IR_NEXT 0x29
};
//****************************************************
//****************************************************
void Send_Key_To_IR()
{
EX1=0; //INT DISABLED
Send_IR_Head_Syscode();
Send_IR_CustomCode();
EX1=1;
}
//****************************************************
//****************************************************
void Send_IR_Head_Syscode()
{
unsigned int sys_code;
unsigned char i;
sys_code =IR_SYSTEM_CODE;
PIN_CONV_IR=0;
TH1=0xf5;
TL1=0x9f; //9ms f582
ir_conv_timer=0;
while(ir_conv_timer==0);
PIN_CONV_IR=1;
TH1=0xfa;
TL1=0xdd; //fac1
ir_conv_timer=0;
while(ir_conv_timer==0);
PIN_CONV_IR=0;
//************************************
for(i=0;i<16;i++)
{
if(sys_code&0x0001)
Send_IR_1();
else
Send_IR_0();
sys_code>>=1;
}
}
//****************************************************
void Send_IR_CustomCode()
{
unsigned int Vfd_key;
unsigned char i;
Vfd_key =IR_Code_Tbl[_VFD_Key-0x20];
for(i=0;i<16;i++)
{
if(Vfd_key&0x0001)
Send_IR_1();
else
Send_IR_0();
Vfd_key>>=1;
}
#ifdef IR_16MHZ
for(i=0;i<90;i++)
#else
for(i=0;i<22;i++)
#endif
{_nop_();_nop_();_nop_();_nop_();_nop_();} //90 for 16mhz
PIN_CONV_IR=1;
}
//****************************************************
void Send_IR_1() //2.25ms
{
TH1=0xff;
TL1=0xa4; //0.75ms fe40
ir_conv_timer=0;
while(ir_conv_timer==0);
PIN_CONV_IR=1;
TH1=0xfe;
TL1=0x30; //1.5ms ff1f //57
ir_conv_timer=0;
while(ir_conv_timer==0);
PIN_CONV_IR=0;
}
//****************************************************
void Send_IR_0() //1.25ms
{
TH1=0xff;
TL1=0xa4; //0.75ms //fe70
ir_conv_timer=0;
while(ir_conv_timer==0);
PIN_CONV_IR=1;
TH1=0xff;
TL1=0x37; //0.5ms ff69
ir_conv_timer=0;
while(ir_conv_timer==0);
PIN_CONV_IR=0;
}
//****************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -