void timer_pwr_off_hdlr() { if(timer_pwr_idx>0){ timer_pwr_cnt++; //if(timer_pwr_cnt>=(timer_tab[timer_pwr_idx]/*2*60*/)){ if(timer_pwr_cnt>=(timer_tab[timer_pwr_idx]*2*60)){ timer_pwr_idx =0; timer_pwr_cnt =0; set_brightness_all_on(); work_mode = IDLE_MODE; put_msg_fifo(MSG_SYS_POWERON); } } }
void radio_chip_set_freq(u8 mode,bool disp_pro) { xd_u8 freq_step =0; set_brightness_all_on(); freq_step = Current_Band.Tune_Step; if (mode == FM_FRE_INC) { frequency=frequency+freq_step; if (frequency > REG_MAX_FREQ) frequency = REG_MIN_FREQ; } else if (mode == FM_FRE_DEC) { frequency=frequency-freq_step; if (frequency < REG_MIN_FREQ) frequency =REG_MAX_FREQ; } else{ if (frequency > REG_MAX_FREQ) frequency = REG_MAX_FREQ; if (frequency < REG_MIN_FREQ) frequency =REG_MIN_FREQ; } set_freq(frequency); if(disp_pro) Disp_Con(DISP_FREQ); #if 1//def SAVE_BAND_FREQ_INFO #ifdef FM_UART_ENABLE printf("------->- set_radio_freq fre:%4u \r\n",frequency); #endif save_radio_freq(frequency,cur_sw_fm_band*2+MEM_FREQ_BASE); #endif set_sys_vol(my_music_vol); }
/*----------------------------------------------------------------------------*/ void ap_handle_hotkey(u8 key) { u8 res; switch (key) { case MSG_POWER_DOWN: if(sys_pwr_flag==0){ sys_pwr_flag =1; sys_mute_flag =1; dac_mute_control(sys_mute_flag,1); //调节音量时,自动UNMUTE work_mode = IDLE_MODE; put_msg_lifo(MSG_CHANGE_WORK_MODE); } else{ sys_mute_flag =0; //dac_mute_control(sys_mute_flag,1); //调节音量时,自动UNMUTE sys_pwr_flag =0; //work_mode = IDLE_MODE; } break; case MSG_MUTE_UNMUTE: sys_mute_flag=~sys_mute_flag; //dac_mute_toggle(); dac_mute_control(sys_mute_flag,1); //调节音量时,自动UNMUTE break; #if 1 case MSG_MUSIC_PREV_FILE: //选择上一个文件进行播放 case MSG_MUSIC_FR: //启动快退 if ((disp_scenario == DISP_RTC_SCEN)&&(rtc_setting_flag!=0)) { rtc_set_cnt=30; curr_time_minus(); write_rtc(&curr_time); //write_next_alm_sec(); disp_port(MENU_RTC); } break; case MSG_MUSIC_NEXT_FILE: //选择下一个文件进行播放 case MSG_MUSIC_FF: //启动快退 if ((disp_scenario == DISP_RTC_SCEN)&&(rtc_setting_flag!=0)) { rtc_set_cnt=30; curr_time_plus(); write_rtc(&curr_time); //write_next_alm_sec(); disp_port(MENU_RTC); } break; case MSG_NEXT_WORKMODE: //set_brightness_all_on(); if(work_mode==FM_RADIO_MODE)break; if(rtc_setting_flag!=0){ rtc_coordinate++; rtc_set_cnt=30; if(rtc_coordinate>4){ rtc_coordinate = 3; rtc_setting_flag = 0x00; } break; } if(disp_scenario == DISP_NORMAL){ input_number_en = 0; //允许数字输入功能 disp_scenario = DISP_RTC_SCEN; rtc_disp_hdlr(); } else{ if(device_online==0)break; input_number_en = 1; //允许数字输入功能 disp_scenario = DISP_NORMAL; disp_port(MENU_MUSIC_MAIN); } break; case MSG_TIME_SETTING: //set_brightness_all_on(); if(disp_scenario == DISP_RTC_SCEN){ rtc_set_cnt=30; rtc_setting_flag = 0x01; rtc_coordinate = 3; } break; case MSG_USB_DISK_OUT: case MSG_SDMMC_OUT: if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status)) { #ifdef AUTO_PLAY_RADIO_REC_FILE auto_play_radio_rec=0; #endif rec_device_out = 1; api_stop_encode(); if(work_mode == FM_RADIO_MODE){ main_menu = MENU_FM_MAIN;// disp_port(MENU_FM_MAIN); break; } } #ifndef LCD_BACK_LIGHT_DUMMY set_brightness_all_on(); #endif if((!device_check()) && (REC_MIC_MODE == work_mode)) { put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; } if(MUSIC_MODE != work_mode) break; //put_msg_lifo(MSG_DEVICE_REMOVED); disk_remove_deal_for_music(); break; #endif #if USB_DEVICE_ENABLE case MSG_USB_PC_IN: break_encode(); set_brightness_all_on(); device_check(); work_mode = USB_DEVICE_MODE; put_msg_lifo(MSG_CHANGE_WORK_MODE); break; case MSG_USB_PC_OUT: set_brightness_all_on(); break; #endif case MSG_SDMMC_IN : #ifndef LCD_BACK_LIGHT_DUMMY set_brightness_all_on(); #endif device_check(); if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status)) { break; } break_encode(); disp_scenario = DISP_NORMAL; #if USB_DEVICE_ENABLE if (work_mode == USB_DEVICE_MODE) break; #endif given_device = read_info(MEM_ACTIVE_DEV); if(given_device != DEVICE_SDMMC0_REC) // given_device = DEVICE_SDMMC0_REC; //else given_device = DEVICE_SDMMC0; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; case MSG_USB_DISK_IN : #ifndef LCD_BACK_LIGHT_DUMMY set_brightness_all_on(); #endif device_check(); if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status)) { break; } break_encode(); disp_scenario = DISP_NORMAL; given_device = read_info(MEM_ACTIVE_DEV); if(given_device != DEVICE_UDISK_REC) // given_device = DEVICE_UDISK_REC; //else given_device = DEVICE_UDISK; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; #if 0 case MSG_NEXT_WORKMODE: #if 0//def K820_LHD_820_REC_V001 if(MUSIC_MODE != work_mode) break; if(device_check()>0){ given_device = DEVICE_AUTO_NEXT; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); backup_music_point(); } else{ //flashled(3); work_mode =IDLE_MODE; put_msg_lifo(MSG_CHANGE_WORK_MODE); } break; #endif break_encode(); work_mode++; if (work_mode > MAX_WORK_MODE) work_mode = MUSIC_MODE; put_msg_lifo(MSG_CHANGE_WORK_MODE); break; #endif #if 1 case MSG_VOL_UP: if(vol_change_en==0) break; dac_mute_control(0,1); //调节音量时,自动UNMUTE main_vol_set(0, CHANGE_VOL_INC); //write_info(MEM_VOL, main_vol_set(0, CHANGE_VOL_INC)); disp_port(MENU_MAIN_VOL); break; case MSG_VOL_DOWN: if(vol_change_en==0) break; dac_mute_control(0,1); //调节音量时,自动UNMUTE main_vol_set(0, CHANGE_VOL_DEC); //write_info(MEM_VOL, main_vol_set(0, CHANGE_VOL_DEC)); disp_port(MENU_MAIN_VOL); break; #endif case MSG_0: case MSG_1: case MSG_2: case MSG_3: case MSG_4: case MSG_5: case MSG_6: case MSG_7: case MSG_8: case MSG_9: if (!input_number_en) break; if((input_number)>6553){ input_number = 0x0000; } if (input_number > 9999) input_number = 0; input_number = input_number * 10 + key; disp_port(MENU_INPUT_NUMBER); break; //2 REC FSM BEGIN case MSG_REC_KEY: //录音开始和结束 if(work_mode ==IDLE_MODE) break; if(RECODE_PLAY >= encode_status) { put_msg_lifo(MSG_REC_FIND); #ifdef AUTO_PLAY_RADIO_REC_FILE if(work_mode == FM_RADIO_MODE){ auto_play_radio_rec=1; } #endif } else { #ifdef AUTO_PLAY_RADIO_REC_FILE //auto_play_radio_rec=0; #endif put_msg_lifo(MSG_REC_STOP); } break; case MSG_MUSIC_PP: //录音暂停和继续录音 //case MSG_REC_PP: //录音暂停和继续录音 if(RECODE_WORKING == encode_status) { put_msg_lifo(MSG_REC_PAUSE); } else if(RECODE_PAUSE == encode_status) { put_msg_lifo(MSG_REC_CONTINUE); } break; case MSG_ENCODE_END: //设备写err 或 设备满 if(rec_device_out) //录音时活动设备拔出,在设备拔出那里处理,在此不做处理 { rec_device_out =0; break; } api_stop_encode(); //停止录音 put_msg_lifo(MSG_REC_PLAY); break; case MSG_ENCODE_FAT_FULL: //建文件时 api_stop_encode(); //停止录音 if((!device_check())&& (REC_MIC_MODE == work_mode)) { put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; } // break_encode(); disp_port(main_menu); break; ////////////////录音涉及的各种状态 case MSG_REC_FIND: // if(RECODE_PLAY >= encode_status) // { // break; // } if(get_device_online_status()==0){ disp_port(MENU_NODEVICE); break; } encode_status = RECODE_INIT; if(MUSIC_MODE == work_mode) { encode_device = device_active; //设置录音存储设备 work_mode = REC_MIC_MODE; put_msg_lifo(MSG_CHANGE_WORK_MODE); break; } else if(REC_MIC_MODE == work_mode){ given_device = encode_device; } else //if((MUSIC_MODE != work_mode)) { if (given_device == NO_DEVICE) { given_device = read_info(MEM_ACTIVE_DEV); } } // if( ((given_device & (~VIRTUAL_DEVICE)) != DEVICE_SDMMC0) && ((given_device & (~VIRTUAL_DEVICE)) != DEVICE_UDISK)) { //given_device = DEVICE_SDMMC0; } SYSTEM_CLK_DIV2(); put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); break; case MSG_REC_START: //开始录音 rec_device_out = 0; rec_sys_set(0); //0:24M 1:48M init_rec_name(); device_active |= VIRTUAL_DEVICE; encode_device = device_active; //设置录音存储设备 write_file_info(0); SYSTEM_CLK_DIV2(); set_rec_channel(encode_channel); //设置录音通道 set_rec_vol(encode_vol); //设置录音音量 if(REC_MIC == encode_channel) { set_rec_track(TRACK_LEFT); } else { set_rec_track(TRACK_ALL); } /**/ CLKGAT |= MP3CLK;// | SPIURCLK; CLKCON0 |= DACCLK; if(DEVICE_SDMMC0 == (device_active & (~VIRTUAL_DEVICE))) { CLKGAT |= USBCLK; } else if(DEVICE_UDISK == (device_active & (~VIRTUAL_DEVICE))) { CLKGAT |= SDCLK; } if(1 != start_encode(IS_MP3)) //开始录音 { put_msg_lifo(MSG_ENCODE_FAT_FULL); break; } /* if(REC_MIC_MODE == work_mode) { while(!((cmd_ctl_rec(REC_NO_OPT,0)) & FRIST_ADC_PACKET)) //采数据前的处理 { } delay_10ms(50);//抛弃半秒的数据 } cmd_ctl_rec(ENABLE_REC_DATA,ENABLE_REC_BIT); */ encode_status = RECODE_WORKING; #if FM_MODULE // if(FM_RADIO_MODE != work_mode) #endif { main_menu = MENU_RECWORKING;// } disp_port(main_menu); break; case MSG_REC_STOP: //停止录音 api_stop_encode(); //停止录音 if(work_mode==REC_MIC_MODE){ put_msg_lifo(MSG_REC_PLAY); } #ifdef REC_PLAY_KEY_BREAK_POINT rec_pley_bp_flag=0; #endif break; case MSG_REC_PAUSE: //暂停录音 encode_status = RECODE_PAUSE; #if FM_MODULE if(FM_RADIO_MODE == work_mode) disp_port(MENU_FM_MAIN); else #endif { //main_menu = MENU_REC_PAUSE; disp_port(MENU_RECWORKING); } pause_encode(); break; case MSG_REC_CONTINUE: //暂停录音之后继续录音 encode_status = RECODE_WORKING; #if FM_MODULE if(FM_RADIO_MODE == work_mode) disp_port(MENU_FM_MAIN); else #endif { main_menu = MENU_RECWORKING;// disp_port(MENU_RECWORKING); } continue_encode(); break; case MSG_REC_PLAY: //播放最后的录音文件 if(work_mode ==IDLE_MODE) break; #ifdef REC_PLAY_KEY_BREAK_POINT rec_pley_bp_flag=~rec_pley_bp_flag; if(rec_pley_bp_flag){ last_play_index = given_file_number; } else{ given_file_number=last_play_index; put_msg_lifo(MSG_MUSIC_PLAY_NEW_FILE); break; } #endif encode_status = RECODE_PLAY; given_device = encode_device & (~VIRTUAL_DEVICE); if( (given_device != DEVICE_SDMMC0) && (given_device != DEVICE_UDISK)) { given_device = DEVICE_SDMMC0; } given_device |= VIRTUAL_DEVICE; if((MUSIC_MODE != work_mode)) { put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); } else { put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); } break; case MSG_MUSIC_SELECT_NEW_DEVICE: //重新选择设备 res = find_device(given_device); if ((res == DEV_INIT_ERR) || (res == NO_DEFINE_DEV)) //指定的设备不在线,或初始化失败 { given_device = DEVICE_AUTO_NEXT; //自动选择下一个设备 put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); break; } else if ((res == NO_EFFECTIVE_DEV) || (res == NO_DEV_ONLINE)) //无可播放的设备 { if(RECODE_STOP != encode_status) { encode_status = RECODE_STOP; if(REC_MIC_MODE == work_mode) { put_msg_lifo(MSG_NEXT_WORKMODE); } } else { //put_msg_lifo(MSG_NEXT_WORKMODE); if(disp_scenario == DISP_NORMAL){ #ifdef PLAY_STATUS_LED_FUNC set_play_status_led_spark(PLED_ON); #endif disp_scenario = DISP_RTC_SCEN; rtc_disp_hdlr(); } } break; } else { if(RECODE_PLAY < encode_status) { put_msg_lifo(MSG_REC_START); } else { if(RECODE_PLAY == encode_status) //4去播刚录好的文件 { encode_status = RECODE_STOP; #if VIRTUAL_ENABLE #if 1//defined(K820_LHD_820_REC_V001) given_file_number = logic_fileTotal; #else given_file_number = encode_filenum; #endif #else given_file_number = logic_fileTotal; //given_file_number = encode_filenum + encode_fristfile -1; #endif put_msg_lifo(MSG_MUSIC_PLAY_NEW_FILE); } else { put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE); //找到可用设备 } } } break; //2 REC FSM END } }
/*----------------------------------------------------------------------------*/ void sys_init(void) { #ifdef UART_ENABLE uartInit(); printf("power up \r\n"); #endif #if RTC_ENABLE if (init_rtc()) { work_mode = SYS_RTC; } #else { u8 rtc_reg; rtc_reg=read_rtc_reg(); //printf("RTC reg:%02bx\n",rtc_reg); if (rtc_reg & BIT(6)) ///<RTC是否完全掉电 { #if (MEMORY_STYLE == USE_RTCRAM) reset_rtc_ram(); #endif rtc_reg &= ~(BIT(6)); //清零PDGLG write_rtc_reg(rtc_reg); } } #endif set_brightness_all_on(); P0IE_init(); keyInit(); timer1Init(); timer3Init(); #ifdef USE_USB_SD_DECODE_FUNC #ifndef NO_SD_DECODE_FUNC sd_speed_init(1,100); init_port_sd(); #endif #endif #if SDMMC_CMD_MODE sd_chk_ctl(SET_SD_H_CHK); #endif #ifdef USE_POWER_KEY sys_power_up(); #endif DACCON0 |= 0x05; //打开DSP EA = 1; #ifdef USE_POWER_KEY sys_power_up(); #endif work_mode = read_info(MEM_SYSMODE); #ifdef CUSTOMED_POWER_ON_AT_RADIO_MODE work_mode = SYS_FMREV; #endif if (work_mode == SYS_MP3DECODE_USB){ #ifdef REMOVE_USE_MODE work_mode = SYS_FMREV; Disp_Con(DISP_TUNER); return; #endif Disp_Con(DISP_SCAN_DISK); } else if ((work_mode == SYS_FMREV) #ifdef AM_RADIO_FUNC ||(work_mode == SYS_AMREV) #endif ){ #ifdef AM_RADIO_FUNC if(work_mode == SYS_AMREV){ cur_sw_fm_band = MW_MODE; } else #endif { cur_sw_fm_band = FM_MODE; } Disp_Con(DISP_TUNER); } else if (work_mode == SYS_MCU_CD){ Disp_Con(DISP_SCAN_TOC); } else if (work_mode == SYS_AUX){ Disp_Con(DISP_AUX); } #if defined(USE_BLUE_TOOTH_FUNC) else if (work_mode == SYS_BLUE_TOOTH){ Disp_Con(DISP_BT); } #endif CD_PWR_GPIO_CTRL_INIT(); CD_PWR_GPIO_OFF(); //TUNER_PWR_GPIO_CTRL_INIT(); //TUNER_PWR_GPIO_OFF(); AUX_GPIO_CTRL_INIT(); AUX_PWR_GPIO_OFF(); BT_GPIO_CTRL_INIT(); BT_PWR_GPIO_OFF(); }
void main(void) { #if defined(USE_LCD_DRV_HT1621) lcd_ht1621_init(); #endif work_mode = MUSIC_MODE; //amp_mute(1); clock_in = T0CNT; //输入时钟,define in clock.h //WDT_EN(); sys_init(); AMUX_P2IE_SET(AMUX1_IE); sys_info_init(); clear_all_event(); flush_all_msg(); #ifndef LCD_BACK_LIGHT_DUMMY set_brightness_all_on(); #endif #if (DISP_VER!=0) if(ADKEY_PORT==0){ disp_port(MENU_VER); delay_10ms(80); } #endif delay_10ms(10); ///* while (1) { switch (work_mode) { case MUSIC_MODE: music_decode(); break; #if USB_DEVICE_ENABLE case USB_DEVICE_MODE: usb_audio_massstorage(); break; #endif #if FM_MODULE case FM_RADIO_MODE: radio_main_hdlr(); break; #endif #ifdef USE_BLUE_TOOTH_FUNC case BLUE_TOOTH_MODE: Blue_tooth_main(); break; #endif //case AUX_MODE: //aux_fun(); // break; #if RTC_ENABLE //case RTC_MODE: //rtc_fun(); // break; #endif case REC_MIC_MODE: rec_mic_fun(); break; case IDLE_MODE: idle_mode(); sys_mute_flag =0; dac_mute_control(0,1); //调节音量时,自动UNMUTE //set_brightness_all_on(); break; default: work_mode = MUSIC_MODE; break; } //write_info(MEM_SYSMODE ,work_mode); } //*/ }
void set_radio_freq(u8 mode) { xd_u16 freq_step =0; #ifndef LCD_BACK_LIGHT_DUMMY set_brightness_all_on(); #endif #if defined(FAST_STICK_TUNE_FUNC) if(fast_step_cnt==0){ fast_step_cnt=1; } if(radio_band.bCurBand==FM_MODE){ if(fast_step_cnt<6) freq_step = (radio_band.bTuneStep*fast_step_cnt); else if(fast_step_cnt<12) freq_step = (radio_band.bTuneStep*fast_step_cnt*5); } if(radio_band.bCurBand==MW_MODE){ if(fast_step_cnt<6) freq_step = (radio_band.bTuneStep*fast_step_cnt); else if(fast_step_cnt<12) freq_step = (radio_band.bTuneStep*fast_step_cnt*5); #ifdef MW_MODE_ADVANCED_TUNE_STEP else freq_step = (radio_band.bTuneStep*fast_step_cnt*10); #endif } else{ if(fast_step_cnt<6) freq_step = (radio_band.bTuneStep*fast_step_cnt); else if(fast_step_cnt<12) freq_step = (radio_band.bTuneStep*fast_step_cnt*10); else freq_step = (radio_band.bTuneStep*fast_step_cnt*20); } #if 0 if(fast_step_cnt>3){ am_adj_timer=2; } #endif #elif defined(MID_SPEED_STICK_TUNE_FUNC) if(fast_step_cnt==0){ fast_step_cnt=1; } if(radio_band.bCurBand==FM_MODE){ if(fast_step_cnt<8) freq_step = (radio_band.bTuneStep*fast_step_cnt); else if(fast_step_cnt<12) freq_step = (radio_band.bTuneStep*fast_step_cnt*3); } if(radio_band.bCurBand==MW_MODE){ if(fast_step_cnt<6) freq_step = (radio_band.bTuneStep*fast_step_cnt); else if(fast_step_cnt<12) freq_step = (radio_band.bTuneStep*fast_step_cnt*5); else freq_step = (radio_band.bTuneStep*fast_step_cnt*8); } else{ if(fast_step_cnt<6) freq_step = (radio_band.bTuneStep*fast_step_cnt); else if(fast_step_cnt<12) freq_step = (radio_band.bTuneStep*fast_step_cnt*5); else freq_step = (radio_band.bTuneStep*fast_step_cnt*8); } #else if(radio_band.bCurBand==FM_MODE){ freq_step = (radio_band.bTuneStep); } if(radio_band.bCurBand==MW_MODE){ freq_step = (radio_band.bTuneStep); } else{ freq_step = (radio_band.bTuneStep); } #endif if (mode == RADIO_FRE_INC) { radio_band.wFreq=radio_band.wFreq+freq_step; } else if (mode == RADIO_FRE_DEC) { radio_band.wFreq=radio_band.wFreq-freq_step; } if (radio_band.wFreq > radio_band.wFreqUpLimit) radio_band.wFreq = radio_band.wFreqUpLimit; if (radio_band.wFreq < radio_band.wFreqDownLimit) radio_band.wFreq =radio_band.wFreqDownLimit; if(radio_band.bCurBand==0){ #ifdef FM_SOFTMUTE KT_FM_SOFTMUTE(radio_band.wFreq); #else KT_FMTune(radio_band.wFreq); #endif } else{ #ifdef AM_SOFTMUTE KT_AM_SOFTMUTE(radio_band.wFreq); #else KT_AMTune(radio_band.wFreq); #endif } disp_port(MENU_RADIO_MAIN); #ifdef SAVE_BAND_FREQ_INFO save_radio_freq(radio_band.wFreq,radio_band.bCurBand); #endif flush_all_msg(); #ifdef SEMI_AUTO_SCAN_FUNC if(scan_mode!=RADIO_SCAN_STOP){ radio_all_scan_stop(); } #endif }
void ap_handle_hotkey(u8 key) { u8 res; switch (key) { #if ECHO_ENABLE case MSG_REV_SW: echo_sw(); break; case MSG_REV_STRONG_UP: case MSG_REV_STRONG_DOWN: if(echo_strong(key)) { disp_port(MENU_REV_STRONG); } break; case MSG_REV_DEEP_UP: case MSG_REV_DEEP_DOWN: if(echo_deep(key)) { disp_port(MENU_REV_DEEP); } break; #endif case MSG_ALM_SETUP: //clr_alarm_func(); break; case MSG_SNOOZE_SETUP: set_snooze_func(); break; case MSG_MUTE_UNMUTE: sys_mute_flag =~sys_mute_flag; if(sys_mute_flag){ amp_mute(1); PT2313_Config(0,VOL_ADJ); } else{ PT2313_Config(sys_main_vol,VOL_ADJ); amp_mute(0); } break; case MSG_SLEEP_SETUP: if(work_mode != RTC_MODE){ timer_pwr_setting(); } break; case MSG_SYS_POWERON: if(work_mode==RTC_MODE){ work_mode= MUSIC_MODE; } else{ work_mode= RTC_MODE; } timer_pwr_idx=0; put_msg_lifo(MSG_CHANGE_WORK_MODE); break; case MSG_USB_DISK_OUT: case MSG_SDMMC_OUT: set_brightness_all_on(); if( (!device_check() ) && (encode_status >= RECODE_INIT )) //在录音时,活动设备拔出 { rec_device_out = 1; api_stop_encode(); if(AUX_MODE == work_mode) { main_menu = MENU_AUX; disp_port(MENU_AUX); } #if FM_MODULE else if(FM_RADIO_MODE == work_mode) { main_menu = MENU_FM_MAIN; disp_port(MENU_FM_MAIN); } #endif else { put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); //break; } } /* if((!device_check()) && (REC_MIC_MODE == work_mode)) { put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; } */ if(MUSIC_MODE != work_mode) break; put_msg_lifo(MSG_DEVICE_REMOVED); disk_remove_deal_for_music(); break; #if USB_DEVICE_ENABLE case MSG_USB_PC_IN: #if ECHO_ENABLE if(BUSY == echo_ptr->status) { close_echo(); } #endif break_encode(); set_brightness_all_on(); device_check(); work_mode = USB_DEVICE_MODE; put_msg_lifo(MSG_CHANGE_WORK_MODE); break; case MSG_USB_PC_OUT: set_brightness_all_on(); break; #endif case MSG_AUX_IN : break_encode(); set_brightness_all_on(); #if USB_DEVICE_ENABLE if ((AUX_MODE != work_mode) && (work_mode != USB_DEVICE_MODE)) #else if (AUX_MODE != work_mode) #endif { work_mode = AUX_MODE; put_msg_lifo(MSG_CHANGE_WORK_MODE); } break; case MSG_AUX_OUT : set_brightness_all_on(); if(work_mode != AUX_MODE)break; if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status)) { break; } break_encode(); given_device = DEVICE_UDISK; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; case MSG_SDMMC_IN : set_brightness_all_on(); device_check(); if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status)) { break; } break_encode(); #if USB_DEVICE_ENABLE if (work_mode == USB_DEVICE_MODE) break; #endif given_device = read_info(MEM_ACTIVE_DEV); if(given_device == DEVICE_SDMMC0_REC) given_device = DEVICE_SDMMC0_REC; else given_device = DEVICE_SDMMC0; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; case MSG_USB_DISK_IN : set_brightness_all_on(); device_check(); if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status)) { break; } break_encode(); given_device = read_info(MEM_ACTIVE_DEV); if(given_device == DEVICE_UDISK_REC) given_device = DEVICE_UDISK_REC; else given_device = DEVICE_UDISK; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; case MSG_NEXT_WORKMODE: break_encode(); if(work_mode == MUSIC_MODE){ device_check(); if(((device_active &(~VIRTUAL_DEVICE))== DEVICE_UDISK)&&(device_online&DEVICE_SDMMC0)>0){ given_device = DEVICE_SDMMC0; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; } } work_mode++; if(work_mode > MAX_WORK_MODE){ work_mode = MUSIC_MODE; if(get_device_online_status()&DEVICE_UDISK){ given_device = DEVICE_UDISK; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); } else if(get_device_online_status()&DEVICE_SDMMC0){ given_device = DEVICE_SDMMC0; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); } else{ work_mode++; } } put_msg_lifo(MSG_CHANGE_WORK_MODE); break; case MSG_VOL_UP: if (vol_change_en==0) break; sys_main_vol++; sys_main_vol++; case MSG_VOL_DOWN: if (vol_change_en==0) break; if(sys_main_vol>0) sys_main_vol--; if(sys_main_vol>MAX_MAIN_VOL){ sys_main_vol =MAX_MAIN_VOL; } sys_mute_flag =0; PT2313_Config(sys_main_vol,VOL_ADJ); if(sys_main_vol==0){ amp_mute(1); } else{ amp_mute(0); } dac_mute_control(0,1); //调节音量时,自动UNMUTE write_info(MEM_VOL, sys_main_vol); disp_port(MENU_MAIN_VOL); break; case MSG_MUSIC_NEXT_EQ: if(work_mode == RTC_MODE) break; eq_mode++; if (eq_mode > CLASSIC) { eq_mode = NORMAL; } PT2313_Config(eq_mode,EQ_ADJ); set_eq(NORMAL); disp_port(MENU_SET_EQ); break; case MSG_100: if (!input_number_en) break; if (input_number > 999) input_number = 0; key_100_flag = 0xFF; #ifdef USE_10_PLUS_FUNC input_number = input_number+10; #else input_number = input_number+100; #endif disp_port(MENU_INPUT_NUMBER); break; case MSG_0: case MSG_1: case MSG_2: case MSG_3: case MSG_4: case MSG_5: case MSG_6: case MSG_7: case MSG_8: case MSG_9: if (!input_number_en) break; if(key_100_flag ==0xFF){ input_number += key; key_100_flag = 0xFE; } else if(key_100_flag ==0xFE){ input_number += (input_number%10)*10-(input_number%10)+key; key_100_flag = 0x00; } else { if((input_number)>6553){ input_number = 0x0000; } input_number = input_number * 10 + key; key_100_flag = 0x00; } #if 1 if (input_number > 9999) { input_number = 0; input_number = input_number *10 + key; } #endif disp_port(MENU_INPUT_NUMBER); break; ////////////////录音 case MSG_REC_KEY_AT_USB: if(RTC_MODE == work_mode){ break; } if(RECODE_PLAY >= encode_status) { rec_device_sel=DEVICE_UDISK; api_stop_encode(); put_msg_lifo(MSG_REC_FIND); } else { put_msg_lifo(MSG_REC_STOP); } break; case MSG_REC_KEY_AT_SD: if(RTC_MODE == work_mode){ break; } if(RECODE_PLAY >= encode_status) { rec_device_sel=DEVICE_SDMMC0; api_stop_encode(); put_msg_lifo(MSG_REC_FIND); } else { put_msg_lifo(MSG_REC_STOP); } break; #if 0 case MSG_REC_KEY: //录音开始和结束 if(RECODE_PLAY >= encode_status) { put_msg_lifo(MSG_REC_FIND); } else { put_msg_lifo(MSG_REC_STOP); } break; #endif case MSG_REC_PP: //录音暂停和继续录音 if(RECODE_WORKING == encode_status) { put_msg_lifo(MSG_REC_PAUSE); } else if(RECODE_PAUSE == encode_status) { put_msg_lifo(MSG_REC_CONTINUE); } break; case MSG_ENCODE_END: //设备写err 或 设备满 // deg_str("MSG_ENCODE_END \n"); if(rec_device_out) //录音时活动设备拔出,在设备拔出那里处理,在此不做处理 { rec_device_out =0; break; } api_stop_encode(); //停止录音 put_msg_lifo(MSG_REC_PLAY); break; case MSG_ENCODE_FAT_FULL: //建文件时 // deg_str("MSG_ENCODE_FAT_FULL \n"); api_stop_encode(); //停止录音 if(REC_MIC_MODE == work_mode) //录音时写设备出现问题、设备满 { put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); break; } // break_encode(); if(AUX_MODE == work_mode) { main_menu = MENU_AUX; } #if FM_MODULE else if(FM_RADIO_MODE == work_mode) { main_menu = MENU_FM_MAIN; } #endif disp_port(main_menu); break; ////////////////录音涉及的各种状态 case MSG_REC_FIND: // if(RECODE_PLAY >= encode_status) // { // break; // } #if USB_DEVICE_ENABLE if(USB_DEVICE_MODE == work_mode) { break; } #endif encode_status = RECODE_INIT; if(REC_MIC_MODE != work_mode) { work_mode = REC_MIC_MODE; put_msg_lifo(MSG_CHANGE_WORK_MODE); given_device = rec_device_sel;//read_info(MEM_ACTIVE_DEV); break; } #if 0 else //if((MUSIC_MODE != work_mode)) { if (given_device == NO_DEVICE) { given_device = read_info(MEM_ACTIVE_DEV); } } if( (( given_device & (~VIRTUAL_DEVICE )) != DEVICE_SDMMC0) && ((given_device & (~VIRTUAL_DEVICE)) != DEVICE_UDISK) ) { given_device = DEVICE_SDMMC0; } #endif given_device = rec_device_sel;//read_info(MEM_ACTIVE_DEV); sys_clk_div(2);//SYSTEM_CLK_DIV2(); put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); break; case MSG_REC_START: //开始录音 rec_device_out = 0; #if 0 rec_sys_set(0); //0:24M 1:48M sys_clk_div(2);//SYSTEM_CLK_DIV2(); //24 M #else rec_sys_set(1); sys_clk_div(1);//SYSTEM_CLK_DIV1(); //48 M #endif //init_rec_name(); device_active |= VIRTUAL_DEVICE; encode_device = device_active; //设置录音存储设备 write_file_info(0); set_rec_channel(encode_channel); //设置录音通道 set_rec_vol(encode_vol); //设置录音音量 if(REC_MIC_MODE == work_mode) { kala_dac_off(); // dac_mute_control(1,1); #if KALAOK_FUNCTION dsp_set_adc_con(0); P3HD &=~(1<<6); #endif } if(REC_MIC == encode_channel) { set_rec_track(TRACK_LEFT); } else { set_rec_track(TRACK_ALL); } /**/ CLKGAT |= MP3CLK;// | SPIURCLK; // CLKCON0 |= DACCLK; // P3HD &=~(1<<6); if(DEVICE_SDMMC0 == (device_active & (~VIRTUAL_DEVICE))) { CLKGAT |= USBCLK; } else if(DEVICE_UDISK == (device_active & (~VIRTUAL_DEVICE))) { CLKGAT |= SDCLK; } #if ECHO_ENABLE if(BUSY == echo_ptr->status) { close_echo(); } #endif ///0x //my_memset(0x4000,0,0x787f-0x4000); //my_memset(0x8000,0,0x9c3f-0x8000); //混响强度 0x400c 取值范围 0-255 //混响深度 0x4015 0x4014 取值范围 0-2048 #if ECHO_ENABLE if(1 != start_encode_echo(IS_MP3)) //开始录音 #else if(1 != start_encode(IS_MP3)) //开始录音 #endif { put_msg_lifo(MSG_ENCODE_FAT_FULL); break; } #if ECHO_ENABLE ///<减弱冲击声,打开混响深度和强度 delay_10ms(20); if( REC_MIC == ( encode_channel & 0xf ) ) ///<MIC 下有混响 { set_echo(app_echo.strong, app_echo.deep); } // app_echo.strong = REC_ECHO_STRONG; echo_vol_set(REC_MIC_VOL); #endif /* if(REC_MIC_MODE == work_mode) { while(!((cmd_ctl_rec(REC_NO_OPT,0)) & FRIST_ADC_PACKET)) //采数据前的处理 { } delay_10ms(50);//抛弃半秒的数据 } cmd_ctl_rec(ENABLE_REC_DATA,ENABLE_REC_BIT); */ encode_status = RECODE_WORKING; #if 0//FM_MODULE if(FM_RADIO_MODE != work_mode) #endif { main_menu = MENU_RECWORKING;// } disp_port(main_menu); //disp_port(MENU_REC); break; case MSG_REC_STOP: //停止录音 api_stop_encode(); //停止录音 put_msg_lifo(MSG_REC_PLAY); break; case MSG_REC_PAUSE: //暂停录音 encode_status = RECODE_PAUSE; #if 0//FM_MODULE if(FM_RADIO_MODE == work_mode) disp_port(MENU_FM_MAIN); else #endif { main_menu = MENU_REC_PAUSE; disp_port(MENU_REC_PAUSE); } pause_encode(); break; case MSG_REC_CONTINUE: //暂停录音之后继续录音 encode_status = RECODE_WORKING; #if FM_MODULE if(FM_RADIO_MODE == work_mode) disp_port(MENU_FM_MAIN); else #endif { main_menu = MENU_RECWORKING;// disp_port(MENU_RECWORKING); } continue_encode(); break; case MSG_REC_PLAY: //播放最后的录音文件 encode_status = RECODE_PLAY; given_device = encode_device & (~VIRTUAL_DEVICE); if( (given_device != DEVICE_SDMMC0) && (given_device != DEVICE_UDISK)) { given_device = DEVICE_SDMMC0; } given_device |= VIRTUAL_DEVICE; if((MUSIC_MODE != work_mode)) { put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN); } else { put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); } break; case MSG_MUSIC_SELECT_NEW_DEVICE: //重新选择设备 res = find_device(given_device); if ((res == DEV_INIT_ERR) || (res == NO_DEFINE_DEV)) //指定的设备不在线,或初始化失败 { given_device = DEVICE_AUTO_NEXT; //自动选择下一个设备 put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); break; } else if ((res == NO_EFFECTIVE_DEV) || (res == NO_DEV_ONLINE)) //无可播放的设备 { if(RECODE_STOP != encode_status) { encode_status = RECODE_STOP; if(REC_MIC_MODE == work_mode) { put_msg_lifo(MSG_NEXT_WORKMODE); } break; } else { put_msg_lifo(MSG_NEXT_WORKMODE); } break; } else { if(RECODE_PLAY < encode_status) { put_msg_lifo(MSG_REC_START); } else { if(RECODE_PLAY == encode_status) //去播刚录好的文件 { encode_status = RECODE_STOP; #if VIRTUAL_ENABLE given_file_number = encode_filenum; #else given_file_number = encode_filenum + encode_fristfile - 1; #endif put_msg_lifo(MSG_MUSIC_PLAY_NEW_FILE); } else { put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE); //找到可用设备 } } } break; } }