📄 fp_handler.c
字号:
/****************************************************************************************************
* Copyright (c) 2005 ZORAN Corporation, All Rights Reserved
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
* Created by William Lei 2005/12/25
*
* File: fp_handler.c
*
* Description:
* =========
* FP Event Handler
* VFD Display Refresher
* FP Key Scanner
****************************************************************************************************/
#include "Config.h" // Global Configuration - do not remove!
#include "include\sysdefs.h" // Global definition - do not remove!
/****************************************************************************************************
* INCLUDE FILES
****************************************************************************************************/
// Include C Standard
// Include project specific
#ifdef DEBUG_UI_TRACE
#undef IFTRACE
#define IFTRACE if (gTraceUI)
#include "Debug\DbgMain.h"
#endif //DEBUG_UI_TRACE
#ifndef DEBUG_UI_TRACE
#undef dbg_printf(sMsg)
#define dbg_printf(sMsg)
#undef dbgm_printf(sMsg, mode)
#define dbgm_printf(sMsg, mode)
#endif//DEBUG_UI_TRACE
#include "Kernel\ker_api.h"
#include "Kernel\EventDef.h"
#include "Playcore\Coremain\coremain.h"
#include "Playcore\Coremain\coregdef.h"
#include "Playcore\playmode\playmode.h"
#ifdef D_GINGER_I96
#include "Devices\FP\FP_api.h"
#else
#include "FP\FP_api.h"
#endif
#include "CoreAPI\DeviceManager.h"
#include "CoreAPI\CoreAPI.h"
#ifdef D_FP_DVP3040
#include "Playcore\timing\timing.h"
#endif
#include "UI_Manager\FP_Handler\fp_handler.h"
#include "UI_Manager\UI_Input\ui_input_fp.h"
#include "UI_Manager\FP_Handler\fp_handler_config.c"
/****************************************************************************************************
* DEFINITION: Private named constants
****************************************************************************************************/
/****************************************************************************************************
* DEFINITION: Private macros
****************************************************************************************************/
#define LOADING_BLINK_TIME_COUNT 7
#define READY_MEDIA_TYPE_BLINK_TIME_COUNT 10
#define NO_DISC_BAD_DISC_TIME_OUT 3
/****************************************************************************************************
* DEFINITION: Private typedefs
****************************************************************************************************/
/****************************************************************************************************
* DEFINITION: Public (global) variables
****************************************************************************************************/
#ifdef D_TEST
#include "Menu\menu_operation_def.h"
BYTE cur_grid = 1;
BYTE cur_seg = 1;
BYTE g_adjust_grid = 0;
//WORD cur_keycode;
WORD first_key = 0xffff;
#ifdef UPD_16311
BYTE MAX_GRID = 6;
BYTE MAX_SEG = 20;
#define VFD_BUFF_SIZE (3 * MAX_GRID)
#else
BYTE MAX_GRID = 7;
BYTE MAX_SEG = 15;
#define VFD_BUFF_SIZE (2 * MAX_GRID)
#endif
BYTE g_vfd_grid_buffer[48];
#else
#ifdef UPD_16311
#define VFD_BUFF_SIZE (3 * MAX_GRID)
#else
#define VFD_BUFF_SIZE (2 * MAX_GRID)
#endif
BYTE g_vfd_grid_buffer[VFD_BUFF_SIZE];
#endif
BYTE g_vfd_grid_count;
#define REPEAT_DELAY 5
static void VFD_Set_Str(LPCSTR Str);
static void VFD_Set_Char(char pos, unsigned int Letter);
#define VFD_SET_BIT(bit) (g_vfd_grid_buffer[(bit)>>8] |= (BYTE)((bit) & 0x00FF))
#define VFD_CLEAR_BIT(bit) (g_vfd_grid_buffer[(bit)>>8] &= (~(BYTE)((bit) & 0x00FF)))
/****************************************************************************************************
* DEFINITION: Private (static) variables
****************************************************************************************************/
/****************************************************************************************************
* DECLARATION: Private (static) functions
****************************************************************************************************/
static void _DisplayUpdateHandler(void);
void _KeyScanHandler(void);
static UINT8 __RAMTYPE spin_state = 0;
static UINT8 __RAMTYPE spin_speed = 0;
//static int __RAMTYPE chapter_bak = 1;
static UINT8 __RAMTYPE load_blink=0;
#ifdef D_FP_DVP3040
static UINT8 __RAMTYPE loading_blink_time = LOADING_BLINK_TIME_COUNT;
static UINT8 __RAMTYPE ready_blink_time = READY_MEDIA_TYPE_BLINK_TIME_COUNT;
static UINT8 __RAMTYPE no_disc_bad_disc_timer = NO_DISC_BAD_DISC_TIME_OUT;
#endif
/****************************************************************************************************
* DEFINITION: Public functions
****************************************************************************************************/
#if VFD_S_NUM
static void VFD_Set_S_Total(void)
{
CHAR i, j;
for (i = 0; i < VFD_S_NUM; i++)
for (j = 0; j < VFD_S_LIGHT; j++)
VFD_SET_BIT(VFD_S_Rotate[i][j]);
}
static void VFD_Set_S_Single(BYTE num, BYTE dir)
{
CHAR i;
if (!dir)
num = VFD_S_NUM -1 - num;
for (i = 0; i < VFD_S_LIGHT; i++)
VFD_SET_BIT(VFD_S_Rotate[num][i]);
}
#endif
/**********************************************************************************
* Name :
*
* Purpose :
*
* Input :
*
* Return Value :
*
* Description :
*
* Comments :
*
**********************************************************************************/
void _KeyScanHandler(void)
{
UINT16 i;
BYTE *key_scan,Byte_Num;
static WORD __RAMTYPE LastFPKey= -1,__RAMTYPE Fp_KeyCode=0;
static BYTE repeat=0;
#ifdef D_TEST
BYTE key_count;
key_count = 0;
#endif
Byte_Num = VFD_ReadKeyScan( &key_scan );
for (i=0; i<Byte_Num; i++)
{
if (key_scan[i])
{
#ifdef D_TEST
BYTE j;
for (j = 0; j < 8; j++)
if (key_scan[i] & (1 << j))
key_count++;
#endif
Fp_KeyCode = key_scan[i] | (i<<8);
}
}
if (LastFPKey == Fp_KeyCode)
{
/*Not send eject or power key again if it's not released*/
if ( UI_CheckIfFPEjectKey( Fp_KeyCode ) )
Fp_KeyCode = 0;
else
{
repeat = (repeat+1)%REPEAT_DELAY;
if (repeat != 0)
Fp_KeyCode = 0;
}
}
else
{
repeat = 0;
LastFPKey = Fp_KeyCode;
}
#ifdef D_TEST
if ((Fp_KeyCode!=0) && ((Fp_KeyCode&0xff)!=0xFF))
{
// extern void ui_tmp_string(wchar_t *str);
// extern char g_ui_tmp_msg_cnt;
printf("\nKey code1 : 0x%08li\n", Fp_KeyCode);
if (key_count > 1)
{
g_adjust_grid = !g_adjust_grid;
if (g_adjust_grid)
{
MS_SendOp(MS_OP_MSG_SYS_ADJUST_GRID, MAX_GRID);
}
else
{
MS_SendOp(MS_OP_MSG_SYS_CLEAR, 0);
}
return;
}
if (g_adjust_grid)
{
MAX_GRID++;
#ifdef UPD_16311
if (MAX_GRID > 16)
MAX_GRID = 8;
MAX_SEG = 28 - MAX_GRID;
#else
if (MAX_GRID > 11)
MAX_GRID = 4;
MAX_SEG = 22 - MAX_GRID;
#endif
g_vfd_grid_count = MAX_GRID;
first_key = 0xffff;
MS_SendOp(MS_OP_MSG_SYS_ADJUST_GRID, MAX_GRID);
}
if (first_key == 0xffff)
{
first_key = Fp_KeyCode;
cur_grid = 1;
cur_seg = 0;
}
if (first_key == Fp_KeyCode)
{
if (cur_grid > MAX_GRID)
cur_grid = 1;
if (cur_seg >= MAX_SEG)
{
cur_grid++;
if (cur_grid > MAX_GRID)
cur_grid = 1;
cur_seg = 1;
}
else
cur_seg++;
}
else
{
if (cur_seg <= 1)
{
if (cur_grid <= 1)
{
cur_seg = MAX_SEG;
cur_grid = MAX_GRID;
}
else
{
cur_grid--;
cur_seg = MAX_SEG;
}
}
else
{
cur_seg--;
}
}
if (!g_adjust_grid)
MS_SendOp(MS_OP_MSG_SYS_TEST, Fp_KeyCode);
}
for (i = 0; i< VFD_BUFF_SIZE; i++)
g_vfd_grid_buffer[i] = 0xff;
load_blink = (load_blink+1)%6;
if (load_blink <3)
#ifdef UPD_16311
g_vfd_grid_buffer[(cur_seg-1)/8 + (cur_grid - 1)*3] &= (~(0x0001<<((cur_seg-1)%8)));
#else
g_vfd_grid_buffer[(cur_seg-1)/8 + (cur_grid - 1)*2] &= (~(0x0001<<((cur_seg-1)%8)));
#endif
VFD_Refresh_Display(g_vfd_grid_buffer);
return;
#endif
if ((Fp_KeyCode!=0) && ((Fp_KeyCode&0xff)!=0xFF))
{
send_fp_event(Fp_KeyCode);
}
}
#ifdef EXTERNAL_KARAOKE
extern BYTE gc_Karaoke_mode;
#endif
extern enum KARAOKE_MODE_SETTING;
/**********************************************************************************
* Name :
*
* Purpose :
*
* Input :
*
* Return Value :
*
* Description :
*
* Comments :
*
**********************************************************************************/
static void _DisplayUpdateHandler(void)
{
#if 1
// Need to be split to separated files later.
// BYTE g_vfd_grid_buffer[VFD_BUFF_SIZE];
BYTE i;
unsigned long time=0;// total_time=0;
WORD hour=0, min=0, sec=0;
WORD current_chapter=0, total_chapters=0,current_title=0;
DEVICE_MEDIA_TYPE eMediaType;
#ifdef D_TEST
return;
#endif
for (i = 0; i<VFD_BUFF_SIZE; i++)
g_vfd_grid_buffer[i] = 0;
#ifdef D_FP_DVP3040
if (DeviceManager_GetDeviceState(DEVICE_DISC) != DEVICE_LOADING)//(MST_LOADING != gcs.mstate)
{
//load_blink = 0;
loading_blink_time = 0;
}
else
no_disc_bad_disc_timer = NO_DISC_BAD_DISC_TIME_OUT;
if (DeviceManager_GetDeviceState(DEVICE_DISC) != DEVICE_READY)//(MST_DISC_READY != gcs.mstate)
{
ready_blink_time = READY_MEDIA_TYPE_BLINK_TIME_COUNT;
}
#endif
switch(gcs.mstate)
{
#ifdef D_GINGER_I96
case MST_POWER_DOWN:
VFD_Set_Str(VFD_Off_Str);
break;
#endif
#ifndef D_GINGER_I96
case MST_POWER_ON:
//Set_String(" -ON-\0", g_vfd_grid_buffer);
#endif
default:
{
WORD wDeviceID;
wDeviceID = DeviceManager_GetCurrentDevice();
//No Device Constructed!if no device constructed, from fp, we treat it DISC
if(INVALID_DEVICEID == wDeviceID)
wDeviceID = DEVICE_DISC;
switch(DeviceManager_GetDeviceState(wDeviceID))
{
case DEVICE_LOADING:
#ifdef D_FP_DVP3040
if(loading_blink_time>0)
{
loading_blink_time--;
VFD_Set_Str(VFD_Philips_Str);
break;
}
#endif
load_blink = (load_blink+1)%6;
if (load_blink <3)
VFD_Set_Str(VFD_Load_Str);
else
VFD_Set_Str(VFD_Off_Str);
#if VFD_S_NUM
spin_speed = (spin_speed + 1)%2;
if (spin_speed == 0)
spin_state = (spin_state + 1)%VFD_S_NUM;
VFD_Set_S_Single(spin_state, 1);
#endif
break;
case DEVICE_TRAY_OPENING:
case DEVICE_TRAY_OPENED:
VFD_Set_Str(VFD_Open_Str);
break;
case DEVICE_TRAY_CLOSING:
VFD_Set_Str(VFD_Close_Str);
break;
case DEVICE_UNKNOWN:
if (MEDIA_TYPE_UNKNOWN == DeviceManager_GetMediaType(wDeviceID))
{
VFD_Set_Str(VFD_Baddisc_Str);
}
break;
case DEVICE_IDENTIFIED:
if( CoreAPI_IsCDUpdateDisc())
{
VFD_Set_Str(VFD_Cdupdate_Str);
VFD_Refresh_Display(g_vfd_grid_buffer);
return;
}
load_blink = (load_blink+1)%6;
if (load_blink <3)
VFD_Set_Str(VFD_Load_Str);
else
VFD_Set_Str(VFD_Off_Str);
#if VFD_S_NUM
VFD_Set_S_Total();
#endif
break;
case DEVICE_NO_DEVICE:
#ifdef D_FP_DVP3040
if (no_disc_bad_disc_timer)
no_disc_bad_disc_timer--;
else
#endif
{
if(MEDIA_TYPE_NOMEDIA == DeviceManager_GetMediaType(wDeviceID))
VFD_Set_Str(VFD_Nodisc_Str);
else if( CoreAPI_IsCDUpdateDisc())
VFD_Set_Str(VFD_Cdupdate_Str);
}
break;
case DEVICE_READY:
{
if (!CoreAPI_IsMediaReady())
return;
if( CoreAPI_IsCDUpdateDisc())
{
VFD_Set_Str(VFD_Cdupdate_Str);
VFD_Refresh_Display(g_vfd_grid_buffer);
return;
}
switch(CoreAPI_GetCurrentMediaType())
{
case MEDIA_TYPE_CLIPS:
#ifdef D_FP_DVP3040
if (ready_blink_time > 0 && DeviceManager_IsDiscCDDA())
{
ready_blink_time--;
VFD_Set_Str(VFD_CDDA_Str);
VFD_Refresh_Display(g_vfd_grid_buffer);
return;
}
#endif
if ((/* IS_DISC_DATA_ROM &&*/ (eClipType_CDDA == SI_CLIPS_CURR_CLIP_INFO.eType)))
VFD_SET_BIT(VFD_CD);
if ( IS_CLIPS_TYPE_MP3 ) //BT032003
VFD_SET_BIT(VFD_MP3);
break;
case MEDIA_TYPE_VCD:
#ifdef D_FP_DVP3040
if (ready_blink_time > 0)
{
ready_blink_time--;
VFD_Set_Str(VFD_VCD_Str);
VFD_Refresh_Display(g_vfd_grid_buffer);
return;
}
#endif
VFD_SET_BIT(VFD_VCD);
VFD_SET_BIT(VFD_V);
if(SI_SVCD_IS_PBC_ON)
VFD_SET_BIT(VFD_PBC);
break;
case MEDIA_TYPE_SVCD:
#ifdef D_FP_DVP3040
if (ready_blink_time > 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -