/*----------------------------------------------------------------------------*/ void deal_rtc(void) { u8 key; u8 rtc_set_cnt; close_alarm(); while (1) { key = app_get_msg(); #if 0 if (alm_on_flag) { key = alm_msg_convert(key); } #endif switch (key) { case MSG_NEXT_WORKMODE: case MSG_REC_KEY: case MSG_REC_PLAY: break; case MSG_CHANGE_WORK_MODE: return; case MSG_MUSIC_NEW_DEVICE_IN: //有新设备接入 break; case MSG_ALM_SOURCE: //if(rtc_mode_setting == ALARM_SETTING) { #if 1 if(alarm.sw==0)break; if(rtc_mode_setting != ALARM_SETTING){ alarm.bSource =0; alm_coordinate=3; rtc_mode_setting = ALARM_SETTING; disp_port(MENU_ALM_SET); } else{ rtc_mode_setting = RTC_DISPLAY; disp_port(MENU_RTC); break; } #if 0 if(alm_coordinate==3){ rtc_mode_setting = RTC_DISPLAY; disp_port(MENU_RTC); break; } else{ alarm.bSource =0; alm_coordinate=3;; } #endif #else alarm.bSource++; if(alarm.bSource>3){ alarm.bSource =0; } #endif } rtc_set_cnt=0; break; case MSG_ALM_SETUP: if(rtc_mode_setting == ALARM_SETTING){ alm_coordinate++; if(alm_coordinate>2){ rtc_mode_setting = RTC_DISPLAY; } } else{ snooze_init(); alm_coordinate = 1; alarm.sw=1; alarm.bSource =0; rtc_mode_setting = ALARM_SETTING; write_next_alm_sec(); save_alarm_info(); } rtc_set_cnt=0; disp_port(MENU_RTC); break; case MSG_RTC_SETTING: if (rtc_mode_setting == RTC_SETTING) { rtc_mode_setting = RTC_DISPLAY; } else{ rtc_coordinate = 3; rtc_mode_setting = RTC_SETTING; } rtc_set_cnt=0; disp_port(MENU_RTC); break; case MSG_RTC_NEXT: if (rtc_mode_setting == RTC_SETTING) { rtc_coordinate++; if (rtc_coordinate > 4) { rtc_mode_setting = RTC_DISPLAY; } rtc_set_cnt=0; disp_port(MENU_RTC); } break; #if 0 case MSG_RTC_PREV: if (rtc_mode_setting == RTC_SETTING) { rtc_coordinate--; if (rtc_coordinate == 255) { rtc_coordinate = 5; } rtc_set_cnt=0; disp_port(MENU_RTC); } if (rtc_mode_setting == ALARM_SETTING) { alm_coordinate--; if (alm_coordinate == 255) { //if(alarm[0].sw) //{ // alm_coordinate = 9; //} //else //{ alm_coordinate = 2; //} } disp_port(MENU_ALM_SET); } break; #endif case MSG_RTC_PLUS: case MSG_RTC_PLUS_HOLD: if (rtc_mode_setting == RTC_SETTING) { rtc_set_cnt=0; curr_time_plus(); write_rtc(&curr_time); write_next_alm_sec(); disp_port(MENU_RTC); } if (rtc_mode_setting == ALARM_SETTING) { rtc_set_cnt=0; alm_time_plus(); save_alarm_info(); write_next_alm_sec(); if(alm_coordinate==3){ disp_port(MENU_ALM_SET); } else{ disp_port(MENU_RTC); } } break; case MSG_RTC_MINUS: case MSG_RTC_MINUS_HOLD: if (rtc_mode_setting == RTC_SETTING) { rtc_set_cnt=0; curr_time_minus(); write_rtc(&curr_time); write_next_alm_sec(); disp_port(MENU_RTC); } if (rtc_mode_setting == ALARM_SETTING) { rtc_set_cnt=0; alm_time_minus(); save_alarm_info(); write_next_alm_sec(); if(alm_coordinate==3){ disp_port(MENU_ALM_SET); } else{ disp_port(MENU_RTC); } } break; case MSG_HALF_SECOND: snooze_hdlr(); if (main_menu_conter < SUB_MENU_TIME*4) { main_menu_conter++; } else if (cur_menu != main_menu) { rtc_mode_setting = RTC_DISPLAY; read_rtc(&curr_time); chk_date_err(); disp_port(MENU_RTC); } if ((rtc_mode_setting == RTC_SETTING)||(rtc_mode_setting == ALARM_SETTING)) rtc_set_cnt++; if ((rtc_set_cnt==8)&&((rtc_mode_setting == RTC_SETTING)||(rtc_mode_setting == ALARM_SETTING))) { rtc_set_cnt=0; rtc_mode_setting = RTC_DISPLAY; read_rtc(&curr_time); chk_date_err(); disp_port(MENU_RTC); } if (cur_menu == MENU_RTC) { read_rtc(&curr_time); chk_date_err(); disp_port(MENU_RTC); } break; case MSG_ALM_ON: write_next_alm_sec(); alm_on_flag = 1; alrm_vol_bakup=sys_main_vol; sys_main_vol = 10; alm_recover_vol_enable=1; if(alarm.bSource== 0){ work_mode = MUSIC_MODE; } else if(alarm.bSource== 1){ work_mode = MUSIC_MODE; } else if(alarm.bSource== 2){ work_mode = FM_RADIO_MODE; } else{ work_mode = AUX_MODE; } disp_port(MENU_RTC); return; break; default: ap_handle_hotkey(key); break; } } }
void deal_rtc(void) { u8 key; #ifdef USE_RTC_YEAR_FUNCTION bool date_show_active=0; #endif #ifdef TURN_OFF_PLAY_STATUS_LED_IN_RTC_MODE set_play_flash(LED_FLASH_STOP); #endif #ifdef PWR_OFF_IN_RTC_MODE_AFTER_30_MIN #if defined(USE_TIMER_POWER_OFF_FUNC) timer_pwr_idx=3; timer_disp=30; #endif #endif while (1) { key = get_msg(); switch (key) { #if defined(K820_LHD_820_V001) case INFO_EQ_DOWN| KEY_SHORT_UP : if(rtc_set==0){ rtc_mode = RTC_SET_MODE; rtc_set=3; } else if (rtc_set==4) { rtc_set=0; rtc_mode = RTC_PLAY_MODE; } else if(rtc_set==3){ rtc_set=4; } Disp_Con(DISP_RTC); break; #endif #if defined(K686_ZhengYang_686_V001)||defined(USE_MODE_LONG_FOR_RTC_SETTING) case INFO_MODE | KEY_LONG: //4RTC闹钟设置模式 #elif defined(CUSTOM_KEY_LONG_FOR_RTC_HOTKEY) case INFO_CUS_KEY_1 | KEY_LONG: #elif defined(USE_PLAY_LONG_FOR_RTC_SETTING) case INFO_PLAY | KEY_LONG: #elif defined(USE_PREV_LONG_FOR_RTC_SETTING) case INFO_PREV_FIL | KEY_LONG: //4RTC闹钟设置模式 #elif defined(USE_PLAY_MODE_LONG_FOR_RTC_SETTING) case INFO_PLAY_MODE | KEY_LONG: //4RTC闹钟设置模式 #elif defined(MINI_DIGIT_BOX) case INFO_1|KEY_LONG: #elif defined(RTC_MODE_HOT_KEY_ENABLE) case INFO_RTC_MOD | KEY_SHORT_UP: #else case INFO_PLAY | KEY_LONG: //4RTC闹钟设置模式 #endif #if defined(RTC_SETTING_OP_TIMER_ENABLE) op_timer=0; #endif #ifdef INDEPENDENT_KEY_ADJ_TIME if (rtc_mode != ALM_UP_MODE) { if (rtc_mode==RTC_PLAY_MODE) { #ifdef USE_RTC_TIME_ONLY rtc_set=3; #else rtc_set=0; #endif rtc_mode = RTC_SET_MODE; } else if(rtc_mode==RTC_SET_MODE){ goto __TIME_ADJ_POS; } else if (rtc_mode == ALM_SET_MODE) { goto __TIME_ADJ_POS; } Disp_Con(DISP_RTC); } #elif defined(NEW_RTC_SETTING_CTRL) if (rtc_mode != ALM_UP_MODE) { if(new_rtc_setting==0){ rtc_mode=RTC_SET_MODE; rtc_set=3; } else if(new_rtc_setting==1){ rtc_mode=RTC_SET_MODE; rtc_set=0; } else if(new_rtc_setting==2){ rtc_mode=RTC_SET_MODE; rtc_set=1; } else if(new_rtc_setting==3){ rtc_mode=ALM_SET_MODE; alm_set=1; } else if(new_rtc_setting==4){ rtc_mode=ALM_SET_MODE; alm_set=0; } Disp_Con(DISP_RTC); } #else #ifdef K3031_AP_668_V001 if (rtc_mode==ALM_SET_MODE){ if(alm_set==0){ alm_set=1; break; } } #endif #if defined(K820_LHD_820_V001) break; #endif if (rtc_mode != ALM_UP_MODE) { #if defined(MINI_DIGIT_BOX) if (rtc_mode==RTC_SET_MODE) { rtc_mode = RTC_PLAY_MODE; } else{ rtc_mode=RTC_SET_MODE; } op_timer=0; #else rtc_mode++; #ifdef USE_RTC_ALARM_FUNCTION if (rtc_mode>ALM_SET_MODE) { rtc_mode = RTC_PLAY_MODE; } #else if (rtc_mode>RTC_SET_MODE) { rtc_mode = RTC_PLAY_MODE; } #endif #endif #ifdef USE_RTC_TIME_ONLY rtc_set=3; #else rtc_set=0; #endif alm_set=0; Disp_Con(DISP_RTC); } #endif break; #if defined(MINI_DIGIT_BOX) case INFO_6|KEY_LONG: if (rtc_mode != ALM_UP_MODE) { //rtc_mode++; if (rtc_mode==ALM_SET_MODE) { rtc_mode = RTC_PLAY_MODE; } else{ rtc_mode = ALM_SET_MODE; alm_set=1; } } op_timer=0; Disp_Con(DISP_RTC); break; case INFO_2|KEY_LONG: rtc_mode = ALM_SET_MODE; alm_set=0; alm_sw =~alm_sw; Disp_Con(DISP_RTC); op_timer=0; break; #endif #ifdef INDEPENDENT_KEY_ADJ_TIME #ifdef RTC_MODE_HOT_KEY_ENABLE case INFO_RTC_MOD | KEY_LONG: #else case INFO_PLAY | KEY_SHORT_UP: #endif if (rtc_mode==RTC_PLAY_MODE) { alm_set=0; rtc_mode = ALM_SET_MODE; } Disp_Con(DISP_RTC); break; #elif defined(USE_NEXT_LONG_FOR_ALM_SETTING) case INFO_NEXT_FIL | KEY_LONG: //4RTC闹钟设置模式 if (rtc_mode==RTC_PLAY_MODE) { alm_set=0; rtc_mode = ALM_SET_MODE; } Disp_Con(DISP_RTC); break; #endif #if defined(K686_ZhengYang_686_V001)||defined(USE_POWER_KEY_TO_ADJ_HOUR_AND_MIN) case INFO_POWER| KEY_SHORT_UP: #elif defined(USE_MODE_LONG_FOR_RTC_SETTING) case INFO_MODE| KEY_SHORT_UP: if(rtc_mode == RTC_PLAY_MODE){ goto _HOT_KEY_HDLR; } #elif defined(CUSTOM_KEY_LONG_FOR_RTC_HOTKEY) case INFO_CUS_KEY_1 | KEY_SHORT_UP: #elif defined(MINI_DIGIT_BOX) case INFO_1|KEY_SHORT_UP: case INFO_6|KEY_SHORT_UP: op_timer=0; #else case INFO_PLAY| KEY_SHORT_UP: #endif #if defined(RTC_SETTING_OP_TIMER_ENABLE) op_timer=0; #endif #if defined(NEW_RTC_SETTING_CTRL) if ((rtc_mode != ALM_UP_MODE)&&(rtc_mode !=RTC_PLAY_MODE)) { if(new_rtc_setting==0){ rtc_mode=RTC_SET_MODE; rtc_set++; if(rtc_set>4){ rtc_mode=RTC_PLAY_MODE; } } else if(new_rtc_setting==1){ rtc_mode=RTC_PLAY_MODE; Disp_Con(DISP_RTC_DATE); break; } else if(new_rtc_setting==2){ rtc_mode=RTC_SET_MODE; rtc_set++; if(rtc_set>2){ Disp_Con(DISP_RTC_DATE); rtc_mode=RTC_PLAY_MODE; break; } } else if(new_rtc_setting==3){ rtc_mode=ALM_SET_MODE; alm_set++; if(alm_set>2){ Disp_Con(DISP_RTC_DATE); rtc_mode=RTC_PLAY_MODE; break; } } else if(new_rtc_setting==4){ Disp_Con(DISP_RTC_DATE); rtc_mode=RTC_PLAY_MODE; alm_set=0; break; } Disp_Con(DISP_RTC); } #else #if defined(K820_LHD_820_V001) break; #endif __TIME_ADJ_POS: if (rtc_mode == RTC_SET_MODE) { rtc_set++; if (rtc_set>4) { #ifdef USE_RTC_TIME_ONLY rtc_set=3; #else rtc_set=0; #endif #ifdef RTC_SETTING_NO_CYC rtc_mode = RTC_PLAY_MODE; #endif } Disp_Con(DISP_RTC); } else if (rtc_mode == ALM_SET_MODE) { #ifdef K3031_AP_668_V001 if(alm_set==0)break; #endif alm_set++; #if defined(ALARM_SEL_SOURCE) if (alm_set>3) #elif defined(ALARM_ADJ_VOL) if (alm_set>3) #else if (alm_set>2) #endif { #ifdef K3031_AP_668_V001 alm_set=1; #else alm_set=0; #endif #ifdef RTC_SETTING_NO_CYC rtc_mode = RTC_PLAY_MODE; #endif } Disp_Con(DISP_RTC); } #endif break; #ifdef ADJ_TIME_USE_VOL_KEY case INFO_VOL_PLUS: #ifdef RTC_ADJ_VOL if (rtc_mode==RTC_PLAY_MODE) goto _HOT_KEY_HDLR; #endif break; case INFO_VOL_PLUS | KEY_SHORT_UP: case INFO_VOL_PLUS | KEY_HOLD : //4RTC 设置模式下的时间选择(增加) #else case INFO_NEXT_FIL | KEY_SHORT_UP: case INFO_NEXT_FIL | KEY_HOLD: #endif #ifdef USE_NEXT_PREV_KEY_HOLD_FUNC_SKIP if(key==(INFO_NEXT_FIL | KEY_HOLD)) break; #endif #if defined(MINI_DIGIT_BOX)||defined(RTC_SETTING_OP_TIMER_ENABLE) op_timer=0; #endif if (rtc_mode==RTC_SET_MODE) { curr_date_plus(); set_date_sec(); fond_alm_clk(); Disp_Con(DISP_RTC); } else if (rtc_mode==ALM_SET_MODE) { #ifdef ALARM_SEL_SOURCE if (alm_set==3){ alm_source++; if(alm_source>ALM_SOUR_FM){ alm_source=ALM_SOUR_USB; } Disp_Con(DISP_RTC); break; } #elif defined(ALARM_ADJ_VOL) if(alm_set==3){ my_music_vol++; clear_super_mute_lock(); if (my_music_vol > MAX_VOL) { my_music_vol = MAX_VOL; } } #endif alm_time_plus(); set_alm_sec(); Disp_Con(DISP_RTC); } else { #ifdef RTC_ADJ_VOL goto _HOT_KEY_HDLR; #endif #ifdef NEW_RTC_SETTING_CTRL new_rtc_setting++; if(new_rtc_setting>4){ new_rtc_setting=0; } if(new_rtc_setting==0){ Disp_Con(DISP_RTC); } else{ Disp_Con(DISP_RTC_DATE); } #else #ifdef USE_RTC_YEAR_FUNCTION date_show_active = 1; Disp_Con(DISP_RTC_DATE); #endif #endif } break; #ifdef ADJ_TIME_USE_VOL_KEY case INFO_VOL_MINUS: #ifdef RTC_ADJ_VOL if (rtc_mode==RTC_PLAY_MODE) goto _HOT_KEY_HDLR; #endif break; case INFO_VOL_MINUS| KEY_SHORT_UP: case INFO_VOL_MINUS | KEY_HOLD : //4RTC 设置模式下的时间选择(减少) #else case INFO_PREV_FIL | KEY_SHORT_UP: case INFO_PREV_FIL | KEY_HOLD: #endif #ifdef USE_NEXT_PREV_KEY_HOLD_FUNC_SKIP if(key==(INFO_PREV_FIL | KEY_HOLD)) break; #endif #if defined(MINI_DIGIT_BOX)||defined(RTC_SETTING_OP_TIMER_ENABLE) op_timer=0; #endif if (rtc_mode==RTC_SET_MODE) { curr_date_minus(); set_date_sec(); fond_alm_clk(); Disp_Con(DISP_RTC); } else if (rtc_mode==ALM_SET_MODE) { #ifdef ALARM_SEL_SOURCE if (alm_set==3){ if(alm_source--==ALM_SOUR_USB){ alm_source=ALM_SOUR_FM; } Disp_Con(DISP_RTC); break; } #elif defined(ALARM_ADJ_VOL) if(alm_set==3){ if (my_music_vol) my_music_vol--; clear_super_mute_lock(); if(my_music_vol == MIN_VOL){ Mute_Ext_PA(MUTE); } } #endif alm_time_minus(); set_alm_sec(); Disp_Con(DISP_RTC); } else { #ifdef NEW_RTC_SETTING_CTRL new_rtc_setting--; if(new_rtc_setting>4){ new_rtc_setting=4; } if(new_rtc_setting==0){ Disp_Con(DISP_RTC); } else{ Disp_Con(DISP_RTC_DATE); } #else #ifdef USE_RTC_YEAR_FUNCTION date_show_active = 1; Disp_Con(DISP_RTC_DATE); #endif #endif } break; #if defined(MINI_DIGIT_BOX) #if defined(USE_SNOOZE_FUNC) case INFO_7|KEY_SHORT_UP: if (alm_flag>0) //4闹钟响后默认增加一天秒数 { set_snooze_func(); close_alm_bell(); Disp_Con(DISP_RTC); } break; #endif #endif case INFO_EQ_UP | KEY_SHORT_UP: //4清除闹钟 if (alm_flag) //4闹钟响后默认增加一天秒数 { #if defined(USE_SNOOZE_FUNC) set_snooze_func(); #endif close_alm_bell(); Disp_Con(DISP_RTC); } break; case INFO_HALF_SECOND : #if ((USE_DEVICE == MEMORY_STYLE)&&(FAT_MEMORY)) updata_fat_memory(); #endif #if defined(AD_MEASURE_TEMP_FUNC) adc_diode_temp_measure_hdlr(); #endif #ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER Disp_BL_time_out(); #endif #if defined(USE_SNOOZE_FUNC) snooze_hdlr(); #endif #if defined(USE_TIMER_POWER_OFF_FUNC) timer_pwr_off_hdlr(); #endif #ifdef USE_MICPHONE_GPIO_DETECTION if(get_mic_online_status()){ Disp_Con(DISP_MIC); break; } #endif if ((DISP_ALM_UP == curr_menu) || (alm_flag>0)) { if (alm_flag>=60) { close_alm_bell(); return_cnt = (RETURN_TIME); #ifdef RTC_ALRM_MEM_LAST_WORK_MODE Set_Curr_Func(last_work_mode); return; #endif } else if (alm_flag) { rtc_mode = ALM_UP_MODE; alm_flag++; //key_voice_disable = 1; Mute_Ext_PA(UNMUTE); set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL); //设置RTC模式的音量上限 dac_out_select(DAC_DECODE); sys_clock_pll(); my_main_vol(my_music_vol); write_dsp(-3, 10, 0x10); #ifdef ALM_UP_DISP_TIME Disp_Con(DISP_RTC_POINT); #else Disp_Con(DISP_ALM_UP); #endif #ifdef ALM_ON_FLASH_SCR alm_flash_flag=~alm_flash_flag; if(alm_flash_flag){ Disp_Con(DISP_PWR_OFF); } #endif #if defined(USE_BAT_MANAGEMENT) bmt_hdlr(); #endif //delay_10ms(10); break; } } if ((rtc_mode==RTC_PLAY_MODE)||(rtc_mode==ALM_UP_MODE)) //4除闹钟模式外一直更新now_time { get_curr_date(); chk_date_err(); //Disp_Con(DISP_RTC); } #if defined(MINI_DIGIT_BOX)||defined(RTC_SETTING_OP_TIMER_ENABLE) rtc_setting_key_hdlr(); #endif if (return_cnt < (RETURN_TIME)) { return_cnt++; } if ((RETURN_TIME) == return_cnt) { if ((DISP_RTC != curr_menu) || (0 != rtc_mode)) { rtc_set = 0; alm_set = 0; rtc_mode = 0; #if defined(NEW_RTC_SETTING_CTRL) new_rtc_setting=0; #endif get_curr_date(); Disp_Con(DISP_RTC); } #ifdef USE_RTC_YEAR_FUNCTION date_show_active=0; #endif } #ifdef RTC_ADJ_VOL if(DISP_VOL == curr_menu){ } else #endif #ifdef USE_RTC_YEAR_FUNCTION if(!date_show_active) #elif defined(NEW_RTC_SETTING_CTRL) if((rtc_mode == RTC_PLAY_MODE)&&(new_rtc_setting>0)){ break; } #endif { Disp_Con(DISP_RTC_POINT); } #if defined(USE_BAT_MANAGEMENT) bmt_hdlr(); #endif break; default : _HOT_KEY_HDLR: if (!ap_handle_hotkey(key)) { close_alm_bell(); return; } } } }