#include "lvgl.h"
#include "img_def.h"
#include "demo.h"
#include "mxc_meter.h"
#include "moto_list.h"
#include "language_table.h"
#include "img_basic.h"
#include "lan_str_table.h"

#define PAGEBTN_COUNT1     1    //bt switching
#define PAGEBTN_COUNT2     2    //theme setting
#define PAGEBTN_COUNT3     3    //other setting

lv_obj_t * src_win(){
    lv_obj_t * scr_parent_main = get_root_win();

    lv_obj_t * submenu_win = lv_obj_create(scr_parent_main);
    lv_obj_set_scrollbar_mode(submenu_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(submenu_win, LV_PCT(100), LV_PCT(100));
    lv_obj_set_style_pad_all(submenu_win, 0, 0);
    lv_obj_set_style_radius(submenu_win, 0, 0);
    lv_obj_set_style_border_width(submenu_win, 0, LV_PART_MAIN);
    lv_obj_set_style_border_color(submenu_win, lv_color_black(), 0);
//    lv_obj_set_style_bg_color(submenu_win, lv_color_black(), 0);
    lv_obj_set_style_bg_color(submenu_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_clear_flag(submenu_win, LV_OBJ_FLAG_SCROLLABLE);
    return submenu_win;
}

static void key_event_handler(lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);

    lv_obj_t *btn_win = lv_event_get_target(e);
//    lv_obj_t *btn = lv_obj_get_child(mainmenu_win, 0);

    if (code == LV_EVENT_KEY)
    {

        uint32_t *key = lv_event_get_param(e);
        uint8_t key_code = (uint8_t)*key;

//        uint32_t page_count = 0;    // display tile index
        uint32_t btn_num = 0;     // checked item index
//        uint32_t page_num = 0;      // sum of mainmenu pages
//        uint32_t last_item_pos = 0; // last item index of his page
//        uint32_t dis_item_arr[MAINMENU_TILE_END][COMMON_PER_PAGE_NUM];
//        memset(dis_item_arr, 0, sizeof(dis_item_arr));
//        uint32_t btn_totalnum = mainmenu_item_process(dis_item_arr, &page_num, &last_item_pos);
//
//        bool check = false;
//        MAINMENU_ICON_ID_ENUM menu_id = MAINMENU_ICON_ID_MAX;
//        ENUM_MAINMENU_ITEM_ID item_id = MAINMENU_ITEM_ID_MAX;
//        uint8_t curItemState = 0;

        uint8_t win_child_num = lv_obj_get_child_cnt(btn_win);
        // get focus item index
        for (uint32_t i = 0; i < win_child_num; i++)
        {
            lv_obj_t *child = lv_obj_get_child(btn_win, i);
            if (lv_obj_has_state(child, LV_STATE_FOCUS_KEY))
                btn_num = i;
        }

        lv_obj_t *button_cur = lv_obj_get_child(btn_win, btn_num); // get checked item obj

        switch (key_code)
        {
            case LV_KEY_Q:
                printf("LV_KEY_Q ===>btn_num = %d .\n",btn_num);
                lv_obj_clear_state(button_cur, LV_STATE_FOCUS_KEY);
                btn_num++;
                if(btn_num == win_child_num)
                    btn_num=0;
                lv_obj_t *button_next = lv_obj_get_child(btn_win, btn_num); // get checked item obj
                lv_obj_add_state(button_next, LV_STATE_FOCUS_KEY);
                if(btn_num == win_child_num-1){
                    lv_obj_set_style_bg_opa(button_next, LV_OPA_100, 0);
                }else{
                    lv_obj_t *button_next = lv_obj_get_child(btn_win, win_child_num-1);
                    lv_obj_set_style_bg_opa(button_next, LV_OPA_0, 0);
                }
                break;
            case LV_KEY_W:
                switch(Get_UI_page_id()){
                case SUBMENU_SET_THEME:
                    if(btn_num == 0){
                        printf("ENTER theme select .\n");
                        close_all_win();
                        theme_select_create();
                    }else if(btn_num == 1){
                        printf("ENTER theme bg seletc .\n");
                        close_all_win();
                        theme_bg_create();
                    }else{
                        printf("RETURN list .\n");
                        close_all_win();
                        enter_mainmenu_win(get_root_win());
                    }
                    break;
                case SUBMENU_SET_LIGHT:
                    if(btn_num == 0){
                        printf("ENTER light select .\n");

                    }else{
                        printf("RETURN list .\n");
                        close_all_win();
                        enter_mainmenu_win(get_root_win());
                    }
                    break;
                case SUBMENU_SET_BLUETOOTH:
                    if(btn_num == 0){
                        printf("ENTER bt switch .\n");
                    }else{
                        printf("RETURN list .\n");
                        close_all_win();
                        enter_mainmenu_win(get_root_win());
                    }
                    break;
                case SUBMENU_SET_OTHER:
                    if(btn_num == 0){
                        printf("ENTER time setting.\n");
                    }else if(btn_num == 1){
                        printf("ENTER langguage setting .\n");
                    }else if(btn_num == 2){
                        printf("ENTER unit setting .\n");
                    }else{
                        printf("RETURN list .\n");
                        close_all_win();
                        enter_mainmenu_win(get_root_win());
                    }
                    break;
                case SUBMENU_SET_INFORMATION:
                    printf("INFORMATION RETURN list .\n");
                    close_all_win();
                    enter_mainmenu_win(get_root_win());
                    break;
                case SUBMENU_SET_PRESSURE:
                    if(btn_num == 0){
//                        printf("Front tire pressure .\n");
//                    }else if(btn_num == 1){
//                        printf("Rear tire pressure .\n");
//                    }else{
                        printf("RETURN list .\n");
                        close_all_win();
                        enter_mainmenu_win(get_root_win());
                    }
                    break;
                case SUBMENU_SET_FAULT_CODE:
                    printf("FAULT_CODE RETURN list .\n");
                    close_all_win();
                    enter_mainmenu_win(get_root_win());
                    break;
                case SUBMENU_THEME_SELECT:
                    if(btn_num == 0){
                        printf("THEME_SELECT 1.\n");
                    }else if(btn_num == 1){
                        printf("THEME_SELECT 2 .\n");
                    }else if(btn_num == 2){
                        printf("THEME_SELECT 3 .\n");
                    }else{
                        printf("RETURN theme .\n");
                    }
                    close_all_win();
                    theme_create();
                    break;
                case SUBMENU_THEME_BG:
                    if(btn_num == 0){
                        printf("THEME_BG 1.\n");
                    }else if(btn_num == 1){
                        printf("THEME_BG 2 .\n");
                    }else if(btn_num == 2){
                        printf("THEME_BG 3 .\n");
                    }else{
                        printf("RETURN theme .\n");
                    }
                    close_all_win();
                    theme_create();
                    break;
                default:
                    break;
                }
                break;
            default:
                break;
        }
    }
}

static void batch_btn_creat(lv_obj_t *btn_win ,int win_btn_count){
    for(uint8_t i=0;i<win_btn_count;i++){
        lv_obj_t * btn = lv_btn_create(btn_win);
        lv_obj_set_size(btn, 270, 70);
        lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0);

        lv_obj_t * label = lv_label_create(btn);
        lv_label_set_text_fmt(label, "BTN%d         >",i);
        lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0);

        if(i==0){
            lv_obj_add_state(btn, LV_STATE_FOCUS_KEY);
            lv_obj_align(btn, LV_ALIGN_TOP_MID, -10, -5);
            if(win_btn_count==PAGEBTN_COUNT2)
                lv_obj_align(btn, LV_ALIGN_TOP_MID, -10, 30);
        }
        else{
            lv_obj_t * back_btn = lv_obj_get_child(btn_win, i-1);
            lv_obj_align_to(btn,back_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
        }
    }

}

static void batch_return_btn(lv_obj_t *btn_win ){
    lv_obj_t * return_btn = lv_btn_create(btn_win);
    lv_obj_set_size(return_btn, 90, 50);
    lv_obj_set_style_bg_color(return_btn, lv_color_hex(0x02BC2E), NULL);
    lv_obj_set_style_bg_opa(return_btn, LV_OPA_0, 0);
    lv_obj_align(return_btn, LV_ALIGN_BOTTOM_RIGHT, 0, 0);
    lv_obj_t * return_label = lv_label_create(return_btn);
    lv_obj_set_style_text_font(return_label,LV_FONT_MXC_WRYH_CT_16PX,0);
    lv_label_set_text(return_label, "return");
    lv_obj_align(return_label, LV_ALIGN_LEFT_MID, 0, 0);

}

void theme_create()
{
    printf("enter theme_create\n");

    lv_obj_t * submenu_win = src_win();

    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    batch_btn_creat(btn_win,PAGEBTN_COUNT2);

    batch_return_btn(btn_win);

    app_menu_comm_entry(btn_win, SUBMENU_SET_THEME, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);

}

void theme_select_create(){
    printf("enter theme_select_create\n");

    lv_obj_t * submenu_win = src_win();

    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    lv_obj_t * btn = lv_btn_create(btn_win);
    lv_obj_set_size(btn, 150, 100);
    lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0);
    lv_obj_t * label = lv_label_create(btn);
    lv_label_set_text(label, "SELECT1");
    lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0);
    lv_obj_add_state(btn, LV_STATE_FOCUS_KEY);
    lv_obj_align(btn, LV_ALIGN_TOP_LEFT, 30, 10);

    lv_obj_t * btn2 = lv_btn_create(btn_win);
    lv_obj_set_size(btn2, 150, 100);
    lv_obj_set_style_bg_opa(btn2, LV_OPA_0, 0);
    lv_obj_t * label2 = lv_label_create(btn2);
    lv_label_set_text(label2, "SELECT2");
    lv_obj_align(label2, LV_ALIGN_LEFT_MID, 0, 0);
    lv_obj_align(btn2, LV_ALIGN_TOP_RIGHT, -30, 10);

    lv_obj_t * btn3 = lv_btn_create(btn_win);
    lv_obj_set_size(btn3, 150, 100);
    lv_obj_set_style_bg_opa(btn3, LV_OPA_0, 0);
    lv_obj_t * label3 = lv_label_create(btn3);
    lv_label_set_text(label3, "SELECT3");
    lv_obj_align(label3, LV_ALIGN_LEFT_MID, 0, 0);
    lv_obj_align(btn3, LV_ALIGN_CENTER, 0, 60);

    batch_return_btn(btn_win);

    app_menu_comm_entry(btn_win, SUBMENU_THEME_SELECT, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);

}

void theme_bg_create(){
    printf("enter theme_bg_create\n");

    lv_obj_t * submenu_win = src_win();


    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    lv_obj_t * btn = lv_btn_create(btn_win);
    lv_obj_set_size(btn, 150, 100);
    lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0);
    lv_obj_t * label = lv_label_create(btn);
    lv_label_set_text(label, "SELECT1");
    lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0);
    lv_obj_add_state(btn, LV_STATE_FOCUS_KEY);
    lv_obj_align(btn, LV_ALIGN_TOP_LEFT, 30, 10);

    lv_obj_t * btn2 = lv_btn_create(btn_win);
    lv_obj_set_size(btn2, 150, 100);
    lv_obj_set_style_bg_opa(btn2, LV_OPA_0, 0);
    lv_obj_t * label2 = lv_label_create(btn2);
    lv_label_set_text(label2, "SELECT2");
    lv_obj_align(label2, LV_ALIGN_LEFT_MID, 0, 0);
    lv_obj_align(btn2, LV_ALIGN_TOP_RIGHT, -30, 10);

    lv_obj_t * btn3 = lv_btn_create(btn_win);
    lv_obj_set_size(btn3, 150, 100);
    lv_obj_set_style_bg_opa(btn3, LV_OPA_0, 0);
    lv_obj_t * label3 = lv_label_create(btn3);
    lv_label_set_text(label3, "SELECT3");
    lv_obj_align(label3, LV_ALIGN_LEFT_MID, 0, 0);
    lv_obj_align(btn3, LV_ALIGN_CENTER, 0, 60);

    batch_return_btn(btn_win);


    app_menu_comm_entry(btn_win, SUBMENU_THEME_BG, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);

}

