📄 1574osd.c
字号:
/**--------------------------------------------------------------------------
* Name 15xxOSD.c
--------------------------------------------------------------------------**/
#include <string.h>
#include "..\inc\public2.h"
#define EEPROM_WRID 0xA0
#define L44_WRID 0x28
//-------------- OSD Reg # ------------
#define OSD_EN 0x1C
#define OSDADDR_L 0xA0
#define OSDADDR_H 0xA1
#define OSDDATA_L 0xA2
#define OSDDATA_H 0xA3
#define ORWCTRL 0xA4
/*------ OSD External Reg. 0xA4 bit define -------------------
* bit 7 6 5 4 3 2 1 0
* | | | | +-- D1-0: Internal OSD accessing select
* | | | | 00 - OSD control Reg.
* | | | | 01 - OSD RAM Font buffer
* | | | | 10 - OSD Display code buffer
* | | | | 11 - OSD Display attr buffer
* | | | +---- D2: Internal OSD R/W enable
* | | | 0 - Enable OSD Reg. and buf
* | | | 1 - Disable
* | | + --------- D5-3: Reserved
* | + ----------- OSD Clear buffer bit
* | 0 - Normal
* | 1 - Clear Code buffer to 0x3E
* | Clear Attr buffer to 0x00
* + ------------- OSD Read/Write mode Select 0:R 1:W
*--------------------------------------------------------------------------*/
#define SEL_OSDCTRLREG 0x00 //This Value for ORWCTRL(0xA4) Reg.
#define SEL_OSDDISPCODE 0x02
#define SEL_OSDDISPATTR 0x03
#define CLR_OSD_BUF 0x40
#define OSDCTRLREG 0x07
#define OSDWINON 0x53
#define OSDWINOFF 0x02
/*----------------------------------------------------------
* OSD Display code buffer is 64 bytes format is followed
* bit 7 6 5 4 3 2 1 0
* | | |
* | | + --------- D5-0: Character Code
* | + ----------- 0: ROM Font 1: RAM Font
* + ------------- 0: Blink OFF 1: Blink ON
*
* OSD Display Attr buffer is 64 bytes format is followed
* bit 7 6 5 4 3 2 1 0
* | | | |
* | | | + --- D2-0: Backgound Color index
* | | + ----- 0: BG transparent 1: BG opaque
* | + ----------- D6-4: Foregound Color index
* + ------------- 0: Border OFF 1: Border ON
*/
#define OSD_NORMAL_C 0x7C //Forg. Color ->Special Back. Color ->Blue
#define OSD_HIGHL_C 0x42 //Forg. Color ->Blue, Back. Color -> Greeen
#define OSD_TITLE_C 0x17 //Forg. Color ->Red, Back. Color -> special
//-------------- Button Key Define ------------
#define ENTER 0x1E //pressed key then pull low
#define UP 0x1B
#define DOWN 0x17
#define MENU 0x0F
//----------------------------------------------------------------------------
xdata BYTE CBSH_Value[8] _at_ 0x0100; //Byte 0: Brightness buffer _at_ 0x0101
// 1: Contrast buffer _at_ 0x0102
// 2: Saturation buffer _at_ 0x0103
// 3: Hue buffer _at_ 0x0104
// Define OSD Window Start position, size, space and other control
xdata BYTE OSDCtrlVal[16] = {
0x79, //H Start (4*0x4C+12 = 396 pixel)
0x08, //V Start (4*0x20+1 = 21 line)
0x0C, //H Width ( 0x0C+1 = 13 char)
0x00, //D7-4 V Space Start position ( 0 char)
//D3-0 V Heigth ( 0x00+1 = 1 char)
0x00, //H Space Start ( 0x00 = 0 char)
0x00, //H Space Width ( 0x00 = 0 pixel)
0x00, //V Space Heigth ( 0x00 = 0 line)
0x02, //Ctrl. Reg D7-6 Vert. scaling (Vert. enlarged x1)
// D5-4 Horz. scaling (Horz. enlarged x3)
// D1 Type of Char. border (bottom-right)
// D0 0: OSD window OFF (OSD OFF)
// 1: OSD window ON
0x10, //Misc. Ctrl
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //Reserved
xdata char MainMenuStr[104] = {
// Char# 0 1 2 3 4 5 6 7 8 9 10 11 12
' ', ' ', 'L', '/', 'R', ' ', 'U', '/', 'D', ' ', ' ', ' ', ' ', //Item 0
'B', 'R', 'I', 'G', 'H', 'T', 'N', 'E', 'S', 'S', ' ', ' ', ' ', //Item 1
' ', 'C', 'O', 'N', 'T', 'R', 'A', 'S', 'T', ' ', ' ', ' ', ' ', // 2
'S', 'A', 'T', 'U', 'R', 'A', 'T', 'I', 'O', 'N', ' ', ' ', ' ', // 3
' ', ' ', ' ', 'H', 'U', 'E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 4
'E', 'D', 'G', 'E', ' ', 'F', 'I', 'L', 'T', 'E', 'R', ' ', ' ', // 5
' ', ' ', 'S', 'H', 'A', 'R', 'P', 'E', 'N', ' ', ' ', ' ', ' ', // 6
'D', 'I', 'S', 'P', ' ', 'M', 'O', 'D', 'E', ' ', ' ', ' ', ' ' }; // 7
xdata char OSD_Color[24] = { 0x00, 0x00, 0x00, //OSD Color 0
0xFF, 0x00, 0x00, //OSD Color 1
0x00, 0xFF, 0x00, //OSD Color 2
0xFF, 0xFF, 0x00, //OSD Color 3
0x00, 0x00, 0xFF, //OSD Color 4
0xFF, 0x00, 0xFF, //OSD Color 5
0x00, 0xFF, 0xFF, //OSD Color 6
0xFF, 0xFF, 0xFF}; //OSD Color 7
/***---------------------------------------------------------------------------***/
#ifdef CPT_PANEL //---------------------------------------------------------
code BYTE Mode_4by3[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x90, 0x0A, 0x47, 0x0B, 0x13, 0x4D, 0x53, 0x53, 0x18,
0x55, 0x17, 0x57, 0x18, 0x59, 0x17, 0x69, 0x35, 0x6A, 0x01,
0x70, 0x06, 0x8A, 0x80, 0x8B, 0x46, 0x45, 0xC1, 0x47, 0xC2
};
code BYTE Mode_Full[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x00, 0x0A, 0x00, 0x0B, 0x10, 0x4D, 0x12, 0x53, 0x18,
0x55, 0x17, 0x57, 0x18, 0x59, 0x17, 0x69, 0x20, 0x6A, 0x00,
0x70, 0x00, 0x8A, 0x58, 0x8B, 0x09, 0x45, 0xC1, 0x47, 0xC2
};
code BYTE Mode_Zoom1[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x1F, 0x55, 0x1D, 0x57, 0x1F, 0x59, 0x1D, 0x45, 0xC1,
0x47, 0xC2};
code BYTE Mode_Zoom2[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x24, 0x55, 0x22, 0x57, 0x24, 0x59, 0x22, 0x45, 0xC1,
0x47, 0xC2};
#endif
#ifdef HYDIS_PANEL //---------------------------------------------------------
code BYTE Mode_4by3[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x90, 0x0A, 0x47, 0x0B, 0x13, 0x4D, 0x53, 0x53, 0x18,
0x55, 0x17, 0x57, 0x18, 0x59, 0x17, 0x69, 0x35, 0x6A, 0x01,
0x70, 0x06, 0x8A, 0x80, 0x8B, 0x46, 0x45, 0xBF, 0x47, 0xC1
};
code BYTE Mode_Full[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x00, 0x0A, 0x00, 0x0B, 0x10, 0x4D, 0x12, 0x53, 0x18,
0x55, 0x17, 0x57, 0x18, 0x59, 0x17, 0x69, 0x20, 0x6A, 0x00,
0x70, 0x00, 0x8A, 0x58, 0x8B, 0x09, 0x45, 0xBF, 0x47, 0xC1
};
code BYTE Mode_Zoom1[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x1F, 0x55, 0x1D, 0x57, 0x1F, 0x59, 0x1D, 0x45, 0xBF,
0x47, 0xC1};
code BYTE Mode_Zoom2[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x24, 0x55, 0x22, 0x57, 0x24, 0x59, 0x22, 0x45, 0xBF,
0x47, 0xC1};
#endif
#ifdef LG_PANEL //---------------------------------------------------------
code BYTE Mode_4by3[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x8C, 0x0A, 0x28, 0x0B, 0x13, 0x4D, 0x53, 0x53, 0x15,
0x55, 0x14, 0x57, 0x15, 0x59, 0x14, 0x69, 0x35, 0x6A, 0x01,
0x70, 0x05, 0x8A, 0x80, 0x8B, 0x44, 0x45, 0xB3, 0x47, 0xB5
};
code BYTE Mode_Full[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x00, 0x0A, 0x00, 0x0B, 0x10, 0x4D, 0x12, 0x53, 0x15,
0x55, 0x14, 0x57, 0x15, 0x59, 0x14, 0x69, 0x20, 0x6A, 0x00,
0x70, 0x00, 0x8A, 0x59, 0x8B, 0x09, 0x45, 0xC1, 0x47, 0xC2
};
code BYTE Mode_Zoom1[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x1C, 0x55, 0x1B, 0x57, 0x1C, 0x59, 0x1B, 0x45, 0xC1,
0x47, 0xC2};
code BYTE Mode_Zoom2[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x22, 0x55, 0x21, 0x57, 0x22, 0x59, 0x21, 0x45, 0xC1,
0x47, 0xC2};
#endif
#ifdef PVI_PANEL //---------------------------------------------------------
code BYTE Mode_4by3[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x90, 0x0A, 0x47, 0x0B, 0x13, 0x4D, 0x53, 0x53, 0x19,
0x55, 0x17, 0x57, 0x19, 0x59, 0x17, 0x69, 0x35, 0x6A, 0x01,
0x70, 0x06, 0x8A, 0x80, 0x8B, 0x46, 0x45, 0xC3, 0x47, 0xC5
};
code BYTE Mode_Full[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x00, 0x0A, 0x00, 0x0B, 0x10, 0x4D, 0x12, 0x53, 0x19,
0x55, 0x17, 0x57, 0x19, 0x59, 0x17, 0x69, 0x20, 0x6A, 0x00,
0x70, 0x00, 0x8A, 0x58, 0x8B, 0x09, 0x45, 0xC3, 0x47, 0xC5
};
code BYTE Mode_Zoom1[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x1F, 0x55, 0x1D, 0x57, 0x1F, 0x59, 0x1D, 0x45, 0xC3,
0x47, 0xC5};
code BYTE Mode_Zoom2[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x24, 0x55, 0x22, 0x57, 0x24, 0x59, 0x22, 0x45, 0xC3,
0x47, 0xC5};
#endif
#ifdef SAMSUNG_PANEL //---------------------------------------------------------
code BYTE Mode_4by3[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x90, 0x0A, 0x4F, 0x0B, 0x13, 0x4D, 0x8A, 0x53, 0x15,
0x55, 0x13, 0x57, 0x15, 0x59, 0x13, 0x69, 0x32, 0x6A, 0x01,
0x70, 0x06, 0x8A, 0x80, 0x8B, 0x40, 0x45, 0x99, 0x47, 0x9B
};
code BYTE Mode_Full[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x00, 0x0A, 0x00, 0x0B, 0x10, 0x4D, 0x12, 0x53, 0x16,
0x55, 0x14, 0x57, 0x16, 0x59, 0x14, 0x69, 0x20, 0x6A, 0x00,
0x70, 0x00, 0x8A, 0x58, 0x8B, 0x09, 0x45, 0xC1, 0x47, 0xC3
};
code BYTE Mode_Zoom1[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x1F, 0x55, 0x1D, 0x57, 0x1F, 0x59, 0x1D, 0x45, 0xC1,
0x47, 0xC3};
code BYTE Mode_Zoom2[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x24, 0x55, 0x22, 0x57, 0x24, 0x59, 0x22, 0x45, 0xC1,
0x47, 0xC3};
#endif
#ifdef TOSHIBA_PANEL //---------------------------------------------------------
code BYTE Mode_4by3[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x90, 0x0A, 0x4F, 0x0B, 0x13, 0x4D, 0x8A, 0x53, 0x15,
0x55, 0x13, 0x57, 0x15, 0x59, 0x13, 0x69, 0x32, 0x6A, 0x01,
0x70, 0x06, 0x8A, 0x80, 0x8B, 0x40, 0x45, 0x99, 0x47, 0x9B
};
code BYTE Mode_Full[30] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x08, 0x00, 0x0A, 0x00, 0x0B, 0x10, 0x4D, 0x12, 0x53, 0x16,
0x55, 0x14, 0x57, 0x16, 0x59, 0x14, 0x69, 0x20, 0x6A, 0x00,
0x70, 0x00, 0x8A, 0x58, 0x8B, 0x09, 0x45, 0xC1, 0x47, 0xC3
};
code BYTE Mode_Zoom1[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x1F, 0x55, 0x1D, 0x57, 0x1F, 0x59, 0x1D, 0x45, 0xC1,
0x47, 0xC3};
code BYTE Mode_Zoom2[12] = {
// Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule Reg.# Vaule
0x53, 0x24, 0x55, 0x22, 0x57, 0x24, 0x59, 0x22, 0x45, 0xC1,
0x47, 0xC3};
#endif
/***---------------------------------------------------------------------------***/
#define OSD_LINEOFFSET 13
#define OSD_HSTART_BUF_INDEX 0
#define OSD_VSTART_BUF_INDEX 1
#define OSD_WIDTH_BUF_INDEX 2
#define OSD_HEIGHT_BUF_INDEX 3
extern int T0_0Interval;
extern BYTE T0_0Service;
extern BYTE NTSC_PAL;
extern BYTE WaitKey(void);
extern BYTE CVD1_ReadWrite(BYTE, BYTE, BYTE);
//-------------- Function Prototype ----------------
void OSD_Init(void);
void Adj_CBSH(void);
void OSD_ShowTitle(char *, char);
void OSD_Attribute(BYTE, BYTE, BYTE);
void Read_OSDRegD(BYTE *, BYTE, BYTE, BYTE);
void Write_OSDReg(BYTE [], BYTE, BYTE, BYTE);
BYTE ASCII_OSDFont(BYTE);
void Value_ASCII(BYTE, BYTE *, BYTE);
void Adj_LRUD(BYTE);
void Adj_Brightness(BYTE);
void Adj_Contrast(BYTE);
void Adj_Saturation(BYTE);
void Adj_Hue(char);
void Adj_Sharpen(char);
void Adj_Edge(char);
void Adj_DisplayMode(char);
/**--------------------------------------------------------------------------
* Name OSD_Init(void)
*
* Description The OSD all Menu string and T0_0Service Initialized
*
* Flow Chart
*
* Return
*
* DATE Author Description
* ===========================================================================
* 2004-07-12 K.M. Ho This is first time implement
* 2004-10-12 KMHo Add write 15xx Reg. 0x1C Enable the OSD
**/
void OSD_Init(void)
{
T0_0Service = 0; //Turn OFF the timer 0 service
#ifdef CPT_PANEL //-------------------------------------------------------
CBSH_Value[0] = 0x01; //Left/Rigth and Up/Down LG: 0x03 -----
#endif
#ifdef LG_PANEL
CBSH_Value[0] = 0x03; //Left/Rigth and Up/Down LG: 0x03 -----
#endif
#ifdef SAMSUNG_PANEL
CBSH_Value[0] = 0x01; //Left/Rigth and Up/Down LG: 0x03 -----
#endif //-------------------------------------------------------
CBSH_Value[1] = 0x20; //Brighness
CBSH_Value[2] = 0x20; //Contrast
CBSH_Value[3] = 0x20; //Saturation
CBSH_Value[4] = 0x20; //Hue
CBSH_Value[5] = 0x20; //Sharpen
CBSH_Value[6] = 0x00; //Edge Filter ON/OFF default is OFF
CBSH_Value[7] = 0x01; //Display Mode 0: 4:3
// 1: Full
// 2: Zoom 1
// 3: Zoom 2
I2C_WriteByte(L44_WRID, OSD_EN, 0xAC); //2004-10-12 Added by KMHo
Write_OSDReg(OSD_Color, SEL_OSDCTRLREG, 24, 0x0C); //Init. the OSD color index
Write_OSDReg(Font12x18, 0x01, 16, 0x00);
I2C_WriteByte(L44_WRID, 0x11, 0xF2); //Turn ON the Adj Enable bit
}
/**--------------------------------------------------------------------------
* Name Adj_CBSH(void)
*
* Description Enter the OSD main menu wait user press key for service.
* if user not press key over 10sec. that will auto Turn OFF OSD.
*
* Flow Chart
*
* Return
*
* DATE Author Description
* ===========================================================================
* 2004-07-12 K.M. Ho This is first time implement
**/
void Adj_CBSH(void)
{
BYTE press_key, item;
BYTE buf[2];
BYTE value, val_str[3];
T0_0Interval = 500; //set timer 0 interval = 20ms x 500 = 10sec.
T0_0Service = 1; //turn on timer 0 service flag
item = 1; //cancel item0:ud/lr
OSD_ShowTitle(&MainMenuStr[item*OSD_LINEOFFSET], OSD_LINEOFFSET);
value = CBSH_Value[item];
Value_ASCII(value, val_str, item); //Convert current value to Str.
Write_OSDReg(val_str, SEL_OSDDISPCODE, 3, 10); //write value to OSD code buf
while (T0_0Service)
{
press_key = WaitKey();
if (press_key) //have pressed key
{
switch (press_key)
{
case ENTER:
T0_0Service = 0; //Exit OSD function
break;
case DOWN:
if (++value >= 0x3F) value = 0x3F;
break;
case UP:
if (--value == 0xFF) value = 0x00;
break;
case MENU:
CBSH_Value[item] = value; //store old item value
if (++item > 7) item = 1; //chang select item
//cancel item0:ud/lr
// OSD_ShowTitle(&MainMenuStr[item*OSD_LINEOFFSET], OSD_LINEOFFSET);
Write_OSDReg(&MainMenuStr[item*OSD_LINEOFFSET], SEL_OSDDISPCODE, 13, 0);
value = CBSH_Value[item]; //restore new item value
break;
}
switch (item) //set new value to Brightness, Contrast, Saturation or Hue
{
case 0: Adj_LRUD(value&0x03); break;
case 1: Adj_Brightness(value<<2); break;
case 2: Adj_Contrast(value<<2); break;
case 3: Adj_Saturation(value<<2); break;
case 4: Adj_Hue(value<<2); break;
case 5: Adj_Sharpen(value<<1); break;
case 6: value &= 0x01;
Adj_Edge(value); break;
case 7: value &= 0x03;
Adj_DisplayMode(value); break;
}
if (item)
Value_ASCII(value, val_str, item); //Convert current value to Str.
else
Value_ASCII(value&0x03, val_str, item);
Write_OSDReg(val_str, SEL_OSDDISPCODE, 3, 10); //Show current value
}
}
CBSH_Value[item] = value;
// I2C_Write(EEPROM_WRID, 0, 4 , value_temp);
//Turn OFF OSD window befor exit the OSD function
buf[0] = OSDWINOFF;
Write_OSDReg(buf, SEL_OSDCTRLREG, 1, OSDCTRLREG); //write one byte
}
/**--------------------------------------------------------------------------
* Name OSD_ShowTitle(BYTE *str, char ch_no)
*
* Description Show Title on screen
*
* Flow Chart
*
* Return
*
* DATE Author Description
* ===========================================================================
* 2004-07-12 K.M. Ho This is first time implement
**/
void OSD_ShowTitle(char *str, char ch_no)
{
BYTE buf[2];
//Turn OFF the OSD window before show OSD menu
buf[0] = OSDWINOFF;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -