📄 osd.c
字号:
/* **********************************************************************
Copyright (c) 2002-2006 Beyond Innovation Technology Co., Ltd
All rights are reserved. Reproduction in whole or in parts is
prohibited without the prior written consent of the copyright owner.
----------------------------------------------------------------------
Module: OSD.C
Purpose: Implementation of OSD module.
Version: 0.01 11:01AM 2005/11/17
Compiler: Keil 8051 C Compiler v8.01
Reference:
[1] BIT1611B Datasheet Version 1.0, 2005-11-10, Beyond Innovation Technology
[2] MTV121 Super On-Screen-Display for LCD Monitor, Revision 5.0
06/29/1999 Myson Technology
----------------------------------------------------------------------
Modification:
R0.01 09:48AM 2005/11/17 Jeffrey Chang
Reason:
1. Original.
Solution:
********************************************************************** */
#define _OSD_C_
/* ------------------------------------
Header Files
------------------------------------ */
#include "bitek.h"
#include "eeprom.h"
#include "intrins.h"
#include "led.h"
#include "osd.h"
#include "platform.h"
#include "timer.h"
/* ------------------------------------
Macro Definitions
------------------------------------ */
/* ------------------------------------
Type Definitions
------------------------------------ */
/* ------------------------------------
Variables Definitions
------------------------------------ */
static UB8 CODE abProgressBarTV[] = { OSD_00_DASH_0, OSD_01_DASH_1, OSD_02_DASH_2 };
static UB8 CODE abProgressBarMONITOR[] = { OSD_10_BAR_0, OSD_11_BAR_1, OSD_12_BAR_2,
OSD_13_BAR_3, OSD_14_BAR_4, OSD_15_BAR_5 };
static UB8 CODE abTrackBar[] = { OSD_01_TRACK_1, OSD_06_TRACK_2, OSD_07_TRACK_3 };
/* ------------------------------------
Function Prototypes
------------------------------------ */
#pragma OPTIMIZE (6)
/* -------------------------------------------------------------------
Name: OSD_DisplayAddress - (OSD_BIT1611B)
Purpose: To calculate OSD Display Address.
Passed:
UB8 bWindow = OSD Window Identifier.
UB8 bRow = Position in rows
UB8 bCol = Position in columns
Returns: OSD Display Address.
Notes:
------------------------------------------------------------------- */
UW16 OSD_DisplayAddress (
UB8 bWindow,
UB8 bRow,
UB8 bCol
)
{
switch (bWindow)
{
case OSD_WINDOW1:
return(VP_0500_057F_DISPLAY_CODE + OSD_WINDOW1_BASE +
bRow * OSD_WINDOW1_WIDTH + bCol );
break;
case OSD_WINDOW2:
return(VP_0500_057F_DISPLAY_CODE + OSD_WINDOW2_BASE +
bRow * OSD_WINDOW2_WIDTH + bCol );
break;
case OSD_WINDOW3:
default:
return(VP_0500_057F_DISPLAY_CODE + OSD_WINDOW3_BASE +
bRow * OSD_WINDOW3_WIDTH + bCol );
break;
}
} /* OSD_DisplayAddress */
#pragma OPTIMIZE (9)
#if (OSD_DSP_PROGRESSBAR)
/* -------------------------------------------------------------------
Name: OSD_DspProgressBar - (OSD_BIT1611B)
Purpose: To display a progress bar at specified position in OSD window.
Passed:
UB8 bWindow = OSD Window Identifier.
UB8 bCol, = Progress bar horizontal position in columns.
UB8 bRow, = Progress bar vertical position in rows.
UW16 wMin, = Progress bar minimal value.
UW16 wMax, = Progress bar maximal value.
UW16 wValue = Progress bar indicative value.
UB8 bWidth, = Progress bar width
UB8 bStyle = Progress bar Style
Returns: None.
Notes:
------------------------------------------------------------------- */
void OSD_DspProgressBar (
UB8 bWindow,
UB8 bCol, // Progress bar horizontal position in columns
UB8 bRow, // Progress bar vertical position in rows
UW16 wMin, // Progress bar minimal value
UW16 wMax, // Progress bar maximal value
UW16 wValue, // Progress bar indicative value
UB8 bWidth, // Progress bar width
UB8 bStyle // Progress bar style
)
{
UB8 bFull;
UB8 bUnit;
UW16 wAddr;
wAddr = OSD_DisplayAddress(bWindow, bRow, bCol);
// Note: MONITOR Style contains LEFT and RIGHT !
if (bStyle != OSD_STYLE_TV1)
bWidth -= 2;
switch (bStyle)
{
case OSD_STYLE_TV1:
default:
// Dash Type
// Rounding
bUnit = (UW32)(wValue - wMin) * OSD_DASH_TOTAL * bWidth /
(wMax - wMin);
bFull = bUnit / OSD_DASH_TOTAL;
// Fill FULL Dash Bar !
BITEK_TxRepeat(OSD_MAD, wAddr, bFull, OSD_03_DASH_FULL);
if (bFull != bWidth)
{
// Fill Dash 0 Bar !
BITEK_TxRepeat(OSD_MAD, wAddr + bFull, bWidth - bFull, OSD_00_DASH_0);
// Show Dash Bar !
BITEK_TxByte(OSD_MAD, wAddr + bFull, abProgressBarTV[ bUnit % OSD_DASH_TOTAL ]);
}
break;
case OSD_STYLE_MONITOR1:
// Bar Type
// Rounding
bUnit = (UW32)(wValue - wMin) * OSD_BAR_TOTAL * bWidth /
(wMax - wMin);
bFull = bUnit / OSD_BAR_TOTAL;
// LEFT/RIGHT BAR !
BITEK_TxByte(OSD_MAD, wAddr, OSD_5B_BAR_LEFT);
BITEK_TxByte(OSD_MAD, wAddr+bWidth+1, OSD_5D_BAR_RIGHT);
// Fill FULL BAR !
wAddr++;
BITEK_TxRepeat(OSD_MAD, wAddr, bFull, OSD_16_BAR_FULL);
if (bFull != bWidth)
{
// Fill Dash 0 Bar !
BITEK_TxRepeat(OSD_MAD, wAddr + bFull, bWidth - bFull, OSD_10_BAR_0);
// Show Dash Bar !
BITEK_TxByte(OSD_MAD, wAddr + bFull, abProgressBarMONITOR[ bUnit % OSD_BAR_TOTAL ]);
}
break;
}
} /* OSD_DspProgressBar */
#endif
#if (OSD_DSP_TRACKBAR)
/* -------------------------------------------------------------------
Name: OSD_DspTrackBar - (OSD_BIT1611B)
Purpose: To display a track bar at specified position in OSD window.
Passed:
UB8 bWindow = OSD Window Identifier.
UB8 bCol, = Track bar horizontal position in columns
UB8 bRow, = Track bar vertical position in rows
UW16 wMin, = Track bar minimal value
UW16 wMax, = Track bar maximal value
UW16 wValue = Track bar indicative value
UB8 bWidth = Track bar width
Returns: None.
Notes:
------------------------------------------------------------------- */
void OSD_DspTrackBar (
UB8 bWindow,
UB8 bCol, // Track bar horizontal position in columns
UB8 bRow, // Track bar vertical position in rows
UW16 wMin, // Track bar minimal value
UW16 wMax, // Track bar maximal value
UW16 wValue, // Track bar indicative value
UB8 bWidth // Track bar width
)
{
UB8 bUnit;
UW16 wAddr;
wAddr = OSD_DisplayAddress(bWindow, bRow, bCol);
// Rounding
bUnit = ((UW32)(wValue - wMin) * OSD_TRACK_TOTAL * bWidth) /
(wMax - wMin);
if (bUnit == OSD_TRACK_TOTAL * bWidth)
bUnit--;
// Fill Track 0 Bar !
BITEK_TxRepeat(OSD_MAD, wAddr, bWidth, OSD_00_TRACK_0);
// Show Track Bar !
BITEK_TxByte(OSD_MAD, wAddr + bUnit / OSD_TRACK_TOTAL, abTrackBar[ bUnit % OSD_TRACK_TOTAL ]);
} /* OSD_DspTrackBar */
#endif
/* -------------------------------------------------------------------
Name: OSD_EnableWindow - (OSD_BIT1611B)
Purpose: To enable/disable OSD Windows.
Passed:
UB8 bWindow = OSD Window Identifier.
BOOL fOn = Enable (TRUE) or Disable (FALSE).
Returns: None.
Notes: [1]118
------------------------------------------------------------------- */
void OSD_EnableWindow (
UB8 bWindow,
BOOL fOn
)
{
UB8 bData;
if (bWindow & OSD_WINDOW1)
{
////////////////////////////////////////////////////////
// [JC010] OSD Image Retention issue fixed by JC 09:15AM 2006/04/25
#ifdef NOT_JUNK
bData = BITEK_RxByte(OSD_MAD, VP_143_OSD1_ATTR4);
if ( fOn )
bData |= VP_MASK_OSD1_EN;
else
bData &= (~VP_MASK_OSD1_EN);
BITEK_TxByte(OSD_MAD, VP_143_OSD1_ATTR4, bData);
#endif
bData = BITEK_RxByte(OSD_MAD, VP_13A_OSD1_POSITION_MSB);
if ( fOn )
bData &= (~VP_MASK_H_POSITION_OFF);
else
bData |= VP_MASK_H_POSITION_OFF;
BITEK_TxByte(OSD_MAD, VP_13A_OSD1_POSITION_MSB, bData);
////////////////////////////////////////////////////////
}
if (bWindow & OSD_WINDOW2)
{
bData = BITEK_RxByte(OSD_MAD, VP_151_OSD2_ATTR4);
if ( fOn )
bData |= VP_MASK_OSD2_EN;
else
bData &= (~VP_MASK_OSD2_EN);
BITEK_TxByte(OSD_MAD, VP_151_OSD2_ATTR4, bData);
}
if (bWindow & OSD_WINDOW3)
{
bData = BITEK_RxByte(OSD_MAD, VP_15F_OSD3_ATTR4);
if ( fOn )
bData |= VP_MASK_OSD3_EN;
else
bData &= (~VP_MASK_OSD3_EN);
BITEK_TxByte(OSD_MAD, VP_15F_OSD3_ATTR4, bData);
}
} /* OSD_EnableWindow */
/* -------------------------------------------------------------------
Name: OSD_FillCharAttr - (OSD_BIT1611B)
Purpose:
To fill OSD display RAM with the same character attribute.
Passed:
bOffset = The character attribute start location.
bCnt = The number of filled characters (1..255).
bCharAttr = The same character attribute.
Returns: None.
Notes:
------------------------------------------------------------------- */
void OSD_FillCharAttr (
UB8 bOffset,
UB8 bCnt, // 1..255
UB8 bCharAttr // Char Attribute
)
{
BITEK_TxRepeat(OSD_MAD, VP_0580_05FF_DISPLAY_ATTR + bOffset, bCnt, bCharAttr);
} /* OSD_FillCharAttr */
/* -------------------------------------------------------------------
Name: OSD_FillCharCode - (OSD_BIT1611B)
Purpose:
To fill OSD display RAM with the same character code.
Passed:
bOffset = The character code start location.
bCnt = The number of filled characters (1..255).
bCharCode = The same character code.
Returns: None.
Notes:
------------------------------------------------------------------- */
void OSD_FillCharCode (
UB8 bOffset,
UB8 bCnt, // 1..255
UB8 bCharCode // Character Code
)
{
BITEK_TxRepeat(OSD_MAD, VP_0500_057F_DISPLAY_CODE + bOffset, bCnt, bCharCode);
} /* OSD_FillCharCode */
/* -------------------------------------------------------------------
Name: OSD_FillCharCodeAttr - (OSD_BIT1611B)
Purpose:
To fill OSD display RAM with the same character code and attribute.
Passed:
bOffset = The character start location.
bCnt = The number of filled characters (1..255).
bCharCode = The same character code.
bCharAttr = The same character attribute.
5 4 3 2 1 0
| | | |_|_|_ Foregound Attribute Index (0..7)
|_|_|_______ Backgound Attribute Index (0..7)
Returns: None.
Notes:
------------------------------------------------------------------- */
void OSD_FillCharCodeAttr (
UB8 bOffset,
UB8 bCnt, // 1..255
UB8 bCharCode, // Char Code
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -