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;



    }
}
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;
            }
        }
    }
}