UINT32 upg_check_exit_key(void) { UINT32 hkey,vkey; struct pan_key key_struct; if(key_get_key(&key_struct, 0)) { hkey = scan_code_to_msg_code(&key_struct); ap_hk_to_vk(0,hkey, &vkey); if(vkey == V_KEY_EXIT || vkey==V_KEY_MENU) return TRUE; } return FALSE; }
void power_switch(UINT32 mode) { unsigned long keycode; SYSTEM_DATA* sys_data; UINT32 vkey; UINT32 times = 0,display_type=0; date_time dt; UINT32 hh,mm,ss; char time_str[10]; struct pan_key key_struct; UINT32 timer; struct sf_panel_attr panel_attr; /*alfred.wu 1.0版本的MCU程序因为待机时间不能超过256小时*/ #ifdef MCUSTANDBY struct sf_panel_time time; date_time sRecentTime; UINT32 nDurationTime = 0; UINT32 nYear = 0; UINT32 nMonth = 0; UINT32 nDay = 0; UINT32 nHour = 0; UINT32 nMin = 0; UINT32 nSec = 0; struct sf_standby_param standby_param; /*Note: For the limited memory size of MCU, if using led panel, the maximum IR key num is 5 and for vfd panel the size is 2. */ struct sf_power_ir_key ir_key[] = \ { #ifdef RC04_A {0x007f, 0x1c}, /*RC04_A*/ #endif #ifdef RC09_A {0x00FD, 0x1A}, /*RC09_A*/ #endif #ifdef RC11_A {0x00ff, 0x54}, /*RC11_A*/ #endif #ifdef RC19_D {0x01fe, 0x00}, /*RC11_A*/ #endif #ifdef RC01_A_02 {0x807f, 0x0a}, /*RC01_A_02*/ #endif #ifdef ORDER_GZ1010001 {0x007f, 0x1c}, /*RC04_A*/ #else {0x007f, 0x0a}, /*RC01_A*/ #endif {0x01FE, 0x01}, /*REMOTE02420100*/ {0x06FB, 0x0E}, /*ALI_RCU_60_KEY*/ }; #endif sys_data = sys_data_get(); sys_data->bstandmode = 1; sys_data_save(1); system_state = SYS_STATE_POWER_OFF; /*Archer:The following process is unnessary when using mcu standby resolution.*/ #if 0 power_off_process(); power_off_process2(); #endif #ifndef MCUSTANDBY if(mode != 1) key_pan_display("off ", 4); key_pan_display_standby(1); key_pan_display_lock(0); api_standby_led_onoff(TRUE); #else #if 0 get_local_time(&dt); nDurationTime = api_get_recently_timer(); POWER_PRINTF("nDurationTime = 0x%x\n",nDurationTime); if(0 != nDurationTime) { sRecentTime.year = YEAR(nDurationTime); sRecentTime.month= MONTH(nDurationTime); sRecentTime.day= DAY(nDurationTime); sRecentTime.hour= HOUR(nDurationTime); sRecentTime.min= MIN(nDurationTime); sRecentTime.sec= SEC(nDurationTime); POWER_PRINTF("RecentTime:%d-%d-%d %d:%d:%d\n",sRecentTime.year,sRecentTime.month,\ sRecentTime.day, sRecentTime.hour,sRecentTime.min,sRecentTime.sec); get_time_offset(&dt,&sRecentTime,&nDay,&nHour,&nMin,&nSec); //standby_param.standby_time_sec = nHour*60*60+nMin*60; standby_param.standby_time_sec = 60; POWER_PRINTF("standby:hour:%d, minute:%d, total secs:%d\n",nHour,nMin, standby_param.standby_time_sec); //pan_set_standby_time((struct pan_device*)dev_get_by_id(HLD_DEV_TYPE_PAN,0),&sPanelTime); } else { POWER_PRINTF("no timer\n"); } #endif //pan_display(g_pan_dev, " ", 8);//albert.li del 2011.1.25 /*albert.li add 2011.1.25*/ get_local_time(&dt); time.hour = dt.hour; time.min= dt.min; time.sec = dt.sec; #ifndef FAKE_STANDBY sf_panel_clear(); reset_sf_panel_all_led(); /*albert.li add end*/ sf_panel_display_time(&time); sf_panel_term(); #else pan_io_control(g_pan_dev, PAN_DRIVER_GET_ATTRIBUTE, &panel_attr); if (panel_attr.type == SF_PANEL_TYPE_LED) { pan_display(g_pan_dev,"OFF ", 4); } else { pan_display(g_pan_dev,"STANDBY", 7); } #endif power_off_process(); //S5PanelStandby(g_pan_dev,(const)&sPanIRSpecialKey,2);//guop edit standby_param.ir_key_num = sizeof(ir_key)/sizeof(struct sf_power_ir_key); standby_param.ir_key_list = ir_key; standby_param.standby_time_sec = 0; #ifndef FAKE_STANDBY sf_power_down(&standby_param); #else //zhouxp fake standby { while (1) { ControlMsg_t msg; times++; times = times % 100; osal_delay(5000); vkey = V_KEY_NULL; if(key_get_key(&key_struct,0)) { keycode = scan_code_to_msg_code(&key_struct); ap_hk_to_vk(0, keycode, &vkey); } else keycode = PAN_KEY_INVALID; if(vkey == V_KEY_POWER) { power_on_process(); } ap_receive_msg( &msg, 10); libc_printf("got msg type=%d\n",msg.msgType); if(msg.msgType== CTRL_MSG_SUBTYPE_CMD_TIMER_WAKEUP) power_on_process(); } } #endif #endif #ifndef MCUSTANDBY if(1) /* Real Standby*//*alfred.wu ali的IC真待机处理流程在MCUSTANDBY后不会执行*/ { UINT32 cur_time, target_time; get_local_time(&dt); pan_close(g_pan_dev); timer = api_get_recently_timer(); // disable interrupt osal_interrupt_disable(); cur_time = (dt.sec & 0x3F ) | ((dt.min & 0x3F )<<6) | ((dt.hour & 0x1F )<<12) | ((dt.day & 0x1F)<<17) | ((dt.month & 0xF) << 22) | (((dt.year % 100) & 0x3F)<<26); sys_ic_enter_standby(timer, cur_time); // enable interrupt osal_interrupt_enable(); } while (1) { times++; times = times % 100; osal_delay(5000); if(times==0) { //get_cur_time(&hh,&mm,&ss); get_local_time(&dt); hh = dt.hour; mm = dt.min; if(display_type==0) sprintf(time_str,"%02d%02d ",hh,mm); else sprintf(time_str,"%02d.%02d",hh,mm); key_pan_display(time_str, 5); display_type++; display_type %= 2; } vkey = V_KEY_NULL; if(key_get_key(&key_struct,0)) { keycode = scan_code_to_msg_code(&key_struct); ap_hk_to_vk(0, keycode, &vkey); } else keycode = PAN_KEY_INVALID; if(vkey == V_KEY_POWER) { power_on_process(); } } #endif }