📄 osd.c
字号:
#include "golbal.h"
BYTE data CursorX;
BYTE data CursorY;
BYTE code HexTab[16]={_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f};
BYTE code NullRow[31]={__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,__,DataEnd};
enum window
{
window1=1,
window2,
window3,
window4
};
void gotoxy(BYTE x, BYTE y)
{
CursorX=x;
CursorY=y;
}
void SetOSDAttribute(BYTE color)
{
byM230_OSDRA=CursorY|OSD_ATTRIBUTE;
byM230_OSDCA=CursorX;
byM230_OSDDT0=color;
}
void SetOSDDisplay(BYTE font, bit page2)
{
byM230_OSDRA=CursorY|OSD_DISPLAY;
byM230_OSDCA=CursorX;
if(page2)
{
byM230_OSDDT1=font;
}
else
{
byM230_OSDDT0=font;
}
}
void PrintChar(BYTE FontCode, BYTE Color, bit Page2)
{
SetOSDDisplay(FontCode,Page2);
SetOSDAttribute(Color);
CursorX++;
if(CursorX>29)
{
CursorX=0;
CursorY++;
}
if(CursorY>14)
{
CursorY=0;
}
}
void PrintString(BYTE *string, BYTE color)
{
while((*string)!=DataEnd)
{
if((*string)==SecondPage)
{
string++;
PrintChar(*string, color, 1);
}
else
{
PrintChar(*string, color, 0);
}
string++;
}
}
void PrintDec(BYTE value, BYTE color)
{
BYTE data buf[3];
buf[2]=value/0x64;
buf[1]=(value%0x64)/0x0a;
buf[0]=(value%0x64)%0x0a;
if(buf[2]==0x00)
{
PrintChar(__,color,0);
}
else
{
PrintChar(HexTab[buf[2]], color, 0);
}
PrintChar(HexTab[buf[1]], color, 0);
PrintChar(HexTab[buf[0]], color, 0);
}
void PrintHex(BYTE value, BYTE color)
{
PrintChar(HexTab[value/16], color, 0);
PrintChar(HexTab[value%16], color, 0);
}
#define GAUGE_DEGREE 5
#define GAUGE_LENGTH 16
#define MAX_GAUGE (GAUGE_DEGREE*GAUGE_LENGTH)
void PrintBar(BYTE value, BYTE color)
{
BYTE data full,i;
BYTE code NFULL_CODE[GAUGE_DEGREE]=
{
_BAR_EMP,_BAR_1, _BAR_2, _BAR_3,_BAR_F
};
value=MAX_GAUGE*value/(MaxValue-MinValue);
full=value/GAUGE_DEGREE;
if( (value==0) && (full==0) )
{
for(i=0;i<GAUGE_LENGTH;i++)
{
PrintChar(_BAR_EMP, color, 0);
}
//PrintChar(_BAR_END,color, 0);
return;
}
for(i=0;i<GAUGE_LENGTH;i++)
{
if(i<full)
{
PrintChar(_BAR_F,color, 0);
}
else if(i==full)
{
PrintChar(NFULL_CODE[value%GAUGE_DEGREE],color, 0);
}
else
{
PrintChar(_BAR_EMP,color, 0);
}
}
//PrintChar(_BAR_END,color, 0);
}
void PrintOneBar(BYTE Cstart, BYTE Rstart, BYTE color)
{
BYTE data data_value;
BYTE data bar_value;
bar_value=WorkValue;
data_value=(bar_value-MinValue)*100/(MaxValue-MinValue);
gotoxy(19,7);
PrintDec(data_value, color);
gotoxy(Cstart,Rstart);
//PrintChar(_BAR_S,color,0);
PrintBar(bar_value, color);
}
void InitialOSD(void)
{
BYTE data i;
CloseOSD();
//ClearOSD();
byM230_RSPACE=0x00;
//byM230_HORD=OSDHPos;
//byM230_VERTD=OSDVPos;
byM230_CH=0x00;
byM230_CHSC=0x00;
byM230_FSSTP=0x00;
byM230_WINSW=0x00;
byM230_WINSH=0x00;
for(i=0;i<4;i++)
{
CloseOSDWindow(i);
}
for(i=0;i<=14;i++)
{
byM230_OSDRA=i;
byM230_OSDCA=30;
byM230_OSDDT0=0x00;
}
}
void OpenOSD(void)
{
byM230_OSDCON=OSD_ENABLE;
}
void CloseOSD(void)
{
byM230_OSDCON=WEN_Clr+RAM_Clr;
DelayX1ms(1);
byM230_OSDCON=0x00;
}
void CloseOSDWindow(BYTE WinNo)
{
switch(WinNo)
{
case window1:
byM230_W1COL1=0x00;
break;
case window2:
byM230_W2COL1=0x00;
break;
case window3:
byM230_W3COL1=0x00;
break;
case window4:
byM230_W4COL1=0x00;
break;
default:
break;
}
}
void ClearRow(BYTE row, BYTE color)
{
gotoxy(CursorX,row);
PrintString(NullRow, color);
}
void SetWindow(BYTE CStart,BYTE CEnd,BYTE RStart,BYTE REnd,BYTE Color,BYTE WinNum)
{
switch(WinNum)
{
case window1:
byM230_W1ROW=(RStart<<4)|REnd;
byM230_W1COL1=((CStart<<3)|WEN_En)&0xfe;
byM230_W1COL2=(CEnd<<3)|(Color&0x07);
break;
case window2:
byM230_W2ROW=(RStart<<4)|REnd;
byM230_W2COL1=((CStart<<3)|WEN_En)&0xfe;
byM230_W2COL2=(CEnd<<3)|(Color&0x07);
break;
case window3:
byM230_W3ROW=(RStart<<4)|REnd;
byM230_W3COL1=((CStart<<3)|WEN_En)&0xfe;
byM230_W3COL2=(CEnd<<3)|(Color&0x07);
break;
case window4:
byM230_W4ROW=(RStart<<4)|REnd;
byM230_W4COL1=((CStart<<3)|WEN_En)&0xfe;
byM230_W4COL2=(CEnd<<3)|(Color&0x07);
break;
default:
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -