osd.c
来自「Verilog, c and asm source codes of the M」· C语言 代码 · 共 444 行 · 第 1/2 页
C
444 行
0x00,0x00,0x00,0x00,0x00, // 192 [0xc0]
0x00,0x00,0x00,0x00,0x00, // 193 [0xc1]
0x00,0x00,0x00,0x00,0x00, // 194 [0xc2]
0x00,0x00,0x00,0x00,0x00, // 195 [0xc3]
0x00,0x00,0x00,0x00,0x00, // 196 [0xc4]
0x00,0x00,0x00,0x00,0x00, // 197 [0xc5]
0x00,0x00,0x00,0x00,0x00, // 198 [0xc6]
0x00,0x00,0x00,0x00,0x00, // 199 [0xc7]
0x00,0x00,0x00,0x00,0x00, // 200 [0xc8]
0x00,0x00,0x00,0x00,0x00, // 201 [0xc9]
0x00,0x00,0x00,0x00,0x00, // 202 [0xca]
0x00,0x00,0x00,0x00,0x00, // 203 [0xcb]
0x00,0x00,0x00,0x00,0x00, // 204 [0xcc]
0x00,0x00,0x00,0x00,0x00, // 205 [0xcd]
0x00,0x00,0x00,0x00,0x00, // 206 [0xce]
0x00,0x00,0x00,0x00,0x00, // 207 [0xcf]
0x00,0x00,0x00,0x00,0x00, // 208 [0xd0]
0x00,0x00,0x00,0x00,0x00, // 209 [0xd1]
0x00,0x00,0x00,0x00,0x00, // 210 [0xd2]
0x00,0x00,0x00,0x00,0x00, // 211 [0xd3]
0x00,0x00,0x00,0x00,0x00, // 212 [0xd4]
0x00,0x00,0x00,0x00,0x00, // 213 [0xd5]
0x00,0x00,0x00,0x00,0x00, // 214 [0xd6]
0x00,0x00,0x00,0x00,0x00, // 215 [0xd7]
0x00,0x00,0x00,0x00,0x00, // 216 [0xd8]
0x00,0x00,0x00,0x00,0x00, // 217 [0xd9]
0x00,0x00,0x00,0x00,0x00, // 218 [0xda]
0x00,0x00,0x00,0x00,0x00, // 219 [0xdb]
0x00,0x00,0x00,0x00,0x00, // 220 [0xdc]
0x00,0x00,0x00,0x00,0x00, // 221 [0xdd]
0x00,0x00,0x00,0x00,0x00, // 222 [0xde]
0x00,0x00,0x00,0x00,0x00, // 223 [0xdf]
0x00,0x00,0x00,0x00,0x00, // 224 [0xe0]
0x00,0x00,0x00,0x00,0x00, // 225 [0xe1]
0x00,0x00,0x00,0x00,0x00, // 226 [0xe2]
0x00,0x00,0x00,0x00,0x00, // 227 [0xe3]
0x00,0x00,0x00,0x00,0x00, // 228 [0xe4]
0x00,0x00,0x00,0x00,0x00, // 229 [0xe5]
0x00,0x00,0x00,0x00,0x00, // 230 [0xe6]
0x00,0x00,0x00,0x00,0x00, // 231 [0xe7]
0x00,0x00,0x00,0x00,0x00, // 232 [0xe8]
0x04,0x54,0x50,0x14,0x44, // 233 [0xe9]
0x00,0x00,0x00,0x00,0x00, // 234 [0xea]
0x00,0x00,0x00,0x00,0x00, // 235 [0xeb]
0x10,0x22,0x10,0x22,0x10, // 236 [0xec]
0x10,0x22,0x20,0x22,0x10, // 237 [0xed]
0x20,0x22,0x20,0x22,0x20, // 238 [0xee]
0x40,0x22,0x20,0x22,0x40, // 239 [0xef]
0x00,0x00,0x00,0x00,0x00, // 240 [0xf0]
0x00,0x00,0x00,0x00,0x00, // 241 [0xf1]
0x00,0x00,0x00,0x00,0x00, // 242 [0xf2]
0x00,0x00,0x00,0x00,0x00, // 243 [0xf3]
0x00,0x00,0x00,0x00,0x00, // 244 [0xf4]
0x00,0x00,0x00,0x00,0x00, // 245 [0xf5]
0x00,0x00,0x00,0x00,0x00, // 246 [0xf6]
0x00,0x00,0x00,0x00,0x00, // 247 [0xf7]
0x00,0x00,0x00,0x00,0x00, // 248 [0xf8]
0xfe,0x7b,0xff,0x7b,0xfe, // 249 [0xf9]
0xfe,0x7a,0xfe,0x7a,0xfe, // 250 [0xfa]
0xfc,0x78,0xfc,0x78,0xfc, // 251 [0xfb]
0xf8,0x78,0xf8,0x78,0xf8, // 252 [0xfc]
0xf0,0x70,0xf0,0x70,0xf0, // 253 [0xfd]
0xe0,0x60,0xe0,0x60,0xe0, // 254 [0xfe]
0xc0,0x40,0xc0,0x40,0xc0 // 255 [0xff]
;
/*some constants*/
#define OSDNLINE 8 /*number of lines of OSD*/
#define OSDLINELEN 128 /*single line length in bytes*/
#define OSDCMDREAD 0x00 //OSD read controller/key status
#define OSDCMDWRITE 0x20 //OSD write video data command
#define OSDCMDENABLE 0x60 //OSD enable command
#define OSDCMDDISABLE 0x40 //OSD disable command
#define OSDCMDRESET 0x80 //OSD reset command
#define OSDCMDFILTER 0xE0 //OSD settings: filter
#define OSDCMDMEMCFG 0xF0 //OSD settings: memory config
#define REPEATTIME 50 /*repeat delay in 10ms units*/
#define REPEATRATE 5 /*repeat rate in 10ms units*/
/*write a null-terminated string <s> to the OSD buffer starting at line <n>*/
void OsdWrite(unsigned char n,const unsigned char *s,char invert)
{
unsigned char b;
const unsigned char *p;
/*select OSD SPI device*/
EnableOsd();
/*select buffer and line to write to*/
if (invert)
SPI(OSDCMDWRITE|0x10|n);
else
SPI(OSDCMDWRITE|n);
/*send all characters in string to OSD*/
while(1)
{
b=*(s++);
if(b==0)/*end of string*/
break;
else if(b==0x0d || b==0x0a)//cariage return / linefeed, go to next line
{
/*increment line counter*/
if(++n>=OSDNLINE)
n=0;
/*send new line number to OSD*/
DisableOsd();
EnableOsd();
SPI(OSDCMDWRITE|n);
}
else/*normal character*/
{
SPI(0x00);
p=&charfont[b][0];
SPI(*(p++));
SPI(*(p++));
SPI(*(p++));
SPI(*(p++));
SPI(*(p++));
}
}
/*deselect OSD SPI device*/
DisableOsd();
}
/*clear buffer <c>*/
void OsdClear(void)
{
unsigned short n;
/*select OSD SPI device*/
EnableOsd();
/*select buffer to write to*/
SPI(OSDCMDWRITE|0x18);
/*clear buffer*/
for(n=0;n<(OSDLINELEN*OSDNLINE);n++)
SPI(0x00);
/*deselect OSD SPI device*/
DisableOsd();
}
/*enable displaying of OSD*/
void OsdEnable(void)
{
/*send command*/
EnableOsd();
SPI(OSDCMDENABLE);
DisableOsd();
}
/*disable displaying of OSD*/
void OsdDisable(void)
{
/*send command*/
EnableOsd();
SPI(OSDCMDDISABLE);
DisableOsd();
}
void OsdReset(unsigned char boot)
{
EnableOsd();
SPI(OSDCMDRESET | (boot&0x01));
DisableOsd();
}
void OsdFilter(unsigned char lr_filter, unsigned char hr_filter)
{
EnableOsd();
SPI(OSDCMDFILTER | ((hr_filter&0x03)<<2) | (lr_filter&0x03));
DisableOsd();
}
void OsdMemoryConfig(unsigned char memcfg)
{
EnableOsd();
SPI(OSDCMDMEMCFG | (memcfg&0x03));
DisableOsd();
}
/*get key status*/
unsigned char OsdGetCtrl(void)
{
static unsigned char c2;
static unsigned short repeat;
unsigned char c1,c;
/*send command and get current ctrl status*/
EnableOsd();
c1=SPI(OSDCMDREAD);
DisableOsd();
/*add front menu button*/
if(CheckButton())
c1|=OSDCTRLMENU;
/*generate normal "key-pressed" event*/
c=c1&(~c2);
c2=c1;
/*generate repeat "key-pressed" events
do not for menu button*/
if(!c1)
repeat=GetTimer(REPEATTIME);
else if(CheckTimer(repeat))
{
repeat=GetTimer(REPEATRATE);
c=c1&(~OSDCTRLMENU);
}
/*return events*/
return(c);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?