📄 tvtuner.c
字号:
#include "reg51.h"
#include "tvtune.h"
#include "global.h"
//***************************************************************************************
void Tv_Process_key(void)
{
unsigned char _IR_Key0;
if(_fgIRKeyValid==TRUE)
{
_fgIRKeyValid=FALSE;
_IR_Key0=_IR_key;
_IR_key=IR_NONE;
}
else if(_fgVfdKeyValid==TRUE)
{
_fgVfdKeyValid=FALSE;
if(player_status==PLAYER_STATUS_DVD)
Send_Key_To_IR();
_IR_Key0=_VFD_Key;
_VFD_Key=IR_NONE;
}
else
return;
if( (player_status==PLAYER_STATUS_DVD||player_status==PLAYER_STATUS_VIDEO_INPUT)
&&(_IR_Key0!=IR_TV_DVD && _IR_Key0!=IR_TV_POWER ) )
return ;
switch(_IR_Key0)
{
case IR_NUM0 :
case IR_NUM1 :
case IR_NUM2 :
case IR_NUM3 :
case IR_NUM4 :
case IR_NUM5 :
case IR_NUM6 :
case IR_NUM7 :
case IR_NUM8 :
case IR_NUM9 :
Proc_Key_Digit_Key(_IR_Key0);
_IR_Key0=IR_NONE;
break;
case IR_TV_SEARCH :
player_status=PLAYER_STATUS_TV_SEARCH;
Proc_Key_Tv_Search();
_IR_Key0=IR_NONE;
break;
case IR_TV_DVD:
Proc_Key_Tv_Dvd();
_IR_Key0=IR_NONE;
break;
case IR_TV_POWER:
Proc_Key_Power();
_IR_Key0=IR_NONE;
break;
case IR_NEXT_CH:
Proc_Key_Next_Ch();
_IR_Key0=IR_NONE;
break;
case IR_PREV_CH:
Proc_Key_Prev_Ch();
_IR_Key0=IR_NONE;
break;
case IR_DISPLAY:
Proc_Key_Display();
break;
case IR_TV_MENU:
Proc_Key_Tv_Menu();
break;
case IR_TV_SEARCH_RETURN:
Proc_Key_Tv_Search_Return();
break;
default:
break;
_IR_Key0=IR_NONE;
}
}
//***************************************************************************************
void Proc_Key_Digit_Key(unsigned char Key)
{
if(player_status==PLAYER_STATUS_TVPLAYING)
{
M35055_Display_line(0,DISP_OSD_HYPHEN);
M35055_Display_a_char(CHANNEL_NUM1_POS,num_digit[Key]);
player_status=PLAYER_STATUS_TV_SELECT_0;
Channel_Num.num0=Key;
Channel_Num.num1=0;
}
else if(player_status==PLAYER_STATUS_TV_SELECT_0)
{
if(Channel_Num.num0>6||(Channel_Num.num0==0&&Key<2))
{
player_status=PLAYER_STATUS_TVPLAYING;
Channel_Num.num0=0;
f_osd_displaying=0;
f_osd_ch_displaying=0;
Clear_All_Osd();
return ;
}
player_status=PLAYER_STATUS_TV_SELECT_1;
Channel_Num.num1=Channel_Num.num0;
Channel_Num.num0=Key;
M35055_Display_a_char(CHANNEL_NUM1_POS,num_digit[Channel_Num.num1]);
M35055_Display_a_char(CHANNEL_NUM0_POS,num_digit[Key]);
}
f_osd_displaying=1;
if(player_status==PLAYER_STATUS_TV_SELECT_1)
{
f_timer_2s_ch=1;
timer1_counter_ch=200;
player_status=PLAYER_STATUS_TVPLAYING;
}
else
{
f_timer_2s_ch=0;
timer1_counter_ch=0;
}
}
//***************************************************************************************
void Proc_Key_Tv_Dvd()
{
if(player_status==PLAYER_STATUS_DVD)
{
Read24c02(&cur_ch_num,CURRENT_CHANNEL_NUM_ADDR,1);
Read24c02(&total_ch_num,TOTAL_CHANNEL_NUM_ADDR,1);
Read24c02(&vhfl_ch_num,VHFL_CHANNEL_NUM_ADDR,1);
Read24c02(&vhfh_ch_num,VHFH_CHANNEL_NUM_ADDR,1);
Read24c02(&uhf_ch_num,UHF_CHANNEL_NUM_ADDR,1);
Clear_All_Osd();
f_osd_displaying=0;
f_timer_2s_ch=0;
M35055_Display_line(0,DISP_OSD_CAAV);
Sub_Set_Channel();
player_status=PLAYER_STATUS_TVPLAYING;
Video_Output_TV_SW();
}
else if(player_status>PLAYER_STATUS_DVD&&player_status<PLAYER_STATUS_VIDEO_INPUT)
{
player_status=PLAYER_STATUS_VIDEO_INPUT;
Clear_All_Osd();
Video_Output_Input_SW();
f_osd_ch_displaying=1;
f_timer_2s_ch=0;
M35055_Display_line(0,DISP_OSD_VIDEO_INPUT);
timer1_counter=0; //BEGION TO SEARCH INPUTVIDEO EXIST OR NOT ALL TIME!
f_timer_2s=0;
}
else if(player_status==PLAYER_STATUS_VIDEO_INPUT)
{
Clear_All_Osd();
Send_CR_Set(0);
Video_Output_DVD_SW();
player_status=PLAYER_STATUS_DVD;
}
}
//***************************************************************************************
void Dvd_Resume_delay(unsigned char times)
{
unsigned char i;
EA=0;
for(i=0;i<times;i++)
DelayMs(100);DelayMs(100);
EA=1;
}
void Proc_Key_Power()
{
if(POWER_CTRL_PIN==0)
{
PIN_MUTE1=1;//MUTE ON
POWER_RESUME_KEY_PIN=0;//for dvd resume
Write24c02(&player_status,PLAYER_STATUS_ADDR,1);
P3=P3&0x1f;
Dvd_Resume_delay(150);
POWER_CTRL_PIN=1;
P1=P1&0x8F;
}
else if(POWER_CTRL_PIN==1)
{
U1369_RESET_PIN=1;
POWER_CTRL_PIN=0;
DelayMs(100);DelayMs(100);
Read24c02(&player_status,PLAYER_STATUS_ADDR,1);
if(player_status==PLAYER_STATUS_DVD)
player_status=PLAYER_STATUS_VIDEO_INPUT;
else if(player_status>PLAYER_STATUS_DVD&&player_status<PLAYER_STATUS_VIDEO_INPUT)
player_status=PLAYER_STATUS_DVD;
else if(player_status==PLAYER_STATUS_VIDEO_INPUT)
player_status=PLAYER_STATUS_TVPLAYING;
else
player_status=PLAYER_STATUS_VIDEO_INPUT;
_fgIRKeyValid=TRUE;
_IR_key=IR_TV_DVD;
POWER_RESUME_KEY_PIN=1;
m35055_init();
VFD_init();
}
}
void Process_Tv_Osd(void)
{
bit f_inputvideo_exist=0;
if(player_status==PLAYER_STATUS_DVD)return ;
if(player_status==PLAYER_STATUS_VIDEO_INPUT)
{//1
while(f_timer_2s==0){ if(TV_VIDEO_EXIST==1)f_inputvideo_exist=1;}
if(f_timer_2s==1)
{
timer1_counter=50;
f_timer_2s=0;
if(f_inputvideo_exist!=f_last_videoinput)
{
if(f_inputvideo_exist)
{
Send_CR_Set(0);
f_last_videoinput=1;
}
else
{
f_last_videoinput=0;
Send_CR_Set(1);
}
f_osd_ch_displaying=1;
f_timer_2s_ch=0;
M35055_Display_line(0,DISP_OSD_VIDEO_INPUT);
}
}
}//1
if((f_osd_ch_displaying==1||f_osd_displaying==1)&&f_timer_2s_ch==2)
{
Clear_All_Osd();
if(f_osd_ch_displaying==1)
{
f_osd_ch_displaying=0;
}
if(f_osd_displaying==1)
{
f_osd_displaying=0;
player_status=PLAYER_STATUS_TVPLAYING;
if(Proc_Digit_Input_Tv_Channel()==0)
{
M35055_Display_line(0,DISP_OSD_ERROR);
f_osd_displaying=1;
f_timer_2s_ch=0;
timer1_counter_ch=0;
}
Channel_Num.num0=0x0;
Channel_Num.num1=0x0;
Channel_Num.num2=0x0;
}
}
}
//***************************************************************************************
void Proc_Key_Tv_Search_Return()
{
player_status=PLAYER_STATUS_TVPLAYING;
PIN_MUTE2=0;
Send_CR_Set(0);
Clear_All_Osd();
Sub_Set_Channel();
if(_IR_key==IR_TV_POWER||_VFD_Key==IR_TV_POWER)
Proc_Key_Power();
_IR_key=IR_NONE;
_VFD_Key=IR_NONE;
}
//***************************************************************************************
void Proc_Key_Tv_Search()
{
unsigned char Search_ch_num=0;
unsigned char first_valid_ch=1;
unsigned int ch_freq;
unsigned char temp0=0;
bit f_first_ch=0;
bit f_video_exist=0;
total_ch_num=0;
first_valid_ch=cur_ch_num;
PIN_MUTE1=1;//MUTE ON
//init eprom
Write24c02(&total_ch_num,TOTAL_CHANNEL_NUM_ADDR,1);
//***********************************************************
Send_CR_Set(1);
Clear_All_Osd();
M35055_Display_line(6,DISP_OSD_AUTO_SEARCH);
M35055_Display_line(7,DISP_OSD_SEARCHING);
for(Search_ch_num=0;Search_ch_num<VHF_L_BAND_LENGTH;Search_ch_num++)
{
f_video_exist=0;
ch_freq=Wireless_Tv_channel_tbl[Search_ch_num];
Write_Tv_tune(ch_freq,0);//a0
timer1_counter=0;
f_timer_2s=0;
while(f_timer_2s==0){; if(timer1_counter>60&&TV_VIDEO_EXIST==1)f_video_exist=1;}
//*****************************************************************
Sub_Display_Searching_bar(1,Search_ch_num);
//*****************************************************************
if(f_video_exist==1)
{
total_ch_num++;
if(first_valid_ch==cur_ch_num&&Search_ch_num>0&&f_first_ch==0)
{
first_valid_ch=Search_ch_num;
if(first_valid_ch==1&&cur_ch_num==1)f_first_ch=1;
}
Write24c02(&Search_ch_num,(Search_ch_num+FIRST_CHANNEL_FREQ),1);
}
else
Write24c02(&val_zero,(Search_ch_num+FIRST_CHANNEL_FREQ),1);
Write24c02(&total_ch_num,TOTAL_CHANNEL_NUM_ADDR,1);
Player_Power_On_Off();
if(_IR_key==IR_TV_SEARCH||_IR_key==IR_TV_POWER||_VFD_Key==IR_TV_POWER) {
cur_ch_num=first_valid_ch;
Proc_Key_Tv_Search_Return();
return;
}
}
for(Search_ch_num=0;Search_ch_num<VHF_H_BAND_LENGTH;Search_ch_num++)
{
f_video_exist=0;
ch_freq=Wireless_Tv_channel_tbl[Search_ch_num+VHF_L_BAND_LENGTH];
Write_Tv_tune(ch_freq,1);//90
timer1_counter=0;
f_timer_2s=0;
while(f_timer_2s==0){; if(timer1_counter>60&&TV_VIDEO_EXIST==1)f_video_exist=1;}
//*****************************************************************
Sub_Display_Searching_bar(2,Search_ch_num);
//*****************************************************************
temp0=Search_ch_num+VHF_L_BAND_LENGTH;
if(f_video_exist==1)
{
if(first_valid_ch==cur_ch_num&&f_first_ch==0)
{
f_first_ch=1;
first_valid_ch=Search_ch_num+VHF_L_BAND_LENGTH;
}
total_ch_num++;
Write24c02(&temp0,(temp0+FIRST_CHANNEL_FREQ),1);
}
else
Write24c02(&val_zero,(temp0+FIRST_CHANNEL_FREQ),1);
Write24c02(&total_ch_num,TOTAL_CHANNEL_NUM_ADDR,1);
Player_Power_On_Off();
if(_IR_key==IR_TV_SEARCH||_IR_key==IR_TV_POWER||_VFD_Key==IR_TV_POWER) {
cur_ch_num=first_valid_ch;
Proc_Key_Tv_Search_Return();
return;
}
}
for(Search_ch_num=0;Search_ch_num<UHF_BAND_LENGTH;Search_ch_num++)
{
f_video_exist=0;
ch_freq=Wireless_Tv_channel_tbl[Search_ch_num+VHF_L_BAND_LENGTH+VHF_H_BAND_LENGTH];
Write_Tv_tune(ch_freq,2);//30
timer1_counter=0;
f_timer_2s=0;
while(f_timer_2s==0){ if(timer1_counter>60&&TV_VIDEO_EXIST==1)f_video_exist=1;}
//*********************************************************
Sub_Display_Searching_bar(3,Search_ch_num);
//*****************************************************************
temp0=Search_ch_num+VHF_L_BAND_LENGTH+VHF_H_BAND_LENGTH;
if(f_video_exist==1)
{
if(first_valid_ch==cur_ch_num&&f_first_ch==0)
{
first_valid_ch=Search_ch_num+VHF_L_BAND_LENGTH+VHF_H_BAND_LENGTH;
f_first_ch=1;
}
total_ch_num++;
Write24c02(&temp0,(temp0+FIRST_CHANNEL_FREQ),1);
}
else
Write24c02(&val_zero,(temp0+FIRST_CHANNEL_FREQ),1);
Write24c02(&total_ch_num,TOTAL_CHANNEL_NUM_ADDR,1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -