#include "esp_lcd_panel_ops.h"
#include "lcd_display_drv.h"
#include "log.h"
#include "rtos_drv.h"
#include "system_freertos_define.h"
#include "ui.h"
#include "events/ui_menu_screen_event.h"

#include "parameter.h"

static const char* TAG = "ui_menu_screen_event";

/*编程周标记*/
uint8_t prog_weekday = 1;
/*编程段标记*/
uint8_t prog_weekday_seg = 1;

/*定时周标记*/
uint8_t schedule_weekday = 1;
/*定时段标记*/
uint8_t schedule_weekday_seg = 1;

static char weekday_text[7][5] = {"Mon", "Tue", "Wen", "Thu", "Fri", "Sta", "Sun"};

lv_obj_t **sch_copy_panel[6][2] = {
  {&ui_ProgramScheduleCopyPanelSeg1Panel, &ui_ProgramScheduleCopyPanelSeg1PanelLable},
  {&ui_ProgramScheduleCopyPanelSeg2Panel, &ui_ProgramScheduleCopyPanelSeg2PanelLable},
  {&ui_ProgramScheduleCopyPanelSeg3Panel, &ui_ProgramScheduleCopyPanelSeg3PanelLable},
  {&ui_ProgramScheduleCopyPanelSeg4Panel, &ui_ProgramScheduleCopyPanelSeg4PanelLable},
  {&ui_ProgramScheduleCopyPanelSeg5Panel, &ui_ProgramScheduleCopyPanelSeg5PanelLable},
  {&ui_ProgramScheduleCopyPanelSeg6Panel, &ui_ProgramScheduleCopyPanelSeg6PanelLable},
  };

lv_obj_t **pro_copy_panel[6][2] = {
  {&ui_ProgramCopyPanelSeg1Panel, &ui_ProgramCopyPanelSeg1PanelLable},
  {&ui_ProgramCopyPanelSeg2Panel, &ui_ProgramCopyPanelSeg2PanelLable},
  {&ui_ProgramCopyPanelSeg3Panel, &ui_ProgramCopyPanelSeg3PanelLable},
  {&ui_ProgramCopyPanelSeg4Panel, &ui_ProgramCopyPanelSeg4PanelLable},
  {&ui_ProgramCopyPanelSeg5Panel, &ui_ProgramCopyPanelSeg5PanelLable},
  {&ui_ProgramCopyPanelSeg6Panel, &ui_ProgramCopyPanelSeg6PanelLable},
  };


/*0:OFF, 1:Timer, 2:Prog*/
void menu_screen_interface_refresh(uint8_t program_type)
{
  if(lv_scr_act() != ui_MenuScreen)
  return;

  char text[20] = {0};

  /*变成数据获取*/
  programme_data_t programme_data = programme_data_get();
  /*编程/睡眠/定时开关刷新*/
  if(programme_state_get(GetProgram_option()))
  {
    if(!lv_obj_has_state(ui_MenuProgramPanelSwitch, LV_STATE_CHECKED))
    {
      _ui_state_modify(ui_MenuProgramPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
    }
  }
  else
  {
    if(lv_obj_has_state(ui_MenuProgramPanelSwitch, LV_STATE_CHECKED))
    {
      _ui_state_modify(ui_MenuProgramPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    }
  }

  switch (program_type)
  {
    case 0:
    /* code */
    lv_img_set_src(ui_MenuProgramPanelImage, &ui_img_21_sleep_sleep_normal_png);
    _ui_flag_modify(ui_MenuProgramPanelSleepPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
    _ui_flag_modify(ui_MenuProgramPanelSetLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
    lv_label_set_text(ui_MenuProgramPanelLabel, "Sleep");

    lv_snprintf(text, sizeof(text), "%dh", programme_data.sleep_data.sleep_hour);
    _ui_label_set_property(ui_MenuProgramPanelSleepPanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);
    break;

    case 1:
    /* code */
    lv_img_set_src(ui_MenuProgramPanelImage, &ui_img_21_timing_nromal_png);
    _ui_flag_modify(ui_MenuProgramPanelSleepPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
    _ui_flag_modify(ui_MenuProgramPanelSetLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
    lv_label_set_text(ui_MenuProgramPanelLabel, "Power Schedule");

    _ui_state_modify(ui_ProgramScheduleWeekDaySelect1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect7Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

    _ui_state_modify(ui_ProgramScheduleWeekDaySelect1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleWeekDaySelect7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

    _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

    char on_off_text[10];
    /*第1段*/
    if(programme_data.sch_data.day[schedule_weekday -1].seg[0].on_off)
    {
      strcpy(on_off_text,"ON");
    }
    else
    {
      strcpy(on_off_text,"OFF");
    }
    lv_snprintf(text, sizeof(text), "%02d:%02d       %s", 
          programme_data.sch_data.day[schedule_weekday - 1].seg[0].time / 60, 
          programme_data.sch_data.day[schedule_weekday - 1].seg[0].time % 60,
          on_off_text);
        _ui_label_set_property(ui_ProgramScheduleWeekDaySeg1PanelChildPanelLable, _UI_LABEL_PROPERTY_TEXT, text);

    if(programme_data.sch_data.day[schedule_weekday -1].seg[0].enable)
    {
      _ui_state_modify(ui_ProgramScheduleWeekDaySeg1PanelChildPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
    }
    else
    {
      _ui_state_modify(ui_ProgramScheduleWeekDaySeg1PanelChildPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    }

    /*第二段*/
    if(programme_data.sch_data.day[schedule_weekday -1].seg[1].on_off)
    {
      strcpy(on_off_text,"ON");
    }
    else
    {
      strcpy(on_off_text,"OFF");
    }
    lv_snprintf(text, sizeof(text), "%02d:%02d       %s",
          programme_data.sch_data.day[schedule_weekday - 1].seg[1].time / 60, 
          programme_data.sch_data.day[schedule_weekday - 1].seg[1].time % 60,
          on_off_text);
        _ui_label_set_property(ui_ProgramScheduleWeekDaySeg2PanelChildPanelLable, _UI_LABEL_PROPERTY_TEXT, text);

    if(programme_data.sch_data.day[schedule_weekday -1].seg[1].enable)
    {
      _ui_state_modify(ui_ProgramScheduleWeekDaySeg2PanelChildPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
    }
    else
    {
      _ui_state_modify(ui_ProgramScheduleWeekDaySeg2PanelChildPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    }

    /*第三段*/
    if(programme_data.sch_data.day[schedule_weekday -1].seg[2].on_off)
    {
      strcpy(on_off_text,"ON");
    }
    else
    {
      strcpy(on_off_text,"OFF");
    }
    lv_snprintf(text, sizeof(text), "%02d:%02d       %s",
          programme_data.sch_data.day[schedule_weekday - 1].seg[2].time / 60, 
          programme_data.sch_data.day[schedule_weekday - 1].seg[2].time % 60,
          on_off_text);
        _ui_label_set_property(ui_ProgramScheduleWeekDaySeg3PanelChildPanelLable, _UI_LABEL_PROPERTY_TEXT, text);

    if(programme_data.sch_data.day[schedule_weekday -1].seg[2].enable)
    {
      _ui_state_modify(ui_ProgramScheduleWeekDaySeg3PanelChildPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
    }
    else
    {
      _ui_state_modify(ui_ProgramScheduleWeekDaySeg3PanelChildPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    }

    /*第四段*/
    if(programme_data.sch_data.day[schedule_weekday -1].seg[3].on_off)
    {
      strcpy(on_off_text,"ON");
    }
    else
    {
      strcpy(on_off_text,"OFF");
    }
    lv_snprintf(text, sizeof(text), "%02d:%02d       %s",
          programme_data.sch_data.day[schedule_weekday - 1].seg[3].time / 60, 
          programme_data.sch_data.day[schedule_weekday - 1].seg[3].time % 60,
          on_off_text);
        _ui_label_set_property(ui_ProgramScheduleWeekDaySeg4PanelChildPanelLable, _UI_LABEL_PROPERTY_TEXT, text);

    if(programme_data.sch_data.day[schedule_weekday -1].seg[3].enable)
    {
      _ui_state_modify(ui_ProgramScheduleWeekDaySeg4PanelChildPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
    }
    else
    {
      _ui_state_modify(ui_ProgramScheduleWeekDaySeg4PanelChildPanelSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    }

    /*设置界面刷新*/
    if(programme_data.sch_data.day[schedule_weekday -1].seg[schedule_weekday_seg -1].on_off)
    {
      lv_label_set_text(ui_ProgramScheduleSetPanelTempPanelLable, "ON");
    }
    else
    {
      lv_label_set_text(ui_ProgramScheduleSetPanelTempPanelLable, "OFF");
    }

    lv_snprintf(text, sizeof(text), "%02d  %02d",
          programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg -1].time / 60, 
          programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg -1].time % 60);
        _ui_label_set_property(ui_ProgramScheduleSetPanelTimePanelLable, _UI_LABEL_PROPERTY_TEXT, text);

    

    switch(schedule_weekday)
    {
      case 1:
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        break;

      case 2:
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
      break;

      case 3:
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        break;

      case 4:
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
      break;

      case 5:
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        break;

      case 6:
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
      break;

      case 7:
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect7Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleWeekDaySelect7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        break;

      default:
        break;
    }
    break;
  
    case 2:
    /* code */
    lv_img_set_src(ui_MenuProgramPanelImage, &ui_img_21_program_normal_png);
    _ui_flag_modify(ui_MenuProgramPanelSleepPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
    _ui_flag_modify(ui_MenuProgramPanelSetLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
    lv_label_set_text(ui_MenuProgramPanelLabel, "Program");

    _ui_state_modify(ui_ProgramWeekDaySelect1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect7Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

    _ui_state_modify(ui_ProgramWeekDaySelect1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramWeekDaySelect7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

    _ui_state_modify(ui_ProgramSetPanelWeekDay1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramSetPanelWeekDay2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramSetPanelWeekDay3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramSetPanelWeekDay4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramSetPanelWeekDay5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramSetPanelWeekDay6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramSetPanelWeekDay7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

    /*编程设置页面抬头刷新*/
    lv_snprintf(text, sizeof(text), "Time Zone %01d", prog_weekday_seg);
    _ui_label_set_property(ui_ProgramSetPanelLabel, _UI_LABEL_PROPERTY_TEXT, text);

    /*冷热选择开关刷新*/
    if(pro_cool_heat_get() == 2)
    {
        if(!lv_obj_has_state(ui_ProgramPanelHeatCoolSwitch, LV_STATE_CHECKED))
        { 
          _ui_state_modify(ui_ProgramPanelHeatCoolSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
          _ui_flag_modify(ui_ProgramPanelHeatCoolSwitchCoolLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
          _ui_flag_modify(ui_ProgramPanelHeatCoolSwitchHeatLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
        }
    }
    else 
    {
        if(lv_obj_has_state(ui_ProgramPanelHeatCoolSwitch, LV_STATE_CHECKED))
        { 
          _ui_state_modify(ui_ProgramPanelHeatCoolSwitch, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
          _ui_flag_modify(ui_ProgramPanelHeatCoolSwitchCoolLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
          _ui_flag_modify(ui_ProgramPanelHeatCoolSwitchHeatLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
        }
    }

    /*六段编程数据刷新*/
    /*摄氏度*/
    if(Gettemperature_unit() == 0)
    {
      if(pro_cool_heat_get() == 1)
      {
        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_cool.day[prog_weekday - 1].seg[0].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[0].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[0].temp / 10, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[0].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg1PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_cool.day[prog_weekday - 1].seg[1].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[1].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[1].temp / 10, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[1].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg2PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_cool.day[prog_weekday - 1].seg[2].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[2].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[2].temp / 10, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[2].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg3PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_cool.day[prog_weekday - 1].seg[3].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[3].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[3].temp / 10, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[3].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg4PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_cool.day[prog_weekday - 1].seg[4].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[4].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[4].temp / 10, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[4].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg5PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_cool.day[prog_weekday - 1].seg[5].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[5].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[5].temp / 10, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[5].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg6PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);
      }
      /*制热*/
      else if(pro_cool_heat_get() == 2)
      {
        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_heat.day[prog_weekday - 1].seg[0].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[0].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[0].temp / 10, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[0].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg1PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_heat.day[prog_weekday - 1].seg[1].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[1].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[1].temp / 10, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[1].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg2PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_heat.day[prog_weekday - 1].seg[2].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[2].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[2].temp / 10, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[2].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg3PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_heat.day[prog_weekday - 1].seg[3].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[3].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[3].temp / 10, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[3].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg4PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_heat.day[prog_weekday - 1].seg[4].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[4].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[4].temp / 10, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[4].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg5PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d.%01d℃", programme_data.pro_data_heat.day[prog_weekday - 1].seg[5].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[5].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[5].temp / 10, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[5].temp % 10);
        _ui_label_set_property(ui_ProgramPanelSeg6PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);
      }
    }
    /*华氏度*/
    else
    {
      if(pro_cool_heat_get() == 1)
      {
        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_cool.day[prog_weekday - 1].seg[0].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[0].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[0].temp);
        _ui_label_set_property(ui_ProgramPanelSeg1PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_cool.day[prog_weekday - 1].seg[1].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[1].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[1].temp);
        _ui_label_set_property(ui_ProgramPanelSeg2PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_cool.day[prog_weekday - 1].seg[2].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[2].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[2].temp);
        _ui_label_set_property(ui_ProgramPanelSeg3PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_cool.day[prog_weekday - 1].seg[3].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[3].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[3].temp);
        _ui_label_set_property(ui_ProgramPanelSeg4PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_cool.day[prog_weekday - 1].seg[4].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[4].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[4].temp);
        _ui_label_set_property(ui_ProgramPanelSeg5PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_cool.day[prog_weekday - 1].seg[5].time / 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[5].time % 60, 
          programme_data.pro_data_cool.day[prog_weekday - 1].seg[5].temp);
        _ui_label_set_property(ui_ProgramPanelSeg6PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);
      }
      /*制热*/
      else if(pro_cool_heat_get() == 2)
      {
        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_heat.day[prog_weekday - 1].seg[0].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[0].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[0].temp);
        _ui_label_set_property(ui_ProgramPanelSeg1PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_heat.day[prog_weekday - 1].seg[1].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[1].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[1].temp);
        _ui_label_set_property(ui_ProgramPanelSeg2PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_heat.day[prog_weekday - 1].seg[2].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[2].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[2].temp);
        _ui_label_set_property(ui_ProgramPanelSeg3PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_heat.day[prog_weekday - 1].seg[3].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[3].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[3].temp);
        _ui_label_set_property(ui_ProgramPanelSeg4PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_heat.day[prog_weekday - 1].seg[4].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[4].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[4].temp);
        _ui_label_set_property(ui_ProgramPanelSeg5PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);

        lv_snprintf(text, sizeof(text), "%02d:%02d     %02d℉", programme_data.pro_data_heat.day[prog_weekday - 1].seg[5].time / 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[5].time % 60, 
          programme_data.pro_data_heat.day[prog_weekday - 1].seg[5].temp);
        _ui_label_set_property(ui_ProgramPanelSeg6PanelTimeLable, _UI_LABEL_PROPERTY_TEXT, text);
      }
    }

    /*摄氏度*/
    if(Gettemperature_unit() == 0)
    {
        /*某一段设置数据刷新*/
        if(pro_cool_heat_get() == 2)
        {
          lv_snprintf(text, sizeof(text), "%02d  %02d", 
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time / 60, 
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time % 60);
          _ui_label_set_property(ui_ProgramSetPanelTimePanelLable, _UI_LABEL_PROPERTY_TEXT, text);

          lv_snprintf(text, sizeof(text), "%02d.%01d℃", 
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp / 10, 
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp % 10);
          _ui_label_set_property(ui_ProgramSetPanelTempPanelLable, _UI_LABEL_PROPERTY_TEXT, text);
        }
        else if(pro_cool_heat_get() == 1)
        {
          lv_snprintf(text, sizeof(text), "%02d  %02d", 
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time / 60, 
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time % 60);
          _ui_label_set_property(ui_ProgramSetPanelTimePanelLable, _UI_LABEL_PROPERTY_TEXT, text);

          lv_snprintf(text, sizeof(text), "%02d.%01d℃", 
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp / 10, 
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp % 10);
          _ui_label_set_property(ui_ProgramSetPanelTempPanelLable, _UI_LABEL_PROPERTY_TEXT, text);
        }
    }
    /*华氏度*/
    else
    {
      /*某一段设置数据刷新*/
        if(pro_cool_heat_get() == 2)
        {
          lv_snprintf(text, sizeof(text), "%02d  %02d", 
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time / 60, 
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time % 60);
          _ui_label_set_property(ui_ProgramSetPanelTimePanelLable, _UI_LABEL_PROPERTY_TEXT, text);

          lv_snprintf(text, sizeof(text), "%02d℉", 
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp);
          _ui_label_set_property(ui_ProgramSetPanelTempPanelLable, _UI_LABEL_PROPERTY_TEXT, text);
        }
        else if(pro_cool_heat_get() == 1)
        {
          lv_snprintf(text, sizeof(text), "%02d  %02d", 
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time / 60, 
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time % 60);
          _ui_label_set_property(ui_ProgramSetPanelTimePanelLable, _UI_LABEL_PROPERTY_TEXT, text);

          lv_snprintf(text, sizeof(text), "%02d℉", 
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp);
          _ui_label_set_property(ui_ProgramSetPanelTempPanelLable, _UI_LABEL_PROPERTY_TEXT, text);
        }
    }
    
    switch(prog_weekday)
    {
      case 1:
        _ui_state_modify(ui_ProgramWeekDaySelect1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramWeekDaySelect1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramSetPanelWeekDay1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        break;

      case 2:
        _ui_state_modify(ui_ProgramWeekDaySelect2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramWeekDaySelect2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramSetPanelWeekDay2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
      break;

      case 3:
        _ui_state_modify(ui_ProgramWeekDaySelect3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramWeekDaySelect3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramSetPanelWeekDay3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        break;

      case 4:
        _ui_state_modify(ui_ProgramWeekDaySelect4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramWeekDaySelect4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramSetPanelWeekDay4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
      break;

      case 5:
        _ui_state_modify(ui_ProgramWeekDaySelect5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramWeekDaySelect5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramSetPanelWeekDay5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        break;

      case 6:
        _ui_state_modify(ui_ProgramWeekDaySelect6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramWeekDaySelect6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramSetPanelWeekDay6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
      break;

      /*周天*/
      case 7:
        _ui_state_modify(ui_ProgramWeekDaySelect7Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramWeekDaySelect7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        _ui_state_modify(ui_ProgramSetPanelWeekDay7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
        break;

      default:
        break;
    }
    break;
  
    default:
    break;
  }
}

void MenuScreenLoadStartCallback(lv_event_t * e)
{
  if(GetWork_mode() == 2)
  {
    /*制热编程*/
    pro_cool_heat_set(2);
  }
  else
  {
    /*制冷编程*/
    pro_cool_heat_set(1);
  }
  menu_screen_interface_refresh(GetProgram_option());
}

void MenuScreenLoadedCallback(lv_event_t * e)
{

}

void MenuScreenUnloadedCallback(lv_event_t * e)
{
    lv_obj_t* target = lv_event_get_target(e);
  if (target != ui_MenuScreen) {
    USER_LOGE(TAG, "ui_MenuScreen target error");
    goto End;
  }

  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTempLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTempPanelDownPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTempPanelUpPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTempPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTempPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTimeLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTimePanelMinuteDownPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTimePanelMinuteUpPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTimePanelHourDownPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTimePanelHourUpPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTimePanelImage);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTimePanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelTimePanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay7PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay7Panel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay6PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay6Panel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay5PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay5Panel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay4PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay4Panel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay3PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay3Panel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay2PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay2Panel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay1PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDay1Panel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelWeekDayPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelLabel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanelReturnPanel);
  lvgl_obj_delete(&ui_ProgramScheduleSetPanel);
  lvgl_obj_delete(&ui_ProgramScheduleResetPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleResetPanel);
  lvgl_obj_delete(&ui_ProgramScheduleResetBackPanel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyBackPanelConfirmPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyBackPanelConfirmPanel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyBackPanelCancelPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyBackPanelCancelPanel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg6PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg6Panel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg5PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg5Panel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg4PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg4Panel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg3PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg3Panel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg2PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg2Panel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg1PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelSeg1Panel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleCopyPanel);
  lvgl_obj_delete(&ui_ProgramScheduleCopyBackPanel);
  lvgl_obj_delete(&ui_ProgramSchedulePanelResetPanelLable);
  lvgl_obj_delete(&ui_ProgramSchedulePanelResetPanel);
  lvgl_obj_delete(&ui_ProgramSchedulePanelCopyPanelLable);
  lvgl_obj_delete(&ui_ProgramSchedulePanelCopyPanel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg4PanelChildPanelSwitch);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg4PanelChildPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg4PanelChildPanel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg4Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg3PanelChildPanelSwitch);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg3PanelChildPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg3PanelChildPanel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg3Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg2PanelChildPanelSwitch);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg2PanelChildPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg2PanelChildPanel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg2Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg1PanelChildPanelSwitch);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg1PanelChildPanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg1PanelChildPanel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySeg1Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect7PanelDot);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect7PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect7Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect6PanelDot);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect6PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect6Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect5PanelDot);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect5PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect5Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect4PanelDot);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect4PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect4Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect3PanelDot);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect3PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect3Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect2PanelDot);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect2PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect2Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect1PanelDot);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect1PanelLable);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelect1Panel);
  lvgl_obj_delete(&ui_ProgramScheduleWeekDaySelectPanel);
  lvgl_obj_delete(&ui_ProgramSchedulePanelLabel);
  lvgl_obj_delete(&ui_ProgramSchedulePanelReturnPanel);
  lvgl_obj_delete(&ui_ProgramSchedulePanel);
  lvgl_obj_delete(&ui_ProgramSetPanelTempLable);
  lvgl_obj_delete(&ui_ProgramSetPanelTempPanelDownPanel);
  lvgl_obj_delete(&ui_ProgramSetPanelTempPanelUpPanel);
  lvgl_obj_delete(&ui_ProgramSetPanelTempPanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelTempPanel);
  lvgl_obj_delete(&ui_ProgramSetPanelTimeLable);
  lvgl_obj_delete(&ui_ProgramSetPanelTimePanelMinuteDownPanel);
  lvgl_obj_delete(&ui_ProgramSetPanelTimePanelMinuteUpPanel);
  lvgl_obj_delete(&ui_ProgramSetPanelTimePanelHourDownPanel);
  lvgl_obj_delete(&ui_ProgramSetPanelTimePanelHourUpPanel);
  lvgl_obj_delete(&ui_ProgramSetPanelTimePanelImage);
  lvgl_obj_delete(&ui_ProgramSetPanelTimePanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelTimePanel);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay7PanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay7Panel);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay6PanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay6Panel);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay5PanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay5Pane);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay4PanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay4Panel);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay3PanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay3Panel);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay2PanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay2Panel);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay1PanelLable);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDay1Panel);
  lvgl_obj_delete(&ui_ProgramSetPanelWeekDayPanel);
  lvgl_obj_delete(&ui_ProgramSetPanelLabel);
  lvgl_obj_delete(&ui_ProgramSetPanelReturnPanel);
  lvgl_obj_delete(&ui_ProgramSetPanel);
  lvgl_obj_delete(&ui_ProgramResetPanelLable);
  lvgl_obj_delete(&ui_ProgramResetPanel);
  lvgl_obj_delete(&ui_ProgramResetBackPanel);
  lvgl_obj_delete(&ui_ProgramCopyBackPanelConfirmPanelLable);
  lvgl_obj_delete(&ui_ProgramCopyBackPanelConfirmPanel);
  lvgl_obj_delete(&ui_ProgramCopyBackPanelCancelPanelLable);
  lvgl_obj_delete(&ui_ProgramCopyBackPanelCancelPanel);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg6PanelLable);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg6Panel);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg5PanelLable);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg5Panel);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg4PanelLable);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg4Panel);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg3PanelLable);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg3Panel);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg2PanelLable);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg2Panel);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg1PanelLable);
  lvgl_obj_delete(&ui_ProgramCopyPanelSeg1Panel);
  lvgl_obj_delete(&ui_ProgramCopyPanelLable);
  lvgl_obj_delete(&ui_ProgramCopyPanel);
  lvgl_obj_delete(&ui_ProgramCopyBackPanel);
  lvgl_obj_delete(&ui_ProgramPanelResetPanelLable);
  lvgl_obj_delete(&ui_ProgramPanelResetPanel);
  lvgl_obj_delete(&ui_ProgramPanelCopyPanelLable);
  lvgl_obj_delete(&ui_ProgramPanelCopyPanel);
  lvgl_obj_delete(&ui_ProgramPanelSeg6PanelTimeLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg6PanelSegLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg6Panel);
  lvgl_obj_delete(&ui_ProgramPanelSeg5PanelTimeLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg5PanelSegLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg5Panel);
  lvgl_obj_delete(&ui_ProgramPanelSeg4PanelTimeLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg4PanelSegLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg4Panel);
  lvgl_obj_delete(&ui_ProgramPanelSeg3PanelTimeLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg3PanelSegLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg3Panel);
  lvgl_obj_delete(&ui_ProgramPanelSeg2PanelTimeLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg2PanelSegLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg2Panel);
  lvgl_obj_delete(&ui_ProgramPanelSeg1PanelTimeLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg1PanelSegLable);
  lvgl_obj_delete(&ui_ProgramPanelSeg1Panel);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect7PanelDot);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect7PanelLable);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect7Panel);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect6PanelDot);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect6PanelLable);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect6Panel);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect5PanelDot);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect5PanelLable);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect5Panel);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect4PanelDot);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect4PanelLable);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect4Panel);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect3PanelDot);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect3PanelLable);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect3Panel);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect2PanelDot);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect2PanelLable);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect2Panel);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect1PanelDot);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect1PanelLable);
  lvgl_obj_delete(&ui_ProgramWeekDaySelect1Panel);
  lvgl_obj_delete(&ui_ProgramWeekDaySelectPanel);
  lvgl_obj_delete(&ui_ProgramPanelHeatCoolSwitchHeatLable);
  lvgl_obj_delete(&ui_ProgramPanelHeatCoolSwitchCoolLable);
  lvgl_obj_delete(&ui_ProgramPanelHeatCoolSwitch);
  lvgl_obj_delete(&ui_ProgramPanelLabel);
  lvgl_obj_delete(&ui_ProgramPanelReturnPanel);
  lvgl_obj_delete(&ui_ProgramPanel);
  lvgl_obj_delete(&ui_MenuPanelUserSetPanelChildPanelRightImage);
  lvgl_obj_delete(&ui_MenuPanelUserSetPanelChildPanelLable);
  lvgl_obj_delete(&ui_MenuPanelUserSetPanelChildPanelIconImage);
  lvgl_obj_delete(&ui_MenuPanelUserSetPanelChildPanel);
  lvgl_obj_delete(&ui_MenuPanelUserSetPanel);
  lvgl_obj_delete(&ui_MenuPanelWifiPanelChildPanelRightImage);
  lvgl_obj_delete(&ui_MenuPanelWifiPanelChildPanelLable);
  lvgl_obj_delete(&ui_MenuPanelWifiPanelChildPanelIconImage);
  lvgl_obj_delete(&ui_MenuPanelWifiPanelChildPanel);
  lvgl_obj_delete(&ui_MenuPanelWifiPanel);
  lvgl_obj_delete(&ui_MenuProgramPanelSleepPanelConfirmPanel);
  lvgl_obj_delete(&ui_MenuProgramPanelSleepPanelPlusPanel);
  lvgl_obj_delete(&ui_MenuProgramPanelSleepPanelTimeLable);
  lvgl_obj_delete(&ui_MenuProgramPanelSleepPanelMinuPanel);
  lvgl_obj_delete(&ui_MenuProgramPanelSleepPanel);
  lvgl_obj_delete(&ui_MenuProgramPanelSetLableImage);
  lvgl_obj_delete(&ui_MenuProgramPanelSetLable);
  lvgl_obj_delete(&ui_MenuProgramPanelLabel);
  lvgl_obj_delete(&ui_MenuProgramPanelImage);
  lvgl_obj_delete(&ui_MenuProgramPanelSwitch);
  lvgl_obj_delete(&ui_MenuProgramPanel);
  lvgl_obj_delete(&ui_MenuMainLabel);
  lvgl_obj_delete(&ui_MenuReturnPanel);
  lvgl_obj_delete(&ui_MenuPanel);
  lvgl_obj_delete(&ui_MenuScreen);

End:
  return;
}

void MenuReturnPanelClickedCallback(lv_event_t * e)
{
  if(e->target == ui_MenuReturnPanel)
  {
    _ui_screen_change(&ui_MainScreen, LV_SCR_LOAD_ANIM_NONE, 0, 50, &ui_MainScreen_screen_init);
  }
  else if(e->target == ui_ProgramPanelReturnPanel)
  {
    _ui_flag_modify(ui_ProgramPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
  }
  else if(e->target == ui_ProgramSchedulePanelReturnPanel)
  {
    _ui_flag_modify(ui_ProgramSchedulePanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
  }
}

void MenuProgramPanelSwitchClickedCallback(lv_event_t * e)
{
  if(lv_obj_has_state(e->target, LV_STATE_CHECKED))
  {
    programme_state_set(GetProgram_option(), 1);
  }
  else
  {
    programme_state_set(GetProgram_option(), 0);
  }
}

void MenuProgramPanelSetLableClickedCallback(lv_event_t * e)
{
  /*开关型编程*/
  if(GetProgram_option() == 1)
  {
    _ui_flag_modify(ui_ProgramSchedulePanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
    schedule_weekday = 1;
  }
  else if(GetProgram_option() == 2)
  {
    _ui_flag_modify(ui_ProgramPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
    prog_weekday = 1;
  }

  menu_screen_interface_refresh(GetProgram_option());
}


void MenuProgramPanelSleepPanelAddMinuPanelClickedCallback(lv_event_t * e)
{
  if((e->code == LV_EVENT_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED_REPEAT))
  {
    programme_data_t programme_data = programme_data_get();
    if(e->target == ui_MenuProgramPanelSleepPanelMinuPanel)
    {
      if(programme_data.sleep_data.sleep_hour > 6)
      {
        programme_data.sleep_data.sleep_hour--;
      }
    }
    else if(e->target == ui_MenuProgramPanelSleepPanelPlusPanel)
    {
      if(programme_data.sleep_data.sleep_hour < 12)
      {
        programme_data.sleep_data.sleep_hour++;
      }
    }
    programme_data_set(programme_data);
    menu_screen_interface_refresh(GetProgram_option());
  }
}

void MenuProgramPanelSleepPanelConfirmPanelClickedCallback(lv_event_t * e)
{

}

void MenuPanelWifiPanelChildPanelClickedCallback(lv_event_t * e)
{
  _ui_screen_change(&ui_WifiMatchScreen, LV_SCR_LOAD_ANIM_NONE, 0, 50, &ui_WifiMatchScreen_screen_init);   
}

void MenuPanelUserSetPanelChildPanelClickedCallback(lv_event_t * e)
{
  _ui_screen_change(&ui_UserSettingScreen, LV_SCR_LOAD_ANIM_NONE, 0, 50, &ui_UserSettingScreen_screen_init);  
}

void ProgramPanelHeatCoolSwitchClickedCallback(lv_event_t * e)
{
  /*制热*/
  if(lv_obj_has_state(e->target, LV_STATE_CHECKED))
  {
    _ui_flag_modify(ui_ProgramPanelHeatCoolSwitchCoolLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
    _ui_flag_modify(ui_ProgramPanelHeatCoolSwitchHeatLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
    pro_cool_heat_set(2);
  }
  /*制冷*/
  else
  {
    _ui_flag_modify(ui_ProgramPanelHeatCoolSwitchCoolLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
    _ui_flag_modify(ui_ProgramPanelHeatCoolSwitchHeatLable, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
    pro_cool_heat_set(1);
  }
}

void ProgramWeekDaySelectXPanelClickedCallback(lv_event_t * e)
{
  // _ui_state_modify(ui_ProgramWeekDaySelect1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramWeekDaySelect2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramWeekDaySelect3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramWeekDaySelect4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramWeekDaySelect5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramWeekDaySelect6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramWeekDaySelect7Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  //_ui_state_modify(e->target, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);

  if(e->target == ui_ProgramWeekDaySelect1Panel)
  {
    prog_weekday = 1;
  }
  else if(e->target == ui_ProgramWeekDaySelect2Panel)
  {
    prog_weekday = 2;
  }
  else if(e->target == ui_ProgramWeekDaySelect3Panel)
  {
    prog_weekday = 3;
  }
  else if(e->target == ui_ProgramWeekDaySelect4Panel)
  {
    prog_weekday = 4;
  }
  else if(e->target == ui_ProgramWeekDaySelect5Panel)
  {
    prog_weekday = 5;
  }
  else if(e->target == ui_ProgramWeekDaySelect6Panel)
  {
    prog_weekday = 6;
  }
  else if(e->target == ui_ProgramWeekDaySelect7Panel)
  {
    prog_weekday = 7;
  }

  menu_screen_interface_refresh(GetProgram_option());
}

void ProgramPanelSegPanelClickedCallback(lv_event_t * e)
{
  _ui_flag_modify(ui_ProgramSetPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
  if(e->target == ui_ProgramPanelSeg1Panel)
  {
    prog_weekday_seg = 1;
  }
  else if(e->target == ui_ProgramPanelSeg2Panel)
  {
    prog_weekday_seg = 2;
  }
  else if(e->target == ui_ProgramPanelSeg3Panel)
  {
    prog_weekday_seg = 3;
  }
  else if(e->target == ui_ProgramPanelSeg4Panel)
  {
    prog_weekday_seg = 4;
  }
  else if(e->target == ui_ProgramPanelSeg5Panel)
  {
    prog_weekday_seg = 5;
  }
  else if(e->target == ui_ProgramPanelSeg6Panel)
  {
    prog_weekday_seg = 6;
  }

  menu_screen_interface_refresh(GetProgram_option());

  // _ui_state_modify(ui_ProgramSetPanelWeekDay1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramSetPanelWeekDay2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramSetPanelWeekDay3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramSetPanelWeekDay4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramSetPanelWeekDay5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramSetPanelWeekDay6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramSetPanelWeekDay7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

  // switch(prog_weekday)
  // {
  //   case 1:
  //     _ui_state_modify(ui_ProgramSetPanelWeekDay1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //     break;

  //   case 2:
  //     _ui_state_modify(ui_ProgramSetPanelWeekDay2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //    break;

  //   case 3:
  //     _ui_state_modify(ui_ProgramSetPanelWeekDay3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //     break;

  //   case 4:
  //     _ui_state_modify(ui_ProgramSetPanelWeekDay4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //    break;

  //   case 5:
  //     _ui_state_modify(ui_ProgramSetPanelWeekDay5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //     break;

  //   case 6:
  //     _ui_state_modify(ui_ProgramSetPanelWeekDay6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //    break;

  //   case 7:
  //     _ui_state_modify(ui_ProgramSetPanelWeekDay7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //     break;

  //   default:
  //     break;
  // }
  
}

void ProgramPanelCopy_ResetPanelClickedCallback(lv_event_t * e)
{
  if(e->target == ui_ProgramPanelCopyPanel)
  {
    _ui_flag_modify(ui_ProgramCopyBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);

    _ui_state_modify(ui_ProgramCopyPanelSeg1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramCopyPanelSeg2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramCopyPanelSeg3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramCopyPanelSeg4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramCopyPanelSeg5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramCopyPanelSeg6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

    switch (prog_weekday)
    {
    case 1:
      /* code */
      lv_label_set_text(ui_ProgramCopyPanelLable, "Copy \"Mon\" to");
      lv_label_set_text(ui_ProgramCopyPanelSeg1PanelLable, "Tue");
      lv_label_set_text(ui_ProgramCopyPanelSeg2PanelLable, "Wen");
      lv_label_set_text(ui_ProgramCopyPanelSeg3PanelLable, "Thu");
      lv_label_set_text(ui_ProgramCopyPanelSeg4PanelLable, "Fri");
      lv_label_set_text(ui_ProgramCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramCopyPanelSeg6PanelLable, "Sun");
      break;
    
    case 2:
      /* code */
      lv_label_set_text(ui_ProgramCopyPanelLable, "Copy \"Tue\" to");
      lv_label_set_text(ui_ProgramCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramCopyPanelSeg2PanelLable, "Wen");
      lv_label_set_text(ui_ProgramCopyPanelSeg3PanelLable, "Thu");
      lv_label_set_text(ui_ProgramCopyPanelSeg4PanelLable, "Fri");
      lv_label_set_text(ui_ProgramCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramCopyPanelSeg6PanelLable, "Sun");
      break;

    case 3:
      /* code */
      lv_label_set_text(ui_ProgramCopyPanelLable, "Copy \"Wen\" to");
      lv_label_set_text(ui_ProgramCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramCopyPanelSeg3PanelLable, "Thu");
      lv_label_set_text(ui_ProgramCopyPanelSeg4PanelLable, "Fri");
      lv_label_set_text(ui_ProgramCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramCopyPanelSeg6PanelLable, "Sun");
      break;

    case 4:
      /* code */
      lv_label_set_text(ui_ProgramCopyPanelLable, "Copy \"Thu\" to");
      lv_label_set_text(ui_ProgramCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramCopyPanelSeg3PanelLable, "Wen");
      lv_label_set_text(ui_ProgramCopyPanelSeg4PanelLable, "Fri");
      lv_label_set_text(ui_ProgramCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramCopyPanelSeg6PanelLable, "Sun");
      break;

    case 5:
      /* code */
      lv_label_set_text(ui_ProgramCopyPanelLable, "Copy \"Fri\" to");
      lv_label_set_text(ui_ProgramCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramCopyPanelSeg3PanelLable, "Wen");
      lv_label_set_text(ui_ProgramCopyPanelSeg4PanelLable, "Thu");
      lv_label_set_text(ui_ProgramCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramCopyPanelSeg6PanelLable, "Sun");
      break;

    case 6:
      /* code */
      lv_label_set_text(ui_ProgramCopyPanelLable, "Copy \"Sta\" to");
      lv_label_set_text(ui_ProgramCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramCopyPanelSeg3PanelLable, "Wen");
      lv_label_set_text(ui_ProgramCopyPanelSeg4PanelLable, "Thu");
      lv_label_set_text(ui_ProgramCopyPanelSeg5PanelLable, "Fri");
      lv_label_set_text(ui_ProgramCopyPanelSeg6PanelLable, "Sun");
      break;

    case 7:
      /* code */
      lv_label_set_text(ui_ProgramCopyPanelLable, "Copy \"Sun\" to");
      lv_label_set_text(ui_ProgramCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramCopyPanelSeg3PanelLable, "Wen");
      lv_label_set_text(ui_ProgramCopyPanelSeg4PanelLable, "Thu");
      lv_label_set_text(ui_ProgramCopyPanelSeg5PanelLable, "Fri");
      lv_label_set_text(ui_ProgramCopyPanelSeg6PanelLable, "Sta");
      break;
    
    default:
      break;
    }
  }
  else if(e->target == ui_ProgramPanelResetPanel)
  {
    _ui_flag_modify(ui_ProgramResetBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
  }
}

void ProgramCopyPanelSegXPanelClickedCallback(lv_event_t * e)
{
  // _ui_state_modify(ui_ProgramCopyPanelSeg1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramCopyPanelSeg2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramCopyPanelSeg3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramCopyPanelSeg4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramCopyPanelSeg5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramCopyPanelSeg6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  //_ui_state_modify(e->target, LV_STATE_CHECKED, _UI_MODIFY_STATE_TOGGLE);
  //lv_event_send(e->target, LV_STATE_CHECKED, NULL);
}

void ProgramCopyBackPanelCancelConfirmPanelClickedCallback(lv_event_t * e)
{
  programme_data_t programme_data = programme_data_get(); 
  if(e->target == ui_ProgramCopyBackPanelCancelPanel)
  {
    _ui_flag_modify(ui_ProgramCopyBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
  }
  else if(e->target == ui_ProgramCopyBackPanelConfirmPanel)
  {
    _ui_flag_modify(ui_ProgramCopyBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);

    for(uint8_t i = 0; i < 6; i++)
    {
      if(lv_obj_has_state(*pro_copy_panel[i][0], LV_STATE_CHECKED))
      {
        for(uint8_t j = 0; j < 7; j++)
        {
          if(strcmp(lv_label_get_text(*pro_copy_panel[i][1]), weekday_text[j]) == 0)
          {
            /*设置当天数据到 j天*/
            if(pro_cool_heat_get() == 1)
            {
              programme_data.pro_data_cool.day[j] = programme_data.pro_data_cool.day[prog_weekday -1];
            }
            else if(pro_cool_heat_get() == 2)
            {
              programme_data.pro_data_heat.day[j] = programme_data.pro_data_heat.day[prog_weekday -1];
            }
          }
        }
      }
    }
  }
  programme_data_set(programme_data);
  programme_state_reset();
  menu_screen_interface_refresh(GetProgram_option());
}

void ProgramResetPanelClickedCallback(lv_event_t * e)
{
  programme_data_cool_reset(pro_cool_heat_get());
  _ui_flag_modify(ui_ProgramResetBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
  menu_screen_interface_refresh(GetProgram_option());
}

void ProgramSetPanelReturnPanelClickedCallback(lv_event_t * e)
{
  _ui_flag_modify(ui_ProgramSetPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
}

void ProgramSetPanelTimePanelTimePanelSetCallback(lv_event_t * e)
{
  programme_data_t programme_data = programme_data_get();
  /*小时+*/
  if(e->target == ui_ProgramSetPanelTimePanelHourUpPanel)
  {
    if((e->code == LV_EVENT_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED_REPEAT))
    {
      if(pro_cool_heat_get() == 1)
      {
        if((prog_weekday_seg != 1) && (prog_weekday_seg != 6))
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            <programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            >programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 1)
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            <programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            >=0))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 6)
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            <1440)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            >programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
      else if(pro_cool_heat_get() == 2)
      {
        if((prog_weekday_seg != 1) && (prog_weekday_seg != 6))
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            <programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            >programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 1)
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            <programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            >=0))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 6)
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            <1440)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 60 
            >programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
    }
  }
  /*小时-*/
  else if(e->target == ui_ProgramSetPanelTimePanelHourDownPanel)
  {
    if((e->code == LV_EVENT_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED_REPEAT))
    {
      if(pro_cool_heat_get() == 1)
      {
        if((prog_weekday_seg != 1) && (prog_weekday_seg != 6))
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            <programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            >programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 1)
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            <programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            >=0))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 6)
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            <1440)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            >programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
      else if(pro_cool_heat_get() == 2)
      {
        if((prog_weekday_seg != 1) && (prog_weekday_seg != 6))
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            <programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            >programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 1)
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            <programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            >=0))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 6)
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            <1440)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 60 
            >programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
    }
  }
  /*分钟+*/
  else if(e->target == ui_ProgramSetPanelTimePanelMinuteUpPanel)
  {
    if((e->code == LV_EVENT_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED_REPEAT))
    {
      if(pro_cool_heat_get() == 1)
      {
        if((prog_weekday_seg != 1) && (prog_weekday_seg != 6))
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            <programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            >programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 1)
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            <programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            >=0))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 6)
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            <1440)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            >programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
      else if(pro_cool_heat_get() == 2)
      {
        if((prog_weekday_seg != 1) && (prog_weekday_seg != 6))
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            <programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            >programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 1)
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            <programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            >=0))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 6)
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            <1440)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time + 1 
            >programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
    }
  }
  /*分钟-*/
  else if(e->target == ui_ProgramSetPanelTimePanelMinuteDownPanel)
  {
    if((e->code == LV_EVENT_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED_REPEAT))
    {
      if(pro_cool_heat_get() == 1)
      {
        if((prog_weekday_seg != 1) && (prog_weekday_seg != 6))
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            <programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            >programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 1)
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            <programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            >=0))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 6)
        {
          if((programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            <1440)  
          &&(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            >programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
      else if(pro_cool_heat_get() == 2)
      {
        if((prog_weekday_seg != 1) && (prog_weekday_seg != 6))
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            <programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            >programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 1)
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            <programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 +1].time)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            >=0))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(prog_weekday_seg == 6)
        {
          if((programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            <1440)  
          &&(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time - 1 
            >programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1 -1].time))
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
    }
  }
  menu_screen_interface_refresh(2);
}

void ProgramSetPanelTempPanelSetCallback(lv_event_t * e)
{
  programme_data_t programme_data = programme_data_get();
  if(e->target == ui_ProgramSetPanelTempPanelUpPanel)
  {
    if((e->code == LV_EVENT_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED_REPEAT))
    {
      /*摄氏度*/
      if(Gettemperature_unit() == 0)
      {
        if(pro_cool_heat_get() == 1)
        {
          if(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp < GetSet_upper_temperature_limit()*10)
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp += 5;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(pro_cool_heat_get() == 2)
        {
          if(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp < GetSet_upper_temperature_limit()*10)
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp += 5;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
      /*华氏度*/
      else
      {
        if(pro_cool_heat_get() == 1)
        {
          if(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp < GetSet_upper_temperature_limit())
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp += 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(pro_cool_heat_get() == 2)
        {
          if(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp < GetSet_upper_temperature_limit())
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp += 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
    }
  }
  else if(e->target == ui_ProgramSetPanelTempPanelDownPanel)
  {
    if((e->code == LV_EVENT_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED_REPEAT))
    {
      /*摄氏度*/
      if(Gettemperature_unit() == 0)
      {
        if(pro_cool_heat_get() == 1)
        {
          if(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp > GetSet_lower_temperature_limit()*10)
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp -= 5;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(pro_cool_heat_get() == 2)
        {
          if(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp > GetSet_lower_temperature_limit()*10)
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp -= 5;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
      /*华氏度*/
      else
      {
        if(pro_cool_heat_get() == 1)
        {
          if(programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp > GetSet_lower_temperature_limit())
          {
            programme_data.pro_data_cool.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp -= 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
        else if(pro_cool_heat_get() == 2)
        {
          if(programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp > GetSet_lower_temperature_limit())
          {
            programme_data.pro_data_heat.day[prog_weekday - 1].seg[prog_weekday_seg - 1].temp -= 1;
            programme_data_set(programme_data);
            programme_state_reset();
          }
        }
      }
    }
  }
  menu_screen_interface_refresh(2);
}

void ProgramScheduleWeekDaySelectXPanelClickedCallback(lv_event_t * e)
{
  // _ui_state_modify(ui_ProgramScheduleWeekDaySelect1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleWeekDaySelect2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleWeekDaySelect3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleWeekDaySelect4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleWeekDaySelect5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleWeekDaySelect6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleWeekDaySelect7Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  //_ui_state_modify(e->target, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);

  if(e->target == ui_ProgramScheduleWeekDaySelect1Panel)
  {
    schedule_weekday = 1;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySelect2Panel)
  {
    schedule_weekday = 2;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySelect3Panel)
  {
    schedule_weekday = 3;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySelect4Panel)
  {
    schedule_weekday = 4;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySelect5Panel)
  {
    schedule_weekday = 5;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySelect6Panel)
  {
    schedule_weekday = 6;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySelect7Panel)
  {
    schedule_weekday = 7;
  }

  menu_screen_interface_refresh(GetProgram_option());
}

void ProgramScheduleWeekDaySegXPanelChildPanelClickedCallback(lv_event_t * e)
{
  _ui_flag_modify(ui_ProgramScheduleSetPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
  if(e->target == ui_ProgramScheduleWeekDaySeg1PanelChildPanel)
  {
    schedule_weekday_seg = 1;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySeg2PanelChildPanel)
  {
    schedule_weekday_seg = 2;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySeg3PanelChildPanel)
  {
    schedule_weekday_seg = 3;
  }
  else if(e->target == ui_ProgramScheduleWeekDaySeg4PanelChildPanel)
  {
    schedule_weekday_seg = 4;
  }

  menu_screen_interface_refresh(GetProgram_option());

  // _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

  // switch(schedule_weekday)
  // {
  //   case 1:
  //     _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay1PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //     break;

  //   case 2:
  //     _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay2PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //    break;

  //   case 3:
  //     _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay3PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //     break;

  //   case 4:
  //     _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay4PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //    break;

  //   case 5:
  //     _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay5PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //     break;

  //   case 6:
  //     _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay6PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //    break;

  //   case 7:
  //     _ui_state_modify(ui_ProgramScheduleSetPanelWeekDay7PanelLable, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD);
  //     break;

  //   default:
  //     break;
  // }
}

void ProgramScheduleWeekDaySegXPanelChildPanelSwitchClickedCallback(lv_event_t * e)
{
  programme_data_t programme_data = programme_data_get();
  if(lv_obj_has_state(ui_ProgramScheduleWeekDaySeg1PanelChildPanelSwitch, LV_STATE_CHECKED))
  {
    programme_data.sch_data.day[schedule_weekday -1].seg[0].enable = 1;
  }
  else
  {
    programme_data.sch_data.day[schedule_weekday -1].seg[0].enable = 0;
  }

  if(lv_obj_has_state(ui_ProgramScheduleWeekDaySeg2PanelChildPanelSwitch, LV_STATE_CHECKED))
  {
    programme_data.sch_data.day[schedule_weekday -1].seg[1].enable = 1;
  }
  else
  {
    programme_data.sch_data.day[schedule_weekday -1].seg[1].enable = 0;
  }

  if(lv_obj_has_state(ui_ProgramScheduleWeekDaySeg3PanelChildPanelSwitch, LV_STATE_CHECKED))
  {
    programme_data.sch_data.day[schedule_weekday -1].seg[2].enable = 1;
  }
  else
  {
    programme_data.sch_data.day[schedule_weekday -1].seg[2].enable = 0;
  }

  if(lv_obj_has_state(ui_ProgramScheduleWeekDaySeg4PanelChildPanelSwitch, LV_STATE_CHECKED))
  {
    programme_data.sch_data.day[schedule_weekday -1].seg[3].enable = 1;
  }
  else
  {
    programme_data.sch_data.day[schedule_weekday -1].seg[3].enable = 0;
  }
  programme_data_set(programme_data);
  menu_screen_interface_refresh(GetProgram_option());
}


void ProgramSchedulePanelCopy_ResetPanelClickedCallback(lv_event_t * e)
{
  if(e->target == ui_ProgramSchedulePanelCopyPanel)
  {
    _ui_flag_modify(ui_ProgramScheduleCopyBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);

    _ui_state_modify(ui_ProgramScheduleCopyPanelSeg1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleCopyPanelSeg2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleCopyPanelSeg3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleCopyPanelSeg4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleCopyPanelSeg5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
    _ui_state_modify(ui_ProgramScheduleCopyPanelSeg6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);

    switch (schedule_weekday)
    {
    case 1:
      /* code */
      lv_label_set_text(ui_ProgramScheduleCopyPanelLable, "Copy \"Mon\" to");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg1PanelLable, "Tue");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg2PanelLable, "Wen");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg3PanelLable, "Thu");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg4PanelLable, "Fri");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg6PanelLable, "Sun");
      break;
    
    case 2:
      /* code */
      lv_label_set_text(ui_ProgramScheduleCopyPanelLable, "Copy \"Tue\" to");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg2PanelLable, "Wen");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg3PanelLable, "Thu");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg4PanelLable, "Fri");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg6PanelLable, "Sun");
      break;

    case 3:
      /* code */
      lv_label_set_text(ui_ProgramScheduleCopyPanelLable, "Copy \"Wen\" to");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg3PanelLable, "Thu");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg4PanelLable, "Fri");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg6PanelLable, "Sun");
      break;

    case 4:
      /* code */
      lv_label_set_text(ui_ProgramScheduleCopyPanelLable, "Copy \"Thu\" to");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg3PanelLable, "Wen");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg4PanelLable, "Fri");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg6PanelLable, "Sun");
      break;

    case 5:
      /* code */
      lv_label_set_text(ui_ProgramScheduleCopyPanelLable, "Copy \"Fri\" to");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg3PanelLable, "Wen");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg4PanelLable, "Thu");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg5PanelLable, "Sta");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg6PanelLable, "Sun");
      break;

    case 6:
      /* code */
      lv_label_set_text(ui_ProgramScheduleCopyPanelLable, "Copy \"Sta\" to");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg3PanelLable, "Wen");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg4PanelLable, "Thu");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg5PanelLable, "Fri");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg6PanelLable, "Sun");
      break;

    case 7:
      /* code */
      lv_label_set_text(ui_ProgramScheduleCopyPanelLable, "Copy \"Sun\" to");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg1PanelLable, "Mon");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg2PanelLable, "Tue");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg3PanelLable, "Wen");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg4PanelLable, "Thu");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg5PanelLable, "Fri");
      lv_label_set_text(ui_ProgramScheduleCopyPanelSeg6PanelLable, "Sta");
      break;
    
    default:
      break;
    }
  }
  else if(e->target == ui_ProgramSchedulePanelResetPanel)
  {
    _ui_flag_modify(ui_ProgramScheduleResetBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE);
  }
}

