/*****************************************************************************
* Module    : UI
* File      : ui_aux.c
* Author    : Hanny
* Function  : 扩音器任务用户自定义UI设计，处理按键功能映射与显示
*****************************************************************************/
#ifndef CONFIG_C

//扩音器任务显示处理
#if IS_LEDSEG_7PIN_DISPLAY
#pragma location="TASK_AUX_SEG"
void task_aux_display(void)
{
    ledseg_ocx_event();

    switch (ledseg_ocx.disp_status) {
    case LEDSEG_OCX_NULL:
        ledseg_disp(MENU_LINEIN);
        break;
    default:
        ledseg_ocx_display();
        break;
    }
}
#else
#pragma location="TASK_AUX_SEG"
void task_aux_display(void)
{
}
#endif

//任务消息处理
#pragma location="TASK_AUX_SEG"
void task_aux_deal_msg(u8 msg)
{
#if WARNING_VOL_MAXMIN
    if(sys_ctl.vol_maxmin_music_flag == 1){ //恢复以前的声音
		sys_ctl.vol_maxmin_music_flag = 0;
	    dac_disable();
        if (!t_aux.mute){
            amux_play(); //打开aux通道
        }
        flush_msg();
        return;
    }
#endif

    switch(msg) {
    case KU_PLAY:
    case KU_PLAY_POWER:
        //控制MUTE
        if (t_aux.mute) {
            t_aux.mute = 0;
            sys_ctl.sleep_cnt = 0xffff;
            amux_play();
        } else {
            t_aux.mute = 1;
#if AUX_AUTO_STANDBY_EN
            sys_ctl.sleep_cnt = STANDBY_TIME;
#endif
            amux_stop();
        }
        break;

        //音量加减
    case K_VOL_DOWN:
    case KL_VOL_DOWN:
    case KH_VOL_DOWN:
    case KH_PREV_VOL_DOWN:
         user_set_volume(user_volume_dec(sys_ctl.volume));
         show_volume();
#if WARNING_VOL_MAXMIN
        if(!sys_ctl.volume){
            aux_play_vol_music();
        }
#endif
        break;
    case K_VOL_UP:
    case KL_VOL_UP:
    case KH_VOL_UP:
    case KH_NEXT_VOL_UP:
        user_set_volume(user_volume_inc(sys_ctl.volume));
        show_volume();
#if WARNING_VOL_MAXMIN
        if(sys_ctl.volume == VOLUME_MAX){
            aux_play_vol_music();
        }
#endif
        break;

    default:
        deal_msg(msg);
        break;
    }
}
#endif
