📄 joetoevb.c
字号:
/*++
Copyright (c) 2001 Sunplus Technology Co., Ltd.
Module Name:
JoeToEvb.c
Abstract:
Module related to user interface from turnkey V2.3 to EVB
Environment:
Keil C51 Compiler
Revision History:
02/12/2003 Joe created(reference turnkey V2.3)
--*/
//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "ui.h"
#include "main.h"
#include "uiflow.h"
#include "timer.h"
#include "JoeToEvb.h"
#include "lcdtv.h"
#include "main.h"
#include "playback.h"
#include "smccon.h"
#include "smcfunc.h"
#include "initio.h"
#include "sdramhw.h"
#include "l1_3a.h"
#include "exifvar.h"
#include "dosusr.h"
#include "quantdef.h"
#include "doslink.h"
#include "img533.h"
#include "usbmsdc2.h"
code unsigned char *MEM_FULL[]={
"Memory Full",
"M^moire plein",
"Speicher voll",
"Memoria piena",
"Memoria Llena",
"\x01\x58\x01\x59\x01\x50\x01\x51\x01\x32\x01\x33\x01\x38\x01\x39\x01\x20\x01\x21\x01\x30\x01\x31",//J
"\x01\xcc\x01\xcd\x01\xce\x01\xcf",
"\x01\xcc\x01\xcd\x01\x36\x01\x37"
};
code unsigned char *LOW_BATTERY[]={
"Low Battery",
"Batterie faible",
"Batterie schwach",
"Batteria scarica",
"Bateria baja",
"Low Battery",//J
"\x01\xc8\x01\xc9\x01\x84\x01\x85",
"\x01\xc8\x01\xc9\xee\xef"
};
code unsigned char *GOOD_BYE[]={
"Goodbye",
"Au revoir",
"Ciao",
"Adios",
"Arrivederci",
"Goodbye",//J
"\x01\xc4\x01\xc5\x01\xc6\x01\xc7",
"\x01\xc4\x01\xc5\x24\x25"
};
USHORT DeletLowBattEN=1;
sfr RamPage = 0x9B;
sfr MemStretch = 0x8E;
#if(TURNKEY_OPTION == 1)
sbit PWR_DET = P3^4;
sbit VIDEO_DET = P3^5;
/*#define PWR_DET (XBYTE[0x2040] & 0x04)
#define VIDEO_DET (XBYTE[0x2040] & 0x01)
#define FOCUS_DET (XBYTE[0x2040] & 0x20)*/
#endif
//=============================================================================
//Symbol
//=============================================================================
xdata UCHAR G_FlashCharging;
xdata USHORT G_HighPowerCount;
xdata USHORT G_MidPowerCount;
xdata USHORT G_LowPowerCount;
xdata ULONG G_AutoPowerOffCount;
xdata UCHAR G_FlashOnFlag;//wendy
xdata UCHAR G_Refresh_Status_OSD;
xdata UCHAR G_ColorAutoManu;
xdata UCHAR G_SensorPowerOnOff;
xdata UCHAR G_KeepPressPowerOn;
xdata USHORT G_FlashChargingCount;
xdata ULONG G_AutoTimeInSec;
xdata UCHAR G_StayInMenu;
xdata USHORT G_StayInMenuCount;
xdata USHORT G_USR_FileOrder;
xdata UCHAR G_DisplayMode;
xdata UCHAR G_Language;
xdata UCHAR G_FlashChargeFlag;//wendy@2004/9/8 ;0 flash off; 1 flash charging; 2, flash charged;
xdata USHORT G_FlashChargeCount;//wendy@2004/9/8
xdata UCHAR FmGpioState[8];
xdata UCHAR TvGpioState[6];
xdata UCHAR TGOeState[5];
extern bit STROBE; //andrew
extern xdata BYTE G_Card_Type;
extern xdata UCHAR AEtype;//patch4.5@jhyu@50HzTable
extern xdata UCHAR G_FlashStatus;
extern xdata USHORT G_usZoomOSDTimer;
extern xdata UCHAR G_ucStorData[];
extern xdata UCHAR G_Image_QTableIndex;//hx@2003.6.2 add for mito
#define G_ucDataBuffer G_ucStorData
////////////////////////////
code UCHAR GoodByeC[] =
{
0x01,0xF6,0x01,0xF7,0x01,0xF8,0x01,0xF9,0x00,
};
//#################################################################################################
//void UI_Save_NAND_UiParameters(void) USING_0
//void UI_Read_NAND_UiParameters(void) USING_0
//UCHAR L2_Suspend_UI(UCHAR Mode) USING_0
//void L2_Resume_UI(void) USING_0
//void UI_UIResumeDetectIntrEnable(UCHAR IntrEnable, UCHAR Edge) USING_0
//void UI_UsbDPlusPullHigh(UCHAR On) USING_0
//void UI_SetCPUPort(void) USING_0
//void UI_PowerOnOffDetect(UCHAR OnOff) USING_0
//void UI_LowPowerDetect(void) USING_0
//void UI_AutoPowerOffDetect(void) USING_0
//void UI_TVOutDetect(void) USING_0
//void UI_CardHotInsertionDetect(void) USING_0
//void UI_Buzzer(void) USING_0
//void UI_BusyLed(UCHAR OnOff) USING_0
//void UI_SelfTimerLed(UCHAR OnOff) USING_0
//void UI_FlashLight_Charge(void) USING_0
//void UI_FlashLight_Power(UCHAR On) USING_0
//void UI_FlashLight_Trigger(USHORT flashtime) USING_0
//void UI_SensorPowerOnOff(UCHAR On) USING_0
//void UI_SensorReset(void) USING_0
//void UI_CardPowerOnOff(UCHAR On) USING_0
//void UI_TimeOutCancelMenu(UCHAR timeout) USING_0
//void UI_ShowGoodBye(void) USING_0
//void DELAY_100ms(void) USING_0
//void UI_ShowLowBattery(void) USING_0
//void UI_ShowMemoryFull(void) USING_0
//void UI_GetFOSDSize(PUCHAR FOSD_H_num, PUCHAR FOSD_V_num) USING_0
//void CopySunplusIcon(void) USING_0
//void UI_GetCheckSum(UCHAR TotalBank, PUSHORT CheckSum) USING_0
//void UI_DispRTC(UCHAR x, UCHAR y, UCHAR attrib, UCHAR option) USING_0
//#################################################################################################
extern void INITIO_StorageInitialize(void);
extern UCHAR L1_ScaleImage(ULONG SrcAddr, USHORT SrcHsize, USHORT SrcVsize,ULONG DstAddr, USHORT DstHsize, USHORT DstVsize, ULONG TempAddr);
extern void ChangeTable(int index);//patch4.4@jhyu@50/60HzTable
extern void UI_DestroyMenu();
//=============================================================================
//UI_Save_NAND_UiParameters
//=============================================================================
void UI_Save_NAND_UiParameters(void) USING_0
{
USHORT i;
//Joe@2003.3.5 9:52 add for check sum begin
USHORT sum;
//Joe@2003.3.5 9:52 add for check sum end
for (i = 0; i < 512; i++)
{
G_ucDataBuffer[i] = 0;
}
G_ucDataBuffer[0] = 'S';
G_ucDataBuffer[1] = 'U';
G_ucDataBuffer[2] = 'N';
G_ucDataBuffer[3] = 'P';
G_ucDataBuffer[4] = 'L';
G_ucDataBuffer[5] = 'U';
G_ucDataBuffer[6] = 'S';
G_ucDataBuffer[7] = G_DATEINFO.Year;
G_ucDataBuffer[8] = G_DATEINFO.Month;
G_ucDataBuffer[9] = G_DATEINFO.Day;
G_ucDataBuffer[10] = G_DATEINFO.Hour;
G_ucDataBuffer[11] = G_DATEINFO.Minute;
G_ucDataBuffer[12] = G_DATEINFO.Second;
G_ucDataBuffer[13] = G_autoTime.min;
G_ucDataBuffer[14] = G_autoTime.sec;
G_ucDataBuffer[15] = G_DateStamp;
//G_ucDataBuffer[16] = G_Playback_Mode;
G_ucDataBuffer[17] = G_CameraOptions.Storage;
G_ucDataBuffer[18] = G_CameraOptions.ImageSize;
G_ucDataBuffer[19] = G_CameraOptions.Timeout;//wendy@2004/9/7
// G_ucDataBuffer[20] = G_CameraOptions.function;
G_ucDataBuffer[21] = G_CameraOptions.Manual;
G_ucDataBuffer[22] = G_CameraOptions.TVDispType;
// G_ucDataBuffer[23] = (UCHAR)(((G_UIStatus & UI_Status_Level2_Mask) >> 8) - 1);
G_ucDataBuffer[24] = G_AE_com_index;
G_ucDataBuffer[25] = G_MANUAL_WB_Flag;
G_ucDataBuffer[26] = G_MANUAL_SHARP_Flag;
G_ucDataBuffer[27] = AEtype;
G_ucDataBuffer[28] = G_Language;
//Joe@2003.3.5 9:52 add for check sum begin
sum = 0;
for (i = 0; i < 30; i++)
{
sum += G_ucDataBuffer[i];
}
sum ^= 0xffff;
G_ucDataBuffer[30] = sum;
G_ucDataBuffer[31] = sum >> 8;
//Joe@2003.3.5 9:52 add for check sum end
//patch5.04@Joe@2003.5.27 16:03 modify begin
//L2_DRAMSetStartAddr(K_SDRAM_CommonEndAddr,K_/SDRAM_NoPrefetch);
L2_DRAMSetStartAddr(K_SDRAM_ImagePlaybackGeneralBufAddr,K_SDRAM_NoPrefetch);
//patch5.04@Joe@2003.5.27 16:04 modify end
for (i = 0; i < 32; i += 2)
{
L2_DRAMWriteWord(G_ucDataBuffer[i],G_ucDataBuffer[i + 1]);
}
//patch5.04@Joe@2003.5.27 16:04 modify begin
//NANDF_AccessReserveBlock(K_NANDF_Reserve_DramToFlash,K_NANDF_UIStatus_BlockNumber,K_NANDF_UIStatus_PageNumber,K_NANDF_UIStatus_PageCount,K_SDRAM_CommonEndAddr);
NANDF_AccessReserveBlock(K_NANDF_Reserve_DramToFlash,K_NANDF_UIStatus_BlockNumber,K_NANDF_UIStatus_PageNumber,K_NANDF_UIStatus_PageCount,K_SDRAM_ImagePlaybackGeneralBufAddr);
//patch5.04@Joe@2003.5.27 16:04 modify end
}
//=============================================================================
//UI_Read_NAND_UiParameters
//=============================================================================
void UI_Read_NAND_UiParameters(void) USING_0
{
UCHAR i;
//Joe@2003.3.5 9:52 add for check sum begin
USHORT sum;
//Joe@2003.3.5 9:52 add for check sum end
//NANDF_AccessReserveBlock(K_NANDF_Reserve_FlashToDram,K_NANDF_UIStatus_BlockNumber,K_NANDF_UIStatus_PageNumber,K_NANDF_UIStatus_PageCount,K_SDRAM_CommonEndAddr/*K_SDRAM_TemporaryBufAddr*/);
//L2_DRAMSetStartAddr(K_SDRAM_CommonEndAddr,K_SDRAM_Prefetch);
NANDF_AccessReserveBlock(K_NANDF_Reserve_FlashToDram,K_NANDF_UIStatus_BlockNumber,K_NANDF_UIStatus_PageNumber,K_NANDF_UIStatus_PageCount,K_SDRAM_ImagePlaybackGeneralBufAddr/*K_SDRAM_TemporaryBufAddr*/);
L2_DRAMSetStartAddr(K_SDRAM_ImagePlaybackGeneralBufAddr,K_SDRAM_Prefetch);
for (i = 0; i < 32; i += 2)
{
L2_DRAMReadWord(&G_ucDataBuffer[i],&G_ucDataBuffer[i + 1]);
}
//Joe@2003.3.5 9:52 add for check sum begin
sum = 0;
for (i = 0; i < 30; i++)
{
sum += G_ucDataBuffer[i];
}
sum += G_ucDataBuffer[30];
sum += G_ucDataBuffer[31] << 8;
if (sum != 0xffff)
{
G_KeyState = K_UI_BUTTON_PREVIEW_SWITCH;
return; // check error
}
//Joe@2003.3.5 9:52 add for check sum end
if ((G_ucDataBuffer[0] == 'S') && (G_ucDataBuffer[1] == 'U') && (G_ucDataBuffer[2] == 'N') && (G_ucDataBuffer[3] == 'P')
&& (G_ucDataBuffer[4] == 'L') && (G_ucDataBuffer[5] == 'U') && (G_ucDataBuffer[6] == 'S'))
{
G_DATEINFO.Year = G_ucDataBuffer[7];
if ((G_DATEINFO.Year < 1) || (G_DATEINFO.Year > 100)) //Not in date range
{
//turnkey_patch2.2@ada@Fix RTC bugs begin
G_DATEINFO.Year = 1;
//G_DATEINFO.Year = 2;
//turnkey_patch2.2@ada@Fix RTC bugs end
G_DATEINFO.Month = 1;
G_DATEINFO.Day = 1;
G_DATEINFO.Hour = 0;
G_DATEINFO.Minute = 0;
G_DATEINFO.Second = 0;
}
else
{
G_DATEINFO.Month = G_ucDataBuffer[8];
G_DATEINFO.Day = G_ucDataBuffer[9];
G_DATEINFO.Hour = G_ucDataBuffer[10];
G_DATEINFO.Minute = G_ucDataBuffer[11];
G_DATEINFO.Second = G_ucDataBuffer[12];
}
G_autoTime.min =1 ;//G_ucDataBuffer[13];
G_autoTime.sec = 0;//G_ucDataBuffer[14];
//G_AutoTimeInSec = ((USHORT)G_autoTime.min) * 60 + (USHORT)G_autoTime.sec;
//turnkey_patch2.2@ada@fix the auto power time less than 30 sec bug begin
//turnkey_patch2.2@ada@fix the auto power time less than 30 sec bug begin
G_DateStamp = G_ucDataBuffer[15];
// G_Playback_Mode = G_ucDataBuffer[16];
G_CameraOptions.Storage = G_ucDataBuffer[17];
G_CameraOptions.ImageSize = G_ucDataBuffer[18];
if(G_CameraOptions.ImageSize>2)
G_CameraOptions.ImageSize=K_UIOPTION_IMGSIZE_HIGH;
G_CameraOptions.Timeout = G_ucDataBuffer[19];//wendy@2004/9/9
if (G_CameraOptions.ImageQty == K_UIOPTION_IMGQTY_HIGH)
{
G_Image_QTableIndex = 0x07;
}
else
{
G_Image_QTableIndex = 0x03;//wendy@2004/8/21
G_CameraOptions.ImageQty = K_UIOPTION_IMGQTY_STAND;
}
G_CameraOptions.function = G_ucDataBuffer[20];
G_CameraOptions.Manual = G_ucDataBuffer[21];
G_CameraOptions.TVDispType = G_ucDataBuffer[22];
/* if (G_ucDataBuffer[23] == K_UI_MODE_DSC_PREVIEW)//wendy
G_KeyState = K_UI_BUTTON_PREVIEW_SWITCH;
else
G_KeyState = K_UI_BUTTON_PLAY_SWITCH;//wendy
*/
G_AE_com_index = G_ucDataBuffer[24];
if(G_AE_com_index>4)
G_AE_com_index=2;
G_CameraOptions.EV=G_AE_com_index;//wendy@2004/9/10
G_MANUAL_WB_Flag = G_ucDataBuffer[25];
G_MANUAL_SHARP_Flag = G_ucDataBuffer[26];
AEtype = G_ucDataBuffer[27];
ChangeTable(AEtype);//patch4.5@jhyu@50/60HzTable
G_Language = G_ucDataBuffer[28];
if( G_Language==5)
{
FOSDtoDRAM(0x05, 1, K_SDRAM_CharFontBufAddr+K_SDRAM_CharFontBufSize/2);//wendy@30/8/2004
}
}
//Joe@2003.3.5 10:59 add begin
else
G_KeyState = K_UI_BUTTON_PREVIEW_SWITCH;//wendy
if( G_Language==5)
{
FOSDtoDRAM(0x05, 1, K_SDRAM_CharFontBufAddr+K_SDRAM_CharFontBufSize/2);//wendy@30/8/2004
}
//Joe@2003.3.5 10:59 add end
}
//=============================================================================
//UI_PowerOnOffDetect
//=============================================================================
void UI_PowerOnOffDetect(UCHAR OnOff) USING_0
{
UCHAR i;
#if(TURNKEY_OPTION == 1)
if (OnOff)
{
}
else
{
if (G_KeepPressPowerOn)
{
if (PWR_DET == 1)
{
DELAY_100ms();
if (PWR_DET == 1)
{
G_KeepPressPowerOn = 0;
}
}
}
if (G_KeepPressPowerOn == 0)
{
if (PWR_DET == 0)
{
for (i = 0; i < 5; i++)
{
DELAY_100ms();
}
if (PWR_DET == 0)
{
UI_FlashLight_Power(0);
UI_ShowGoodBye();
UI_Save_NAND_UiParameters();
UI_Buzzer();
DELAY_100ms();
UI_Buzzer();
L2_TurnOnOffDisplay(1);
DELAY_1s();
L2_TurnOnOffDisplay(0);
//DbgPrint("L2_TurnOnOffDisplay1=%bu\n",1);
while (PWR_DET == 0);
L2_SetGPIOBit(14,0); //Power off
while(1);
}
}
}
}
#else
//Joe@2003.2.25 14:56 add begin
L2_ConfigGPIOBit(14,1);
L2_ConfigGPIOBit(2,0);
//Joe@2003.2.25 14:56 add end
if (OnOff)
{
if ((XBYTE[0x2040] & 0x04) > 0)
{
DELAY_1s();
if ((XBYTE[0x2040] & 0x04) > 0)
{
L2_SetGPIOBit(14,1); //Go on the following program
G_KeepPressPowerOn = 1;
}
}
}
else
{
if (G_KeepPressPowerOn)
{
if ((XBYTE[0x2040] & 0x04) == 0)
{
DELAY_100ms();
if ((XBYTE[0x2040] & 0x04) == 0)
{
G_KeepPressPowerOn = 0;
}
}
}
if (G_KeepPressPowerOn == 0)
{
if ((XBYTE[0x2040] & 0x04) > 0)
{
for (i = 0; i < 5; i++)
{
DELAY_100ms();
}
if ((XBYTE[0x2040] & 0x04) > 0)
{
UI_ShowGoodBye();
UI_Save_NAND_UiParameters();
UI_Buzzer();
DELAY_100ms();
DELAY_100ms();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -