📄 main.c
字号:
/*******************************************************************************
MAIN.C
Copyright (c) SmartASIC, Inc. All rights reserved.
*******************************************************************************/
#include <MTV230.H>
#include <DEFINE.H>
#define DETECT_PERIOD 36//252ms //Loop1=7ms
/*==============================================================================
==============================================================================*/
void Main(void) {
unsigned int DetectTime;
unsigned char i, j;
//-----MTV230-----//
PADMOD[0]=0xe1;
PADMOD[1]=0x83;
PADMOD[2]=0xfc;
PADMOD[3]=0xfc;
OPTION=0x00;
HVINTFLG=HVINTEN=0x00;
HVCTR0=0x41;
HVCTR2=0x00;
ADC=WDT=0x00;
//-----8051-----//
IE=IP=TMOD=TCON=SCON=TH0=TL0=TH1=TL1=0;
TMOD=0x11;//mode1 for timer1, mode1 for timer0
TH0=0x3c;//Timer0 using 50ms interrupt
TL0=0xb0;
TH1=0x3c;//Timer0 using 50ms interrupt
TL1=0xb0;
EA=1;
ET0=TR0=1;
//---Remote Control---//
Remote_Code.ir_rdy=Remote_Code.ir_index=Remote_Code.ir_sys=Remote_Code.ir_cmd=0;
EX0=1;
Start:
Initial();
Source_Select:
Switch_Source(Source);
Blank_TV_Screen();
Display_Window();
OSD_Show(1,0,0,0,0);
Power_Sequence(YES);
Set_Caption(0);
Pre_VChipSys=Pre_VChipRating=Pre_VChipMisc=0;
while(!Set_Line21())
Z86_Reset();
OSD_CountDown=DISPLAY_TIMER;
Remote=REMOTE_NULL;
switch(Source) {
case(AV1):
case(AV2):
case(AV3):
goto AV_Loop;
break;
case(TV):
goto TV_Loop;
break;
}
//***************************AV Close Loop****************************************//
AV_Loop:
//---------------------------initial-----------------------------//
/*
Video_Source=Video_Detection();
if(Video_Source==NOVIDEO) {
bno_signal=0;
}
else {
bno_signal=1;
}
DetectTime=0;
*/
Pre_Video_Source=255;
//-----------------------------looping---------------------------//
while(1){
//-----Signal Detecting-----//
Video_Source=Video_Detection();
if(Video_Source!=Pre_Video_Source) {//signal different
Pre_Video_Source=Video_Source;//update signal type
DetectTime=0;//reset stable counter
Set_Mute(1);
Set_Caption(0);
Pre_VChipSys=Pre_VChipRating=Pre_VChipMisc=0;
}
else {//signal the same
if(DetectTime<DETECT_PERIOD)//wait sync stable
DetectTime++;
if(DetectTime==DETECT_PERIOD) {//signal stable
DetectTime=(DETECT_PERIOD+1);
if(Video_Source==NOVIDEO) {
Set_Background(YES, BLUE);
}
else {
Video_Setting(Video_Source);
Set_Background(NO, BLACK);
Set_Mute(Mute);
Set_Caption(Caption);
}
}
}
//-----Program Rating-----//
/*
if(Program_Rating(&Now_VChipSys, &Now_VChipRating, &Now_VChipMisc)) {
if((Now_VChipSys!=Pre_VChipSys)||(Now_VChipRating!=Pre_VChipRating)||(Now_VChipMisc!=Pre_VChipMisc)) {
OSD_Show(0,0,0,0,0);
Page=201;
Item=0;
badjust=0;
VChip_Display();
OSD_Show(1,0,0,0,0);
}
}
*/
//-----KeyBoard pressed-----//
Get_Key();
if(bkey_code_now!=KEY_NULL) {
if(bkey_code_now==KEY_SOURCE) {//SOURCE key switch to next source
Source=(Source+1)%4;
EE_MCU_Byte_Write(EE_SOURCE, Source);
goto Source_Select;
}
if(bkey_code_now==KEY_POWER) {//POWER key pressed to POWER DOWN
goto Start;
}
if(bsmart) {//Normal OSD
Smart_OSD();
}
else {
if(bfactory)
Factory_OSD();
else
Video_OSD();
Smart();
}
}
//-----Remote Control active-----//
if(Remote!=REMOTE_NULL) {
Remote_OSD();
Remote=REMOTE_NULL;
}
//-----Password Input Process-----//
if((PassDig==6)&&(Page==110)) {
if((PassIn==FACTORY_PASSWORD)||(PassIn==Password)) {
OSD_Show(0,0,0,0,0);
switch(Item) {
case(1)://V-Chip Form
Page=200;
Item=1;
badjust=1;
VChip_Window();
OSD_Show(1,0,0,0,0);
break;
}
}
else {
Print_String(1, 1, " Password Incorrect! ", RED|BLINK);
DelayX10ms(200);
OSD_Show(0,0,0,0,0);
Page=Item=badjust=0;
}
PassIn=PassDig=0;
}
//---OSD OFF Timer---//
if(bosdtimeout) {
if(bhotosd) {//hot adjustment off after HOT_TIMER seconds
Page=Item=badjust=bhotosd=0;
OSD_Show(0,0,0,0,0);
}
else {
if((Page==100)&&(Item==0)) {//in DISPLAY WINDOW
if(OSD_Disp==0) {
Page=Item=badjust=bhotosd=0;
OSD_Show(0,0,0,0,0);
}
}
else {//in other windows
if(OSD_Disp==1) {//decide if re-show DISPLAY_WINDOW
OSD_Show(0,0,0,0,0);
Display_Window();
OSD_Show(1,0,0,0,0);
}
else {
Page=Item=badjust=bhotosd=0;
OSD_Show(0,0,0,0,0);
}
}
}
OSD_CountDown=0;
bosdtimeout=0;
}
//---Sleep Timer---//
if(bshutdown) {
bshutdown=0;
goto Start;
}
}
//***************************AV Close While Loop**********************************//
//********************************TV Close Loop***********************************//
TV_Loop:
//---------------------------initial-----------------------------//
bno_signal=1;
CH_Input=Input_CountDown=0;
bsetchok=Channel_Input(255);
Pre_Channel=Channel;
Set_Channel(Channel);
Video_Setting(NTSC);
DetectTime=0;
//-----------------------------looping---------------------------//
while(1){
//-----Signal Detecting-----//
Video_Source=Video_Detection();
if(bno_signal) {//ON from No Signal
if(Video_Source!=NOVIDEO) {
if(DetectTime==0) {//initial MTS for new coming
MSP_Write_Address(WR_DEM, 0x0020, 0x0020);//BTSC-Stereo
MSP_Write_Address(WR_DEM, 0x0030, 0x2003);//enable automatic detect
}
if(DetectTime++==DETECT_PERIOD) {//SYNC stable period OK
Real_MTS=Get_MTS_Mode();//get MTS status
Set_MTS_Mode(MTS_Mode);//set MTS
Set_Caption(Caption);//set caption
i=EE_MCU_Byte_Read(ChannelLockTable_EEPROM_Address()+Channel/8);//read channel lock information
j=Channel%8;
if(Get_Bit(i, j)==0) { //Channel==UnLock
Set_Background(NO, BLACK); //Turn ON screen
if(Page==100) { //display message
Display_MTS_Type(MTS_Mode);
OSD_CountDown=DISPLAY_TIMER;
}
Set_Mute(Mute);
}
else { //Channel==Lock
Set_Background(YES, BLUE); //turn screen to blue
Set_Mute(1); //disable audio
OSD_Show(0,0,0,0,0); //turn off OSD
Page=110; //display password dialog
Item=badjust=bhotosd=0;
Password_Dialog();
OSD_Show(1,0,0,0,0);
}
DetectTime=bno_signal=0;
Pre_VChipSys=Pre_VChipRating=Pre_VChipMisc=0;
}
}
else {//SYNC not stable & keep on polling
DetectTime=0;
}
}
else {//if no SYNC
if(Video_Source==NOVIDEO) {
Blank_TV_Screen();
Set_Mute(1);
Set_Caption(0);
if(Page==100)
Print_String(2, 0, " ", GREEN);
bno_signal=1;
DetectTime=0;
}
}
//-----Program Rating-----//
if(Program_Rating(&Now_VChipSys, &Now_VChipRating, &Now_VChipMisc)) {
if((Now_VChipSys!=Pre_VChipSys)||(Now_VChipRating!=Pre_VChipRating)||(Now_VChipMisc!=Pre_VChipMisc)) {
OSD_Show(0,0,0,0,0);
Page=201;
Item=0;
badjust=0;
VChip_Display();
OSD_Show(1,0,0,0,0);
}
}
//-----KeyBoard pressed-----//
Get_Key();
if(bkey_code_now!=KEY_NULL) {
if(bkey_code_now==KEY_SOURCE) {//SOURCE key switch to next source
Source=(Source+1)%4;
EE_MCU_Byte_Write(EE_SOURCE, Source);
goto Source_Select;
}
if(bkey_code_now==KEY_POWER) {//POWER key pressed to POWER DOWN
goto Start;
}
if(bsmart) {//Normal OSD
Smart_OSD();
}
else {
if(bfactory)
Factory_OSD();
else {
Video_OSD();
Smart();
}
}
}
//-----Remote Control active-----//
if(Remote!=REMOTE_NULL) {
Remote_OSD();
Remote=REMOTE_NULL;
}
//-----Input Set Channel Timer-----//
if(bsetchok) {
CH_Input=String_To_Int(Channel_Input_Str, 3);
if(((TV_Mode==TV_AIR)&&(CH_Input>0)&&(CH_Input<70))||((TV_Mode!=TV_AIR)&&(CH_Input>0)&&(CH_Input<126))) {
Blank_TV_Screen();
Set_Caption(0);
bno_signal=1;
Pre_Channel=Channel;
Channel=CH_Input-1;
Set_Channel(Channel);
EE_MCU_Byte_Write(Channel_EEPROM_Address(), Channel);
}
Channel_Display();//Print_Char(1, 3, Channel+1, GREEN);
CH_Input=0;
bsetchok=Channel_Input(255);
OSD_CountDown=HOT_TIMER;
}
//-----?????-----//
/* if(bno_signal) {
OSD_CountDown=5;
DetectTime=0;
}*/
//-----Password Input Process-----//
if(PassDig==6) {
if((PassIn==FACTORY_PASSWORD)||(PassIn==Password)) {
OSD_Show(0,0,0,0,0);
switch(Page) {
case(110)://Channel Lock/Unlock
Page=4;
Item=5;
badjust=1;
Adjustment_Win();
OSD_Show(1,0,0,0,0);
break;
case(120)://V-Chip Form
Page=200;
Item=0;
badjust=1;
VChip_Window();
OSD_Show(1,0,0,0,0);
break;
case(130)://Renew Password
break;
}
}
else {
switch(Page) {
case(110):
case(120):
Print_String(2, 3, "PASSWORD INCORRECT!", RED|BLINK);
DelayX10ms(200);
Print_String(2, 3, " PASSWORD: ", WHITE);
Print_String(2, 14, "------ ", WHITE|BLINK);
break;
case(130):
Password=PassIn;
EE_MCU_Byte_Write(EE_PASSWORD+0, Password/256);
EE_MCU_Byte_Write(EE_PASSWORD+1, Password%256);
Print_String(2, 3, "PASSWORD RENEW OK! ", RED|BLINK);
DelayX10ms(200);
Page=Item=badjust=bhotosd=0;
OSD_Show(0,0,0,0,0);
break;
}
}
PassIn=PassDig=0;
}
//---OSD OFF Timer---//
if(bosdtimeout) {
if(bhotosd) {//hot adjustment off after HOT_TIMER seconds
Page=Item=badjust=bhotosd=0;
OSD_Show(0,0,0,0,0);
}
else {
if((Page==100)&&(Item==0)) {//in DISPLAY WINDOW
if(OSD_Disp==0) {
Page=Item=badjust=bhotosd=0;
OSD_Show(0,0,0,0,0);
}
}
else {//in other windows
if(OSD_Disp==1) {//decide if re-show DISPLAY_WINDOW
OSD_Show(0,0,0,0,0);
Display_Window();
OSD_Show(1,0,0,0,0);
}
else {
Page=Item=badjust=bhotosd=0;
OSD_Show(0,0,0,0,0);
}
}
}
OSD_CountDown=0;
bosdtimeout=0;
}
//---Sleep Timer---//
if(bshutdown) {
bshutdown=0;
goto Start;
}
}
//********************************TV Close Loop***********************************//
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -