📄 1574main.c
字号:
#include "..\inc\public2.h"
#include <string.h>
#define RX_PARSE 0x80 //pack data ready, wait process Parse routine
#define ENTER 0x1E //pressed key then pull low
#define UP 0x1B
#define DOWN 0x17
#define MENU 0x0F
#define WR_CVD1_BYTE 14
#define L44_WRID 0x28
#define SEL_OSDDISPCODE 0x02
extern code unsigned char CVD1_NTSCTab[WR_CVD1_BYTE*2];
extern code unsigned char CVD1_PALMTab[WR_CVD1_BYTE*2];
extern code unsigned char CVD1_PALTab[WR_CVD1_BYTE*2];
extern code unsigned char CVD1_SECAMTab[WR_CVD1_BYTE*2];
extern BYTE CVD1_ReadWrite(BYTE, BYTE, BYTE);
extern xdata BYTE CBSH_Value[8];
extern void Adj_CBSH(void);
extern void All_Init(void);
extern void OSD_ShowTitle(char *, char);
extern void Write_OSDReg(BYTE [], BYTE, BYTE, BYTE);
extern void Adj_DisplayMode(char);
extern int T0_0Interval;
extern BYTE T0_0Service; //Timer 0 service Var.
//--- Function Prototype Define ----------------
BYTE WaitKey(void);
BYTE NTSC_PAL;
//===========================================================================
//===========================================================================
void main(void)
{
BYTE key, dig_cvd, i, show_type;
BYTE cdv_3Astatus, cdv_3Cstatus, set_times;
BYTE ch_type[14], dig_str[14];
All_Init(); //Init. all of IC Reg. and Variable
// There are include 8051, 15xx and TV-Decoder
strcpy(ch_type, "VIDEO 1 NTSC ");
// strcpy(dig_str, "DIGITAL ");
NTSC_PAL = 0; //default NTSC mode
dig_cvd = 1; //flag for switch CCIR or CVD1 CH#1, 2, 3
set_times = 0;
show_type = 0;
OSD_ShowTitle(ch_type, 13);
while(1)
{
cdv_3Astatus = CVD1_ReadWrite(0x00, 0x3A, 0x00) & 0x0E; // read CVD1 status: chroma PLL/V/H line lock
cdv_3Cstatus = CVD1_ReadWrite(0x00, 0x3C, 0x00) & 0x04; // 625 scan line detected
//Check is Composite input CH# and CDV signal is not LOCK
if (dig_cvd && cdv_3Astatus!=0x0E)
{
NTSC_PAL = cdv_3Cstatus;
if (!show_type)
{
OSD_ShowTitle(ch_type, 13);
show_type = 1;
}
I2C_WriteByte(L44_WRID, 0x20, 0xC0); //Turn OFF Screen
if (cdv_3Cstatus) // PAL system input
{
if (set_times++ < 3)
{
for (i=0; i<WR_CVD1_BYTE; i++)
CVD1_ReadWrite(0x01, CVD1_SECAMTab[i*2], CVD1_SECAMTab[i*2+1]);
strcpy(&ch_type[8], "SECAM");
}
else
{
for (i=0; i<WR_CVD1_BYTE; i++) // set reg for PAL input
CVD1_ReadWrite(0x01, CVD1_PALTab[i*2], CVD1_PALTab[i*2+1]);
strcpy(&ch_type[8], "PAL ");
}
if (CBSH_Value[6]) //Turn ON the Edge filter
CVD1_ReadWrite(0x01, 0x01, 0x08);
I2C_WriteByte(L44_WRID, 0x71, 0xA3);
I2C_WriteByte(L44_WRID, 0x68, 0x74);
set_times &= 0x07;
}
else // NTSC system input
{
I2C_WriteByte(L44_WRID, 0x71, 0x09);
if (set_times++ < 3)
{
for (i=0; i<WR_CVD1_BYTE; i++)
CVD1_ReadWrite(0x01, CVD1_NTSCTab[i*2], CVD1_NTSCTab[i*2+1]);
strcpy(&ch_type[8], "NTSC ");
}
else
{ //PAL M mode
for (i=0; i<WR_CVD1_BYTE; i++)
CVD1_ReadWrite(0x01, CVD1_PALMTab[i*2], CVD1_PALMTab[i*2+1]);
strcpy(&ch_type[8], "PAL M");
}
if (CBSH_Value[6]) //Turn ON the Edge filter
CVD1_ReadWrite(0x01, 0x01, 0x09);
set_times &= 0x07;
}
Adj_DisplayMode(CBSH_Value[7]);
}
else
{
if (show_type)
{
I2C_WriteByte(L44_WRID, 0x20, 0x40); //Turn ON Screen //***
if (dig_cvd)
OSD_ShowTitle(ch_type, 13);
show_type = 0;
}
}
key = WaitKey();
if (key == ENTER) //Switch Input CH# CCIR / Composite 1,2,3
{
if (++dig_cvd > 3) dig_cvd = 0;
Adj_DisplayMode(CBSH_Value[7]);
if (dig_cvd)
{
if (dig_cvd == 1) CVD1_ReadWrite(0x01, 0x90, 0x00); //CH#1
if (dig_cvd == 2) CVD1_ReadWrite(0x01, 0x90, 0x40); //CH#2
if (dig_cvd == 3) CVD1_ReadWrite(0x01, 0x90, 0x80); //CH#3
I2C_WriteByte(L44_WRID, 0x00, 0x41); //Switch to CVD1
ch_type[5] = dig_cvd | 0x30;
OSD_ShowTitle(ch_type, 13);
}
else
{
NTSC_PAL = 0x00;
I2C_WriteByte(L44_WRID, 0x68, 0x10);
I2C_WriteByte(L44_WRID, 0x00, 0x78); //Switch to CCIR 601
OSD_ShowTitle(dig_str, 13);
}
}
if (key == MENU)
Adj_CBSH();
}
}
/**--------------------------------------------------------------------------
* Name BYTE WaitKey()
*
* Description There are 2 working item in this function
* 1. Detect the UART Flag for RS-232 parse process
*
* 2. Detect and return whick key press and release
* Press key Return code 8051 Port
* ----------------------------------------------
* Enter 0x1E P0.0
* DOWN 0x1B P0.2
* UP 0x17 P0.3
* MENU 0x0F P0.4
*
* Not press 0x00
*
* Flow Chart
*
* Return press_key
*
* DATE Author Description
* ===========================================================================
* 2004-07-10 K.M. Ho This is first time implement
*/
BYTE WaitKey(void)
{
BYTE press_key;
press_key = P0 & 0x1F; // get press key from Port#0
//***************************************
//--- Process the UART service -----
//***************************************
if (UARTFlag & RX_PARSE) //service the parse
UART_ParseFun(); //Jump into UART_ParseFun() function
//***********************************
//--- Process The 15xx Key -----
//***********************************
if (press_key != 0x1F)
{
for (;;) //wait all key release
if ((P0&0x1F)==0x1F)
break;
T0_0Interval = 500; //reset the Timer interval 10sec.
//P2 ^= ~(press_key|0xE0);
}
else
press_key = 0;
return (press_key); //if not press key will return 0x00
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -