/*----------------------------------------------------------------------------*/
void rtc_function(void)
{
#if !defined(MINI_DIGIT_BOX)        
    rtc_mode = RTC_PLAY_MODE;
    rtc_set = 0;
    alm_set = 0;
#endif	
    flush_low_msg();
    PT1 = 1;
    Mute_Ext_PA(MUTE);		     

    if (alm_flag)	 //闹钟响时默认进入闹钟模式
    {
		rtc_mode = ALM_UP_MODE;
#ifdef ALM_UP_DISP_TIME
          	Disp_Con(DISP_RTC);
#else
        	Disp_Con(DISP_ALM_UP);
#endif
        	goto _deal_rtc0;
    }
    else
    {
        get_curr_date();
        Disp_Con(DISP_RTC);
    }

    set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL);			//设置RTC模式的音量上限
    dac_out_select(DAC_DECODE);
    sysclock_div2(1);
#ifdef UART_ENABLE_RTC
		//printf(" -----> RTC MODE %x rtc_set   %x\r\n",(u16)rtc_mode,(u16)rtc_set);
			
		//printf(" --0000-->RTC MODE ==%d \r\n",(u16)curr_date.year);
		//printf(" --1111--->RTC MODE ==%d \r\n",(u16)curr_date.month);
		//printf(" --3333--->RTC MODE ==%d \r\n",(u16)curr_date.day);
		printf(" --HOUR--->RTC MODE ==%d \r\n",(u16)curr_date.hour);
		printf(" --MIN  --->RTC MODE ==%d \r\n",(u16)curr_date.minutes);

		//printf(" --date--->RTC MODE ==%d \r\n",(u16)curr_date.date);
#endif		

_deal_rtc0:
    deal_rtc();

#if defined(NEW_RTC_SETTING_CTRL)
	new_rtc_setting=0;
#endif			
	
    main_vol_set(0, CHANGE_VOL_NO_MEM);
	
    sys_clock_pll();
}
void fond_alm_clk(void)
{
    u8 i;
    RTC_TIME temp_date;
    get_curr_date();
    //memcpy(&temp_date,&curr_date,7);
    for (i = 0; i < sizeof(RTC_TIME); i++)
    {
        ((u8 *)(&temp_date))[i] =  ((u8 *)(&curr_date))[i];
    }
    if ((curr_alm.hour<curr_date.hour)||((curr_alm.hour==curr_date.hour)&&(curr_alm.minutes<=curr_date.minutes)))
        temp_date.day+=1;
    temp_date.second=0;
    temp_date.hour=curr_alm.hour;
    temp_date.minutes=curr_alm.minutes;
    send_alm_sec(date_sec(&temp_date,0));
}
/*----------------------------------------------------------------------------*/
void fm_rev( void )
{
    u8 key;

#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(UNLOCK);
#endif		  

#if defined(FM_PAUSE_LED_INDICATOR)
    set_play_flash(LED_FLASH_NOR);
#endif

    my_main_vol(my_music_vol);	
	
    while (1)
    {
        key = get_msg();
#if defined(KEY_PRESS_LED_INDICATOR)
	key_press_led_indicator(key);
#elif defined(CUSTOM_KEY_FEATURE_USE)
		custom_key_hdlr(key);
#endif

#if defined(KPL_MSG_COMPATIBLE)
	kpl_msg_hdlr(key);
#endif

#if 0
	if(key!=0xff)
	printf(" music_play get_msg %x \r\n",(u16)key);
#endif
	dac_sw_check();

#ifndef FM_BY_PASS
       dac_out_select(aux_ch_reg);
#endif

        switch (key)
        {

#if defined(K000_HG_898_V001)||defined(USE_STOP_KEY_SHORT_CH_DOWN)
	case INFO_STOP |KEY_SHORT_UP :
		goto __CH_DOWN;
		break;
#endif
#ifdef USE_STOP_KEY_SHORT_SCAN
    	case INFO_STOP| KEY_SHORT_UP :
	goto __SCAN_FREQ;
#endif

#ifdef IR_INFO_EQ_DOWN_SCAN
        case INFO_EQ_DOWN| KEY_SHORT_UP :
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			goto __SCAN_FREQ;
		}
		break;
#endif

#ifdef USE_MODE_KEY_LONG_SCAN
    	case INFO_MODE | KEY_LONG :
	goto __SCAN_FREQ;
#endif
#ifdef RADIO_MODE_HOT_KEY_ENABLE	
#ifdef RADIO_MODE_HOT_KEY_LONG_SCAN
    	case INFO_FM_MOD| KEY_LONG :
	goto __SCAN_FREQ;
#endif	
#endif
#ifdef USE_EQ_KEY_SHORT_SCAN
    	case INFO_EQ_UP| KEY_SHORT_UP :
	goto __SCAN_FREQ;
#endif
#ifdef USE_EQ_KEY_SHORT_CH_UP
    case INFO_EQ_UP | KEY_SHORT_UP :
	goto __CH_DOWN;
		break;
#endif
#if 1//def USE_POWER_KEY
#ifdef USE_POWER_KEY_SHORT_SCAN
    	case INFO_POWER | KEY_SHORT_UP :
#ifdef USE_IR_POWER_KEY_TO_POWER_OFF
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			goto _HOT_KEY_HDLR;	
		}
#endif		
	goto __SCAN_FREQ;

#endif
#endif  
#if defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
    	 case INFO_CUS_KEY_1 | KEY_SHORT_UP :

		radio_freq_tune_pop=~radio_freq_tune_pop;
		radio_tune_timer=12;
		
		if(radio_freq_tune_pop){

                     Disp_Con(DISP_FREQ);
		}
		break;
#endif

#ifdef RADIO_MODE_HOT_KEY_ENABLE	

#ifdef RADIO_AM_WM_SEL_IN_ONE_KEY
#ifdef RADIO_AM_WM_ENABLE
    case INFO_FM_MOD | KEY_SHORT_UP:
        if (work_mode == SYS_AMREV){
		Set_Curr_Func(SYS_FMREV);			
	     	FMAM_Mode_Switch_Profile(SYS_FMREV);
	}
	else if(work_mode == SYS_FMREV){
		Set_Curr_Func(SYS_AMREV);			
	     	FMAM_Mode_Switch_Profile(SYS_AMREV);
	}
		break;
#endif		
#endif
#endif		
#if defined(USE_POWER_KEY_FOR_FM_PLAY)
    	 case INFO_POWER | KEY_SHORT_UP :
#if defined(USE_IR_LONG_POWER_KEY_TO_FAKE_POWER_OFF)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif			
#ifdef USE_IR_POWER_KEY_TO_POWER_OFF
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif
#elif defined(USE_MODE_LONG_FOR_FM_PLAY)
    	 case INFO_MODE| KEY_LONG:
#endif
        case INFO_PLAY | KEY_SHORT_UP :
#if defined(FM_PLAY_KEY_PAUSE)        
#if defined(K722_YJH_722_V001)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif	
#if defined(IR_PLAY_KEY_SCAN_FREQ_ALL)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			goto __SCAN_FREQ;
		}
#endif
            play_status = !play_status;

            if (play_status)
            {
		  my_main_vol(my_music_vol);
  		  Mute_Ext_PA(UNMUTE);
#if defined(FM_PAUSE_LED_INDICATOR)
		 set_play_flash(LED_FLASH_ON);
#endif
            }
	     else{
  		Mute_Ext_PA(MUTE);		 	
		my_main_vol(0);	

#if defined(USE_SPECTRUM_PARTTERN)		  		
		set_lcd_flash_lock(LOCK);
#endif

#if defined(FM_PAUSE_LED_INDICATOR)
    		set_play_flash(LED_FLASH_NOR);
#endif		
	     }

#if defined(PAUSE_FLASH_WHOLE_SCREEN)
            if (play_status == MUSIC_PAUSE)
			set_led_flash_tpye(2);
	     else{
			set_led_flash_tpye(0);
	     }
#endif
          Disp_Con(DISP_FREQ);		 
		
	   break;        
#endif	   
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_PLAY_KEY_SCAN_FREQ_DISABLE)
			break;
#elif defined(IR_PLAY_SHORT_CH_UP)
			goto __CH_UP;
#else
			goto __SCAN_FREQ;
#endif
		}
		else{
			
#if defined(ADKEY_PLAY_SHORT_SCAN_FRE_DISABLE)		
		break;
#endif			
		#ifdef ADKEY_PLAY_SHORT_SCAN_FRE
			goto __SCAN_FREQ;	
		#else
			#if defined( ADKEY_NEXT_ADJST_FREQ)
			goto __CH_UP;
			#endif
			#if defined(ADKEY_PLAY_SHORT_ADJ_CH)
			goto __CH_UP;
			#endif
		#endif
		}
            break;
#if defined(K120_YJH_120_V001)||defined(K000_HG_898_V001)||defined(EQ_DOWN_SCAN_ALL)
        case INFO_EQ_DOWN| KEY_SHORT_UP :
#if 1//defined(EQ_DOWN_SCAN_ALL)	
		goto __SCAN_FREQ;
#endif
#ifndef K722_YJH_722_V001		
		goto __FRE_DOWN;
#endif
#endif			
        case INFO_PLAY | KEY_LONG :

		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_PLAY_KEY_LONG_SCAN_FREQ)
		goto __SCAN_FREQ;
#else
		break;
#endif
		}
#ifdef USE_LONG_PLAY_KEY_TO_SWITCH_MODE		
		goto _HOT_KEY_HDLR;
#endif

#ifdef AUX_MODE_HOT_KEY_USE_PLAY_LONG		
		goto _HOT_KEY_HDLR;
#endif

#ifdef USE_EQ_KEY_SHORT_SCAN
		break;
#endif
#ifdef ADKEY_PLAY_SHORT_SCAN_FRE
		break;
#endif
__SCAN_FREQ:

#if defined(USE_SPECTRUM_PARTTERN)		  
	     set_lcd_flash_lock(LOCK);
#endif

#ifdef DISP_SCH_AT_FM_SCAN	
            Disp_Con(DISP_SCH);
	     delay_10ms(60);
#endif
            scan_fre();

#if defined(USE_SPECTRUM_PARTTERN)		  
	     set_lcd_flash_lock(UNLOCK);
#endif

	     if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			//break;
	     }			
            //flush_low_msg();
            fre_channl = 1;
            get_channl(fre_channl);
            //Disp_Con(DISP_FREQ);
            break;
#if RTC_ENABLE 
		case INFO_ALM_BELL :				///<闹钟响消息,进入闹钟循环
            		sys_clock_pll();
			dac_out_select(DAC_DECODE);
			if(alm_bell_mode())
			{
				dac_out_select(DAC_AMUX0);
				return;
			}
			dac_out_select(DAC_AMUX0);
			break;
#endif
        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

#ifdef USE_USB_HOTPLUG_FUNC
		usb_hotplug_hdlr();
#endif
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		if(mute_release_timer>0)
			mute_release_timer--;

		 if(mute_release_timer==0){
			my_main_vol(my_music_vol);	
			Mute_Ext_PA(UNMUTE);
		 }
#endif

#if defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
		if(radio_tune_timer>0){
			radio_tune_timer--;
			
			if(radio_tune_timer==0){
				radio_freq_tune_pop=0;
	                    Disp_Con(DISP_FREQ);
			}

			if(radio_freq_tune_pop){

			      pop_spark=~pop_spark;

			     if(pop_spark){
	                    		Disp_Con(DISP_PWR_OFF);
			     }
			     else{				
	                    		Disp_Con(DISP_FREQ);
			    }
			}
		}
#endif
#ifdef VOL_ADJ_SPARK_LED
		if(vol_adj_spark_bit){
			vol_adj_spark_bit=0;
			restore_led_flash_mod(last_led_play_mod);		
		}
#endif	 
            if (return_cnt < RETURN_TIME)
            {
                return_cnt++;
            }

#if defined(TIME_FORCE_SHOW_ON_SCREEN)

            if (DISP_FREQ == curr_menu){
				
	            if (time_show_return_cnt>RETURN_TIME_SHOW_TIME){
	                    get_curr_date();
	                    Disp_Con(DISP_RTC_POINT);
				break;
		    }	
		     else{
#if defined(MANUAL_SWITCH_TIME_DISPLAY)
	                    Disp_Con(DISP_FREQ);
#else
	                if(DISP_RTC != curr_menu){
				time_show_return_cnt++;
	                }
#endif				
		     }
	     }
#endif
            if (RETURN_TIME == return_cnt)
            {
#ifdef SUPPORT_PT2313
		  clr_aud_effect_state();
#endif			
#if defined(LED_DRV_USE_SM1628)
		led_spark_protect=0;
#endif

                if (DISP_DWORD_NUMBER == curr_menu)
                {
                    goto _PICK_CH;
                }
                else if (DISP_FREQ != curr_menu)
                    Disp_Con(DISP_FREQ);
#if defined(NEW_VOLUME_KEY_FEATURE)||defined(VOL_TUNE_NEW_VOLUME_KEY_FEATURE)
		if(new_vol_feature){
			new_vol_feature =0;
			if(last_disp_menu!=DISP_NULL)			
                     Disp_Con(last_disp_menu);
		}
#endif								
            }
#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif
	     Disp_Update();			
            break;

        case INFO_PICK_FRE | KEY_LONG:
            save_fre(frequency);
            Disp_Con(DISP_FREQ);
            break;

        case INFO_PICK_FRE | KEY_SHORT_UP:
_PICK_CH:
            if (DISP_DWORD_NUMBER != curr_menu)
            {
                break;
            }

            if (( cfilenum <= MAX_FRE) && (cfilenum >= MIN_FRE))
            {

                frequency = cfilenum;
                cfilenum = 0;
                set_fre(frequency, 1);
            }
            else if ((cfilenum) && (cfilenum<=all_channl))
            {
                fre_channl = cfilenum;
                get_channl(fre_channl);
            }
            cfilenum = 0;
            Disp_Con(DISP_FREQ);
            write_info(MEM_FRE,frequency - MIN_FRE);
            break;

#if defined(VOL_TUNE_FREQ_VOL)||defined(VOL_TUNE_FREQ_ONLY)||defined(VOL_TUNE_NEW_VOLUME_KEY_FEATURE)||defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
        case INFO_PLUS:	
      	     frequency += 2;
            goto __FRE_DOWN;			
			
        case INFO_MINUS:			 
		goto __FRE_DOWN;			
		break;
#endif
        case INFO_NEXT_FIL | KEY_SHORT_UP:

#if defined(NEW_VOLUME_KEY_FEATURE)
		break;
        case INFO_NEXT_FIL :
        case INFO_NEXT_FIL | KEY_HOLD:

		if(new_vol_feature){
			goto _HOT_KEY_HDLR;
		}
#endif				
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_SHORT_ADJ_CH)
			     goto __CH_UP;
#elif defined( IR_NEXT_PREV_DO_NOTHING)
			break;
#elif defined( IR_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_UP;	
#else
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
#endif
		}
		else{
#if defined(K722_YJH_722_V001)
		if(fre_channl==1){
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
		}
		else{
			     goto __CH_UP;
		}
#endif

#if defined( ADKEY_NEXT_ADJST_FREQ)
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
#elif defined(ADKEY_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_UP;	
#else
			     goto __CH_UP;
#endif
		}

	case INFO_PREV_FIL | KEY_SHORT_UP:
		
#if defined(NEW_VOLUME_KEY_FEATURE)
		break;
	case INFO_PREV_FIL :
	case INFO_PREV_FIL | KEY_HOLD:

		if(new_vol_feature){
			goto _HOT_KEY_HDLR;
		}
#endif				
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_SHORT_ADJ_CH)
			     goto __CH_DOWN;
#elif defined( IR_NEXT_PREV_DO_NOTHING)
			break;
#elif defined(IR_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_DOWN;
#else
		            goto __FRE_DOWN;
#endif
		}
		else{
#if defined(K722_YJH_722_V001)
		if(fre_channl==1){
		            goto __FRE_DOWN;
		}
		else{
			     goto __CH_DOWN;
		}
#endif
				
#if defined( ADKEY_NEXT_ADJST_FREQ)
				goto __FRE_DOWN;
#elif defined(ADKEY_NEXT_PREV_SHORT_AUTO_SCAN)
				goto __SCAN_DOWN;		
#else				
				goto __CH_DOWN;
#endif
		}
		
__FRE_DOWN:
            frequency--;
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV

#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		 if(mute_release_timer==0)
#endif
		{
			Mute_Ext_PA(MUTE);
			my_main_vol(0);		
		}
#endif

#ifdef RADIO_AM_WM_ENABLE			
	    if(work_mode==SYS_FMREV){
			
	            if ( frequency > MAX_FRE)
	            {
	                frequency = MIN_FRE;
	            }
	            else if (frequency < MIN_FRE)
	            {
	                frequency = MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            write_info(MEM_FRE,frequency - MIN_FRE);
	    	}
		else	{

		     if ( frequency > AM_MAX_FRE)
	            {
	                frequency = AM_MIN_FRE;
	            }
	            else if (frequency < AM_MIN_FRE)
	            {
	                frequency = AM_MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            Save_AM_Freq((frequency - AM_MIN_FRE),(AM_FREQ_MAGIC_NUM));
		}
#else
	            if ( frequency > MAX_FRE)
	            {
	                frequency = MIN_FRE;
	            }
	            else if (frequency < MIN_FRE)
	            {
	                frequency = MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            write_info(MEM_FRE,frequency - MIN_FRE);
#endif
            Disp_Con(DISP_FREQ);
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		 mute_release_timer=2;
#else
		my_main_vol(my_music_vol);	
		Mute_Ext_PA(UNMUTE);
#endif
#endif

            //delay_ms(20);
            break;

#if defined(USE_MODE_LONG_FOR_FM_CH_UP)
    	 case INFO_MODE| KEY_LONG:
#endif		 	
        case INFO_CH_NEXT | KEY_SHORT_UP:
        case INFO_CH_UP| KEY_SHORT_UP:
	__CH_UP:
			fre_channl += 2;
        case INFO_CH_PREV | KEY_SHORT_UP:
        case INFO_CH_DOWN| KEY_SHORT_UP:
	__CH_DOWN:
            fre_channl--;
            if (fre_channl > all_channl)
            {
                fre_channl = 1;
            }
            else if (!fre_channl)
            {
                fre_channl = all_channl;
            }
            get_channl(fre_channl);
            Disp_Con(DISP_FREQ);
            flush_low_msg();
			
            break;

#ifdef SEMI_AUTO_SCAN_FREQ

#if defined(K722_YJH_722_V001)
        case INFO_PLAY_MODE | KEY_SHORT_UP:
		frequency += 2;
		goto __FRE_DOWN;					
#endif		
        case INFO_CH_UP| KEY_HOLD:

        case INFO_NEXT_FIL | KEY_HOLD:
	 if(IR_KEY_Detect){
		IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_HOLD_AUTO_SCAN)

#elif defined(IR_NEXT_PREV_KEY_HOLD_DO_NOTHING)
	break;
#else
	break;
#endif
		
	 }
	 else{
#if defined(ADKEY_NEXT_PREV_HOLD_AUTO_SCAN)
	//goto __SCAN_UP;
#elif defined(ADKEY_NEXT_PREV_HOLD_FREQ_ADJ)
      		frequency += 2;
		goto __FRE_DOWN;			
#elif defined(ADKEY_NEXT_PREV_HOLD_CH_SEL)
	goto __CH_UP;
#else
	goto _HOT_KEY_HDLR;
#endif
        }
        case INFO_PLUS | KEY_SHORT_UP:
#if defined(INDEPENDENT_KEY_TUNE_FREQ)
	frequency += 2;
	goto __FRE_DOWN;
#endif
        case INFO_PLUS | KEY_HOLD:
 #if defined(INDEPENDENT_KEY_FAST_TUNE_FREQ)			
 	frequency += 2;
	goto __FRE_DOWN;
#endif

__SCAN_UP:			
		auto_scan(SEARCH_UP);
            break;
#if defined(K722_YJH_722_V001)
        case INFO_EQ_UP | KEY_SHORT_UP:
		goto __FRE_DOWN;			
#endif
        case INFO_CH_DOWN| KEY_HOLD:
        case INFO_PREV_FIL | KEY_HOLD:

	 if(IR_KEY_Detect){
		IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_HOLD_AUTO_SCAN)

#elif defined(IR_NEXT_PREV_KEY_HOLD_DO_NOTHING)
	break;
#else
	break;
#endif	
	 }
	 else{
 	
#if defined(ADKEY_NEXT_PREV_HOLD_AUTO_SCAN)
	//goto __SCAN_DOWN;
#elif defined(ADKEY_NEXT_PREV_HOLD_FREQ_ADJ)
		goto __FRE_DOWN;			
#elif defined(ADKEY_NEXT_PREV_HOLD_CH_SEL)
	goto __CH_DOWN;
#else
	goto _HOT_KEY_HDLR;
#endif
        }
        case INFO_MINUS|KEY_SHORT_UP:			 

#if defined(INDEPENDENT_KEY_TUNE_FREQ)			
	goto __FRE_DOWN;
#endif

        case INFO_MINUS| KEY_HOLD:
#if defined(INDEPENDENT_KEY_FAST_TUNE_FREQ)			
	goto __FRE_DOWN;
#endif
			
__SCAN_DOWN:			
		auto_scan(SEARCH_DN);			
            break;
#endif

        default :
_HOT_KEY_HDLR:			
            if (!ap_handle_hotkey(key))
                return;
        }
    }
}
Beispiel #4
0
void actions_dataentry_scr(const char *curr_path, const char *case_num) {
  const size_t n_fields = 4;
  const size_t starty = 6;
  const size_t startx = 25;
  FIELD *field[n_fields];
  FORM *my_form;
  Action_t record;
  int width[] = {  MAX_ACT_DATE - 1, MAX_ACT_TYPE, MAX_ACT_NOTE - 200 };
  int height[] = { 1, 1, 4 };
 
  for ( size_t i = 0; i < n_fields - 1; ++i )
    field[i] = new_field(height[i], width[i], starty + i * 2, startx, 0, 0);
  field[n_fields - 1] = NULL;

  set_field_back( field[0], A_UNDERLINE  );
  field_opts_off( field[0], O_AUTOSKIP   );
  set_field_back( field[1], A_UNDERLINE  );
  field_opts_off( field[1], O_AUTOSKIP   );
  set_field_back( field[2], A_UNDERLINE  );
  field_opts_off( field[2], O_AUTOSKIP   );
  field_opts_off( field[2], O_STATIC     );
  set_max_field(  field[2], MAX_ACT_NOTE );

  my_form = new_form(field);
  post_form(my_form);
  refresh();

  int note_count = MAX_ACT_NOTE;
  char note_msg[4];
  char date_str[MAX_ACT_DATE];
  get_curr_date( date_str );
  mvprintw( 0, 0,   curr_path );
  mvprintw( 4, 10,  "Case Number:   %s", case_num );
  mvprintw( 6, 10,  "Entry Date:    " );
  mvprintw( 8, 10,  "Type:          " );
  mvprintw( 10, 10, "Note:          " );
  mvprintw( 15, 77, "%d", note_count );
  mvprintw( 16, 10, "(F2) = Add | (ESC) = Previous Screen" );
  set_visible_fields( field, 1, 3 );
  size_t actions_count = actions_list( case_num );
  move( 6, 25 );
  set_field_buffer( field[0], 0, date_str );
  set_current_field( my_form, field[0] );

  record.id = 0;
  int ch;

  do {
 
    ch = getch();

    switch ( ch ) {
      case KEY_UP:
        form_driver(my_form, REQ_PREV_FIELD);
        form_driver(my_form, REQ_END_LINE);
        break;
      case KEY_LEFT:
        form_driver(my_form, REQ_LEFT_CHAR);
        break;
      case KEY_RIGHT:
        form_driver(my_form, REQ_RIGHT_CHAR);
        break;
      case KEY_BACKSPACE:
        {
          FIELD * curr_fld = current_field( my_form );

          if ( curr_fld == field[2] ) {
            snprintf( note_msg, 4, "%d", ++note_count );
            display_msg( 15, 77, my_form, curr_fld, note_msg );
          }
        }
        form_driver(my_form, REQ_PREV_CHAR);
        form_driver(my_form, REQ_DEL_CHAR);
        break;
     case DEL:
        {
          FIELD * curr_fld = current_field( my_form );

          if ( curr_fld == field[2] ) {
            snprintf( note_msg, 4, "%d", ++note_count );
            display_msg( 15, 77, my_form, curr_fld, note_msg );
          }
        }
        form_driver( my_form, REQ_DEL_CHAR );
        break;
      case ENTER:
        form_driver( my_form, REQ_NEXT_FIELD );
        form_driver( my_form, REQ_END_LINE );
        break;
      case KEY_F(1):
        {
          FIELD * curr_fld = current_field( my_form );

          if ( curr_fld == field[1] ) {
            if ( query_select_all_codes_from_action_types()  ) {
              clear_line(18, 10);
              mvprintw( 18, 10, db_get_error_msg() );
            } else {
              const Code_t const * code_ptr;
              size_t count = 0;
              
              mvprintw( 8, 75, "Type Options:" );
              while ( ( code_ptr = get_code_from_result() ) != NULL )      
                mvprintw( 9 + count++, 81, "[%d] %s", code_ptr->code, code_ptr->desc );
              free_code_result();

              int row, col;
              get_cursor_pos( curr_fld, &row, &col );
              move( row, col );
              set_current_field( my_form, curr_fld );
            }
          }
        }
        break;
      case KEY_F(2):
        {
          clear_line( 18, 10 );
          strncpy( record.case_num, case_num, MAX_CANUM );
          strncpy( record.entry_date, compress_str( field_buffer(field[0], 0) ), MAX_ACT_DATE );
          record.type = atoi( compress_str( field_buffer(field[1], 0) ) );
          strncpy( record.note, field_buffer(field[2], 0), MAX_ACT_NOTE );
          
          if ( is_empty_str( record.note, MAX_ACT_NOTE ) ) {
            mvprintw( 18, 10, "[!] Action must at least have a note." ); 
            move( 10, 25 );
            set_current_field( my_form, field[2] );
            break;
          }

          if ( query_add_action( &record ) ) {
            mvprintw( 18, 10, db_get_error_msg() );
          } else {
            clear_fields( field, 0, 2 );
            actions_count++;
            print_action( &record, actions_count );
            note_count = MAX_ACT_NOTE;
            mvprintw( 15, 77, "%d", note_count );
          }
          move( 6, 25 );
          set_current_field( my_form, field[0] );
        }
        break;
      default:
        {
          FIELD * curr_fld = current_field( my_form );

          if ( ch == '\'' )
            break;
          if ( curr_fld == field[1] ) {
            if ( !isdigit( ch ) )
              break;
          } else if ( curr_fld == field[2] ) {
            snprintf( note_msg, 4, "%d", --note_count );
            display_msg( 15, 77, my_form, curr_fld, note_msg );
          }
        }
        form_driver( my_form, ch );
        break;
    }
  } while ( ch != ESC );

  unpost_form( my_form );
  free_form( my_form );
  for ( size_t i = 0; i < n_fields - 1; ++i )
    free_field( field[i] );
  return;
}
/*----------------------------------------------------------------------------*/
void blue_tooth_main(void)
{
    u8 key;
#ifdef TURN_OFF_PLAY_STATUS_LED_IN_BLUETOOTH_MODE
    set_play_flash(LED_FLASH_STOP);
#endif

#ifdef K000_XC_BC_BT_V001
        play_status =MUSIC_PAUSE;
#endif
    while (1)
    {
        key = get_msg();
#if 0
	if(key!=0xFF)
	printf( "---->---deal_aux %x \r\n",(u16)key);
#endif
		
#if defined(KEY_PRESS_LED_INDICATOR)
	key_press_led_indicator(key);
#elif defined(CUSTOM_KEY_FEATURE_USE)
	custom_key_hdlr(key);
#endif
#ifdef BLUE_TOOTH_GPIO_STATUS
	if(blue_tooth_detect){
		blue_tooth_detect=0;
		bt_disp_status_hdlr();		
	}
#endif
#if defined(KPL_MSG_COMPATIBLE)
	kpl_msg_hdlr(key);
#endif

	 dac_sw_check();

 	switch (key)
        {

#ifdef BLUE_TOOTH_DETECTION_FOR_POWER_OFF
        case INFO_POWER|KEY_SHORT_UP:
	    sys_power_down();
	    break;
#endif 

#ifdef PP_KEY_LONG_CONFIG_BT
        case INFO_PLAY | KEY_LONG:
	     blue_tooth_key_hdlr(BT_CONFIG_HOLD);
		 break;
#endif
        case INFO_PLAY | KEY_HOLD:
#ifdef PP_KEY_LONG_CONFIG_BT
		 break;
	     //blue_tooth_key_hdlr(BT_CONFIG_HOLD);			
#else
	     blue_tooth_key_hdlr(BT_PP_HOLD);			
#endif
	     break;
        case INFO_PLAY | KEY_SHORT_UP :

	     blue_tooth_key_hdlr(BT_PP);
#ifndef BLUE_TOOTH_NO_SYS_MUTE_CTRL
#if !defined(BLUE_TOOTH_BYPASS)	 
            if (play_status == MUSIC_PAUSE)
            {
	         play_status =MUSIC_PLAY;
		  my_main_vol(my_music_vol);
#ifndef BLUE_TOOTH_PP_NOT_EXT_MUTE
  		  Mute_Ext_PA(UNMUTE);
#endif
            }
	     else if (play_status == MUSIC_PLAY){

	        play_status =MUSIC_PAUSE;
#ifndef BLUE_TOOTH_PP_NOT_EXT_MUTE	 	
  		Mute_Ext_PA(MUTE);		 	
#endif
		my_main_vol(0);	
	     }
#endif		 
#endif		 
            Disp_Con(DISP_BLUE_TOOTH);		 
	   break;        

        case INFO_NEXT_FIL | KEY_SHORT_UP:	
        	blue_tooth_key_hdlr(BT_NEXT_FILE);
		break;
		
        case INFO_PREV_FIL | KEY_SHORT_UP:
	     	 blue_tooth_key_hdlr(BT_PREV_FILE);
		 break;

        case INFO_HALF_SECOND :

#ifdef USE_USB_HOTPLUG_FUNC
		usb_hotplug_hdlr();
#endif
#ifdef BLUE_TOOTH_MUTE_DETECT_FUNC
		blue_tooth_mute_detect();
#endif
#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif
#ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER
	 	Disp_BL_time_out();
#endif

#ifdef BLUE_TOOTH_LINK_IDLE_POWER_OFF
		bt_link_idle_hdlr();
#endif

	    if(bt_key_release_cnt--==0){
#ifdef PP_KEY_HOLD_CONFIG_BT
		if(key_release_hdlr==BT_CONFIG_HOLD){

	     	 	blue_tooth_key_hdlr(BT_CONFIG_HOLD_RELEASE);
#else				
		if(key_release_hdlr==BT_PP_HOLD){
		
	     	 	blue_tooth_key_hdlr(BT_PP_HOLD_RELEASE);
#endif
		}
		else if((key_release_hdlr==BT_VOL_UP_HOLD)||(key_release_hdlr==BT_VOL_DOWN_HOLD)){
	     	 	blue_tooth_key_hdlr(BT_VOL_HOLD_RELEASE);

		}
	    }
		
#ifdef USE_BT_ACTIVATED_PIN
	   if(ACTIVATED_PIN_cnt--==0){
			BT_RST_OFF();
	   }
#endif
		
#ifdef BT_DISP_CONNECT_TIME
		bt_disp_time_hdlr();
#endif


#if defined(LINE_IN_PLAY_KEY_PAUSE)
		if(play_status==MUSIC_PAUSE){

#ifdef LINE_IN_FLASH_WHOLE_SCREEN	
			aux_screen_flash_bit=~aux_screen_flash_bit;
			if(aux_screen_flash_bit){
		                  Disp_Con(DISP_BLUE_TOOTH);
			}
			else{
		                   Disp_Con(DISP_PWR_OFF);
					break;
			}
#endif
		}
#endif

			
#if defined(TIME_FORCE_SHOW_ON_SCREEN)

	if(DISP_BLUE_TOOTH == curr_menu){
		
	            if (time_show_return_cnt>RETURN_TIME_SHOW_TIME){
	                    get_curr_date();
	                    Disp_Con(DISP_RTC_POINT);
				break;
		    }	
		     else{
#if defined(MANUAL_SWITCH_TIME_DISPLAY)
	                    Disp_Con(DISP_BLUE_TOOTH);
#else			 	
	                if(DISP_RTC != curr_menu){
				time_show_return_cnt++;
	                }
#endif				
		     }
	     }
#endif
            if (return_cnt < RETURN_TIME)
            {
                return_cnt++;
            }
            else if (RETURN_TIME == return_cnt)
            {
                if (DISP_BLUE_TOOTH != curr_menu)
                    Disp_Con(DISP_BLUE_TOOTH);
				
#if defined(CUSTOM_MAIN_DISP_VOL)
	         if (DISP_BLUE_TOOTH== curr_menu){
                    Disp_Con(DISP_VOL);
	         }
#endif
            }

            if (DISP_BLUE_TOOTH == curr_menu)
	 	     Disp_Con(DISP_BLUE_TOOTH);

	     Disp_Update();			
            break;
			
#ifdef BLUE_TOOTH_BYPASS
    case INFO_VOL_PLUS:
    case INFO_VOL_PLUS | KEY_HOLD :
    case INFO_NEXT_FIL:
    case INFO_NEXT_FIL| KEY_HOLD :
		
    case INFO_VOL_MINUS:
    case INFO_VOL_MINUS | KEY_HOLD :
    case INFO_PREV_FIL:
    case INFO_PREV_FIL| KEY_HOLD :		
		break;
#else
#if defined(NEW_VOLUME_KEY_FEATURE)
        case INFO_NEXT_FIL :
        case INFO_NEXT_FIL | KEY_SHORT_UP:
        case INFO_NEXT_FIL | KEY_HOLD:

		if(!new_vol_feature){
			break;
		}
#else			

    case INFO_VOL_PLUS:
	break;
    case INFO_VOL_PLUS| KEY_SHORT_UP:
#ifdef BLUE_TOOTH_INDEPENDENT_VOLUME_KEY
      	blue_tooth_key_hdlr(BT_VOL_UP);
	break;
#endif	
    case INFO_VOL_PLUS | KEY_HOLD :
#if !defined(INDEPENDENT_VOLUME_KEY)		
    //case INFO_NEXT_FIL:
    case INFO_NEXT_FIL| KEY_HOLD :
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			break;
		}
#endif		

#endif		

#ifdef SUPPORT_PT2313
	if((audio_effect_state>0)){
		audio_effect_hdlr(0x01);
		flush_low_msg();	
		break;
	}
#endif
#ifndef BLUE_TOOTH_INDEPENDENT_VOLUME
        my_music_vol += 2;
#endif
      	blue_tooth_key_hdlr(BT_VOL_UP_HOLD);
	goto __VOL_HDLR;
	
#if defined(NEW_VOLUME_KEY_FEATURE)
        case INFO_PREV_FIL :
        case INFO_PREV_FIL | KEY_SHORT_UP:
        case INFO_PREV_FIL | KEY_HOLD:

		if(!new_vol_feature){
			break;
		}
#else				

    case INFO_VOL_MINUS:
		break;
    case INFO_VOL_MINUS| KEY_SHORT_UP:
#ifdef BLUE_TOOTH_INDEPENDENT_VOLUME_KEY
      	blue_tooth_key_hdlr(BT_VOL_DOWN);
	break;
#endif
    case INFO_VOL_MINUS | KEY_HOLD :
#if !defined(INDEPENDENT_VOLUME_KEY)				
    //case INFO_PREV_FIL:
    case INFO_PREV_FIL| KEY_HOLD :
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			break;
		}
#endif		
#endif

#ifdef SUPPORT_PT2313	
	if((audio_effect_state>0)){
		audio_effect_hdlr(0x02);
		flush_low_msg();
		break;
	}
#endif
      	blue_tooth_key_hdlr(BT_VOL_DOWN_HOLD);

__VOL_HDLR:

#ifndef BLUE_TOOTH_INDEPENDENT_VOLUME
        if(my_music_vol)
            my_music_vol--;

        if (my_music_vol > MAX_VOL)
        {
            my_music_vol = MAX_VOL;
        }
#if defined(LINE_IN_PLAY_KEY_PAUSE)
        if (play_status == MUSIC_PAUSE)
        {
	       play_status =MUSIC_PLAY;
	 }
#endif		
	 clear_super_mute_lock();

        write_info(MEM_VOL,my_music_vol);
	 my_main_vol(my_music_vol);	
	 Disp_Con(DISP_VOL);
#endif	 
        break;
#endif		
#if RTC_ENABLE 
	case INFO_ALM_BELL :					   ///<闹钟响消息,进入闹钟循环
		sys_clock_pll();
		dac_out_select(DAC_DECODE);
		if(alm_bell_mode())
		{
			dac_out_select(DAC_AMUX0);
			return;
		}		
		dac_out_select(DAC_AMUX0);
	break;
#endif
        default :							    
            if (!ap_handle_hotkey(key))
                return;
        }
    }
}
/*----------------------------------------------------------------------------*/
/**@brief  AUX功能入口
   @param  无
   @return 无
   @note   void aux_function(void)
*/
/*----------------------------------------------------------------------------*/
void blue_tooth_hdlr(void)
{
#if 1//defined(LINE_IN_PLAY_KEY_PAUSE)
         play_status =MUSIC_PLAY;
#endif

#ifdef BLUE_TOOTH_MUTE_DETECT_FUNC
	bluetooth_mute_detect=0;
#endif

#ifdef BT_DISP_CONNECT_TIME
    link_sec =0;
    link_min =0; 
    link_hour =0;		
#endif

    set_play_flash(LED_FLASH_ON);
    Disp_Con(DISP_BLUE_TOOTH);

    PT1 = 1;										//timer1 interrupt 低优先级
    flush_low_msg();
#if SDMMC_CMD_MODE
   sd_chk_ctl(SET_SD_L_CHK);
#endif
    main_vol(0);

    blue_tooth_init();
	
    set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL);			//设置AUX模式的音量上限

#ifdef SUPPORT_PT2313

#ifdef BT_USE_AUX_0
    aux_channel_crosstalk_improve(DAC_AMUX0);	//4P24,P25 AUX_IN	 
#else	
    aux_channel_crosstalk_improve(DAC_AMUX1);//4	P26,P27 AUX_IN
#endif

    PT2313_Config(MP3_CHAN,CHAN_ADJ);

    my_main_vol(my_music_vol);	
	
#elif defined(BLUE_TOOTH_BYPASS)||defined(BLUE_TOOTH_PATH_DIRECT_IN_PA)

    dac_out_select(DAC_DECODE);
    my_main_vol(0);	

#else

#ifdef BT_USE_AUX_0
    aux_channel_crosstalk_improve(DAC_AMUX0);	//4P24,P25 AUX_IN	 
#else	
    aux_channel_crosstalk_improve(DAC_AMUX1);//4	P26,P27 AUX_IN
#endif

    my_main_vol(my_music_vol);	
	
#endif

#ifdef FIX_VOL_TO_MAX
    my_main_vol(30);	
#endif
    sysclock_div2(1);

    Mute_Ext_PA(UNMUTE);	

    blue_tooth_main();
	
    main_vol_set(0, CHANGE_VOL_NO_MEM);

    sys_clock_pll();
    Mute_Ext_PA(MUTE);		

#ifdef BLUETOOTH_GPIO_CTRL
    BT_PWR_OFF();
#endif 

#if SDMMC_CMD_MODE
	sd_chk_ctl(SET_SD_H_CHK);
#endif

}
void ipone_hdlr()
{
    u8 key;
#if defined(IPHONE_PP_FLASH)
	bool PP_FLASH_LED = 0;
#endif

    Disp_Con(DISP_IPOD);
#if defined(TURN_ON_MUSIC_WHEN_IPHONE_DOCK)
	delay_10ms(120);

	IPOD_STOP;
	delay_10ms(1);
     	IPOD_RELEASE;	
	delay_10ms(2);
	IPOD_PLAY;
	delay_10ms(1);
     	IPOD_RELEASE;
	delay_10ms(10);
#endif

#if defined(IPONE_LINE_IN_CHANNEL_USE_AUX0)
    aux_channel_crosstalk_improve(DAC_AMUX0);
#else	
    aux_channel_crosstalk_improve(DAC_AMUX1);
#endif
    Mute_Ext_PA(UNMUTE);
    my_main_vol(my_music_vol);
	
    while (1)
    {
        key = get_msg();
#if 0
	if(key!=0xff)
	printf(" ipone_hdlr  %x \r\n",(u16)key);
#endif

       dac_out_select(aux_ch_reg);

	 dac_sw_check();
	 
	switch (key)
        {
        case INFO_PLAY | KEY_SHORT_UP :
	  	play_status = !play_status;

#if defined(IPHONE_CTRL_FAKE)		
            if (play_status)
            {
		  my_main_vol(my_music_vol);
  		  Mute_Ext_PA(UNMUTE);
            }
	     else{
  		Mute_Ext_PA(MUTE);		 	
		my_main_vol(0);	
	     }
#endif		 
		IPOD_PLAY;
		delay_10ms(1);
	     	IPOD_RELEASE;		
            	Disp_Con(DISP_IPOD);
	   break;
	   
        case INFO_NEXT_FIL | KEY_SHORT_UP:
		IPOD_NEXT_TRACK;
		delay_10ms(1);	
	     	IPOD_RELEASE;		
            break;
			
        case INFO_PREV_FIL | KEY_SHORT_UP:
		IPOD_PREVIOUS_TRACK;
		delay_10ms(1);	
	     	IPOD_RELEASE;				
            break;
			       
        case INFO_HALF_SECOND :

#ifdef USE_USB_HOTPLUG_FUNC
		usb_hotplug_hdlr();
#endif

#ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER
	 	Disp_BL_time_out();
#endif
            if (return_cnt < RETURN_TIME)
            {
                return_cnt++;
            }

#if defined(TIME_FORCE_SHOW_ON_SCREEN)
            if (time_show_return_cnt>RETURN_TIME_SHOW_TIME){
                    get_curr_date();
                    Disp_Con(DISP_RTC_POINT);
			break;
	    }	
	     else{
#if defined(MANUAL_SWITCH_TIME_DISPLAY)
                    Disp_Con(DISP_IPOD);
#else			 	
                if(DISP_RTC != curr_menu){
			time_show_return_cnt++;
                }
#endif				
	     }
#endif
			
            if (RETURN_TIME == return_cnt)
            {

#ifdef SUPPORT_PT2313
		  clr_aud_effect_state();
#endif            
                if (DISP_DWORD_NUMBER == curr_menu)
                {
                    cfilenum = 0;
                }

                if (DISP_IPOD != curr_menu)
    			Disp_Con(DISP_IPOD);
            }
#if defined(IPHONE_PP_FLASH)
            if(!play_status){

			PP_FLASH_LED=~PP_FLASH_LED;
			if(PP_FLASH_LED){
    				Disp_Con(DISP_CLR);
			}
			else{

    				Disp_Con(DISP_IPOD);
			}		
	    }				
#endif

#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif
	     Disp_Update();			
            break;

    case INFO_VOL_PLUS:
    case INFO_VOL_PLUS | KEY_HOLD :
#if 1//!defined(INDEPENDENT_VOLUME_KEY)		
    //case INFO_NEXT_FIL:
    //case INFO_NEXT_FIL| KEY_HOLD :
	//	if(IR_KEY_Detect){
	//		IR_KEY_Detect =0;
	//		break;
	//	}
#endif		

	 IPOD_VOLUME_UP;
	 delay_10ms(1);
	 IPOD_RELEASE;
	 delay_10ms(1);	 
	 goto __HOTKEY_HDLR;
	 break;
	 
    case INFO_VOL_MINUS:
    case INFO_VOL_MINUS | KEY_HOLD :
#if 1//!defined(INDEPENDENT_VOLUME_KEY)				
    //case INFO_PREV_FIL:
    //case INFO_PREV_FIL| KEY_HOLD :
	//	if(IR_KEY_Detect){
	//		IR_KEY_Detect =0;
	//		break;
	//	}
#endif
	 IPOD_VOLUME_DOWN;
	 delay_10ms(1);
	 IPOD_RELEASE;
	 delay_10ms(1); 
 	 goto __HOTKEY_HDLR;
	 break;
	 
        default :
__HOTKEY_HDLR:			
            if (!ap_handle_hotkey(key))
                return;
        }
    }
}
void deal_aux( void )
{
    u8 key;
#if defined(K755_JinYeHeLi_755_V001)||defined(K755_AnJieEr_755_V001)
    set_play_flash(LED_FLASH_SLOW);
#endif

#if defined(AUX_PAUSE_LED_INDICATOR_FLASH_WHEN_PLAY)
    set_play_flash(LED_FLASH_NOR);
#endif
#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(UNLOCK);
#endif		  

    my_main_vol(my_music_vol);	

    while (1)
    {
        key = get_msg();
#if 0
	if(key!=0xFF)
	printf( "---->---deal_aux %x \r\n",(u16)key);
#endif

       dac_out_select(aux_ch_reg);
		
#if defined(KEY_PRESS_LED_INDICATOR)
	key_press_led_indicator(key);
#elif defined(CUSTOM_KEY_FEATURE_USE)
	custom_key_hdlr(key);
#endif

#if defined(KPL_MSG_COMPATIBLE)
	kpl_msg_hdlr(key);
#endif

	 dac_sw_check();
	 
	switch (key)
        {
#ifdef USE_IR_LONG_POWER_KEY_TO_FAKE_POWER_OFF
        case INFO_POWER | KEY_LONG:

		if(IR_KEY_Detect){
			goto _HOT_KEY_HDLR;	
		}
		break;
#endif			
        
#if defined(LINE_IN_PLAY_KEY_PAUSE)
#if 1//defined(USE_ONLY_POWER_HOLD_CTRL)
#if defined(USE_POWER_KEY_FOR_AUX_PLAY)
        case INFO_POWER | KEY_SHORT_UP :
#ifdef USE_IR_LONG_POWER_KEY_TO_FAKE_POWER_OFF
		if(IR_KEY_Detect){
			IR_KEY_Detect=0;		
			break;
		}
        case INFO_PLAY | KEY_SHORT_UP :				
#endif			
#ifdef USE_IR_POWER_KEY_TO_POWER_OFF
		if(IR_KEY_Detect){
			goto _HOT_KEY_HDLR;	
		}
        case INFO_PLAY | KEY_SHORT_UP :		
#endif		
			
#else
        case INFO_PLAY | KEY_SHORT_UP :
#endif
#else
        case INFO_PLAY | KEY_SHORT_UP :
#endif			
#ifdef K722_YJH_722_V001
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif			

            if (play_status == MUSIC_PAUSE)
            {
	         play_status =MUSIC_PLAY;
		  my_main_vol(my_music_vol);
#ifndef NO_AUX_MUTE_WHEN_PAUSE		  
  		  Mute_Ext_PA(UNMUTE);
#endif

#if defined(USE_SPECTRUM_PARTTERN)		  
		  set_lcd_flash_lock(UNLOCK);
#endif

#if defined(AUX_PAUSE_LED_INDICATOR)
		 set_play_flash(LED_FLASH_ON);
#elif defined(AUX_PAUSE_LED_INDICATOR_FLASH_WHEN_PLAY)
		 set_play_flash(LED_FLASH_NOR);
#endif
#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(UNLOCK);
#endif		  
            }
	     else if (play_status == MUSIC_PLAY){

	        play_status =MUSIC_PAUSE;

#ifndef NO_AUX_MUTE_WHEN_PAUSE		  		 	
  		Mute_Ext_PA(MUTE);		 
#endif
		my_main_vol(0);	
		
#if defined(USE_SPECTRUM_PARTTERN)		  		
		set_lcd_flash_lock(LOCK);
#endif

#if defined(AUX_PAUSE_LED_INDICATOR)
    		set_play_flash(LED_FLASH_FAST);
#elif defined(AUX_PAUSE_LED_INDICATOR_FLASH_WHEN_PLAY)
		 set_play_flash(LED_FLASH_ON);
#endif	
#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(LOCK);
#endif		  
	     }
#if defined(PAUSE_FLASH_WHOLE_SCREEN)
            if (play_status == MUSIC_PAUSE)
			set_led_flash_tpye(2);
	     else{
			set_led_flash_tpye(0);
	     }
#endif		 
            Disp_Con(DISP_AUX);		 
	   break;        
#endif	   
#ifdef ADC_DETECT_LINE_IN
    case MSG_AUX_IN :
		sys_printf("  MSG_AUX_IN");
	 my_main_vol(my_music_vol);	
	 Mute_Ext_PA(UNMUTE);
        break;

    case MSG_AUX_OUT :
		sys_printf("  MSG_AUX_OUT");
	 Mute_Ext_PA(MUTE);		
	 main_vol(0);			
        break;
#endif

#ifdef USE_AUX_2
     case INFO_MODE | KEY_SHORT_UP:
	 	
		if(aux_2_sel==0){
			aux_2_sel =1;
		       Set_Curr_Func(AUX_2_DEV);
			set_play_flash(LED_FLASH_ON);			   
	   		PT2313_Config(AUX_CHAN,CHAN_ADJ);			
		}
		else{
			aux_2_sel =0;
			goto _HOT_KEY_HDLR;
		}
		break;

     case INFO_AUX_MOD | KEY_SHORT_UP:
	aux_2_sel=~aux_2_sel;
	if(aux_2_sel){

	       Set_Curr_Func(AUX_2_DEV);
   		PT2313_Config(AUX_CHAN,CHAN_ADJ);
	}	
	else{

	       Set_Curr_Func(AUX_DEV);
		PT2313_Config(MP3_CHAN,CHAN_ADJ);
	}

	set_play_flash(LED_FLASH_ON);

	break;
#endif
        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 USE_USB_HOTPLUG_FUNC
		usb_hotplug_hdlr();
#endif

#ifdef VOL_ADJ_SPARK_LED
		if(vol_adj_spark_bit){
			vol_adj_spark_bit=0;
			restore_led_flash_mod(last_led_play_mod);		
		}
#endif	 
#ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER
	 	Disp_BL_time_out();
#endif


            if (return_cnt < RETURN_TIME)
            {
                return_cnt++;
            }

#if defined(LINE_IN_PLAY_KEY_PAUSE)
		if(play_status==MUSIC_PAUSE){

#ifdef LINE_IN_FLASH_WHOLE_SCREEN	
			aux_screen_flash_bit=~aux_screen_flash_bit;
			if(aux_screen_flash_bit){
		                  Disp_Con(DISP_AUX);
			}
			else{
		                   Disp_Con(DISP_PWR_OFF);
					break;
			}
#endif
		}
#endif

			
#if defined(TIME_FORCE_SHOW_ON_SCREEN)

	if(DISP_AUX == curr_menu){
		
	            if (time_show_return_cnt>RETURN_TIME_SHOW_TIME){
	                    get_curr_date();
	                    Disp_Con(DISP_RTC_POINT);
				break;
		    }	
		     else{
#if defined(MANUAL_SWITCH_TIME_DISPLAY)
	                    Disp_Con(DISP_AUX);
#else			 	
	                if(DISP_RTC != curr_menu){
				time_show_return_cnt++;
	                }
#endif				
		     }
	     }
#endif

            if (RETURN_TIME == return_cnt)
            {
            
#ifdef SUPPORT_PT2313
		  clr_aud_effect_state();
#endif
#if defined(LED_DRV_USE_SM1628)
		led_spark_protect=0;
#endif

                if (DISP_DWORD_NUMBER == curr_menu)
                {
                    cfilenum = 0;
                }
                if (DISP_AUX != curr_menu)
                    Disp_Con(DISP_AUX);
				
#if defined(CUSTOM_MAIN_DISP_VOL)
	         if (DISP_AUX== curr_menu){
                    Disp_Con(DISP_VOL);
	         }
#endif
				
            }
#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif
	     Disp_Update();			
            break;
#if defined(NEW_VOLUME_KEY_FEATURE)
        case INFO_NEXT_FIL :
        case INFO_NEXT_FIL | KEY_SHORT_UP:
        case INFO_NEXT_FIL | KEY_HOLD:

		if(!new_vol_feature){
			break;
		}
#else			

    case INFO_VOL_PLUS:
    case INFO_VOL_PLUS | KEY_HOLD :
#ifdef KEY_NEXT_PREV_HOLD_ADJ_VOL_IN_AUX
    case INFO_NEXT_FIL| KEY_HOLD :
#endif
#if !defined(INDEPENDENT_VOLUME_KEY)		
    case INFO_NEXT_FIL:
    case INFO_NEXT_FIL| KEY_HOLD :
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			break;
		}
#endif		

#endif		

#ifdef SUPPORT_PT2313
	if((audio_effect_state>0)){
		audio_effect_hdlr(0x01);
		flush_low_msg();	
		break;
	}
#endif

        my_music_vol += 2;

#if defined(NEW_VOLUME_KEY_FEATURE)
        case INFO_PREV_FIL :
        case INFO_PREV_FIL | KEY_SHORT_UP:
        case INFO_PREV_FIL | KEY_HOLD:

		if(!new_vol_feature){
			break;
		}
#else				

    case INFO_VOL_MINUS:
    case INFO_VOL_MINUS | KEY_HOLD :
#ifdef KEY_NEXT_PREV_HOLD_ADJ_VOL_IN_AUX
    case INFO_PREV_FIL| KEY_HOLD :
#endif		
#if !defined(INDEPENDENT_VOLUME_KEY)				
    case INFO_PREV_FIL:
    case INFO_PREV_FIL| KEY_HOLD :
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			break;
		}
#endif		
#endif

#ifdef SUPPORT_PT2313	
	if((audio_effect_state>0)){
		audio_effect_hdlr(0x02);
		flush_low_msg();
		break;
	}
#endif

        if(my_music_vol)
            my_music_vol--;
#ifdef VOL_ADJ_SPARK_LED

	if(!vol_adj_spark_bit){
		vol_adj_spark_bit=1;
		last_led_play_mod = get_led_flash_mode();
	}
	set_play_flash(LED_FLASH_VERY_FAST);
#endif

        if (my_music_vol > MAX_VOL)
        {
            my_music_vol = MAX_VOL;
        }
#if defined(LINE_IN_PLAY_KEY_PAUSE)
        if (play_status == MUSIC_PAUSE)
        {
	       play_status =MUSIC_PLAY;
#ifndef NO_AUX_MUTE_WHEN_PAUSE		  
  		  Mute_Ext_PA(UNMUTE);
#endif		   
	 }
#endif		
	 clear_super_mute_lock();

        write_info(MEM_VOL,my_music_vol);
	 my_main_vol(my_music_vol);	
	 Disp_Con(DISP_VOL);
        break;			
#if RTC_ENABLE 
	case INFO_ALM_BELL :					   ///<闹钟响消息,进入闹钟循环
		sys_clock_pll();
		dac_out_select(DAC_DECODE);
		if(alm_bell_mode())
		{
			dac_out_select(DAC_AMUX0);
			return;
		}		
		dac_out_select(DAC_AMUX0);
	break;
#endif
        default :
_HOT_KEY_HDLR:			        
            if (!ap_handle_hotkey(key))
                return;
        }
    }
}
Beispiel #8
0
/*********************************************************************************
 * void set_time_buf(void)
 * Description : 提取需要播放的音乐文件序号
 * Arguments   : 
 * Returns     :  
 * Notes       : 
 *********************************************************************************/
void get_time_tobuf(void)
{
   u8 time;
   play_len =0;
   get_curr_date();
  // my_memset((u8 _xdata *)play_buf,0,8);
  // play_buf[play_len++]= BPF_XZSJ_MP3;
    if(0 == curr_date.hour)
    {
        play_buf[play_len++]= music_file_0; 
        play_buf[play_len++]= music_file_dian;
    }
    else
    {
       
        if(curr_date.hour >= 10)
        {   
            time = curr_date.hour /10;
            if( 2 == time)
            {
                play_buf[play_len++]= (u16)vocicetime_num[time];//time; //2 1   
            }
            play_buf[play_len++]= music_file_shi; 
        }
    
        time = curr_date.hour %10;
        if(0 != time)
        { 
            play_buf[play_len++]= (u16)vocicetime_num[time];//time;   
        } 
        play_buf[play_len++]= music_file_dian;
    }

    if(0 == curr_date.minutes)
    {
       // play_buf[i++]= music_file_0; 
       // play_buf[i++]= music_file_fen;
    }
    else
    {
        
        if(curr_date.minutes >= 10)
        {
            time = curr_date.minutes /10;
            if( 1 != time)
            {
                play_buf[play_len++]= (u16)vocicetime_num[time];//time; //5 4 3 2 1   
            }
            play_buf[play_len++]= music_file_shi; 
        }
        else
        {
             play_buf[play_len++]= music_file_0; 
        }
        time = curr_date.minutes %10;
        if(0 != time)
        { 
            play_buf[play_len++]= (u16)vocicetime_num[time];//time;    
        }
        play_buf[play_len++]= music_file_fen;
    }
}
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;
            }
        }
    }
}
bool init_rtc(void)
{
    u8 rtc_con;
    bool alm_wkup;

    curr_alm.hour = read_info(MEM_ALM_HOUR);
    curr_alm.minutes = read_info(MEM_ALM_MIN);
    if (curr_alm.hour > 23)
    {
#ifdef USE_RTC_ALM_CUSTOM_INIT    
        curr_alm.hour = 0;
#else
        curr_alm.hour = 12;
#endif
    }
    if (curr_alm.minutes > 59)
    {
        curr_alm.minutes = 0;
    }
    alm_sw = 0;
    rtc_con=read_rtc_reg();			 //读出IRTCON = 0x05;32KHz enable,32KHz output

    alm_wkup = 0;

    //printf("%u\n",(u16)rtc_con);
    if (rtc_con & BIT(6))   ///<RTC是否完全掉电
    {
#ifdef UART_ENABLE_RTC
    	sys_printf("sys_init from completely power off");
#endif
    
        send_rtc_sec(0);
    }
    else
    {

#ifdef UART_ENABLE_RTC	
    	sys_printf("sys_init from NOT completely power off");
#endif
    
        if (rtc_con & (1<<1))    ///<RTC是否开闹钟
        {
            alm_sw = 1;
        }
        if (rtc_con & BIT(7))   ///<闹钟唤醒
        {
#ifdef PWR_OFF_WAKEUP_FUNC
#if defined(PWR_CTRL_WKUP)
			    wkup_pin_ctrl(1);
#else
			    power_ctl(1);
#endif
#endif
        
            alm_wkup=1;
            alm_flag = 1;

        }
    }
    get_curr_date();
    chk_date_err();
    fond_alm_clk();

    rtc_con &= ~BIT(6); 				 //清零PDGLG
    write_rtc_reg(rtc_con);
    return alm_wkup;
}