void light_create()
{
    printf("enter light_create\n");

    lv_obj_t * submenu_win = src_win();

    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    lv_obj_t * btn = lv_btn_create(btn_win);
    lv_obj_set_size(btn, 300, 150);
    lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0);
    lv_obj_t * label = lv_label_create(btn);
    lv_label_set_text(label, "SELECT1");
    lv_obj_align(label, LV_ALIGN_BOTTOM_MID, 0, 10);
    lv_obj_add_state(btn, LV_STATE_FOCUS_KEY);
    lv_obj_align(btn, LV_ALIGN_CENTER, 0, -10);

    batch_return_btn(btn_win);


    app_menu_comm_entry(btn_win, SUBMENU_SET_LIGHT, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);
}

void bluetooth_create()
{
    printf("enter bluetooth_create\n");

    lv_obj_t * submenu_win = src_win();

    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    lv_obj_t * btn = lv_btn_create(btn_win);
    lv_obj_set_size(btn, 220, 70);
    lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0);

    lv_obj_t * bt_switch = lv_switch_create(btn);
    lv_obj_align(bt_switch, LV_ALIGN_RIGHT_MID, 0, 0);

    lv_obj_t * label = lv_label_create(btn);
    lv_label_set_text(label, "BT");
    lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0);

    lv_obj_add_state(btn, LV_STATE_FOCUS_KEY);
    lv_obj_align(btn, LV_ALIGN_CENTER, 0, -10);

    batch_return_btn(btn_win);

    app_menu_comm_entry(btn_win, SUBMENU_SET_BLUETOOTH, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);
}

void other_create()
{
    printf("enter other_create\n");

    lv_obj_t * submenu_win = src_win();

    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    batch_btn_creat(btn_win,PAGEBTN_COUNT3);

    lv_obj_t *child = lv_obj_get_child(btn_win, 1);
    lv_obj_t *child_label = lv_obj_get_child(child, 0);
    lv_label_set_text_fmt(child_label, "Language");

    child = lv_obj_get_child(btn_win, 2);
    child_label = lv_obj_get_child(child, 0);
    lv_label_set_text_fmt(child_label, "unit");

    batch_return_btn(btn_win);

    app_menu_comm_entry(btn_win, SUBMENU_SET_OTHER, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);

}

void information_create()
{
    printf("enter information_create\n");
    lv_obj_t * submenu_win = src_win();

    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    batch_return_btn(btn_win);

    app_menu_comm_entry(btn_win, SUBMENU_SET_INFORMATION, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);


}

void pressure_create()
{
    printf("enter pressure_create\n");
    lv_obj_t * submenu_win = src_win();

    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    batch_return_btn(btn_win);

    app_menu_comm_entry(btn_win, SUBMENU_SET_PRESSURE, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);
}

void fault_code_create()
{
    printf("enter fault_code_create\n");
    lv_obj_t * submenu_win = src_win();

    lv_obj_t * btn_win = lv_obj_create(submenu_win);
    lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100));
    lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE );
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
    lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
    lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL);
    lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN);

    batch_return_btn(btn_win);

    app_menu_comm_entry(btn_win, SUBMENU_SET_FAULT_CODE, false);
    //按键组
    lv_obj_t *demo_group = get_key_group();
    lv_group_add_obj(demo_group, btn_win);
    lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL);
}

void demo_return()
{
    printf("enter demo_return\n");
    lv_demo(get_root_win(),NULL);
}