void ProgramScheduleCopyBackPanelClickedCallback(lv_event_t * e)
{
  _ui_flag_modify(ui_ProgramScheduleCopyBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
}

void ProgramScheduleCopyPanelSegXPanelClickedCallback(lv_event_t * e)
{
  // _ui_state_modify(ui_ProgramScheduleCopyPanelSeg1Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleCopyPanelSeg2Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleCopyPanelSeg3Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleCopyPanelSeg4Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleCopyPanelSeg5Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  // _ui_state_modify(ui_ProgramScheduleCopyPanelSeg6Panel, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE);
  //_ui_state_modify(e->target, LV_STATE_CHECKED, _UI_MODIFY_STATE_TOGGLE);
}

void ProgramScheduleCopyBackPanelCancelConfirmPanelClickedCallback(lv_event_t * e)
{
  programme_data_t programme_data = programme_data_get(); 
  if(e->target == ui_ProgramScheduleCopyBackPanelCancelPanel)
  {
    _ui_flag_modify(ui_ProgramScheduleCopyBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
  }
  else if(e->target == ui_ProgramScheduleCopyBackPanelConfirmPanel)
  {
    _ui_flag_modify(ui_ProgramScheduleCopyBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);

    for(uint8_t i = 0; i < 6; i++)
    {
      if(lv_obj_has_state(*sch_copy_panel[i][0], LV_STATE_CHECKED))
      {
        for(uint8_t j = 0; j < 7; j++)
        {
          if(strcmp(lv_label_get_text(*sch_copy_panel[i][1]), weekday_text[j]) == 0)
          {
            /*  TODO: 设置当天数据到 j+1 天*/
            programme_data.sch_data.day[j] = programme_data.sch_data.day[schedule_weekday -1];
          }
        }
      }
    }
  }
  programme_data_set(programme_data);
  menu_screen_interface_refresh(GetProgram_option());
}

void ProgramScheduleResetBackPanelCallback(lv_event_t * e)
{
  _ui_flag_modify(ui_ProgramScheduleResetBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
}

void ProgramScheduleResetPanelClickedCallback(lv_event_t * e)
{
  /*  TODO: 增加reset api*/
  prog_schedule_data_reset();
  _ui_flag_modify(ui_ProgramScheduleResetBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
  menu_screen_interface_refresh(GetProgram_option());
}

void ProgramScheduleSetPanelReturnPanelClickedCallback(lv_event_t * e)
{
  _ui_flag_modify(ui_ProgramScheduleSetPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
}

void ProgramScheduleSetPanelTimePanelTimePanelSetCallback(lv_event_t * e)
{
  if((e->code == LV_EVENT_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED) || (e->code == LV_EVENT_LONG_PRESSED_REPEAT))
  {
    programme_data_t programme_data = programme_data_get();
    /*小时+*/
    if(e->target == ui_ProgramScheduleSetPanelTimePanelHourUpPanel)
    {
      if((schedule_weekday_seg != 1) && (schedule_weekday_seg != 4))
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 60
            <programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 +1].time)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 60
            >programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 -1].time))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
        else if(schedule_weekday_seg == 1)
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 60
            <programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 +1].time)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 60 
            >=0))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
        else if(schedule_weekday_seg == 4)
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 60 
            <1440)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 60 
            >programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 -1].time))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time += 60;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
    }
    /*小时-*/
    else if(e->target == ui_ProgramScheduleSetPanelTimePanelHourDownPanel)
    {
      if((schedule_weekday_seg != 1) && (schedule_weekday_seg != 4))
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 60 
            <programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 +1].time)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 60 
            >programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 -1].time))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
        else if(schedule_weekday_seg == 1)
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 60
            <programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 +1].time)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 60 
            >=0))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
        else if(schedule_weekday_seg == 4)
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 60 
            <1440)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 60 
            >programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 -1].time))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time -= 60;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
    }
    /*分钟+*/
    else if(e->target == ui_ProgramScheduleSetPanelTimePanelMinuteUpPanel)
    {
      if((schedule_weekday_seg != 1) && (schedule_weekday_seg != 4))
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 1 
            <programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 +1].time)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 1 
            >programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 -1].time))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
        else if(schedule_weekday_seg == 1)
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 1
            <programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 +1].time)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 1
            >=0))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
        else if(schedule_weekday_seg == 4)
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 1
            <1440)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time + 1
            >programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 -1].time))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time += 1;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
    }
    /*分钟-*/
    else if(e->target == ui_ProgramScheduleSetPanelTimePanelMinuteDownPanel)
    {
      if((schedule_weekday_seg != 1) && (schedule_weekday_seg != 4))
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 1
            <programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 +1].time)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 1
            >programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 -1].time))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
        else if(schedule_weekday_seg == 1)
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 1
            <programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 +1].time)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 1
            >=0))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
        else if(schedule_weekday_seg == 4)
        {
          if((programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 1
            <1440)  
          &&(programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time - 1
            >programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1 -1].time))
          {
            programme_data.sch_data.day[schedule_weekday - 1].seg[schedule_weekday_seg - 1].time -= 1;
            programme_data_set(programme_data);
            //programme_state_reset();
          }
        }
    }

    prog_sch_state_reset();
    menu_screen_interface_refresh(GetProgram_option());
  }
}

void ProgramScheduleSetPanelTempPanelSetCallback(lv_event_t * e)
{
  printf("1\r\n");
  if(e->code == LV_EVENT_CLICKED)
  {
    printf("2\r\n");
    programme_data_t programme_data = programme_data_get();
    if(programme_data.sch_data.day[schedule_weekday -1].seg[schedule_weekday_seg -1].on_off == 0)
    {
      programme_data.sch_data.day[schedule_weekday -1].seg[schedule_weekday_seg -1].on_off = 1;
    }
    else
    {
      programme_data.sch_data.day[schedule_weekday -1].seg[schedule_weekday_seg -1].on_off = 0;
    }
    programme_data_set(programme_data);
  }
  menu_screen_interface_refresh(GetProgram_option());
}

void ProgramCopyBackPanelClickedCallback(lv_event_t * e)
{
  _ui_flag_modify(ui_ProgramCopyBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
}

void ProgramResetBackPanelClickedCallback(lv_event_t * e)
{
  _ui_flag_modify(ui_ProgramResetBackPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
}





