#include "lvgl.h" #include "common_screen_components.h" #include "settings_screen.h" #include "menu_screen.h" static const char *day_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31"; static const char *month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12"; static const char *year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30"; static const char *hour_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23"; static const char *minute_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59"; static const char *second_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59"; const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd"; static void gesture_event_cb(lv_event_t * e) { SettingsScreen_t *settingsScreen = e->user_data; lv_dir_t gesture; switch(gesture = lv_indev_get_gesture_dir(lv_indev_get_act())) { case LV_DIR_LEFT: LV_LOG_USER("GESTURE : LEFT"); break; case LV_DIR_RIGHT: LV_LOG_USER("GESTURE : RIGHT"); // We create the menu screen and switch to it extern MenuScreen_t menuScreen; menu_screen_create(&menuScreen); lv_scr_load_anim(menuScreen.display, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 400, 0, true); break; case LV_DIR_TOP: LV_LOG_USER("GESTURE : TOP"); break; case LV_DIR_BOTTOM: LV_LOG_USER("GESTURE : BOTTOM"); break; default: LV_LOG_USER("GESTURE : %u", gesture); } } static void cleanup_event_cb(lv_event_t * e) { SettingsScreen_t *settingsScreen = e->user_data; settings_screen_destroy(settingsScreen); LV_LOG_USER("cleanup"); } static void time_roller_cb(lv_event_t * e) { SettingsScreen_t *settingsScreen = e->user_data; if(!settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb) return; lv_obj_t *roller = lv_event_get_target(e); uint8_t index = lv_roller_get_selected(roller); if(roller == settingsScreen->hour_roller) { settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(index, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); } else if(roller == settingsScreen->minute_roller) { settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, index, 0xFF, 0xFF, 0xFF, 0xFF); } else if(roller == settingsScreen->second_roller) { settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, 0xFF, index, 0xFF, 0xFF, 0xFF); } else if(roller == settingsScreen->day_roller) { settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, 0xFF, 0xFF, index + 1, 0xFF, 0xFF); } else if(roller == settingsScreen->month_roller) { settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, 0xFF, 0xFF, 0xFF, index + 1, 0xFF); } else { settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, index + 22); } } static void brightness_slider_cb(lv_event_t * e) { SettingsScreen_t *settingsScreen = e->user_data; if(!settingsScreen->settingsScreenAPIInterface.setBrightnessSettingsCb) return; lv_obj_t * slider = lv_event_get_target(e); uint8_t brightness = (float)lv_slider_get_value(slider) * 2.55; if(brightness > 0) settingsScreen->settingsScreenAPIInterface.setBrightnessSettingsCb(brightness); } static lv_obj_t* add_sidebar_entry_to_menu(lv_obj_t *parent, const char *title, lv_obj_t *menu, lv_obj_t *pageToShow) { lv_obj_t *container = lv_menu_cont_create(parent); lv_obj_t *label = lv_label_create(container); lv_label_set_text_static(label, title); lv_obj_set_style_text_color(label, lv_color_make(145, 145, 145), LV_PART_MAIN); lv_obj_set_flex_grow(label, 1); lv_menu_set_load_page_event(menu, label, pageToShow); return label; } static lv_obj_t* create_menu_page_section(lv_obj_t *menu_page) { lv_obj_t *section = lv_menu_section_create(menu_page); lv_obj_set_style_pad_bottom(section, 50, LV_PART_MAIN); lv_obj_set_style_pad_top(section, 5, LV_PART_MAIN); lv_obj_set_style_pad_left(section, 5, LV_PART_MAIN); return section; } static lv_obj_t* create_section_container(lv_obj_t *section) { lv_obj_t *container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_clear_flag(container, LV_OBJ_FLAG_SCROLLABLE); return container; } void settings_screen_init(SettingsScreen_t * const settingsScreen) { if(!settingsScreen) { LV_LOG_ERROR("NULL pointer given !"); return; } memset(settingsScreen, 0, sizeof(SettingsScreen_t)); } void settings_screen_register_API_interface(SettingsScreen_t * const settingsScreen, SettingsScreenAPIInterface_t * const settingsScreenAPIInterface) { if(!settingsScreen) { LV_LOG_ERROR("NULL pointer given !"); return; } if(settingsScreenAPIInterface) settingsScreen->settingsScreenAPIInterface = *settingsScreenAPIInterface; else memset(&settingsScreen->settingsScreenAPIInterface, 0, sizeof(SettingsScreenAPIInterface_t)); } void settings_screen_create(SettingsScreen_t * const settingsScreen) { if(!settingsScreen) { LV_LOG_ERROR("NULL pointer given !"); return; } //We create our parent screen : if(settingsScreen->display) { LV_LOG_ERROR("display should be NULL here !"); lv_obj_del(settingsScreen->display); settingsScreen->display = NULL; } settingsScreen->display = lv_obj_create(NULL); //We add the screen header common_screen_header_component(settingsScreen->display, "Settings", 65); //We create the menu lv_obj_t *menu = lv_menu_create(settingsScreen->display); lv_obj_set_size(menu, lv_pct(100), 240 - 65); lv_obj_set_pos(menu, 0, 65); //We create the menu page for the time and date settings lv_obj_t *menu_page_1 = lv_menu_page_create(menu, NULL); lv_obj_t *section = create_menu_page_section(menu_page_1); lv_obj_t *menu_page_label = lv_label_create(section); lv_label_set_text_static(menu_page_label, "Set Time & Date :"); lv_obj_t *container = create_section_container(section); lv_obj_t *toggle = lv_switch_create(container); lv_obj_t *toggle_label = lv_label_create(container); lv_label_set_text_static(toggle_label, "Automatic"); lv_obj_set_style_pad_top(toggle_label, 5, LV_PART_MAIN); menu_page_label = lv_label_create(section); lv_label_set_text_static(menu_page_label, "Time :"); container = create_section_container(section); /*container = lv_obj_create(section); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_clear_flag(container, LV_OBJ_FLAG_SCROLLABLE); lv_obj_t *arc = lv_arc_create(container); lv_obj_center(arc); lv_obj_set_style_arc_width(arc, 1, LV_PART_INDICATOR); lv_obj_set_style_arc_width(arc, 1, LV_PART_MAIN); arc = lv_arc_create(container); lv_obj_set_size(arc, 100, 100); lv_obj_center(arc); lv_obj_set_style_arc_width(arc, 1, LV_PART_INDICATOR); lv_obj_set_style_arc_width(arc, 1, LV_PART_MAIN); arc = lv_arc_create(container); lv_obj_set_size(arc, 70, 70); lv_obj_center(arc); lv_obj_set_style_arc_width(arc, 1, LV_PART_INDICATOR); lv_obj_set_style_arc_width(arc, 1, LV_PART_MAIN);*/ settingsScreen->hour_roller = lv_roller_create(container); settingsScreen->minute_roller = lv_roller_create(container); settingsScreen->second_roller = lv_roller_create(container); lv_roller_set_options(settingsScreen->hour_roller, hour_options, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(settingsScreen->hour_roller, 2); lv_obj_add_event_cb(settingsScreen->hour_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen); lv_roller_set_options(settingsScreen->minute_roller, minute_options, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(settingsScreen->minute_roller, 2); lv_obj_add_event_cb(settingsScreen->minute_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen); lv_roller_set_options(settingsScreen->second_roller, second_options, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(settingsScreen->second_roller, 2); lv_obj_add_event_cb(settingsScreen->second_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen); menu_page_label = lv_label_create(section); lv_label_set_text_static(menu_page_label, "Time Format :"); container = create_section_container(section); lv_obj_t *checkbox_12 = lv_checkbox_create(container), *checkbox_24 = lv_checkbox_create(container); lv_checkbox_set_text(checkbox_12, "12H"); lv_obj_set_style_radius(checkbox_12, LV_RADIUS_CIRCLE, LV_PART_INDICATOR); lv_checkbox_set_text(checkbox_24, "24H"); lv_obj_add_state(checkbox_24, LV_STATE_CHECKED); lv_obj_set_style_radius(checkbox_24, LV_RADIUS_CIRCLE, LV_PART_INDICATOR); menu_page_label = lv_label_create(section); lv_label_set_text_static(menu_page_label, "Date :"); container = create_section_container(section); settingsScreen->day_roller = lv_roller_create(container); settingsScreen->month_roller = lv_roller_create(container); settingsScreen->year_roller = lv_roller_create(container); lv_roller_set_options(settingsScreen->day_roller, day_options, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(settingsScreen->day_roller, 2); lv_obj_add_event_cb(settingsScreen->day_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen); lv_roller_set_options(settingsScreen->month_roller, month_options, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(settingsScreen->month_roller, 2); lv_obj_add_event_cb(settingsScreen->month_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen); lv_roller_set_options(settingsScreen->year_roller, year_options, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(settingsScreen->year_roller, 2); lv_obj_add_event_cb(settingsScreen->year_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen); menu_page_label = lv_label_create(section); lv_label_set_text_static(menu_page_label, "Date Format :"); container = create_section_container(section); lv_obj_t *date_dropdown = lv_dropdown_create(container); lv_dropdown_set_options_static(date_dropdown, date_format); //We create the menu page for the display settings lv_obj_t *menu_page_2 = lv_menu_page_create(menu, NULL); section = create_menu_page_section(menu_page_2); menu_page_label = lv_label_create(section); lv_label_set_text_static(menu_page_label, "Brightness :"); container = create_section_container(section); lv_obj_t *slider = lv_slider_create(container); lv_obj_clear_flag(slider, LV_OBJ_FLAG_GESTURE_BUBBLE); lv_obj_set_width(slider, lv_pct(90)); lv_obj_set_align(slider, LV_ALIGN_CENTER); lv_obj_add_event_cb(slider, &(brightness_slider_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); menu_page_label = lv_label_create(section); lv_label_set_text_static(menu_page_label, "Sleep Timeout :"); container = create_section_container(section); lv_obj_t *timeout = lv_roller_create(container); lv_roller_set_options(timeout, second_options, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(timeout, 2); lv_obj_t *timeout_label = lv_label_create(container); lv_label_set_text_static(timeout_label, "Second(s)"); lv_obj_set_style_pad_top(timeout_label, 25, LV_PART_MAIN); //We create the side bar page lv_obj_t *sidebar_page = lv_menu_page_create(menu, NULL); lv_obj_t *settings_section_1 = lv_menu_section_create(sidebar_page); lv_obj_set_style_pad_all(settings_section_1, 0, LV_PART_MAIN); lv_obj_set_style_pad_bottom(settings_section_1, 50 , LV_PART_MAIN); lv_obj_set_style_pad_hor(settings_section_1, -10 ,LV_PART_MAIN); lv_obj_t *selected = add_sidebar_entry_to_menu(settings_section_1, "Time & Date", menu, menu_page_1); add_sidebar_entry_to_menu(settings_section_1, "Display", menu, menu_page_2); add_sidebar_entry_to_menu(settings_section_1, "Notifications", menu, NULL); add_sidebar_entry_to_menu(settings_section_1, "Connectivity", menu, NULL); add_sidebar_entry_to_menu(settings_section_1, "Language", menu, NULL); //We set the side bar page lv_menu_set_sidebar_page(menu, sidebar_page); lv_event_send(selected, LV_EVENT_CLICKED, NULL); //We register the event callback to handle gesture lv_obj_add_event_cb(settingsScreen->display, &(gesture_event_cb), LV_EVENT_GESTURE, settingsScreen); //We register the event callback to handle the cleanup lv_obj_add_event_cb(settingsScreen->display, &(cleanup_event_cb), LV_EVENT_DELETE, settingsScreen); } void settings_screen_destroy(SettingsScreen_t * const settingsScreen) { if(!settingsScreen) { LV_LOG_ERROR("NULL pointer given !"); return; } settingsScreen->hour_roller = NULL; settingsScreen->minute_roller = NULL; settingsScreen->second_roller = NULL; settingsScreen->day_roller = NULL; settingsScreen->month_roller = NULL; settingsScreen->year_roller = NULL; settingsScreen->display = NULL; } /* const char *lang_options = "English\nFrench\nGerman\nItalian"; void settings_screen(void) { conf_screen = lv_obj_create(NULL); LV_LOG_USER("Adding event to screen"); lv_obj_add_event_cb(conf_screen, &(event_cb), LV_EVENT_GESTURE, NULL); lv_obj_t *config_bar = lv_obj_create(conf_screen); lv_obj_set_style_bg_color(config_bar, lv_color_make(129, 141,181), LV_PART_MAIN); lv_obj_set_size(config_bar, 240, 65); lv_obj_set_style_radius(config_bar, 0, LV_PART_MAIN); lv_obj_set_style_border_width(config_bar, 0, LV_PART_MAIN); lv_obj_t *config_label = lv_label_create(config_bar); lv_label_set_text_static(config_label, "Settings"); lv_obj_set_style_text_color(config_label, lv_color_white(), LV_PART_MAIN); lv_obj_set_style_text_font(config_label, &lv_font_montserrat_30, LV_PART_MAIN); lv_obj_set_align(config_label, LV_ALIGN_CENTER); lv_obj_t *menu = lv_menu_create(conf_screen); lv_obj_set_size(menu, lv_pct(100), 240 - 65); lv_obj_set_pos(menu, 0, 65); //lv_obj_set_style_text_color(menu, lv_color_make(145, 145, 145), LV_PART_MAIN); //lv_obj_set_style_text_font(menu, &lv_font_montserrat_16, LV_PART_MAIN); //lv_obj_set_style_pad_hor(menu,-10,LV_PART_MAIN); //create sub page lv_obj_t *time_sub_page = lv_menu_page_create(menu, NULL); lv_menu_separator_create(time_sub_page); lv_obj_t *section = lv_menu_section_create(time_sub_page); lv_obj_set_style_pad_bottom(section, 50, LV_PART_MAIN); lv_obj_set_style_pad_left(section, 5, LV_PART_MAIN); lv_obj_t *sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Time Setting :"); lv_obj_t *container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_t *toggle = lv_switch_create(container); lv_obj_add_state(toggle, LV_STATE_CHECKED); lv_obj_t *toggle_label = lv_label_create(container); lv_label_set_text_static(toggle_label, "Automatic"); lv_obj_set_style_pad_top(toggle_label, 5, LV_PART_MAIN); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Date :"); container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_t *day_roller = lv_roller_create(container), *month_roller = lv_roller_create(container), *year_roller = lv_roller_create(container); lv_roller_set_options(day_roller, day_options, LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(day_roller, 2); lv_roller_set_options(month_roller, month_options, LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(month_roller, 2); lv_roller_set_options(year_roller, year_options, LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(year_roller, 2); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Time :"); container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_clear_flag(container, LV_OBJ_FLAG_SCROLLABLE); lv_obj_t *hour_roller = lv_roller_create(container), *minute_roller = lv_roller_create(container), *second_roller = lv_roller_create(container); lv_roller_set_options(hour_roller, hour_options, LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(hour_roller, 2); lv_roller_set_options(minute_roller, sec_min_options, LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(minute_roller, 2); lv_roller_set_options(second_roller, sec_min_options, LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(second_roller, 2); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Time Format :"); container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_t *btn_12 = lv_checkbox_create(container), *btn_24 = lv_checkbox_create(container); lv_checkbox_set_text(btn_12, "12H"); lv_obj_set_style_radius(btn_12, LV_RADIUS_CIRCLE, LV_PART_INDICATOR); lv_obj_add_state(btn_12, LV_STATE_CHECKED); lv_checkbox_set_text(btn_24, "24H"); lv_obj_set_style_radius(btn_24, LV_RADIUS_CIRCLE, LV_PART_INDICATOR); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Date Format :"); container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_t *date_drop = lv_dropdown_create(container); lv_dropdown_set_options_static(date_drop, date_format); lv_obj_t *screen_sub_page = lv_menu_page_create(menu, NULL); lv_menu_separator_create(screen_sub_page); section = lv_menu_section_create(screen_sub_page); lv_obj_set_style_pad_left(section, 5, LV_PART_MAIN); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Brightness :"); container = lv_obj_create(section); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_t *slider = lv_slider_create(container); lv_obj_clear_flag(slider, LV_OBJ_FLAG_GESTURE_BUBBLE); lv_obj_set_width(slider, lv_pct(80)); lv_obj_set_align(slider, LV_ALIGN_CENTER); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Sleep Timeout :"); container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_t *timeout = lv_roller_create(container); lv_roller_set_options(timeout, day_options, LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(timeout, 2); lv_obj_t *timeout_lab = lv_label_create(container); lv_label_set_text_static(timeout_lab, "Second(s)"); lv_obj_set_style_pad_top(timeout_lab, 25, LV_PART_MAIN); lv_obj_t *notify_sub_page = lv_menu_page_create(menu, NULL); lv_menu_separator_create(notify_sub_page); section = lv_menu_section_create(notify_sub_page); lv_obj_set_style_pad_left(section, 5, LV_PART_MAIN); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Vibrator :"); container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_t *vib_toggle = lv_switch_create(container); lv_obj_add_state(vib_toggle, LV_STATE_CHECKED); lv_obj_t *vib_toggle_label = lv_label_create(container); lv_label_set_text_static(vib_toggle_label, "Enabled"); lv_obj_set_style_pad_top(vib_toggle_label, 5, LV_PART_MAIN); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Vibration duration :"); container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); timeout = lv_roller_create(container); lv_roller_set_options(timeout, day_options, LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(timeout, 2); timeout_lab = lv_label_create(container); lv_label_set_text_static(timeout_lab, "Second(s)"); lv_obj_set_style_pad_top(timeout_lab, 25, LV_PART_MAIN); lv_obj_t *lan_sub_page = lv_menu_page_create(menu, NULL); lv_menu_separator_create(lan_sub_page); section = lv_menu_section_create(lan_sub_page); lv_obj_set_style_pad_left(section, 5, LV_PART_MAIN); sub_page_label = lv_label_create(section); lv_label_set_text_static(sub_page_label, "Languages :"); container = lv_obj_create(section); lv_obj_set_flex_flow(container, LV_FLEX_FLOW_ROW); lv_obj_set_style_pad_right(container,0, LV_PART_MAIN); lv_obj_set_style_pad_left(container,0, LV_PART_MAIN); lv_obj_set_style_border_width(container,0, LV_PART_MAIN); lv_obj_set_size(container, lv_pct(100), LV_SIZE_CONTENT); lv_obj_t *lang_drop = lv_dropdown_create(container); lv_dropdown_set_options(lang_drop, lang_options); //Create root page lv_obj_t *main_page = lv_menu_page_create(menu, NULL); lv_obj_t *settings_section = lv_menu_section_create(main_page); lv_obj_set_style_pad_all(settings_section, 0, LV_PART_MAIN); lv_obj_set_style_pad_bottom(settings_section, 50, LV_PART_MAIN); lv_obj_set_style_pad_hor(settings_section,-10,LV_PART_MAIN); lv_obj_t *date_categ = lv_menu_cont_create(settings_section); lv_obj_t *date_categ_text_1 = lv_label_create(date_categ); lv_label_set_text_static(date_categ_text_1, "Time & Date"); lv_obj_set_style_text_color(date_categ_text_1, lv_color_make(145, 145, 145), LV_PART_MAIN); //lv_label_set_long_mode(date_categ_text_1, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_flex_grow(date_categ_text_1, 1); lv_obj_set_style_anim_speed(date_categ_text_1, 15, LV_PART_MAIN); lv_menu_set_load_page_event(menu, date_categ_text_1, time_sub_page); lv_obj_t *categ = lv_menu_cont_create(settings_section); lv_obj_t *categ_text_1 = lv_label_create(categ); lv_label_set_text_static(categ_text_1, "Screen"); lv_obj_set_style_text_color(categ_text_1, lv_color_make(145, 145, 145), LV_PART_MAIN); //lv_label_set_long_mode(categ_text_1, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_flex_grow(categ_text_1, 1); lv_obj_set_style_anim_speed(categ_text_1, 15, LV_PART_MAIN); lv_menu_set_load_page_event(menu, categ_text_1, screen_sub_page); lv_obj_t *vib_categ = lv_menu_cont_create(settings_section); lv_obj_t *vib_categ_text_1 = lv_label_create(vib_categ); lv_label_set_text_static(vib_categ_text_1, "Notifications"); lv_obj_set_style_text_color(vib_categ_text_1, lv_color_make(145, 145, 145), LV_PART_MAIN); //lv_label_set_long_mode(vib_categ_text_1, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_flex_grow(vib_categ_text_1, 1); lv_obj_set_style_anim_speed(vib_categ_text_1, 15, LV_PART_MAIN); lv_menu_set_load_page_event(menu, vib_categ_text_1, notify_sub_page); lv_obj_t *con_categ = lv_menu_cont_create(settings_section); lv_obj_t *con_categ_text_1 = lv_label_create(con_categ); lv_label_set_text_static(con_categ_text_1, "Connectivity"); lv_obj_set_style_text_color(con_categ_text_1, lv_color_make(145, 145, 145), LV_PART_MAIN); //lv_label_set_long_mode(con_categ_text_1, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_flex_grow(con_categ_text_1, 1); lv_obj_set_style_anim_speed(con_categ_text_1, 15, LV_PART_MAIN); //lv_menu_set_load_page_event(menu, con_categ_text_1, notify_sub_page); lv_obj_t *lan_categ = lv_menu_cont_create(settings_section); lv_obj_t *lan_categ_text_1 = lv_label_create(lan_categ); lv_label_set_text_static(lan_categ_text_1, "Language"); lv_obj_set_style_text_color(lan_categ_text_1, lv_color_make(145, 145, 145), LV_PART_MAIN); //lv_label_set_long_mode(lan_categ_text_1, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_flex_grow(lan_categ_text_1, 1); lv_obj_set_style_anim_speed(lan_categ_text_1, 15, LV_PART_MAIN); lv_menu_set_load_page_event(menu, lan_categ_text_1, lan_sub_page); lv_menu_set_sidebar_page(menu, main_page); lv_event_send(date_categ_text_1, LV_EVENT_CLICKED, NULL); }*/