From ba885b52b9ea9378cabd284359130e093d4083ec Mon Sep 17 00:00:00 2001 From: anschrammh Date: Wed, 21 Dec 2022 10:04:27 +0100 Subject: [PATCH] Renamed config_screen to settings_screen work in progress --- .../app/drivers/i2c/BMP280.c | 0 .../app/drivers/i2c/BMP280.h | 6 + .../app/gfx/common_screen_components.c | 16 + .../app/gfx/common_screen_components.h | 8 + .../app/gfx/compass_screen.h | 4 +- src/W800 SDK v1.00.08/app/gfx/gfx_task.c | 26 +- src/W800 SDK v1.00.08/app/gfx/gfx_task.h | 2 +- src/W800 SDK v1.00.08/app/gfx/menu_screen.c | 26 +- .../app/gfx/settings_screen.c} | 252 +++++++- .../app/gfx/settings_screen.h | 27 + .../lvgl/lvgl_port/lv_conf.h | 24 +- .../common_screen_components.c | 16 + .../common_screen_components.h | 8 + .../lv_port_win_codeblocks/compass_screen.c | 91 ++- .../lv_port_win_codeblocks/compass_screen.h | 8 + .../lv_port_win_codeblocks/config_screen.h | 6 - .../lv_port_win_codeblocks/lv_conf.h | 4 +- .../lv_port_win_codeblocks/main.c | 8 +- .../lv_port_win_codeblocks/menu_screen.c | 37 +- .../lv_port_win_codeblocks/settings_screen.c | 575 ++++++++++++++++++ .../lv_port_win_codeblocks/settings_screen.h | 27 + 21 files changed, 1041 insertions(+), 130 deletions(-) create mode 100644 src/W800 SDK v1.00.08/app/drivers/i2c/BMP280.c create mode 100644 src/W800 SDK v1.00.08/app/drivers/i2c/BMP280.h create mode 100644 src/W800 SDK v1.00.08/app/gfx/common_screen_components.c create mode 100644 src/W800 SDK v1.00.08/app/gfx/common_screen_components.h rename src/{lvgl_win_sim/lv_port_win_codeblocks/config_screen.c => W800 SDK v1.00.08/app/gfx/settings_screen.c} (62%) create mode 100644 src/W800 SDK v1.00.08/app/gfx/settings_screen.h create mode 100644 src/lvgl_win_sim/lv_port_win_codeblocks/common_screen_components.c create mode 100644 src/lvgl_win_sim/lv_port_win_codeblocks/common_screen_components.h delete mode 100644 src/lvgl_win_sim/lv_port_win_codeblocks/config_screen.h create mode 100644 src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.c create mode 100644 src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.h diff --git a/src/W800 SDK v1.00.08/app/drivers/i2c/BMP280.c b/src/W800 SDK v1.00.08/app/drivers/i2c/BMP280.c new file mode 100644 index 0000000..e69de29 diff --git a/src/W800 SDK v1.00.08/app/drivers/i2c/BMP280.h b/src/W800 SDK v1.00.08/app/drivers/i2c/BMP280.h new file mode 100644 index 0000000..12e0aad --- /dev/null +++ b/src/W800 SDK v1.00.08/app/drivers/i2c/BMP280.h @@ -0,0 +1,6 @@ +#ifndef BMP280_H +#define BMP280_H + + + +#endif //BMP280_H \ No newline at end of file diff --git a/src/W800 SDK v1.00.08/app/gfx/common_screen_components.c b/src/W800 SDK v1.00.08/app/gfx/common_screen_components.c new file mode 100644 index 0000000..759b1b4 --- /dev/null +++ b/src/W800 SDK v1.00.08/app/gfx/common_screen_components.c @@ -0,0 +1,16 @@ +#include "lvgl.h" + +void common_screen_header_component(lv_obj_t *parent, const char * title, lv_coord_t height) +{ + lv_obj_t *header = lv_obj_create(parent); + lv_obj_set_style_bg_color(header, lv_color_make(129, 141,181), LV_PART_MAIN); + lv_obj_set_size(header, lv_disp_get_hor_res(NULL), height); + lv_obj_set_style_radius(header, 0, LV_PART_MAIN); + lv_obj_set_style_border_width(header, 0, LV_PART_MAIN); + + lv_obj_t *header_title = lv_label_create(header); + lv_label_set_text_static(header_title, title); + lv_obj_set_style_text_color(header_title, lv_color_white(), LV_PART_MAIN); + lv_obj_set_style_text_font(header_title, &lv_font_montserrat_30, LV_PART_MAIN); + lv_obj_set_align(header_title, LV_ALIGN_CENTER); +} diff --git a/src/W800 SDK v1.00.08/app/gfx/common_screen_components.h b/src/W800 SDK v1.00.08/app/gfx/common_screen_components.h new file mode 100644 index 0000000..a1636ef --- /dev/null +++ b/src/W800 SDK v1.00.08/app/gfx/common_screen_components.h @@ -0,0 +1,8 @@ +#ifndef COMMON_SCREEN_COMPONENTS_H +#define COMMON_SCREEN_COMPONENTS_H + +#include "lvgl.h" + +void common_screen_header_component(lv_obj_t *parent, const char * title, lv_coord_t height); + +#endif //COMMON_SCREEN_COMPONENTS_H diff --git a/src/W800 SDK v1.00.08/app/gfx/compass_screen.h b/src/W800 SDK v1.00.08/app/gfx/compass_screen.h index 75d8a06..ae1a705 100644 --- a/src/W800 SDK v1.00.08/app/gfx/compass_screen.h +++ b/src/W800 SDK v1.00.08/app/gfx/compass_screen.h @@ -16,11 +16,11 @@ typedef struct CompassCardinal lv_point_t offset; } CompassCardinal_t; -typedef struct CompassGraduation +/*typedef struct CompassGraduation { lv_obj_t *meter; lv_meter_scale_t *scale; -} CompassGraduation_t; +} CompassGraduation_t;*/ /* Compass screen context object */ typedef struct CompassScreen diff --git a/src/W800 SDK v1.00.08/app/gfx/gfx_task.c b/src/W800 SDK v1.00.08/app/gfx/gfx_task.c index d252ddf..6297ba5 100644 --- a/src/W800 SDK v1.00.08/app/gfx/gfx_task.c +++ b/src/W800 SDK v1.00.08/app/gfx/gfx_task.c @@ -6,6 +6,7 @@ #include "watch_face.h" #include "menu_screen.h" #include "compass_screen.h" +#include "settings_screen.h" #include "i2c.h" #include "QMC5883L.h" @@ -60,6 +61,7 @@ static void date_time_cb(struct tm * const dateTime) WatchFace_t watchFace; MenuScreen_t menuScreen; CompassScreen_t compassScreen; +SettingsScreen_t settingsScreen; static uint16_t angle_with_offset(uint16_t angle, uint16_t offset) { @@ -118,6 +120,7 @@ void gfx_task(void *param) watch_face_init(&watchFace); menu_screen_init(&menuScreen); compass_screen_init(&compassScreen); + settings_screen_init(&settingsScreen); watch_face_register_cb(&watchFace, &(date_time_cb)); watch_face_create(&watchFace); @@ -161,29 +164,6 @@ void gfx_task(void *param) //APP_LOG_TRACE("X %d Y %d Z %d", MDataRaw.MFieldX, MDataRaw.MFieldY, MDataRaw.MFieldZ); QMC5883L_MData_calibrated_t MData = QMC5883L_get_MFields_calibrated(); - - /*if(average++ == 0) - { - temp.MFieldX = MData.MFieldX; - temp.MFieldY = MData.MFieldY; - temp.MFieldZ = MData.MFieldZ; - } - else - { - temp.MFieldX += MData.MFieldX; - temp.MFieldX >>= 1; - temp.MFieldY += MData.MFieldY; - temp.MFieldY >>= 1; - temp.MFieldZ += MData.MFieldZ; - temp.MFieldZ >>= 1; - }*/ - - /*if(average == 1) - { - average = 0; - angle = angle_with_offset(QMC5883L_get_azimuth(MData), 180); - compass_screen_set_azimuth(&compassScreen, angle); - }*/ compass_screen_set_azimuth(&compassScreen, angle_with_offset(QMC5883L_get_azimuth(MData), 180)); } diff --git a/src/W800 SDK v1.00.08/app/gfx/gfx_task.h b/src/W800 SDK v1.00.08/app/gfx/gfx_task.h index e059ca3..c343b74 100644 --- a/src/W800 SDK v1.00.08/app/gfx/gfx_task.h +++ b/src/W800 SDK v1.00.08/app/gfx/gfx_task.h @@ -4,7 +4,7 @@ #include "wm_include.h" -#define GFX_STACK_SIZE_IN_BYTES (512 * sizeof(StackType_t)) +#define GFX_STACK_SIZE_IN_BYTES (1024 * sizeof(StackType_t)) #define GFX_STACK_PRIORITY (5) static u8 gfx_task_stack[GFX_STACK_SIZE_IN_BYTES]; diff --git a/src/W800 SDK v1.00.08/app/gfx/menu_screen.c b/src/W800 SDK v1.00.08/app/gfx/menu_screen.c index 74075a7..519dafe 100644 --- a/src/W800 SDK v1.00.08/app/gfx/menu_screen.c +++ b/src/W800 SDK v1.00.08/app/gfx/menu_screen.c @@ -1,6 +1,7 @@ #include "lvgl.h" +#include "common_screen_components.h" #include "menu_screen.h" -//#include "config_screen.h" +#include "settings_screen.h" #include "watch_face.h" #include "compass_screen.h" @@ -29,8 +30,9 @@ static void menu_item_cb(lv_event_t *e) break; case 7: { - //extern lv_obj_t *conf_screen; - //lv_scr_load_anim(conf_screen, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, false); + extern SettingsScreen_t settingsScreen; + settings_screen_create(&settingsScreen); + lv_scr_load_anim(settingsScreen.display, LV_SCR_LOAD_ANIM_MOVE_LEFT, 400, 0, true); } break; default: @@ -55,21 +57,6 @@ void menu_screen_init(MenuScreen_t * const menuScreen) memset(menuScreen, 0, sizeof(MenuScreen_t)); } -static void screen_create_header(MenuScreen_t * const menuScreen, const char *title) -{ - lv_obj_t *header = lv_obj_create(menuScreen->display); - lv_obj_set_style_bg_color(header, lv_color_make(129, 141,181), LV_PART_MAIN); - lv_obj_set_size(header, 240, 65); - lv_obj_set_style_radius(header, 0, LV_PART_MAIN); - lv_obj_set_style_border_width(header, 0, LV_PART_MAIN); - - lv_obj_t *header_title = lv_label_create(header); - lv_label_set_text_static(header_title, title); - lv_obj_set_style_text_color(header_title, lv_color_white(), LV_PART_MAIN); - lv_obj_set_style_text_font(header_title, &lv_font_montserrat_30, LV_PART_MAIN); - lv_obj_set_align(header_title, LV_ALIGN_CENTER); -} - static void menu_screen_add_item(lv_obj_t *scroll_item_container, uint8_t position, const lv_img_dsc_t *itemImg,const char *itemTitle, lv_event_cb_t itemClickEventCb) { //We add the image button with the icon of the item @@ -117,7 +104,8 @@ void menu_screen_create(MenuScreen_t * const menuScreen) } menuScreen->display = lv_obj_create(NULL); - screen_create_header(menuScreen, "Menu"); + //We add the screen header + common_screen_header_component(menuScreen->display, "Menu", 65); lv_obj_t *scroll_item_container = lv_obj_create(menuScreen->display); lv_obj_set_style_bg_color(scroll_item_container, lv_color_make(0xFF,0xFF,0xFF), LV_PART_MAIN); diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/config_screen.c b/src/W800 SDK v1.00.08/app/gfx/settings_screen.c similarity index 62% rename from src/lvgl_win_sim/lv_port_win_codeblocks/config_screen.c rename to src/W800 SDK v1.00.08/app/gfx/settings_screen.c index d56047c..e5e2b58 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/config_screen.c +++ b/src/W800 SDK v1.00.08/app/gfx/settings_screen.c @@ -1,10 +1,19 @@ -#include "config_screen.h" -#include "menu_screen.h" #include "lvgl.h" -lv_obj_t *conf_screen = NULL; +#include "common_screen_components.h" +#include "settings_screen.h" +#include "menu_screen.h" -static void event_cb(lv_event_t * e) +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"; +const char *month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12"; +const char *year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30"; + +const char *hour_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23"; +const char *sec_min_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\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 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())) { @@ -13,9 +22,10 @@ static void event_cb(lv_event_t * e) 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, false); + 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"); @@ -28,18 +38,228 @@ static void event_cb(lv_event_t * e) } } -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"; -const char *month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12"; -const char *year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30"; +static void cleanup_event_cb(lv_event_t * e) +{ + SettingsScreen_t *settingsScreen = e->user_data; + settings_screen_destroy(settingsScreen); + LV_LOG_USER("cleanup"); +} -const char *hour_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23"; -const char *sec_min_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\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 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); -const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd"; + 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_1_label = lv_label_create(section); + lv_label_set_text_static(menu_page_1_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_1_label = lv_label_create(section); + lv_label_set_text_static(menu_page_1_label, "Time :"); + container = create_section_container(section); + + lv_obj_t *hour_drop = lv_dropdown_create(container); + lv_dropdown_set_options_static(hour_drop, hour_options); + lv_obj_set_width(hour_drop, lv_pct(30)); + + hour_drop = lv_dropdown_create(container); + lv_dropdown_set_options_static(hour_drop, sec_min_options); + lv_obj_set_width(hour_drop, lv_pct(30)); + + hour_drop = lv_dropdown_create(container); + lv_dropdown_set_options_static(hour_drop, sec_min_options); + lv_obj_set_width(hour_drop, lv_pct(30)); + + /*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);*/ + + /*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, 1); + lv_obj_set_style_anim_time(hour_roller, 0, LV_PART_MAIN);*/ + + + /*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);*/ + + + menu_page_1_label = lv_label_create(section); + lv_label_set_text_static(menu_page_1_label, "Date :"); + /*container = create_section_container(section); + + 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);*/ + + + + + + //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, NULL); + + 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->display = NULL; +} + +/*const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd"; const char *lang_options = "English\nFrench\nGerman\nItalian"; -void config_screen(void) +void settings_screen(void) { conf_screen = lv_obj_create(NULL); @@ -61,8 +281,8 @@ void config_screen(void) 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_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 @@ -259,7 +479,7 @@ void config_screen(void) lv_dropdown_set_options(lang_drop, lang_options); //Create root page - lv_obj_t *main_page = lv_menu_page_create(menu, NULL/*"Settings"*/); + 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); @@ -320,4 +540,4 @@ void config_screen(void) lv_menu_set_sidebar_page(menu, main_page); lv_event_send(date_categ_text_1, LV_EVENT_CLICKED, NULL); -} +}*/ diff --git a/src/W800 SDK v1.00.08/app/gfx/settings_screen.h b/src/W800 SDK v1.00.08/app/gfx/settings_screen.h new file mode 100644 index 0000000..b785ce9 --- /dev/null +++ b/src/W800 SDK v1.00.08/app/gfx/settings_screen.h @@ -0,0 +1,27 @@ +#ifndef SETTINGS_SCREEN_H +#define SETTINGS_SCREEN_H + +#include "lvgl.h" + +typedef struct SettingsScreenAPIInterface +{ + +} SettingsScreenAPIInterface_t; + +typedef struct SettingsScreen +{ + SettingsScreenAPIInterface_t settingsScreenAPIInterface; + lv_obj_t *display; +} SettingsScreen_t; + +void settings_screen_init(SettingsScreen_t * const settingsScreen); + +void settings_screen_register_API_interface(SettingsScreen_t * const settingsScreen, SettingsScreenAPIInterface_t * const settingsScreenAPIInterface); + +void settings_screen_create(SettingsScreen_t * const settingsScreen); + +void settings_screen_destroy(SettingsScreen_t * const settingsScreen); + +void settings_screen(void); + +#endif //SETTINGS_SCREEN_H diff --git a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_conf.h b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_conf.h index 9636794..a022751 100644 --- a/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_conf.h +++ b/src/W800 SDK v1.00.08/lvgl/lvgl_port/lv_conf.h @@ -49,7 +49,7 @@ #define LV_MEM_CUSTOM 0 #if LV_MEM_CUSTOM == 0 /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ - #define LV_MEM_SIZE (30 * 1024U) /*[bytes]*/ + #define LV_MEM_SIZE (40 * 1024U) /*[bytes]*/ /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ #define LV_MEM_ADR 0 /*0: unused*/ @@ -219,7 +219,7 @@ *-----------*/ /*Enable the log module*/ -#define LV_USE_LOG 1 +#define LV_USE_LOG 0 #if LV_USE_LOG /*How important log should be added: @@ -342,7 +342,7 @@ #define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ /*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ -#define LV_USE_LARGE_COORD 0 +#define LV_USE_LARGE_COORD 1 /*================== * FONT USAGE @@ -523,13 +523,13 @@ #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 #endif /*LV_USE_CALENDAR*/ -#define LV_USE_CHART 1 +#define LV_USE_CHART 0 -#define LV_USE_COLORWHEEL 1 +#define LV_USE_COLORWHEEL 0 #define LV_USE_IMGBTN 1 -#define LV_USE_KEYBOARD 1 +#define LV_USE_KEYBOARD 0 #define LV_USE_LED 1 @@ -537,11 +537,11 @@ #define LV_USE_MENU 1 -#define LV_USE_METER 1 +#define LV_USE_METER 0 -#define LV_USE_MSGBOX 1 +#define LV_USE_MSGBOX 0 -#define LV_USE_SPAN 1 +#define LV_USE_SPAN 0 #if LV_USE_SPAN /*A line text can contain maximum num of span descriptor */ #define LV_SPAN_SNIPPET_STACK_SIZE 64 @@ -551,11 +551,11 @@ #define LV_USE_SPINNER 1 -#define LV_USE_TABVIEW 1 +#define LV_USE_TABVIEW 0 -#define LV_USE_TILEVIEW 1 +#define LV_USE_TILEVIEW 0 -#define LV_USE_WIN 1 +#define LV_USE_WIN 0 /*----------- * Themes diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/common_screen_components.c b/src/lvgl_win_sim/lv_port_win_codeblocks/common_screen_components.c new file mode 100644 index 0000000..759b1b4 --- /dev/null +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/common_screen_components.c @@ -0,0 +1,16 @@ +#include "lvgl.h" + +void common_screen_header_component(lv_obj_t *parent, const char * title, lv_coord_t height) +{ + lv_obj_t *header = lv_obj_create(parent); + lv_obj_set_style_bg_color(header, lv_color_make(129, 141,181), LV_PART_MAIN); + lv_obj_set_size(header, lv_disp_get_hor_res(NULL), height); + lv_obj_set_style_radius(header, 0, LV_PART_MAIN); + lv_obj_set_style_border_width(header, 0, LV_PART_MAIN); + + lv_obj_t *header_title = lv_label_create(header); + lv_label_set_text_static(header_title, title); + lv_obj_set_style_text_color(header_title, lv_color_white(), LV_PART_MAIN); + lv_obj_set_style_text_font(header_title, &lv_font_montserrat_30, LV_PART_MAIN); + lv_obj_set_align(header_title, LV_ALIGN_CENTER); +} diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/common_screen_components.h b/src/lvgl_win_sim/lv_port_win_codeblocks/common_screen_components.h new file mode 100644 index 0000000..a1636ef --- /dev/null +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/common_screen_components.h @@ -0,0 +1,8 @@ +#ifndef COMMON_SCREEN_COMPONENTS_H +#define COMMON_SCREEN_COMPONENTS_H + +#include "lvgl.h" + +void common_screen_header_component(lv_obj_t *parent, const char * title, lv_coord_t height); + +#endif //COMMON_SCREEN_COMPONENTS_H diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.c b/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.c index da51fb4..1de32ad 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.c +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.c @@ -52,12 +52,13 @@ static void cleanup_event_cb(lv_event_t * e) } //To delete -/*static void timer_anim_cb(lv_timer_t *timer) +static void timer_anim_cb(lv_timer_t *timer) { CompassScreen_t *compassScreen = timer->user_data; static uint16_t azimuth = 0; compass_screen_set_azimuth(compassScreen, azimuth++); -}*/ + lv_meter_set_scale_range(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 0, 330, 330, -azimuth-90); +} static void create_cardinal(CompassCardinal_t *cardidanl, const char *cardinalText, lv_color_t textColor, lv_coord_t x, lv_coord_t y, lv_obj_t *parent) { @@ -165,22 +166,32 @@ void compass_screen_create(CompassScreen_t * const compassScreen) compassScreen->display = lv_obj_create(NULL); lv_obj_set_style_bg_color(compassScreen->display, lv_color_white(), LV_PART_MAIN); + //Let's try to add some arcs + lv_obj_t *arc = lv_arc_create(compassScreen->display); + lv_arc_set_angles(arc, 0, 360); + lv_obj_set_style_arc_width(arc, 2, LV_PART_INDICATOR); + lv_obj_remove_style(arc, NULL, LV_PART_KNOB); + lv_obj_set_style_arc_width(arc, 0, LV_PART_MAIN); + lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE); + + lv_obj_set_size(arc, 168, 168); + lv_obj_center(arc); + + arc = lv_arc_create(compassScreen->display); + lv_arc_set_angles(arc, 0, 360); + lv_obj_set_style_arc_width(arc, 2, LV_PART_INDICATOR); + lv_obj_remove_style(arc, NULL, LV_PART_KNOB); + lv_obj_set_style_arc_width(arc, 0, LV_PART_MAIN); + lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE); + + lv_obj_set_size(arc, 210, 210); + lv_obj_center(arc); + //Marker images are created here lv_obj_t *compassMarker = lv_img_create(compassScreen->display); lv_img_set_src(compassMarker, &compass_marker); lv_obj_set_pos(compassMarker, 113, 0); - if(compassScreen->northMarker) - { - LV_LOG_ERROR("img should be NULL here !"); - lv_obj_del(compassScreen->northMarker); - compassScreen->northMarker = NULL; - } - compassScreen->northMarker = lv_img_create(compassScreen->display); - lv_img_set_src(compassScreen->northMarker, &compass_marker_north); - lv_obj_set_pos(compassScreen->northMarker, 113, 20); - lv_img_set_pivot(compassScreen->northMarker, 7, 100); - //Azimuth label is created here if(compassScreen->compassAzimuth.label) { @@ -193,6 +204,35 @@ void compass_screen_create(CompassScreen_t * const compassScreen) lv_obj_set_style_text_font(compassScreen->compassAzimuth.label, &lv_font_montserrat_28, LV_PART_MAIN); lv_obj_center(compassScreen->compassAzimuth.label); + //Add some graduation : + if(compassScreen->compassGraduation.meter) + { + LV_LOG_ERROR("meter should be NULL here !"); + lv_obj_del(compassScreen->compassGraduation.meter); + compassScreen->compassGraduation.meter = NULL; + } + compassScreen->compassGraduation.meter = lv_meter_create(compassScreen->display); + lv_obj_remove_style(compassScreen->compassGraduation.meter, NULL, LV_PART_INDICATOR); + lv_obj_remove_style(compassScreen->compassGraduation.meter, NULL, LV_PART_MAIN); + lv_obj_set_size(compassScreen->compassGraduation.meter, 204, 204); + lv_obj_center(compassScreen->compassGraduation.meter); + + compassScreen->compassGraduation.scale = lv_meter_add_scale(compassScreen->compassGraduation.meter); + lv_meter_set_scale_ticks(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 12, 1, 0, lv_color_black()); + lv_meter_set_scale_major_ticks(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 1, 1, 0, lv_color_black(), 11); + lv_meter_set_scale_range(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 0, 330, 330, -90); + + if(compassScreen->northMarker) + { + LV_LOG_ERROR("img should be NULL here !"); + lv_obj_del(compassScreen->northMarker); + compassScreen->northMarker = NULL; + } + compassScreen->northMarker = lv_img_create(compassScreen->display); + lv_img_set_src(compassScreen->northMarker, &compass_marker_north); + lv_obj_set_pos(compassScreen->northMarker, 113, 18); + lv_img_set_pivot(compassScreen->northMarker, 7, 101); + //Cardinal labels are created here if(compassScreen->northCardinal.label) { @@ -200,8 +240,7 @@ void compass_screen_create(CompassScreen_t * const compassScreen) lv_obj_del(compassScreen->northCardinal.label); compassScreen->northCardinal.label = NULL; } - create_cardinal(&compassScreen->northCardinal, cardinals[0], lv_palette_main(LV_PALETTE_RED), 120, 50, compassScreen->display); - + create_cardinal(&compassScreen->northCardinal, cardinals[0], lv_palette_main(LV_PALETTE_RED), 120, 53, compassScreen->display); if(compassScreen->eastCardinal.label) { @@ -209,7 +248,7 @@ void compass_screen_create(CompassScreen_t * const compassScreen) lv_obj_del(compassScreen->eastCardinal.label); compassScreen->eastCardinal.label = NULL; } - create_cardinal(&compassScreen->eastCardinal, cardinals[2], lv_color_black(), 190, 120, compassScreen->display); + create_cardinal(&compassScreen->eastCardinal, cardinals[2], lv_color_black(), 187, 120, compassScreen->display); if(compassScreen->southCardinal.label) { @@ -217,7 +256,7 @@ void compass_screen_create(CompassScreen_t * const compassScreen) lv_obj_del(compassScreen->southCardinal.label); compassScreen->southCardinal.label = NULL; } - create_cardinal(&compassScreen->southCardinal, cardinals[4], lv_color_black(), 120, 190, compassScreen->display); + create_cardinal(&compassScreen->southCardinal, cardinals[4], lv_color_black(), 120, 187, compassScreen->display); if(compassScreen->westCardinal.label) { @@ -225,7 +264,7 @@ void compass_screen_create(CompassScreen_t * const compassScreen) lv_obj_del(compassScreen->westCardinal.label); compassScreen->westCardinal.label = NULL; } - create_cardinal(&compassScreen->westCardinal, cardinals[6], lv_color_black(), 50, 120, compassScreen->display); + create_cardinal(&compassScreen->westCardinal, cardinals[6], lv_color_black(), 53, 120, compassScreen->display); //We register the event callback to handle gestures lv_obj_add_event_cb(compassScreen->display, &(gesture_event_cb), LV_EVENT_GESTURE, compassScreen); @@ -244,11 +283,13 @@ void compass_screen_destroy(CompassScreen_t * const compassScreen) return; } - compassScreen->display = NULL; - compassScreen->compassAzimuth.label = NULL; - compassScreen->northCardinal.label = NULL; - compassScreen->eastCardinal.label = NULL; - compassScreen->southCardinal.label = NULL; - compassScreen->westCardinal.label = NULL; - compassScreen->northMarker = NULL; + compassScreen->display = NULL; + compassScreen->compassAzimuth.label = NULL; + compassScreen->northCardinal.label = NULL; + compassScreen->eastCardinal.label = NULL; + compassScreen->southCardinal.label = NULL; + compassScreen->westCardinal.label = NULL; + compassScreen->northMarker = NULL; + compassScreen->compassGraduation.meter = NULL; + compassScreen->compassGraduation.scale = NULL; } diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.h b/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.h index 437488a..6597d26 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.h +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.h @@ -16,6 +16,12 @@ typedef struct CompassCardinal lv_point_t offset; } CompassCardinal_t; +typedef struct CompassGraduation +{ + lv_obj_t *meter; + lv_meter_scale_t *scale; +} CompassGraduation_t; + /* Compass screen context object */ typedef struct CompassScreen { @@ -24,6 +30,8 @@ typedef struct CompassScreen CompassCardinal_t southCardinal; CompassCardinal_t westCardinal; + CompassGraduation_t compassGraduation; + lv_obj_t *northMarker; lv_obj_t *display; diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/config_screen.h b/src/lvgl_win_sim/lv_port_win_codeblocks/config_screen.h deleted file mode 100644 index 66268b6..0000000 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/config_screen.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CONFIG_SCREEN_H -#define CONFIG_SCREEN_H - -void config_screen(void); - -#endif // CONFIG_SCREEN_H diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/lv_conf.h b/src/lvgl_win_sim/lv_port_win_codeblocks/lv_conf.h index 859ea14..c4fc6fe 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/lv_conf.h +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/lv_conf.h @@ -36,7 +36,7 @@ #define LV_USE_BUILTIN_MALLOC 1 #if LV_USE_BUILTIN_MALLOC /*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/ - #define LV_MEM_SIZE (70U * 1024U) /*[bytes]*/ + #define LV_MEM_SIZE (45U * 1024U) /*[bytes]*/ /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ #define LV_MEM_ADR 0 /*0: unused*/ @@ -210,7 +210,7 @@ *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail *LV_LOG_LEVEL_USER Only logs added by the user *LV_LOG_LEVEL_NONE Do not log anything*/ - #define LV_LOG_LEVEL LV_LOG_LEVEL_ERROR + #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN /*1: Print the log with 'printf'; *0: User need to register a callback with `lv_log_register_print_cb()`*/ diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/main.c b/src/lvgl_win_sim/lv_port_win_codeblocks/main.c index 8b88ae4..65b7054 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/main.c +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/main.c @@ -16,7 +16,7 @@ #include #include #include "watch_face.h" -#include "config_screen.h" +#include "settings_screen.h" #include "menu_screen.h" #include "compass_screen.h" @@ -60,6 +60,7 @@ static void date_time_cb(struct tm * const dateTime) WatchFace_t watchFace; MenuScreen_t menuScreen; CompassScreen_t compassScreen; +SettingsScreen_t settingsScreen; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow) { @@ -83,6 +84,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi watch_face_init(&watchFace); menu_screen_init(&menuScreen); compass_screen_init(&compassScreen); + settings_screen_init(&settingsScreen); watch_face_register_cb(&watchFace, &(date_time_cb)); watch_face_create(&watchFace); @@ -90,7 +92,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi lv_scr_load(watchFace.display); - config_screen(); + //settings_screen(); //watch_face(); while(!lv_win32_quit_signal) { @@ -98,8 +100,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi * It could be done in a timer interrupt or an OS task too.*/ lv_task_handler(); usleep(10000); /*Just to let the system breath*/ - static uint16_t angle = 0; - compass_screen_set_azimuth(&compassScreen, angle++); } return 0; } diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/menu_screen.c b/src/lvgl_win_sim/lv_port_win_codeblocks/menu_screen.c index fcaa746..144559f 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/menu_screen.c +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/menu_screen.c @@ -1,6 +1,7 @@ #include "lvgl.h" +#include "common_screen_components.h" #include "menu_screen.h" -#include "config_screen.h" +#include "settings_screen.h" #include "watch_face.h" #include "compass_screen.h" @@ -17,22 +18,32 @@ static void menu_item_cb(lv_event_t *e) { extern WatchFace_t watchFace; watch_face_create(&watchFace); - lv_scr_load_anim(watchFace.display, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, true); + //lv_scr_load_anim(watchFace.display, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, true); + lv_scr_load_anim(watchFace.display, LV_SCR_LOAD_ANIM_MOVE_LEFT, 400, 0, true); } break; case 1: { extern CompassScreen_t compassScreen; compass_screen_create(&compassScreen); - lv_scr_load_anim(compassScreen.display, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, true); + //lv_scr_load_anim(compassScreen.display, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, true); + lv_scr_load_anim(compassScreen.display, LV_SCR_LOAD_ANIM_MOVE_LEFT, 400, 0, true); } break; case 7: + { + extern SettingsScreen_t settingsScreen; + settings_screen_create(&settingsScreen); + //lv_scr_load_anim(settingsScreen.display, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, true); + lv_scr_load_anim(settingsScreen.display, LV_SCR_LOAD_ANIM_MOVE_LEFT, 400, 0, true); + } + break; + /*case 7: { extern lv_obj_t *conf_screen; lv_scr_load_anim(conf_screen, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, false); } - break; + break;*/ default: LV_LOG_USER("Not handled"); } @@ -55,21 +66,6 @@ void menu_screen_init(MenuScreen_t * const menuScreen) memset(menuScreen, 0, sizeof(MenuScreen_t)); } -static void screen_create_header(MenuScreen_t * const menuScreen, const char *title) -{ - lv_obj_t *header = lv_obj_create(menuScreen->display); - lv_obj_set_style_bg_color(header, lv_color_make(129, 141,181), LV_PART_MAIN); - lv_obj_set_size(header, 240, 65); - lv_obj_set_style_radius(header, 0, LV_PART_MAIN); - lv_obj_set_style_border_width(header, 0, LV_PART_MAIN); - - lv_obj_t *header_title = lv_label_create(header); - lv_label_set_text_static(header_title, title); - lv_obj_set_style_text_color(header_title, lv_color_white(), LV_PART_MAIN); - lv_obj_set_style_text_font(header_title, &lv_font_montserrat_30, LV_PART_MAIN); - lv_obj_set_align(header_title, LV_ALIGN_CENTER); -} - static void menu_screen_add_item(lv_obj_t *scroll_item_container, uint8_t position, const lv_img_dsc_t *itemImg,const char *itemTitle, lv_event_cb_t itemClickEventCb) { //We add the image button with the icon of the item @@ -117,7 +113,8 @@ void menu_screen_create(MenuScreen_t * const menuScreen) } menuScreen->display = lv_obj_create(NULL); - screen_create_header(menuScreen, "Menu"); + //We add the screen header + common_screen_header_component(menuScreen->display, "Menu", 65); lv_obj_t *scroll_item_container = lv_obj_create(menuScreen->display); lv_obj_set_style_bg_color(scroll_item_container, lv_color_make(0xFF,0xFF,0xFF), LV_PART_MAIN); diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.c b/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.c new file mode 100644 index 0000000..4c114d2 --- /dev/null +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.c @@ -0,0 +1,575 @@ +#include "lvgl.h" +#include "common_screen_components.h" +#include "settings_screen.h" +#include "menu_screen.h" + +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"; +const char *month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12"; +const char *year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30"; + +const char *hour_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23"; +const char *sec_min_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\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 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 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_1_label = lv_label_create(section); + lv_label_set_text_static(menu_page_1_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_1_label = lv_label_create(section); + lv_label_set_text_static(menu_page_1_label, "Time :"); + + container = create_section_container(section); + + lv_obj_t *hour_drop = lv_dropdown_create(container); + lv_dropdown_set_options_static(hour_drop, hour_options); + lv_obj_set_width(hour_drop, lv_pct(30)); + + hour_drop = lv_dropdown_create(container); + lv_dropdown_set_options_static(hour_drop, sec_min_options); + lv_obj_set_width(hour_drop, lv_pct(30)); + + hour_drop = lv_dropdown_create(container); + lv_dropdown_set_options_static(hour_drop, sec_min_options); + lv_obj_set_width(hour_drop, lv_pct(30)); + + /*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, 75, 75); + 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);*/ + + /*container = create_section_container(section); + + 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); + + + menu_page_1_label = lv_label_create(section); + lv_label_set_text_static(menu_page_1_label, "Date :"); + container = create_section_container(section); + + 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);*/ + + + + + + //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, NULL); + + 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->display = NULL; +} + + +lv_obj_t *conf_screen = NULL; + +static void event_cb(lv_event_t * e) +{ + 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"); + extern MenuScreen_t menuScreen; + menu_screen_create(&menuScreen); + lv_scr_load_anim(menuScreen.display, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 400, 0, false); + 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); + } +} + +/*const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd"; + +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); +}*/ diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.h b/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.h new file mode 100644 index 0000000..b785ce9 --- /dev/null +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.h @@ -0,0 +1,27 @@ +#ifndef SETTINGS_SCREEN_H +#define SETTINGS_SCREEN_H + +#include "lvgl.h" + +typedef struct SettingsScreenAPIInterface +{ + +} SettingsScreenAPIInterface_t; + +typedef struct SettingsScreen +{ + SettingsScreenAPIInterface_t settingsScreenAPIInterface; + lv_obj_t *display; +} SettingsScreen_t; + +void settings_screen_init(SettingsScreen_t * const settingsScreen); + +void settings_screen_register_API_interface(SettingsScreen_t * const settingsScreen, SettingsScreenAPIInterface_t * const settingsScreenAPIInterface); + +void settings_screen_create(SettingsScreen_t * const settingsScreen); + +void settings_screen_destroy(SettingsScreen_t * const settingsScreen); + +void settings_screen(void); + +#endif //SETTINGS_SCREEN_H