📄 osddisplay.c
字号:
#include <define.h>
#include <I2c.h>
#include <variable.h>
#define OSDADDR 0x7A
#define NTSC 1
#define PAL 0
#define CTRADDR 0
#define BRIGHTADDR 5
#define CONTADDR 6
#define COLORADDR 7
#define PICADDR 8
#define TINTADDR 1
#define COMADDR 2
#define SUBRADDR 3
#define SUBBADDR 4
#define BLACK 0x00
#define BLUE 0x01
#define GREEN 0x02
#define CAMBLUE 0x03
#define RED 0x04
#define PURPLE 0x05
#define YELLOW 0x06
#define WHITE 0x07
#define BASEROW 1
#define BASECOL 0
#define SYSMENUROW 12
#define SYSMENUCOL 8
#define SYSNUMCOL 17
#define WINDOWDISPROWSTR 1
#define WINDOWDISPCOLSTR 7
#define RADIOWINDOWDISPROWSTR 0
#define RADIOWINDOWDISPCOLSTR 0
#define RADIOROW 1
#define RADIOCOL 1
#define DVCWINDOWDISPROWSTR 0
#define DVCWINDOWDISPCOLSTR 0
#define DVCROW 1
#define DVCCOL 1
#define A 0x0E
#define a 0x28
#define C(N) (N-'A'+A)
#define c(n) (n-'a'+a)
typedef struct Str
{
__flash uchar *str;
uchar n;
} STR;
static uchar __flash NumStr[]={0x0A,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
C('A'),C('B'),C('C'),C('D'),C('E'),C('F')};
//static __flash uchar SetStr[]={C('S'),C('E'),C('T')};
static __flash uchar VideoStr[]={C('V'),C('I'),C('D'),C('E'),C('O')};
static __flash uchar SoundStr[]={C('S'),C('O'),C('U'),C('N'),C('D')};
static __flash uchar RadioStr[]={0x00,C('R'),0x00,C('A'),0x00,C('D'),0x00,C('I'),0x00,C('O')};
static __flash uchar UsrStr[]={C('S'),C('Y'),C('S'),C('T'),C('E'),C('M')};
static __flash uchar DvcStr[]={0x00,C('C'),0x00,C('H'),0x00,C('A'),0x00,C('N'),0x00,C('G'),0x00,C('E'),0x00,C('R')};
static __flash uchar DvdStr[]={0x00,C('D'),0x00,C('V'),0x00,C('D')};
//static __flash uchar TvStr[]={C('T'),C('V')};
//static __flash uchar GpsStr[]={C('G'),C('P'),C('S')};
static __flash uchar VolumeStr[]={C('V'),C('O'),C('L'),C('U'),C('M'),C('E')};
static __flash uchar MuteStr[]={C('M'),C('U'),C('T'),C('E')};
static __flash STR VideoStrPoint={VideoStr,5};
static __flash STR SoundStrPoint={SoundStr,5};
static __flash STR RadioStrPoint={RadioStr,10};
static __flash STR UsrStrPoint={UsrStr,6};
static __flash STR DvcStrPoint={DvcStr,14};
static __flash STR DvdStrPoint={DvdStr,6};
//static __flash STR TvStrPoint={TvStr,2};
//static __flash STR GpsStrPoint={GpsStr,3};
static __flash STR VolumeStrPoint={VolumeStr,6};
static __flash STR MuteStrPoint={MuteStr,4};
static __flash uchar SourceNoSignStr[]={C('N'),C('O'),C('S'),C('I'),C('G'),C('N')};
static __flash uchar SourceDvdStr[]={C('D'),C('V'),C('D')};
static __flash uchar SourceRadioStr[]={C('R'),C('A'),C('D'),C('I'),C('O')};
static __flash uchar SourceDvcStr[]={C('D'),C('V'),C('C')};
static __flash uchar SourceTvStr[]={C('T'),C('V')};
static __flash uchar SourceGpsStr[]={C('G'),C('P'),C('S')};
static __flash uchar SourceAux1Str[]={C('A'),C('U'),C('X'),1};
static __flash uchar SourceAux2Str[]={C('A'),C('U'),C('X'),2};
static __flash uchar SourceAux3Str[]={C('A'),C('U'),C('X'),3};
static __flash STR SourceModeStrPoint[9]={
{SourceNoSignStr,6},
{SourceDvdStr,3},
{SourceRadioStr,5},
{SourceDvcStr,3},
{SourceTvStr,2},
{SourceGpsStr,3},
{SourceAux1Str,4},
{SourceAux2Str,4},
{SourceAux3Str,4}
};
//video
static __flash uchar BrightStr[]={C('B'),C('R'),C('I'),C('G'),C('H'),C('T')};//BRIGHT
static __flash uchar ColorStr[]={C('C'),C('O'),C('L'),C('O'),C('R')};//COLOR
static __flash uchar ContStr[]={C('C'),C('O'),C('N'),C('T')};//CONT
static __flash uchar PicStr[]={C('P'),C('I'),C('C'),C('T'),C('U'),C('R'),C('E')};//PIC
static __flash uchar TintStr[]={C('T'),C('I'),C('N'),C('T')};//TINT
static __flash uchar ComStr[]={C('C'),C('O'),C('M')};//COM
static __flash uchar SubrStr[]={C('S'),C('U'),C('B'),C('R')};//SUBR
static __flash uchar SubbStr[]={C('S'),C('U'),C('B'),C('B')};//SUBB
static __flash uchar RevStr[]={C('R'),C('E'),C('V')};//REV
static __flash uchar ModeStr[]={C('M'),C('O'),C('D'),C('E')};//MODE
static __flash uchar FullStr[]={C('F'),C('U'),C('L'),C('L')};//FULL
static __flash uchar NormStr[]={C('N'),C('O'),C('R'),C('M')};//NORMAL
static __flash STR BrightStrPoint={BrightStr,6};
static __flash STR ColorStrPoint={ColorStr,5};
static __flash STR ContStrPoint={ContStr,4};
static __flash STR PicStrPoint={PicStr,7};
static __flash STR TintStrPoint={TintStr,4};
static __flash STR ComStrPoint={ComStr,3};
static __flash STR SubrStrPoint={SubrStr,4};
static __flash STR SubbStrPoint={SubbStr,4};
static __flash STR RevStrPoint={RevStr,3};
static __flash STR ModeValPoint[]={
{FullStr, 4},
{NormStr ,4}
};
static __flash STR VideoMenuPoint[VIDEOMENU_NUM]={
{BrightStr,6},
{ColorStr ,5},
{ContStr ,4},
{RevStr ,3},
{ModeStr ,4}
};
//sound
static __flash uchar BassStr[]={C('B'),C('A'),C('S'),C('S')};
static __flash uchar TrebStr[]={C('T'),C('R'),C('E'),C('B')};
static __flash uchar FlatStr[]={C('F'),C('A'),C('D'),C('E'),C('R')};
static __flash uchar BalanceStr[]={C('B'),C('A'),C('L'),C('A'),C('N'),C('C'),C('E')};
static __flash STR SoundMenuPoint[SOUNDMENU_NUM]={
{BassStr,4},
{TrebStr ,4},
{FlatStr ,5},
{BalanceStr,7}
};
//USER SETTING
static __flash uchar DataStr[]={C('D'),C('A'),C('T'),C('A'),0xF3};
static __flash uchar TimeStr[]={C('T'),C('I'),C('M'),C('E'),0xF3};
static __flash uchar BeepStr[]={C('B'),C('E'),C('E'),C('P')};
static __flash uchar CcdStr[]={C('C'),C('C'),C('D')};
static __flash uchar OnStr[]={0x00,C('O'),C('N')};
static __flash uchar OffStr[]={C('O'),C('F'),C('F')};
static __flash uchar ChStr[]={0x84,0x85,0x86,0x87};//up down left right
static __flash STR TimeStrPoint={TimeStr,5};
//static __flash STR BeepStrPoint={BeepStr,4};
static __flash STR UsrMenuPoint[]={
{DataStr,4},
{TimeStr,4},
{BeepStr,4},
{CcdStr,3}
};
static __flash STR OnOffStrPoint[]={
{OffStr,3},
{OnStr,3}
};
//RADIO
static __flash uchar BandStr[]={C('B'),C('A'),C('N'),C('D'),0xF3};
static __flash uchar Fm1Str[]={C('F'),C('M'),0x01};
static __flash uchar Fm2Str[]={C('F'),C('M'),0x02};
static __flash uchar AmStr[]={C('A'),C('M'),0x00};
static __flash uchar MHzStr[]={C('M'),C('H'),c('z')};
static __flash uchar KHzStr[]={C('K'),C('H'),c('z')};
static __flash STR BandStrPoint={BandStr,5};
static __flash STR BandValPoint[]={
{Fm1Str,3},
{Fm2Str,3},
{AmStr,3}
};
static __flash STR HzStrPoint[]={
{MHzStr,3},
{KHzStr,3}
};
//DVD
static __flash uchar DiscNOCDStr[]={C('N'),C('O'),0x00,C('D'),C('I'),C('S'),C('C')};
static __flash uchar DiscCDStr[]={C('C'),C('D'),C('D'),C('A'),0x00,0x00,0x00};
static __flash uchar DiscVCDStr[]={C('V'),C('C'),C('D'),0x00,0x00,0x00,0x00};
static __flash uchar DiscDVDStr[]={C('D'),C('V'),C('D'),0x00,0x00,0x00,0x00};
static __flash uchar DiscMP3Str[]={C('M'),C('P'),0x03,0x00,0x00,0x00,0x00};
static __flash uchar DiscUNKNOWStr[]={C('U'),C('N'),C('K'),C('N'),C('O'),C('W'),0x00};
static __flash uchar DiscLOADINGStr[]={C('L'),C('O'),C('A'),C('D'),C('I'),C('N'),C('G')};
static __flash uchar DiscEJECTGStr[]={C('E'),C('J'),C('E'),C('C'),C('T'),0,0};
static __flash STR DiscTypeStrPoint[]={
{DiscNOCDStr,7},
{DiscCDStr,7},
{DiscVCDStr,7},
{DiscDVDStr,7},
{DiscMP3Str,7},
{DiscUNKNOWStr,7},
{DiscLOADINGStr,7},
{DiscEJECTGStr,7}
};
//DVC
static __flash uchar DiscStr[]={C('D'),C('I'),C('S'),C('C'),0xF3};
static __flash uchar TrackStr[]={C('T'),C('R'),C('A'),C('C'),C('K'),0xF3};
static __flash STR DiscStrPoint={DiscStr,5};
static __flash STR TrackStrPoint={TrackStr,6};
//
void Row_Clear(uchar row,uchar col,uchar n);
void Num16_Disp(uchar row,uchar col,uchar c)
{
OsdBuf[0]=row|0x80;
OsdBuf[1]=col|0x40;
OsdBuf[2]=NumStr[c>>4];
OsdBuf[3]=NumStr[c&0x0f];
I2c_SendMData(OSDADDR,OsdBuf,4);
}
void Num_Disp(uchar row,uchar col,uchar c,uchar leftright)
{
uchar c1,c2,c3;
uchar n;
if(leftright==1)
Row_Clear(row,col-2,3);
else
Row_Clear(row,col,3);
NmDelay(1);
c1=c%10;
c=c/10;
c2=c%10;
c3=c/10;
OsdBuf[0]=row|0x80;
if(c3>0)//>100
{
OsdBuf[2]=NumStr[c3];
OsdBuf[3]=NumStr[c2];
OsdBuf[4]=NumStr[c1];
n=5;
}
else if(c2>0)//>10
{
OsdBuf[2]=NumStr[c2];
OsdBuf[3]=NumStr[c1];
n=4;
}
else
{
OsdBuf[2]=NumStr[c1];
n=3;
}
if(leftright==1)//right
col=col+3-n;
else
col=col;
if(n>3)
OsdBuf[1]=col|0x40;
else
OsdBuf[1]=col;
I2c_SendMData(OSDADDR,OsdBuf,n);
}
void Char_Disp(uchar row,uchar col,uchar c)
{
OsdBuf[0]=row+0x80;
OsdBuf[1]=col;
OsdBuf[2]=c;
I2c_SendMData(OSDADDR,OsdBuf,3);
}
void String_Disp(uchar row,uchar col,uchar __flash *p,uchar n)
{
uchar i=0;
OsdBuf[0]=row|0x80;
OsdBuf[1]=col|0x40;
if(n+col>30)
return;
for(i=0;i<n;i++)
OsdBuf[2+i]=p[i];
I2c_SendMData(OSDADDR,OsdBuf,n+2);
}
void Char_Attrib_Set(uchar row,uchar col,uchar c)
{
OsdBuf[0]=row|0xA0;
OsdBuf[1]=col;
OsdBuf[2]=c;
I2c_SendMData(OSDADDR,OsdBuf,3);
}
void String_Attrib_Set(uchar row,uchar col,uchar n,uchar c)
{
uchar i=0;
if(n+col>30)
return;
OsdBuf[0]=row|0xA0;
OsdBuf[1]=col|0x40;
for(i=0;i<n;i++)
OsdBuf[2+i]=c;
I2c_SendMData(OSDADDR,OsdBuf,n+2);
}
void Row_Ctrol(uchar row,uchar color,uchar chs,uchar cws)//整行的属性 CHS Hight CWS Wide
{
uchar c;
c=((color&0x07)<<2)+(chs<<1)+cws;
Char_Disp(row,30,c);
}
void Row_Clear(uchar row,uchar col,uchar n)
{
uchar i=0;
OsdBuf[0]=row|0x80;
OsdBuf[1]=col|0x40;
if(n+col>30)
return;
for(i=0;i<n;i++)
OsdBuf[2+i]=0x00;
I2c_SendMData(OSDADDR,OsdBuf,n+2);
}
void Window_Disp(uchar w,uchar wen,uchar ccs,uchar color,
uchar rowsta,uchar rowend,uchar colsta,uchar colend)//窗口显示 w 表示窗口类别 c1 c2 c3窗口参数
{
uchar c1,c2,c3;
c1=(rowsta<<4)|rowend;
c2=(colsta<<3)|((wen)<<2)|((ccs)<<1);
c3=(colend<<3)|(color&0x07);
OsdBuf[0]=0x8F;
OsdBuf[1]=0x40+w*3;
OsdBuf[2]=c1;
OsdBuf[3]=c2;
OsdBuf[4]=c3;
I2c_SendMData(OSDADDR,OsdBuf,5);
}
void Window_Control(uchar c)//窗口控制
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -