📄 debug.c
字号:
#include "types.h"
#include "debugDef.h"
#include "global.h"
#include "board.h"
#include "ms_reg.h"
#include "ms_rwreg.h"
#include "msosd.h"
#include "NVRam.h"
#include "i2c.h"
#include "misc.h"
#include "adjust.h"
#include "userPref.h"
#include "menudef.h"
#include "power.h"
#include "menufunc.h"
BYTE SIORxBuffer[5];
BYTE SIORxIndex=0;
BYTE ReSyncCounter;
BYTE CommandLength;
Bool AutoColorTempAdjust(void);
void printData(char *str, WORD value);
void printMsg(char * str);
void putSIOChar(unsigned char sendData);
//BYTE AOCAlign(void);
void ProcessCommand(void)
{
if (DebugCommand==Read_mStar)
{ DebugData=mStar_ReadByte(DebugAddress);
}
else if (DebugCommand==Write_mStar)
{ mStar_WriteByte(DebugAddress, DebugData);
}
else if (DebugCommand==Read_mStarADC)
{ mStar_WriteByte(REGBK, REGBANKADC);
DebugData=mStar_ReadByte(DebugAddress);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
else if (DebugCommand==Write_mStarADC)
{ mStar_WriteByte(REGBK, REGBANKADC);
mStar_WriteByte(DebugAddress, DebugData);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
else if (DebugCommand==Read_mStarTCON)
{ mStar_WriteByte(REGBK, REGBANKTCON);
DebugData=mStar_ReadByte(DebugAddress);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
else if (DebugCommand==Write_mStarTCON)
{ mStar_WriteByte(REGBK, REGBANKTCON);
mStar_WriteByte(DebugAddress, DebugData);
mStar_WriteByte(REGBK, REGBANKSCALER);
}
else if (DebugCommand==Read_mStarOSD)
{ DebugData=mStar_ReadOSDByte(DebugAddress);
}
else if (DebugCommand==Write_mStarOSD)
{ mStar_WriteOSDByte(DebugAddress, DebugData);
}
else if (DebugCommand==Read_NVRam)
{ NVRam_ReadByte(DebugAddress|((WORD)DebugAddressBank<<8), &DebugData);
}
else if (DebugCommand==Write_NVRam)
{ NVRam_WriteByte(DebugAddress|((WORD)DebugAddressBank<<8), DebugData);
}
else if (DebugCommand==Read_Device)
{ i2c_ReadTBL(DebugDeviceAddr, DebugAddress, &DebugData, 1);
}
else if (DebugCommand==Write_Device)
{ i2c_WriteTBL(DebugDeviceAddr, DebugAddress, &DebugData, 1);
}
else if(SIORxBuffer[0]==0x6E) //Add factory alignment condition by karl 20050501
{
AutoColorTempAdjust();
return;
}
if (!(DebugCommand&BIT0))
DebugData=((WORD)DebugData+DebugAddress)&0xFF;
Delay1ms(5);
putSIOChar(DebugData);
}
Bool GetCommand(void)
{ if (ReSyncCounter)
{if (SIORxIndex>2 && SIORxIndex==CommandLength)
{ Set_RxBusyFlag();
return TRUE;
}
if (ReSyncCounter<5)
{ Clr_RxBusyFlag();
SIORxIndex=0;
ReSyncCounter=0;
}
}
else if (SIORxIndex)
{ SIORxIndex=0;
}
return FALSE;
}
void DebugHandler(void)
{
if (GetCommand())
{ ProcessCommand();
SIORxIndex=0;
ReSyncCounter=0;
Clr_RxBusyFlag();
hw_ClrAmberLed();
}
}
void putSIOChar(unsigned char sendData)
{ if (!ES)
return;
while (TI);
SBUF=sendData;
ForceDelay1ms(2);
}
void printMsg(char *str)
{ char sendData;
sendData=Send_Msg;
while (sendData)//!='\0')
{ putSIOChar((unsigned char)sendData);
sendData=*(str++);
}
putSIOChar(0xd);
putSIOChar((char)'\n');
}
void printData(char *str, WORD value)
{ char sendData=Send_MsgValue;
#if 0
putSIOChar(Send_MsgValue);
putSIOChar(value>>8);
putSIOChar(value&0xFF);
#endif
while (sendData=*(str++))
{ if (sendData==(char)'%') // %
{ sendData=*(str++);
if (sendData==(char)'d' || sendData==(char)'x') // d
{ if (value)
{ Bool noneZero=FALSE;
WORD divider=10000;
char dispValue;
if (sendData==(char)'x')
divider=0x1000;
while (divider)
{ dispValue=value/divider;
value-=dispValue*divider;
if (dispValue)
noneZero=TRUE;
if (noneZero)
{ if (dispValue>9)
dispValue+=55;
else
dispValue+=0x30;
putSIOChar(dispValue);
}
if (sendData==(char)'d')
divider/=10;
else
divider/=0x10;
}
}
else
putSIOChar('0');
}
}
else
putSIOChar(sendData);
}
putSIOChar(0xd);
putSIOChar((char)'\n');
}
//Add Factory autoalignment communication by karl 20050501
Bool AutoColorTempAdjust(void)
{
BYTE *buf ;
BYTE AdjustValue = 0;
BYTE temp;
buf = SIORxBuffer;
temp = *buf^*(buf+1)^*(buf+2)^*(buf+3);
if(temp==*(buf+4) && *buf==0x6E)
{
AdjustValue = *(buf+3);
if(*(buf+1) == 0x01)
{
if(!*(buf+2))
{
// Set_AdjustFactoryMenuFlag();
// Set_FactoryModeFlag();
printMsg("Adj FacMenu");
}
else if(*(buf+2)==0x01)
{
// if(FactoryModeFlag && AdjustFactoryMenuFlag)
printMsg("Exit FacMenu");
// else
// printMsg("Had already exit FacMenu");
// Clr_FactoryModeFlag();
// Clr_AdjustFactoryMenuFlag();
//mStar_AdjustPatternColor(12);//Close Pattern by karl 2004/05/06
// Osd_Hide(); // Close osd by karl 2004/05/06
}
}
else if(*(buf+1) == 0x0A)
{
switch(*(buf+2))
{
case 0: // Save 9300
if(UserPrefColorTemp==CTEMP_9300K)
{
SaveFactory9300K();
printMsg("9300K SaveOK");
}
else
printMsg("Save 9300K ERR");
break;
case 1: // Save User
if(UserPrefColorTemp==CTEMP_USER)
{ SaveFactoryUser();
printMsg("CUser SaveOK");
}
else
printMsg("Save CUser ERR");
break;
case 2: // Save 6500
if(UserPrefColorTemp==CTEMP_6500K)
{
SaveFactory6500K();
printMsg("6500K SaveOK");
}
else
printMsg("Save 6500K ERR");
break;
case 3: // Set 9300K
UserPrefColorTemp=CTEMP_9300K;
SetFactoryColorTemp9300K();
printMsg("Adj 9300K");
break;
case 4: // Set User
UserPrefColorTemp=CTEMP_USER;
SetFactoryColorTempOrg();
printMsg("Adj User");
break;
case 5: // Set 6500K
UserPrefColorTemp=CTEMP_6500K;
SetFactoryColorTemp6500K();
printMsg("Adj 6500K");
break;
case 6: // Reset Color Temperature
break;
case 7: // 5400K
/* UserPrefColorTemp=CTEMP_5400K;
SetFactoryColorTemp5400K();
printMsg("Adj 5400K");
*/ break;
case 8: // Save 5400K
/* if(UserPrefColorTemp==CTEMP_5400K)
{
SaveFactory5400K();
printMsg("5400K SaveOK");
}
else
printMsg("Save 5400K ERR");
*/break;
default :
return FALSE;
}
}
else if(*(buf+1) == 0x40) // Get Data From PC
{
switch(*(buf+2))
{
case 0: // Contrast
if(AdjustValue>100)
{
printMsg("Out of the Contrast range ");
break;
}
temp=MaxContrastValue-MinContrastValue;
UserPrefContrast = MinContrastValue+((WORD)AdjustValue*temp)/100;
mStar_AdjustContrast(UserPrefContrast);
NVRam_WriteByte(nvrMonitorAddr(Contrast), UserPrefContrast);
temp=GetContrastValue();
printData("Color Contrast %d",temp);
break;
case 1: // Brightness
if(AdjustValue>100)//(AdjustValue>MaxBrightnessValue ||AdjustValue<MinBrightnessValue)
{
printMsg("Out of the Brightness range ");
break;
}
else if(AdjustValue==100)
{
printMsg("Max Brightness"); //terryadd for communicating with PC 041214
//break;
}
temp=MaxBrightnessValue -MinBrightnessValue;
UserPrefBrightness = MinBrightnessValue+((WORD)AdjustValue*temp)/100;
mStar_AdjustBrightness(UserPrefBrightness);
NVRam_WriteByte(nvrMonitorAddr(Brightness), UserPrefBrightness);
printData("Color Brightness %x", UserPrefBrightness);
break;
case 6: // R
if(UserPrefColorTemp==CTEMP_9300K)
UserPrefRedColor9300K=AdjustValue;
else if(UserPrefColorTemp==CTEMP_6500K)
UserPrefRedColor6500K=AdjustValue;
else if(UserPrefColorTemp==CTEMP_USER)
UserPrefRedColor=AdjustValue;
mStar_AdjustRedColor(AdjustValue);
printData("Red %x",AdjustValue);
break;
case 7: // G
if(UserPrefColorTemp==CTEMP_9300K)
UserPrefGreenColor9300K=AdjustValue;
else if(UserPrefColorTemp==CTEMP_6500K)
UserPrefGreenColor6500K=AdjustValue;
else if(UserPrefColorTemp==CTEMP_USER)
UserPrefGreenColor=AdjustValue;
mStar_AdjustGreenColor(AdjustValue);
printData("Green %x",AdjustValue);
break;
case 8: // B
if(UserPrefColorTemp==CTEMP_9300K)
UserPrefBlueColor9300K=AdjustValue;
else if(UserPrefColorTemp==CTEMP_6500K)
UserPrefBlueColor6500K=AdjustValue;
else if(UserPrefColorTemp==CTEMP_USER)
UserPrefBlueColor=AdjustValue;
mStar_AdjustBlueColor(AdjustValue);
printData("Blue %x",AdjustValue);
break;
case 14: // Contrast
if(AdjustValue>100)
{
printMsg("Out of the Contrast range ");
break;
}
temp=MaxContrastValue-MinContrastValue;
UserPrefContrast = MinContrastValue+((WORD)AdjustValue*temp)/100;
// SetColorTemp();
NVRam_WriteByte(nvrMonitorAddr(Contrast), UserPrefContrast);
temp=GetContrastValue();
printData("Contrast %d",temp);
break;
case 15: // Brightness
if(AdjustValue>100)//(AdjustValue>MaxBrightnessValue ||AdjustValue<MinBrightnessValue)
{
printMsg("Out of the Brightness range ");
break;
}
temp=MaxBrightnessValue -MinBrightnessValue;
UserPrefBrightness = MinBrightnessValue+((WORD)AdjustValue*temp)/100;
// SetColorTemp();
NVRam_WriteByte(nvrMonitorAddr(Brightness), UserPrefBrightness);
printData("Brightness %x", UserPrefBrightness);
break;
default :
return FALSE;
}
}
else if(*(buf+1) == 0x50) // Send Data To PC
{
switch(*(buf+2))
{
case 0: // Contrast
temp=GetContrastValue();
printData("%d",temp);
break;
case 1: // Brightness
temp=GetBrightnessValue();
printData("%d",temp);//UserPrefBrightness);
break;
case 6: // R
if(UserPrefColorTemp==CTEMP_9300K)
temp =UserPrefRedColor9300K;
else if(UserPrefColorTemp==CTEMP_6500K)
temp =UserPrefRedColor6500K;
else if(UserPrefColorTemp==CTEMP_USER)
temp =UserPrefRedColor;
printData("%x",temp);
break;
case 7: // G
if(UserPrefColorTemp==CTEMP_9300K)
temp =UserPrefGreenColor9300K;
else if(UserPrefColorTemp==CTEMP_6500K)
temp =UserPrefGreenColor6500K;
else if(UserPrefColorTemp==CTEMP_USER)
temp =UserPrefGreenColor;
printData("%x",temp);
break;
case 8: // B
if(UserPrefColorTemp==CTEMP_9300K)
temp =UserPrefBlueColor9300K;
else if(UserPrefColorTemp==CTEMP_6500K)
temp =UserPrefBlueColor6500K;
else if(UserPrefColorTemp==CTEMP_USER)
temp =UserPrefBlueColor;
printData("%x",temp);
break;
default :
return FALSE;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -