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

📄 osd.c

📁 一个LCD TV的源程序, 用的是realtek的IC
💻 C
字号:
/*********************************************************************

      COPYRIGHT  (C)  Himax Technologies, Inc.

      File name     : OSD.c

      Description   : Declare OSD Function

      Author        : Taylor

      Create date   : 2004/10/18

      Modifications :
*********************************************************************/

#define _OSD_C

/********************** Include Section *****************************/

#include "osd.h"
#include "osd_font.h"
#include "Key.h"

/********************** Function Implementation *********************/

code unsigned char     // font address
ICONGROUP[TOTAL_ICON][2] = {{0x3C, 0x3D},  //Bri
                            {0x3E, 0x3F},  //Cont
                            {0x40, 0x41},  //HUE
                            {0x50, 0x51},  //Saturation
                            {0x44, 0x45},  //OSD
                            {0x46, 0x47},  //nonlinear
                            {0x48, 0x49},  //Sharp
                            {0x4A, 0x4B},  //Lan
                            {0x4E, 0x4F},  //Source
                            {0x4C, 0x4D},  //Exit
                            {0x54, 0x55},  //InputSource
                            {0x56, 0x57},  //InternalPattern
                            {0x58, 0x59}   //Dithering
                           };

code unsigned char     // display address
ICONPOS[TOTAL_ICON][2] = {{3, 3}, //Bri
                          {3, 6}, //Cont
                          {3, 9}, //HUE
                          {3, 12},//Saturation
                          {3, 15},//OSD
                          {3, 18},//nonlinear
                          {3, 21},//Sharp
                          {3, 24},//Lan
                          {3, 27},//Source
                          {3, 30},//Exit
                          {4, 3}, //InputSource
                          {4, 6}, //InternalPattern
                          {4, 9}  //Dithering
                         };
code unsigned int
OSDPOSITION[5][2] = {{0x0040, 0x0020}, {0x01D0, 0x0020}, {0x0104, 0x00DC}, {0x0040, 0x0150}, {0x01D0, 0x0150}};

void Draw_logo();
/* -------------------------------------------------------------------
  Name    : Init_OSD
  Purpose :
  Passed  :
  Returns :
  Notes   :
  ------------------------------------------------------------------- */
void Init_OSD(void)
{
    // Turn OFF OSD
    OSD_OFF();
    // OSD set pallete
    OsdSetPallete();
    // Load OSD Data to HX8824's RAM
    SetFonts(0);
    // Setup OSD Fonts Size
    I2CWriteByte(HX8824_ADDR, HX8824_OSD_SIZE, (OSD_Y_Ratio << 4) | OSD_X_Ratio) ;
    // Setup OSD Blink Rate
    I2CWriteByte(HX8824_ADDR, HX8824_OSD_BLNKRATE, 0x88);
    I2CWriteByte(HX8824_ADDR, HX8824_OSD_Alpha, 0x88);
    OsdDrawing();
    // OSD Enable
    //OSD_ON();
    SetFonts(0);
}


/* ================================================================
    Name    : SetFonts
    Purpose : Set OSD Fonts to HX8824
    Passed  : Font_page
    Notes   : None
   ================================================================ */

void SetFonts(Byte page)
{
    // Declare Counter Variable
    Word i;

    // Setup Mono/2-Bits/3-bits/4-Bits Color Font Number
    I2CWriteByte(HX8824_ADDR, HX8824_OSD_COLOR_FONT_NUMBER, 0x64);

    // Point to Font First Address
    I2CWrtHead( HX8824_ADDR, HX8824_FONT_IND_ADR );   // 0xBA
	Write(0x00);
	//Write(0x00);
    Stop();

    I2CWrtHead( HX8824_ADDR, HX8824_FONT_IND_DATA );   // 0xBC

    switch(page)
    {
        case 0:
            // Address = 0x00 --> First Data must be Empty          addr: 0
            for (i = 0; i < 27; i++)
            {
                Write(FontAsciiSpace[i]);
            }
            // Address = 0x01~0x0B  --> "0~9"+":"
            for (i = 0; i < 11*27; i++)
            {
                Write(FontAscii_0_9[i]);
            }
            // Address = 0x0C~0x11  -->
            for (i = 0; i < 6*27; i++)
            {
                Write(FontBorder[i]);
            }
            // Address = 0x12~0x2B  --> A~Z
            for (i = 0; i < 26*27; i++)
            {
                Write(FontAscii_A_Z[i]);
            }
            // Address = 0x2C~0x33  --> Bar_left, 0/5~5/5, Bar_right
            for (i = 0; i < 8*27; i++)
            {
                Write(FontBar[i]);
            }
            // Address = 0x34~0x51  --> Menu Icon
            for (i = 0; i < 48*27; i++)
            {
                Write(FontIcon_Menu[i]);
            }

            // Address = 0x25 --> FontIcon                addr: 0x25~0x2A--> border;0x32~0x61 icon
/*            for (i = 0; i < 100*27; i++)
            {
                Write(FontIcon[i]);
            }
*/

        break;
        case 1:
            // Address = 0x00 --> First Data must be Empty          addr: 0
            for (i = 0; i < 27; i++)
            {
                Write(FontAsciiSpace[i]);
            }
            // Address = 0x01~0x0B  --> "0~9"+":"
            for (i = 0; i < 11*27; i++)
            {
                Write(FontAscii_0_9[i]);
            }
            // Address = 0x0C~0x11  -->
            for (i = 0; i < 6*27; i++)
            {
                Write(FontBorder[i]);
            }
            // Address = 0x12~0x2B  --> A~Z
            for (i = 0; i < 26*27; i++)
            {
                Write(FontAscii_A_Z[i]);
            }
            // Address = 0x2C~0x33  --> Bar_left, 0/5~5/5, Bar_right
            for (i = 0; i < 8*27; i++)
            {
                Write(FontBar[i]);
            }
            // Address = 0x34~0x51  --> Menu Icon
            for (i = 0; i < 36*27; i++)
            {
                Write(FontTraditionalChinese[i]);
            }
        break;
        default:
        break;
    }

    Stop();

}

/* ================================================================
    Name    : OsdSetStrValueBL
    Purpose : Write OSD One Line String
    Passed  : None
    Notes   : None
   ================================================================ */
/*
void OsdSetStrValueBL(Byte byRow, Byte byCol,
                      Byte bkColor, Byte frColor,
                      Byte length, Byte *ascii)
{
	Byte jj;
    Word kk;

    kk= byRow*40 + byCol;
	I2CWrtHead(HX8824_ADDR, HX8824_DISPLAY_AREA_Y);
	Write((Byte)(kk));
	Write((Byte)(kk>>8));
	Write(bkColor);
    Write(frColor);
	while (length--)
	{
		if (*ascii == '\0')
		{
			Write (0x00);
	  	    for (jj=0 ; jj< length ; jj++)	Write (0x00);
			goto Stop_write;
		}
		else
		{
			Write	(*ascii);
		}
		ascii++;
	}

Stop_write:
	Stop();
}
*/

/* ================================================================
    Name    : SetOsdAlpha
    Purpose : Set OSD Alpha
    Passed  : Foreground --> Set Foreground
              Background --> Set Background
    Notes   : None
   ================================================================ */
/*
void SetOsdAlpha(Byte byIndex,Byte byValue)
{
    // According to byIndex to select background/foreground alpha
    switch(byIndex)
    {
        case Foreground:
            I2CWriteByte(HX8824_ADDR, HX8824_OSD_Alpha_Fore, byValue);
            break;

        case Background:
            I2CWriteByte(HX8824_ADDR, HX8824_OSD_Alpha_Back, byValue);
            break;
    }
}
*/

/* ================================================================
    Name    : OsdSetChanelValue
    Purpose : Write OSD One Line String
    Passed  : None
    Notes   : None
   ================================================================ */
/*
void OsdSetChanelValue(Byte byRow, Byte byCol,
                      Byte bkColor, Byte frColor,
                      Byte byChannel)
{
	Byte jj;
    Word kk;

    Clear_OSD();

    kk= byRow*40 + byCol;
	I2CWrtHead(HX8824_ADDR, HX8824_DISPLAY_AREA_Y);
	Write((Byte)(kk));
	Write((Byte)(kk>>8));
	Write(bkColor);
    Write(frColor);

    // Process κ

⌨️ 快捷键说明

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