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

📄 osd1csl.c

📁 TFT 屏驱动IC源码头TFT 屏驱动IC源码
💻 C
字号:
//	#include "Common.h"
#include "Global.h"
#include "ICControl.h"	
#include "System.h"
#include "TWICreg.h"
#include "OSD1_Define.h"
#include "OSD1CSL.h"
#include "E_OSDString.H"
#include "Font_Index.h"

void OSD1PutChar(uCHAR cChar,uCHAR x,uCHAR y, uCHAR cColor,uCHAR FontIndexBase)
{
	if((x < OSD_LENGTH) && ( y < OSD_LINE_NUM))
	{
		OSD1SetRamAddr(MENU_RAM_START_ADDRESS+((int)y << 6)+x);
		OSD1SetRamData(cChar+FontIndexBase);
     	OSD1SetRamData(cColor);
	}
}

void OSD1ShowLine(uCHAR *string,uCHAR x,uCHAR y,uCHAR cColor,uCHAR cLength, uCHAR FontIndexBase)
{
	if((x < OSD_LENGTH) && ( y < OSD_LINE_NUM))
	{
		OSD1SetRamAddr(MENU_RAM_START_ADDRESS+((int)y << 6)+x);
     	while((*string) != EOL && (x < cLength))
		{
			OSD1SetRamData((*string++)+FontIndexBase);
     		OSD1SetRamData(cColor);
        	x++;
  		}
	}
}

void OSD1CleanLine(uCHAR x,uCHAR y,uCHAR cColor,uCHAR cLength)
{
	if((x < OSD_LENGTH) && ( y < OSD_LINE_NUM))
  	{
  		OSD1SetRamAddr(MENU_RAM_START_ADDRESS+((int)y << 6)+x);     	
     	while((x < OSD_LENGTH) && (x < cLength))
     	{
     		OSD1SetRamData(BLANK);
        	OSD1SetRamData(cColor);
        	x++;
     	}      	
	}
} 

void OSD1ClearMenu(uCHAR cColor)
{
	uCHAR i;

	for(i = 0; i < OSD_LINE_NUM; i++)
	{
		OSD1CleanLine(0,i,cColor,OSD_LENGTH);
		OSD1SetLineAttribute(i,RGAP_BG|RGAP_0|Char_Height_Single|Char_Width_Single);
	}
}

void OSD1Enable(void)
{
	m_bOSDEnable = 1;
	OSD1CfgSet(OSD1_CTRL,0x84);
  	IC_WritByte(TWIC_P0,0xE2,0x11);
}

void OSD1Disable(void)
{
	OSD1CfgSet(OSD1_CTRL,0x18);
	m_bOSDEnable=0;
}

void OSD1SetLineAttribute(uCHAR cLine,uCHAR cAttribute)
{
     OSD1SetRamAddr(MENU_RAM_START_ADDRESS+((int)cLine << 6)+OSD_LENGTH+1);
	 IC_WritByte(TWIC_P0,OSD_RAM_DL,0x00);
	 IC_WritByte(TWIC_P0,OSD_RAM_DL,cAttribute);
}

void OSD1DrawNum(uWORD wVal, uCHAR cMax, uCHAR x, uCHAR y, uCHAR cColor, uCHAR cAttr)
{
	uCHAR cTemp;
	if(cMax!=0)
	{
		m_wBuff[0]=(unsigned long)wVal*100;
		m_wBuff[0]=m_wBuff[0]/cMax;
  	}
	else //Non percentage
	{
		m_wBuff[0]=wVal;
	}

	if(m_wBuff[0]<10)
	{
	    switch(cAttr)
	    {
			case DRAW_ZERO:
	     	  OSD1PutChar(0x30,x,y,cColor,0);
	     	  OSD1PutChar(0x30,x+1,y,cColor,0);
			default:
			  OSD1PutChar(m_wBuff[0]+0x30,x+2,y,cColor,0); 				
            break;
	    }	
	}
	else if(m_wBuff[0]<100)
	{
	    switch(cAttr)
	    {
			case DRAW_ZERO:
	     	  OSD1PutChar(0x30,x,y,cColor,0);			
			default:
			  cTemp = m_wBuff[0]/10;
		      OSD1PutChar(cTemp+0x30,x+1,y,cColor,0);	
			  cTemp = m_wBuff[0]%10;
		      OSD1PutChar(cTemp+0x30,x+2,y,cColor,0);				  
            break;
	    }	
	}
	else if(m_wBuff[0]<1000)
	{
		cTemp = m_wBuff[0]/100;
		OSD1PutChar(cTemp+0x30,x,y,cColor,0);	
		cTemp = (m_wBuff[0]%100)/10;
		OSD1PutChar(cTemp+0x30,x+1,y,cColor,0); 
		cTemp = (m_wBuff[0]%100)/10;
		OSD1PutChar(cTemp+0x30,x+2,y,cColor,0); 
	}
}

void OSD1DrawGauge(uCHAR cVal, uCHAR cMax, uCHAR x, uCHAR y, uCHAR cColor)
{
	int index,i,j;
	int step_size=100/25;
	
	index= (int)cVal*25/(int)cMax;
    for(i=0;i<index;i++)
		OSD1PutChar(0x0B4,x+i,y,cColor,0); //see font_index.h    _solid
	j=((int)cVal*100/(int)cMax)-index*step_size;
	j=j/2;//2.5;
	OSD1PutChar(0x20,x+index,y,cColor,0); 	//see font_index.h   _space

    for(i=index+1;i<25;i++)
		OSD1PutChar(0x20,x+i,y,cColor,0);	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -