📄 eeprom.c
字号:
#include "gen.h"
#include "comm.h"
#include "intpro.h"
#include "eeprom.h"
#include "osd.h"
#include "I2C.h"
void Save_Parameter(void);
void Get_Mode_Num(void);
void Get_Mode_Data(void);
void Color9300Save(void);
void Color9300Load(void);
void Color6500Save(void);
void Color6500Load(void);
void ColorUserSave(void);
void ColorUserLoad(void);
void FactorySave(void);
void UserSave(void);
void GetFactoryData(void);
void GetUserData(void);
void Get_Color_Data(void);
void Get_SysConfig_Data(void);
extern BYTE idata ColorTempIndex;
/*********************************************************************
* 函 数 名: Save_Parameter
* 功能描述: 如果用户有对显示器参数进行修改,在条件满足之后调用该程序进行
* 参数保存
* 输 入: 无
* 返 回: 无
***********************************************************************/
ModelPARA idata ModelPara;
NORELATEUSER idata NorelateUser;
NORELATEFACTORY idata NorelateFactory;
COLORTEMP9300 idata ColorTemp9300;
COLORTEMP6500 idata ColorTemp6500;
COLORTEMPUSER idata ColorTempUser;
FACTORYAUX idata FactoryAux;
typedef struct {
unsigned char hfre;
unsigned char vfre;
unsigned char pol;
}SYNCATTR;
SYNCATTR code PresetTiming[10]={
{31,70,0x0f}, // 720 X 400 /31.469k/70.087Hz,-/+ 28.322MHz
{31,60,0x00}, // 640 X 480 /31.469k/59.940Hz,-/- 25.175MHz
{54,85,0xff}, // 800 X 600 /53.674k/85.061Hz,+/+ 56.250MHz
{60,75,0xff}, // 1024 X 768 /60.023k/75.029Hz,+/+ 78.750MHz
{69,85,0xff}, // 1024 X 768 /68.677k/84.997Hz,+/+ 94.500MHz
{68,75,0xff}, // 1152 X 864 /67.500k/75.000Hz,+/+ 108.000MHz
{86,85,0xff}, // 1280 X 960 /85.938k/85.002Hz,+/+ 148.500MHz
{80,75,0xff}, // 1280 X 1024 /79.976k/75.025Hz,+/+ 135.000MHz
{91,85,0xff}, // 1280 X 1024 /91.146k/85.024Hz,+/+ 157.500MHz
{94,75,0xff}, // 1600 X 1200 /93.750k/75.000Hz,+/+ 202.500MHz
};
void Norelation_UserSave(void)
{
eepByteOut(0x190,NorelateUser.Bright);
eepByteOut(0x190+1,NorelateUser.Contr);
eepByteOut(0x190+2,NorelateUser.Rotation);
eepByteOut(0x190+3,NorelateUser.Hmoire);
eepByteOut(0x190+4,NorelateUser.Vmoire);
}
void Norelation_FactorySave(void)
{
eepByteOut(0x1a0,NorelateFactory.Bright);
eepByteOut(0x1a0+1,NorelateFactory.Contr);
eepByteOut(0x1a0+2,NorelateFactory.Rotation);
eepByteOut(0x1a0+3,NorelateFactory.Vlinbal);
eepByteOut(0x1a0+4,NorelateFactory.Vlin);
}
void FactoryAuxSave(void)
{
eepByteOut(0x198,FactoryAux.Sub_Brightness);
eepByteOut(0x198+1,FactoryAux.Sub_Contrast);
eepByteOut(0x198+2,FactoryAux.Sub_Vposition);
eepByteOut(0x198+3,FactoryAux.Sub_Vsize);
}
void Get_Norelation_User(void)
{
eepByteIn(NorelateUser.Bright);
eepByteIn(NorelateUser.Contr);
eepByteIn(NorelateUser.Rotation);
eepByteIn(NorelateUser.Hmoire);
eepByteIn(NorelateUser.Vmoire);
}
void Get_Norelation_Factory(void)
{
eepByteIn(NorelateFactory.Bright);
eepByteIn(NorelateFactory.Contr);
eepByteIn(NorelateFactory.Rotation);
eepByteIn(NorelateFactory.Vlinbal);
eepByteIn(NorelateFactory.Vlin);
}
void Get_FactoryAux(void)
{
eepByteIn(FactoryAux.Sub_Brightness);
eepByteIn(FactoryAux.Sub_Contrast);
eepByteIn(FactoryAux.Sub_Vposition);
eepByteIn(FactoryAux.Sub_Vsize);
}
void Color9300Save(void)
{
eepByteOut(0x17c,ColorTemp9300.RGain);
eepByteOut(0x17c+1,ColorTemp9300.GGain);
eepByteOut(0x17c+2,ColorTemp9300.BGain);
eepByteOut(0x17c+3,ColorTemp9300.RBias);
eepByteOut(0x17c+4,ColorTemp9300.GBias);
eepByteOut(0x17c+5,ColorTemp9300.BBias);
}
void Color9300Load(void)
{
ColorTemp9300.RGain=eepByteIn(0x17c);
ColorTemp9300.GGain=eepByteIn(0x17c+1);
ColorTemp9300.BGain=eepByteIn(0x17c+2);
ColorTemp9300.RBias=eepByteIn(0x17c+3);
ColorTemp9300.GBias=eepByteIn(0x17c+4);
ColorTemp9300.BBias=eepByteIn(0x17c+5);
}
void Color6500Save(void)
{
eepByteOut(0x17c,ColorTemp6500.RGain);
eepByteOut(0x17c+1,ColorTemp6500.GGain);
eepByteOut(0x17c+2,ColorTemp6500.BGain);
eepByteOut(0x17c+3,ColorTemp6500.RBias);
eepByteOut(0x17c+4,ColorTemp6500.GBias);
eepByteOut(0x17c+5,ColorTemp6500.BBias);
}
void Color6500Load(void)
{
ColorTemp6500.RGain=eepByteIn(0x182);
ColorTemp6500.GGain=eepByteIn(0x182+1);
ColorTemp6500.BGain=eepByteIn(0x182+2);
ColorTemp6500.RBias=eepByteIn(0x182+3);
ColorTemp6500.GBias=eepByteIn(0x182+4);
ColorTemp6500.BBias=eepByteIn(0x182+5);
}
void ColorUserSave(void)
{
eepByteOut(0x188,ColorTempUser.RBias);
eepByteOut(0x188+1,ColorTempUser.GBias);
eepByteOut(0x188+2,ColorTempUser.BBias);
}
void ColorUserLoad(void)
{
ColorTempUser.RBias=eepByteIn(0x188);
ColorTempUser.GBias=eepByteIn(0x188+1);
ColorTempUser.BBias=eepByteIn(0x188+2);
}
void FactorySave(void)
{
unsigned char temp;
temp=(CurrentModel-1)*10+0x78;
eepByteOut(temp,ModelPara.HSize);
eepByteOut(temp+1,ModelPara.HPos);
eepByteOut(temp+2,ModelPara.VSize);
eepByteOut(temp+3,ModelPara.VPos);
eepByteOut(temp+4,ModelPara.Pincushion);
eepByteOut(temp+5,ModelPara.Trape);
eepByteOut(temp+6,ModelPara.Paralle);
eepByteOut(temp+7,ModelPara.SidePin);
eepByteOut(temp+8,ModelPara.HCorner);
}
void UserSave(void)
{
unsigned char temp;
temp=(CurrentModel-1)*10+0xdc;
eepByteOut(temp,ModelPara.HSize);
eepByteOut(temp+1,ModelPara.HPos);
eepByteOut(temp+2,ModelPara.VSize);
eepByteOut(temp+3,ModelPara.VPos);
eepByteOut(temp+4,ModelPara.Pincushion);
eepByteOut(temp+5,ModelPara.Trape);
eepByteOut(temp+6,ModelPara.Paralle);
eepByteOut(temp+7,ModelPara.SidePin);
eepByteOut(temp+8,ModelPara.HCorner);
}
void GetFactoryData(void)
{
unsigned char temp;
temp=(CurrentModel-1)*10+0x78;
ModelPara.HSize=eepByteIn(temp);
ModelPara.HPos=eepByteIn(temp+1);
ModelPara.VSize=eepByteIn(temp+2);
ModelPara.VPos=eepByteIn(temp+3);
ModelPara.Pincushion=eepByteIn(temp+4);
ModelPara.Trape=eepByteIn(temp+5);
ModelPara.Paralle=eepByteIn(temp+6);
ModelPara.SidePin=eepByteIn(temp+7);
ModelPara.HCorner=eepByteIn(temp+8);
}
void GetUserData(void)
{
unsigned char temp;
temp=(CurrentModel-1)*10+0xdc;
ModelPara.HSize=eepByteIn(temp);
ModelPara.HPos=eepByteIn(temp+1);
ModelPara.VSize=eepByteIn(temp+2);
ModelPara.VPos=eepByteIn(temp+3);
ModelPara.Pincushion=eepByteIn(temp+4);
ModelPara.Trape=eepByteIn(temp+5);
ModelPara.Paralle=eepByteIn(temp+6);
ModelPara.SidePin=eepByteIn(temp+7);
ModelPara.HCorner=eepByteIn(temp+8);
}
void Save_Parameter(void)
{
sEvent_SavePar(0); // 禁止保存参数的定时事件
if (!Flg_EnAutoSave) return;
Flg_EnAutoSave=0;
//Save_Hline();
// 保存用户状态下的参数
//写入入与显示模式无关的参数
Norelation_FactorySave();
//写入入与显示模式相关的参数
FactorySave();
// 如果是工厂调试状态,或者是联机调试状态,则参数要保存到工厂设置区中
if (Flg_Factory || Flg_OnLine) {
//写入入与显示模式无关的参数
Norelation_FactorySave();
//写入显示模式的辅助参数
FactoryAuxSave();
if (CurrentModel>=0 && CurrentModel<=PresetModeNum-1)
//写入入与显示模式相关的参数
FactorySave();
}
}
/*void Get_Mode_Num(void)
{
register unsigned char i;
SYNCATTR data sync;
for(i=0;i<20;i++){
sync.pol=
}}*/
void Get_Mode_Num(void)
{
register unsigned char i;
SYNCATTR data sync;
// 判断是不是10个工厂预置模式
for (i=0;i<PresetModeNum;i++) {
sync.pol=PresetTiming[i].pol;
if (Flg_SyncType) sync.pol=sync.pol&0x0f|0x50;
if (HVpol==sync.pol &&
Hfre>=PresetTiming[i].hfre-1 && Hfre<=PresetTiming[i].hfre+1 &&
Vfre>=PresetTiming[i].vfre-1 && Vfre<=PresetTiming[i].vfre+1) {
CurrentModel=i; //设置当前的显示模式号
return;
}
}
// 判断是不是10个用户模式
for (i=0;i<Max_Mode_Num-PresetModeNum;i++) {
eepByteIn(eepUserSyncAttr+i*3);
if (Flg_SyncType) sync.pol=sync.pol&0x0f|0x50;
if (HVpol==sync.pol && Hfre>=sync.hfre-1 && Hfre<=sync.hfre+1 &&
Vfre>=sync.vfre-1 && Vfre<=sync.vfre+1) break;
continue;
}
if (i<Max_Mode_Num-PresetModeNum) { // 在已有的用户模式中找到对应的显示模式
CurrentModel=i+PresetModeNum; //设置当前的显示模式号
//Mode_Num = i; //edit
return ;
}
// 如果在当前的用户模式中找不到对应,则表明这是一个新的用户模式,那么保存当前
// 的同步信号特性到用户模式特性表中,并设置用户模式指针。
eepByteIn(eepUserModeIndex); //读用户模式指针
sync.hfre=Hfre; sync.vfre=Vfre; sync.pol=HVpol;
eepByteOut(eepUserSyncAttr+(i-PresetModeNum)*3,(unsigned char *)&sync); //保存当前显示模式的特征参数
CurrentModel=i; //设置当前的显示模式号
// 调整用户模式指针,因为它总是指向下一个存储位置
i++;
if (i==Max_Mode_Num) i=PresetModeNum;
eepByteOut(eepUserModeIndex,i);
}
/* 功能描述: 从eeprom中读取,当前显示模式的显示特性参数*/
void Get_Mode_Data(void)
{
Get_Color_Data();
//读入与显示模式相关的参数
GetFactoryData();
GetUserData();
//读入与显示模式无关的参数
Get_Norelation_Factory();
//读入辅助参数
Get_FactoryAux();
}
/*********************************************************************
* 函 数 名: Get_Color_Data
* 功能描述: 根据系统当前的色温标准从eeprom中读取色温参数
* 输 入: 无
* 返 回: 无
***********************************************************************/
void Get_Color_Data(void)
{
if(ColorTempIndex==0) Color9300Load();
else if (ColorTempIndex==1) Color6500Load();
else if (ColorTempIndex==2) ColorUserLoad();
}
/*********************************************************************
* 函 数 名: Get_SysConfig_Data
* 功能描述: 从eeprom中读取系统的配置参数
* 输 入: 无
* 返 回: 无
***********************************************************************/
void Get_SysConfig_Data(void)
{
eepByteIn(eepSysConfig);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -