⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osd.c

📁 mtv230 的源程序,供大家参考.
💻 C
字号:
#include "Globe.h"

BYTE MaxValue,MinValue,WorkValue;

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};

enum window
{
	window1=1,
	window2,
	window3,
	window4
};

void Double_W_H(BYTE Attr)
{
	byM230_OSDRA=CursorY|OSD_DISPLAY;
	byM230_OSDCA=30;
	byM230_OSDDT0=Attr;
}

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 buf[3],temp;

  buf[2]=value/100;
  temp=value%100;
  buf[1]=temp/10;
  buf[0]=temp%10;

  if(buf[2]==0x00)
  	{
	  PrintChar(__,color,0);
  	 }
  else
  	{
	  PrintChar(HexTab[buf[2]], color, 0);
  	 }
  if(buf[2]==0x00)
  {
  	if(buf[1]==0x00)
		{
  		PrintChar(__,color,0);
  		}
	else
		{
		PrintChar(HexTab[buf[1]], color, 0);
		}
  }
  else
  {
   PrintChar(HexTab[buf[1]], color, 0);
  }
  
  PrintChar(HexTab[buf[0]], color, 0);
}


#define	GAUGE_DEGREE	3
#define	GAUGE_LENGTH	25	
#define	MAX_GAUGE		(GAUGE_DEGREE*GAUGE_LENGTH)

void PrintBar(WORD value, BYTE color)
{
  BYTE full,i;
   
   BYTE code NFULL_CODE[GAUGE_DEGREE]=
   {
      _BAR_EMP,_BAR_2,_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 bar_value;

	bar_value=WorkValue;
	gotoxy(Cstart,Rstart);		       
	PrintChar(_BAR_S,color,0);
	PrintBar(bar_value, color);
}

void InitialOSD(void)
{
  BYTE i, j;
  
  CloseOSD();
  
  byM230_RSPACE=0x00;		//row to row spacing is 0  !!!
//  byM230_HORD=30;
//  byM230_VERTD=6;
  byM230_CH=0x00;			//character is 18 lines high  !!!
  byM230_CHSC=0x00;			//shadow color
  byM230_FSSTP=0x00;		//self-test pattern

  byM230_WINSW=0x00;		//shadow width of 4 windows are 2  !!!	
  byM230_WINSH=0x00;		//shadow height of 4 windows are 2  !!!

  for(i=0;i<4;i++)
   	{
         CloseOSDWindow(i);  
   	}

   for(i=0;i<=14;i++)
   	{
	  byM230_OSDRA=i;		//initialize every row's CTRL   REG:   RINT CHS CWS
	  byM230_OSDCA=30;
	  byM230_OSDDT0=0x00;
   	}
   
    for(i=0;i<=14;i++)
   	{
	  byM230_OSDRA=i|0x40;//initialize every character's attribute		MTV230---PAGE21
	  for(j=0;j<=29;j++)
	  	{
	  	byM230_OSDCA=j;
	  	byM230_OSDDT0=0x00;
	  	}
   	}
}
void OpenOSD_Border(void)
{
  byM230_OSDCON=OSD_ENABLE_B;
}

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 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 + -