📄 paradj.c
字号:
/*
********************************************************************************
*
* LCD控制程序
*
* 这是一个人机接口交互处理的模块
*
* 文件名 : PARADJ.C
* 设计者 : Terry
********************************************************************************
* 功 能 描 述
*
********************************************************************************
*/
#include "global.h"
#include "scalar.h"
static void DlgBri(uint8 Bri);
static void sRGBCon(void);
uint8 code StrON[] = {0x03 ,_O,_N,__,};
uint8 code StrOFF[] = {0x03, _O,_F,_F};
static void AdjDispBackLight(uint8 color)
{
OsdAttrib(OSD_1BITFONT, color);
#if EN_ACEROSD
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 7, SysPar.Backlight);
OsdShowValScroll(VALROLL_POSX, SubMenuWin.Vs + 7, SysPar.Backlight);
#else
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 4, SysPar.Backlight);
#endif
}
/*
********************************************************************************
* 函 数 名: AdjBacklight
* 功能描述: 调节背光的亮度
* 输 入: step : 高四位是选项,低四位是调节的步长
* color : 显示的颜色
* 返 回: 无
********************************************************************************
*/
void AdjBacklight(uint8 step, unsigned char color)
{
uint8 i;
uint8 Option;
Option = step & 0xF0;
step &= 0x0F;
if (SysPar.Backlight > 100) SysPar.Backlight = 100;
if (Option & SHOWONLY) {
AdjDispBackLight(color);
return;
}
for (i = 0; i< step; i++) {
if (Option & INC) {
if (SysPar.Backlight < 100) SysPar.Backlight++;
}
else {
if (SysPar.Backlight > 0) SysPar.Backlight--;
}
SetBackLight(SysPar.Backlight);
ActiveSave_SYSPAR();
if (Option & SHOW) AdjDispBackLight(color);
}
if (!step) SetBackLight(SysPar.Backlight);
}
#undef MINPAR
#undef MAXPAR
static void AdjDispHpos(uint8 color)
{
uint8 val, Range;
Range = DispModeWidth >> 4;
val = ((uint16)(ModePar.hoffset + Range) * 50) / Range;
OsdAttrib(OSD_1BITFONT, color);
#if EN_ACEROSD
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + MENU_Y_HPOS, val);
OsdShowValScroll(VALROLL_POSX, SubMenuWin.Vs + MENU_Y_HPOS, val);
#else
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 3, val);
#endif
}
/*
********************************************************************************
* 函 数 名: AdjHpos
* 功能描述: 调节水平位置
* 输 入: step : 高四位是选项,低四位是调节的步长
* color : 显示的颜色
* 返 回: 无
********************************************************************************
*/
void AdjHpos(uint8 step, unsigned char color)
{
uint8 i, Range;
uint8 Option;
int16 hpos;
Option = step & 0xF0;
step &= 0x0F;
Range = DispModeWidth >> 4;
if (ModePar.hoffset < -Range) ModePar.hoffset = -Range;
if (ModePar.hoffset > Range) ModePar.hoffset = Range;
if (Option & SHOWONLY) {
AdjDispHpos(color);
return;
}
for (i = 0; i< step; i++) {
if (Option & INC) {
if (ModePar.hoffset < Range) ModePar.hoffset++;
else ModePar.hoffset = Range;
}
else {
if (ModePar.hoffset > -Range) ModePar.hoffset--;
else ModePar.hoffset = -Range;
}
hpos = ModePar.hstart - ModePar.hoffset;
if (hpos < 0) hpos = 0;
SarHpos(hpos);
ActiveSave_VGAMODE();
if (Option & SHOW) AdjDispHpos(color);
}
if (!step) {
hpos = ModePar.hstart - ModePar.hoffset;
if (hpos < 0) hpos = 0;
SarHpos(hpos);
}
}
#if EN_ACEROSD
static void AdjDispAutoAdjust(uint8 color)
{
OsdAttrib(OSD_1BITFONT, color);
OsdShowStr(VALROLL_POSX+10, SubMenuWin.Vs + MENU_Y_AUTOADJ, Icon_MoveR, 1);
}
void AdjAutoAdjust(uint8 step, unsigned char color)
{
uint8 Option;
Option = step & 0xF0;
step &= 0x0F;
if(Option & SHOWONLY)
{
AdjDispAutoAdjust(color);
return;
}
}
#endif
static void AdjDispVpos(uint8 color)
{
uint8 val, Range;
Range = DispModeHeight/30;
val = ((uint16)(ModePar.voffset + Range) * 50) / Range;
OsdAttrib(OSD_1BITFONT, color);
#if EN_ACEROSD
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + MENU_Y_VPOS, val);
OsdShowValScroll(VALROLL_POSX, SubMenuWin.Vs + MENU_Y_VPOS, val);
#else
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 4, val);
#endif
}
/*
********************************************************************************
* 函 数 名: AdjVpos
* 功能描述: 调节水平位置
* 输 入: step : 高四位是选项,低四位是调节的步长
* color : 显示的颜色
* 返 回: 无
********************************************************************************
*/
void AdjVpos(uint8 step, unsigned char color)
{
uint8 i, Range;
uint8 Option;
int16 vpos;
Option = step & 0xF0;
step &= 0x0F;
Range = DispModeHeight/30;
if (ModePar.voffset < -Range) ModePar.voffset = -Range;
if (ModePar.voffset > Range) ModePar.voffset = Range;
if (Option & SHOWONLY) {
AdjDispVpos(color);
return;
}
for (i = 0; i< step; i++) {
if (Option & INC) {
if (ModePar.voffset < Range) ModePar.voffset++;
else ModePar.voffset = Range;
}
else {
if (ModePar.voffset > -Range) ModePar.voffset--;
else ModePar.voffset = -Range;
}
vpos = ModePar.vstart + ModePar.voffset;
if (vpos < 0) vpos = 0;
SarVpos(vpos);
ActiveSave_VGAMODE();
if (Option & SHOW) AdjDispVpos(color);
}
if (!step) {
vpos = ModePar.vstart + ModePar.voffset;
if (vpos < 0) vpos = 0;
SarVpos(vpos);
}
}
/*
********************************************************************************
* 函 数 名: AdjClock
* 功能描述: 调节采样时钟
* 输 入: step : 高四位是选项,低四位是调节的步长
* color : 显示的颜色
* 返 回: 无
********************************************************************************
*/
void AdjClock(uint8 step, unsigned char color)
{
uint8 i, val;
uint8 Option,Err;
uint16 DefClock;
//Err = (uint8)(ModeAttr[ModePar.mode].Hdisp >> 4);
Err = (uint8)(ModeAttr[ModePar.mode].Hdisp >> 3);
DefClock = ModeAttr[ModePar.mode].Htotal;
Option = step & 0xF0;
step &= 0x0F;
if (Option & SHOWONLY) {
val = (unsigned int)(ModePar.htotal - DefClock + Err)*50/Err;
OsdAttrib(OSD_1BITFONT, color);
#if EN_ACEROSD
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + MENU_Y_CLOCK, val);
OsdShowValScroll(VALROLL_POSX, SubMenuWin.Vs + MENU_Y_CLOCK, val);
#else
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 5, val);
#endif
return;
}
if (ModePar.htotal < DefClock-Err) ModePar.htotal = DefClock-Err;
if (ModePar.htotal > DefClock+Err) ModePar.htotal = DefClock+Err;
for (i = 0; i< step; i++) {
if (Option & INC) {
if (ModePar.htotal < DefClock+Err) ModePar.htotal++;
else ModePar.htotal = DefClock+Err;
}
else {
if (ModePar.htotal > DefClock-Err) ModePar.htotal--;
else ModePar.htotal = DefClock-Err;
}
AdcSetPll(ModePar.htotal);
ActiveSave_VGAMODE();
if (Option & SHOW) {
val = (unsigned int)(ModePar.htotal - DefClock + Err)*50/Err;
OsdAttrib(OSD_1BITFONT, color);
#if EN_ACEROSD
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + MENU_Y_CLOCK, val);
OsdShowValScroll(VALROLL_POSX, SubMenuWin.Vs + MENU_Y_CLOCK, val);
#else
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 5, val);
#endif
}
}
if (!step) AdcSetPll(ModePar.htotal);
}
#define MINPAR 0
#define MAXPAR 0x3F
static void AdjDispPhase(uint8 color)
{
uint8 val;
val = ((uint16)(ModePar.phase - MINPAR) * 100)/(MAXPAR - MINPAR);
OsdAttrib(OSD_1BITFONT, color);
#if EN_ACEROSD
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + MENU_Y_PHASE, val);
OsdShowValScroll(VALROLL_POSX, SubMenuWin.Vs + MENU_Y_PHASE, val);
#else
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 6, val);
#endif
}
/*
********************************************************************************
* 函 数 名: AdjPhase
* 功能描述: 调节ADC采样时钟的相位
* 输 入: step : 高四位是选项,低四位是调节的步长
* color : 显示的颜色
* 返 回: 无
********************************************************************************
*/
void AdjPhase(uint8 step, unsigned char color)
{
uint8 i;
uint8 Option;
Option = step & 0xF0;
step &= 0x0F;
if (ModePar.phase < MINPAR) ModePar.phase = MINPAR;
if (ModePar.phase > MAXPAR) ModePar.phase = MAXPAR;
if (Option & SHOWONLY) {
AdjDispPhase(color);
return;
}
for (i = 0; i< step; i++) {
if (Option & INC) {
if (ModePar.phase < MAXPAR) ModePar.phase++;
else ModePar.phase = MAXPAR;
}
else {
if (ModePar.phase > MINPAR) ModePar.phase--;
else ModePar.phase = MINPAR;
}
AdcSetPhase(ModePar.phase);
ActiveSave_VGAMODE();
if (Option & SHOW) AdjDispPhase(color);
}
if (!step) AdcSetPhase(ModePar.phase);
}
#undef MINPAR
#undef MAXPAR
static void AdjDispBri(uint8 color)
{
if (MenuState == MENU_SHORT_BRI) {
OsdAttrib(OSD_1BITFONT, GREEN);
OsdShowScroll(1, ShortMenuWin.Vs + 1 , SysPar.Brightness, 25);
OsdAttrib(OSD_1BITFONT, LIGHTRED);
OsdShowPercent(ShortMenuWin.He - 3, ShortMenuWin.Vs, SysPar.Brightness);
}
else {
OsdAttrib(OSD_1BITFONT, color);
#if EN_ACEROSD
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + MENU_Y_BRI, SysPar.Brightness);
OsdShowValScroll(VALROLL_POSX, SubMenuWin.Vs + MENU_Y_BRI, SysPar.Brightness);
#else
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 2, SysPar.Brightness);
#endif
}
}
/*
********************************************************************************
* 函 数 名: AdjBri
* 功能描述: 调节显示的亮度, 这是用数字的方式调节亮度,并不是调节背光的亮度
* 输 入: step : 高四位是选项,低四位是调节的步长
* color : 显示的颜色
* 返 回: 无
********************************************************************************
*/
void AdjBri(uint8 step, unsigned char color)
{
uint8 i;
uint8 Option;
Option = step & 0xF0;
step &= 0x0F;
if (SysPar.Brightness > 100) SysPar.Brightness = 100;
if (Option & SHOWONLY) {
AdjDispBri(color);
return;
}
for (i = 0; i< step; i++) {
if (Option & INC) {
if (SysPar.Brightness < 100) SysPar.Brightness++;
}
else {
if (SysPar.Brightness > 0) SysPar.Brightness--;
}
SarSetBri(SysPar.Brightness);
ActiveSave_SYSPAR();
if (Option & SHOW) AdjDispBri(color);
}
if (!step) SarSetBri(SysPar.Brightness);//sRGBCon();
}
/*
********************************************************************************
* 函 数 名: sRGBCon
* 功能描述: 通过sRGB的方式输出对比度的值
* 输 入: Con : 需要输出的值
* 返 回: 无
********************************************************************************
*/
static void sRGBCon(void)
{
uint8 Rgain, Ggain, Bgain;
//Rgain = ((uint16)Color.R_Gain * 255)/100;
//Ggain = ((uint16)Color.G_Gain * 255)/100;
//Bgain = ((uint16)Color.B_Gain * 255)/100;
Rgain = ((uint16)Color.R_Gain * 200)/100 + 28;
Ggain = ((uint16)Color.G_Gain * 200)/100 + 28;
Bgain = ((uint16)Color.B_Gain * 200)/100 + 28;
sRGB(SysPar.Contrast, Rgain, Ggain, Bgain);
}
static void AdjDispCon(uint8 color)
{
if (MenuState == MENU_SHORT_CON) {
OsdAttrib(OSD_1BITFONT, GREEN);
OsdShowScroll(1, ShortMenuWin.Vs + 1 , SysPar.Contrast, 25);
OsdAttrib(OSD_1BITFONT, LIGHTRED);
OsdShowPercent(ShortMenuWin.He - 3, ShortMenuWin.Vs, SysPar.Contrast);
}
else {
OsdAttrib(OSD_1BITFONT, color);
#if EN_ACEROSD
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + MENU_Y_CON, SysPar.Contrast);
OsdShowValScroll(VALROLL_POSX, SubMenuWin.Vs + MENU_Y_CON, SysPar.Contrast);
#else
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 3, SysPar.Contrast);
#endif
}
}
/*
********************************************************************************
* 函 数 名: AdjCon
* 功能描述: 调节显示的对比度, 采用的是sRGB的方式
* 输 入: step : 高四位是选项,低四位是调节的步长
* color : 显示的颜色
* 返 回: 无
********************************************************************************
*/
void AdjCon(uint8 step, unsigned char color)
{
uint8 i;
uint8 Option;
Option = step & 0xF0;
step &= 0x0F;
if (SysPar.Contrast > 100) SysPar.Contrast = 100;
if (Option & SHOWONLY) {
AdjDispCon(color);
return;
}
for (i = 0; i< step; i++) {
if (Option & INC) {
if (SysPar.Contrast < 100) SysPar.Contrast++;
}
else {
if (SysPar.Contrast > 0) SysPar.Contrast--;
}
sRGBCon();
ActiveSave_SYSPAR();
if (Option & SHOW) AdjDispCon(color);
}
if (!step) sRGBCon();
}
extern OSDWIN code RGBAdjWin;
static void AdjDispRgain(uint8 color)
{
#if EN_ACEROSD
OsdAttrib(OSD_1BITFONT, color);
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 7, Color.R_Gain);
#else
OsdAttrib(OSD_1BITFONT, color);
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 4, Color.R_Gain);
#endif
}
/*
********************************************************************************
* 函 数 名: AdjRgain
* 功能描述: 调节红色的对比度, 采用的是sRGB的方式
* 输 入: step : 高四位是选项,低四位是调节的步长
* color : 显示的颜色
* 返 回: 无
********************************************************************************
*/
void AdjRgain(uint8 step, unsigned char color)
{
uint8 i;
uint8 Option;
Option = step & 0xF0;
step &= 0x0F;
if (Color.R_Gain > 100) Color.R_Gain = 100;
if (Option & SHOWONLY) {
AdjDispRgain(color);
return;
}
for (i = 0; i< step; i++) {
if (Option & INC) {
if (Color.R_Gain < 100) Color.R_Gain++;
}
else {
if (Color.R_Gain > 0) Color.R_Gain--;
}
sRGBCon();
ActiveSave_COLOR();
if (Option & SHOW) AdjDispRgain(color);
}
if (!step) sRGBCon();
}
static void AdjDispGgain(uint8 color)
{
#if EN_ACEROSD
OsdAttrib(OSD_1BITFONT, color);
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 9, Color.G_Gain);
#else
OsdAttrib(OSD_1BITFONT, color);
OsdShowPercent(SubMenuWin.He - 3, SubMenuWin.Vs + 5, Color.G_Gain);
#endif
}
/*
********************************************************************************
* 函 数 名: AdjGgain
* 功能描述: 调节绿色的对比度, 采用的是sRGB的方式
* 输 入: step : 高四位是选项,低四位是调节的步长
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -