📄 osd_vx1818.c
字号:
#include <intrins.h>
#include <stdio.h>
#define VX1818 0xD8
#define osd0 0x50
#define osd1 0x51
#define osd2 0x52
#define osd3 0x53
#define osd4 0x54
#define osd5 0x55
#define osd6 0x56
#define osd7 0x57
#define osd8 0x58
#define osd9 0x59
#define osd10 0x5a
#define osd11 0x5b
#define osd12 0x5c
#define osd13 0x5d
#define osd14 0x5e
#define osd15 0x5f
#define osd16 0x60
#define osd17 0x61
#define osd18 0x62
#define osd19 0x63
#define osd20 0x64
#define osd21 0x65
#define osd22 0x66
#define osd23 0x67
#define osd24 0x68
#define osd25 0x69
#define osd26 0x6a
#define osd27 0x6b
#define osd28 0x6c
#define osd29 0x6d
#define osd30 0x6e
#define osd31 0x6f
#define osd32 0x70
#define osd33 0x71
#define osd34 0x72
#define osd35 0x73
#define osd36 0x74
#define osd37 0x75
#define osd38 0x76
#define osd39 0x77
#define osd40 0x78
#define osd41 0x79
#define cw1 0xfd
#define cw2 0xfe
#define cw3 0xff
extern void shi_sub_write (char,char,char,char*);
extern void shi_sub_read (char,char,char,char*);
extern void osd_clear(char);
/*********************************************************************
Show OSD Function (For VX1818)
Input Factor:
stpos1 => 8 bits , Lower 2 bits is available.
The two bits is the 8-9bits address of
the starting point of the fontcodes.
stpos2 => 8 bits , The 0-7bits address of the starting point
of the fontcodes.
numfont => 8 bits , (Number of fontcode)-1
fontcode => 8 bits , A pointer of the fonts array to show
Output Factor:
None
Motion:
1.Show the fonts to the arbitrary position on screen
*********************************************************************/
void osd_show(char stpos2,char numfont,char *fontcode)
{
char idata temp[0x02] = {0x10,0x00};
temp[1] = stpos2;
shi_sub_write(VX1818,cw1,0x01,&temp[0]);
shi_sub_write(VX1818,cw3,numfont,fontcode);
}
/*********************************************************************
Turn on/off OSD Function (For VX1818)
Input Factor:
osd_en => 8 bits , Lower 3 bits is available,and higher 5 bits
must be zero.
0 bit => OSD Bottom Block enable or not
1 bit => OSD Content Block enable or not
2 bit => OSD Title Block enable or not
0 => Disable 1 => Enable
Output Factor:
None
Motion:
1.Setup the three block of osd enable or not
*********************************************************************/
void osd_switch(char osd_en)
{
char idata temp2;
osd_en = osd_en & 0x07; // Remove redundant bits
shi_sub_read(VX1818,osd2,0x00,&temp2);
temp2 = temp2 & 0xf8;
temp2 = temp2 | osd_en;
shi_sub_write(VX1818,osd2,0x00,&temp2);
}
/*********************************************************************
Set position of OSD Function (For VX1818)
Input Factor:
block => 8 bits , Choose which block to set
0x01 => Title Block
0x02 => Content Block
0x03 => Bottom Block
posx => 8 bits , The position of X direction
posy => 8 bits , The position of Y direction
Output Factor:
None
Motion:
1.Set the position of OSD Block
*********************************************************************/
void osd_pos(char block,char posx,char posy)
{
char idata temp3[0x02];
temp3[0] = posx;
temp3[1] = posy;
switch(block)
{
case 1: // Setup position of Title Block
shi_sub_write(VX1818,osd9,0x01,&temp3);
break;
case 2: // Setup position of Content Block
shi_sub_write(VX1818,osd16,0x01,&temp3);
break;
case 3: // Setup position of Bottom Block
shi_sub_write(VX1818,osd30,0x01,&temp3);
break;
default:
break;
}
}
/*********************************************************************
Set Size of OSD Function (For VX1818)
Input Factor:
block => 8 bits , Choose which block to set
0x01 => Title Block
0x02 => Content Block
0x03 => Bottom Block
sizex => 8 bits , The size of X direction (Lower 6bits are available)
Value range => for small font:01h-26h
for large font:01h-13h
sizey => 8 bits , The size of Y direction (Lower 5bits are available)
(Just for Content Block)
Value range => for small font:01h-15h
for large font:01h-0ah
Output Factor:
None
Motion:
1.Set the size of OSD Block
*********************************************************************/
void osd_size(char block,char sizex,char sizey)
{
char idata temp4[0x02];
temp4[0] = sizex;
temp4[1] = sizey;
switch(block)
{
case 1: // Setup x size of Title Block
shi_sub_write(VX1818,osd4,0x00,&temp4[0]);
break;
case 2: // Setup x and y size of Content Block
shi_sub_write(VX1818,osd13,0x01,&temp4[0]);
break;
case 3: // Setup x size of Bottom Block
shi_sub_write(VX1818,osd28,0x00,&temp4[0]);
break;
default:
break;
}
}
/*********************************************************************
Switch Big font of OSD Function (For VX1818)
Input Factor:
big_en => 1 bit , 0: Small font 16x20
1: Big font 32x40
Output Factor:
None
Motion:
1.Switch whether big font format is choosed
*********************************************************************/
/*void osd_bigfont(bit big_en)
{
char idata temp5;
shi_sub_read(VX1818,osd2,0x00,&temp5);
if (big_en)
{
temp5 = temp5 | 0x08;
}
else
{
temp5 = temp5 & 0xf7;
}
shi_sub_write(VX1818,osd2,0x00,&temp5);
}*/
/*********************************************************************
Clear font of OSD Function (For VX1818)
Input Factor:
stpos1 => 8 bits , Lower 2 bits is available.
The two bits is the 8-9bits address of
the starting point of the fontcodes.
stpos2 => 8 bits , The 0-7bits address of the starting point
of the fontcodes.
Output Factor:
None
Motion:
1.Clear 16 fonts of OSD from the starting point
*********************************************************************/
void osd_clear(char stpos2)
{
char idata temp6[0x12] = {0x10,0x00,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b,0x7b};
temp6[1] = stpos2;
shi_sub_write(VX1818,cw1,0x01,&temp6[0]);
shi_sub_write(VX1818,cw3,0x0f,&temp6[2]);
}
/*********************************************************************
Clear all fonts memory of OSD Function (For VX1818)
Input Factor:
None
Output Factor:
None
Motion:
1.Clear all fonts memory of OSD
*********************************************************************/
void osd_clearall()
{
char idata count2;
for (count2=0;count2<=0x0f;count2++)
{
osd_clear(count2*0x10);
}
}
/*********************************************************************
Set block initial address in OSD Function (For VX1818)
Input Factor:
block => 8 bits , Choose which block to set
0x02 => Content Block
0x03 => Bottom Block
pos => 8 bits , The block initial address in OSD
Output Factor:
None
Motion:
1.Set the position of OSD Block
*********************************************************************/
void osd_madr(char block,char pos)
{
switch(block)
{
case 2: // Setup position of Content Block
shi_sub_write(VX1818,osd15,0x00,&pos);
break;
case 3: // Setup position of Bottom Block
shi_sub_write(VX1818,osd29,0x00,&pos);
break;
default:
break;
}
}
/*********************************************************************
Adding font to OSD memory Function (For VX1818)
Input Factor:
stpos1 => 8 bits , Lower 2 bits is available.
The two bits is the 8-9bits address of
the starting point of the fontcodes.
stpos2 => 8 bits , The 0-7bits address of the starting point
of the fontcodes.
font => 8 bits , A pointer of the fonts array to show
Output Factor:
None
Motion:
1.Show the fonts to the arbitrary position on screen
*********************************************************************/
void osd_addfont(char stpos1,char stpos2,char *font)
{
char idata temp7[0x02];
stpos1 = stpos1 & 0x07; // Get the lower 2 bits of stpos1
stpos1 = stpos1 + 0x20;
temp7[0] = stpos1;
temp7[1] = stpos2;
shi_sub_write(VX1818,cw1,0x01,&temp7[0]);
shi_sub_write(VX1818,cw3,0x28,font);
}
/*********************************************************************
Set color of OSD's block Function (For VX1818)
Input Factor:
block => 8 bits , Choose which block to set
0x01 => Title Block
0x02 => Content Block
0x03 => Bottom Block
fb => 1 bit , 1 => Foreground color
0 => Background color
h => 1 bit , 1 => Highlight section color
0 => Normal color
color => 8 bits , The lower 4 bits are available.
Output Factor:
None
Motion:
1.Set the color of OSD Block
*********************************************************************/
void osd_color(char block,bit fb,bit h,char color)
{
char idata addr;
char idata temp8;
switch(block)
{
case 1: // Setup position of Title Block
if (h) // Highlight
{
addr = osd12;
}
else // Normal
{
addr = osd11;
}
break;
case 2: // Setup position of Content Block
if (h) // Highlight
{
addr = osd27;
}
else // Normal
{
addr = osd26;
}
break;
case 3: // Setup position of Bottom Block
if (h) // Highlight
{
addr = osd37;
}
else // Normal
{
addr = osd36;
}
break;
default:
break;
}
shi_sub_read(VX1818,addr,0x00,&temp8); // Read back the register
if (fb) // Foreground
{
temp8 = temp8 & 0xf0; // Remove lower 4 bits of temp8
color = color & 0x0f; // Remove higher 4 bits of color
temp8 = temp8 | color; // set lower 4 bits of color to lower 4 bits of temp8
}
else // Background
{
temp8 = temp8 & 0x0f; // Remove higher 4 bits of temp8
color = color & 0x0f; // Remove higher 4 bits of color
color <<= 4; // Shift color left 4 bits
temp8 = temp8 | color; // set higher 4 bits of color to higher 4 bits of temp8
}
shi_sub_write(VX1818,addr,0x00,&temp8);
}
/*********************************************************************
Set Start and End point of Highlight/Blink Section of OSD Function (For VX1818)
Input Factor:
block => 8 bits , Choose which block to set
0x01 => Title Block
0x02 => Content Block
0x03 => Bottom Block
hb => 1 bit , Switch Highlight/Blink
0 => Highlight
1 => Blink
xstart => 8 bits , The highlight starting of X direction
p.s. Lower 6 bits are available
xend => 8 bits , The highlight ending of X direction
p.s. Lower 6 bits are available
ystart => 8 bits , The highlight starting of Y direction
p.s. Lower 5 bits are available
yend => 8 bits , The highlight ending of Y direction
p.s. Lower 5 bits are available
Output Factor:
None
*********************************************************************/
void osd_hbsection(char block,bit hb,char xstart,char xend,char ystart,char yend)
{
xstart = xstart & 0x3f;
xend = xend & 0x3f;
ystart = ystart & 0x1f;
yend = yend & 0x1f;
switch(block)
{
case 1: // Setup x size of Title Block
if (hb) // Blink section
{
shi_sub_write(VX1818,osd7,0x00,&xstart); // Start
shi_sub_write(VX1818,osd8,0x00,&xend); // End
}
else // Highlight section
{
shi_sub_write(VX1818,osd5,0x00,&xstart); // Start
shi_sub_write(VX1818,osd6,0x00,&xend); // End
}
break;
case 2: // Setup x and y size of Content Block
if (hb) // Blink section
{
shi_sub_write(VX1818,osd24,0x00,&xstart); // xStart
shi_sub_write(VX1818,osd25,0x00,&xend); // xEnd
shi_sub_write(VX1818,osd22,0x00,&ystart); // yStart
shi_sub_write(VX1818,osd23,0x00,¥d); // yEnd
}
else // Highlight section
{
shi_sub_write(VX1818,osd20,0x00,&xstart); // xStart
shi_sub_write(VX1818,osd21,0x00,&xend); // xEnd
shi_sub_write(VX1818,osd18,0x00,&ystart); // yStart
shi_sub_write(VX1818,osd19,0x00,¥d); // yEnd
}
break;
case 3: // Setup x size of Bottom Block
if (hb) // Blink section
{
shi_sub_write(VX1818,osd34,0x00,&xstart); // Start
shi_sub_write(VX1818,osd35,0x00,&xend); // End
}
else // Highlight section
{
shi_sub_write(VX1818,osd32,0x00,&xstart); // Start
shi_sub_write(VX1818,osd33,0x00,&xend); // End
}
break;
default:
break;
}
}
/*********************************************************************
Set OSD blinking rate Function (For VX1818)
Input Factor:
blink => 8 bits , OSD blinking rate
P.S. Lower 6 bits are available
Output Factor:
None
*********************************************************************/
void osd_blink(char blink)
{
blink = blink & 0x3f; // Remove redundant bits
shi_sub_write(VX1818,osd3,0x00,&blink);
}
/*********************************************************************
Set OSD alpha-blending Function (For VX1818)
Input Factor:
alpha => 8 bits , OSD alpha-blending
P.S. Lower 4 bits are available
Output Factor:
None
*********************************************************************/
void osd_alpha(char alpha)
{
char temp9;
alpha <<= 4;
alpha = alpha & 0xf0; // Remove redundant bits
shi_sub_read(VX1818,osd2,0x00,&temp9);
temp9 = temp9 & 0x0f;
temp9 = temp9 | alpha;
shi_sub_write(VX1818,osd2,0x00,&temp9);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -