From 66a3c871315c132b3dd88b48a853edbfdd4597d8 Mon Sep 17 00:00:00 2001 From: anschrammh Date: Sun, 12 Mar 2023 21:44:43 +0100 Subject: [PATCH] Renamed some file's header guards to be more consistent, clean some useless object in the UI, renamed a watch settings which name could be misleading --- src/W800_SDK_v1.00.10/app/app_config.h | 6 ++-- .../app/app_include/app_log.h | 6 ++-- .../app/gfx/common_screen_components.c | 1 + src/W800_SDK_v1.00.10/app/gfx/gfx_task.c | 6 ++-- src/W800_SDK_v1.00.10/app/gfx/menu_screen.c | 11 +++--- src/W800_SDK_v1.00.10/app/gfx/watch_face.c | 36 ++++++++++--------- .../app/persistency/watch_settings.c | 2 +- .../app/persistency/watch_settings.h | 2 +- 8 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/W800_SDK_v1.00.10/app/app_config.h b/src/W800_SDK_v1.00.10/app/app_config.h index 7913518..f6452a2 100644 --- a/src/W800_SDK_v1.00.10/app/app_config.h +++ b/src/W800_SDK_v1.00.10/app/app_config.h @@ -1,5 +1,5 @@ -#ifndef APPCONFIG_H -#define APPCONFIG_H +#ifndef APP_CONFIG_H +#define APP_CONFIG_H #include "wm_gpio.h" @@ -79,4 +79,4 @@ #define VIBRATION_MOTOR_ENABLE WM_IO_PB_00 #define VIBRATION_MOTOR_PWM_CHANNEL (0) -#endif //APPCONFIG_H \ No newline at end of file +#endif //APP_CONFIG_H \ No newline at end of file diff --git a/src/W800_SDK_v1.00.10/app/app_include/app_log.h b/src/W800_SDK_v1.00.10/app/app_include/app_log.h index c45ab49..6cef943 100644 --- a/src/W800_SDK_v1.00.10/app/app_include/app_log.h +++ b/src/W800_SDK_v1.00.10/app/app_include/app_log.h @@ -1,5 +1,5 @@ -#ifndef APPLOG_H -#define APPLOG_G +#ifndef APP_LOG_H +#define APP_LOG_G #include "app_common.h" #include "app_config.h" @@ -34,4 +34,4 @@ #define APP_LOG_DEBUG(message, ...) do{}while(0) #endif -#endif //APPLOG_H +#endif //APP_LOG_H diff --git a/src/W800_SDK_v1.00.10/app/gfx/common_screen_components.c b/src/W800_SDK_v1.00.10/app/gfx/common_screen_components.c index 759b1b4..f4f7180 100644 --- a/src/W800_SDK_v1.00.10/app/gfx/common_screen_components.c +++ b/src/W800_SDK_v1.00.10/app/gfx/common_screen_components.c @@ -7,6 +7,7 @@ void common_screen_header_component(lv_obj_t *parent, const char * title, lv_coo 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_clear_flag(header, LV_OBJ_FLAG_SCROLLABLE); lv_obj_t *header_title = lv_label_create(header); lv_label_set_text_static(header_title, title); diff --git a/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c b/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c index 50c5201..c11dbb3 100644 --- a/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c +++ b/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c @@ -84,7 +84,7 @@ static void setTimeCb(uint8_t hour, uint8_t minute, uint8_t second, uint8_t day, static void setTimeoutCb(uint8_t timeout) { - persistency_get_settings()->display.sleep_timeout = timeout; + persistency_get_settings()->display.sleep_delay = timeout; } static void setOrientationCb(uint8_t orientation) @@ -363,8 +363,8 @@ void gfx_task(void *param) } /* Handle inactivity periods : */ - if( persistency_get_settings()->display.sleep_timeout != 0 && - lv_disp_get_inactive_time(NULL) > (persistency_get_settings()->display.sleep_timeout * 1000)) + if( persistency_get_settings()->display.sleep_delay != 0 && + lv_disp_get_inactive_time(NULL) > (persistency_get_settings()->display.sleep_delay * 1000)) { // First, we disable the display backlight and we set all the peripherals in their low power mode setBrightness(0); diff --git a/src/W800_SDK_v1.00.10/app/gfx/menu_screen.c b/src/W800_SDK_v1.00.10/app/gfx/menu_screen.c index 519dafe..912de7f 100644 --- a/src/W800_SDK_v1.00.10/app/gfx/menu_screen.c +++ b/src/W800_SDK_v1.00.10/app/gfx/menu_screen.c @@ -60,10 +60,11 @@ void menu_screen_init(MenuScreen_t * const menuScreen) 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 - lv_obj_t *item_btn = lv_imgbtn_create(scroll_item_container); + lv_obj_t *item_btn = lv_img_create(scroll_item_container); lv_obj_set_size(item_btn, itemImg->header.w, itemImg->header.h); + lv_obj_add_flag(item_btn, LV_OBJ_FLAG_ADV_HITTEST | LV_OBJ_FLAG_CLICKABLE); lv_obj_set_pos(item_btn, 42, 52 * position); - lv_imgbtn_set_src(item_btn, LV_IMGBTN_STATE_RELEASED, NULL, itemImg, NULL); + lv_img_set_src(item_btn, itemImg); lv_obj_add_event_cb(item_btn, itemClickEventCb, LV_EVENT_CLICKED, (void *)(uint32_t)position); //We add the click-able label with the title of the item @@ -105,12 +106,12 @@ void menu_screen_create(MenuScreen_t * const menuScreen) menuScreen->display = lv_obj_create(NULL); //We add the screen header - common_screen_header_component(menuScreen->display, "Menu", 65); + common_screen_header_component(menuScreen->display, "Menu", 50); 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); - lv_obj_set_size(scroll_item_container, lv_pct(100), 240-65); - lv_obj_set_pos(scroll_item_container, 0, 65); + lv_obj_set_size(scroll_item_container, lv_pct(100), 240-50); + lv_obj_set_pos(scroll_item_container, 0, 50); lv_obj_set_style_pad_all(scroll_item_container, 0, LV_PART_MAIN); lv_obj_set_style_pad_top(scroll_item_container, 10, LV_PART_MAIN); lv_obj_set_style_pad_bottom(scroll_item_container, 20, LV_PART_MAIN); diff --git a/src/W800_SDK_v1.00.10/app/gfx/watch_face.c b/src/W800_SDK_v1.00.10/app/gfx/watch_face.c index f4d1c13..8e508a9 100644 --- a/src/W800_SDK_v1.00.10/app/gfx/watch_face.c +++ b/src/W800_SDK_v1.00.10/app/gfx/watch_face.c @@ -148,12 +148,12 @@ void watch_face_create(WatchFace_t * const watchFace) lv_obj_del(watchFace->display); watchFace->display = NULL; } - watchFace->display = lv_obj_create(NULL); + //Our display is the watch face image : + watchFace->display = lv_img_create(NULL); + lv_img_set_src(watchFace->display, &watch_casio_face_asset); lv_obj_set_style_bg_color(watchFace->display, lv_color_black(), LV_PART_MAIN); - //We load our assets : - lv_obj_t *watchFaceImg = lv_img_create(watchFace->display); - lv_img_set_src(watchFaceImg, &watch_casio_face_asset); + //We load our other assets : lv_obj_t *smallHandImg = lv_img_create(watchFace->display); lv_img_set_src(smallHandImg, &watch_casio_small_hand_asset); lv_obj_set_pos(smallHandImg, 69, 98); @@ -259,6 +259,9 @@ void watch_face_create(WatchFace_t * const watchFace) //We set the appropriate angles to each of the hands update_watch_hands_angles(watchFace, 0); + //Don't forget to make the background image clickable to be able to use gestures on it. + lv_obj_add_flag(watchFace->display, LV_OBJ_FLAG_CLICKABLE); + //We register the event callback to handle gestures lv_obj_add_event_cb(watchFace->display, &(gesture_event_cb), LV_EVENT_GESTURE, watchFace); //We register the event callback to handle the cleanup @@ -275,19 +278,6 @@ void watch_face_create(WatchFace_t * const watchFace) watchFace->handAnimationTimer = lv_timer_create(&(hand_timer_anim_cb), 199, watchFace); } -void watch_face_force_sync(WatchFace_t *const watchFace) -{ - if(!watchFace) - { - LV_LOG_ERROR("NULL pointer given !"); - return; - } - - if(!watchFace->display) return; - - update_watch_hands_angles(watchFace, 0); -} - void watch_face_set_battery_indicator(WatchFace_t * const watchFace, uint8_t percentage) { if(!watchFace) @@ -333,3 +323,15 @@ void watch_face_destroy(WatchFace_t * const watchFace) watchFace->batteryIndicator.label = NULL; } +void watch_face_force_sync(WatchFace_t *const watchFace) +{ + if(!watchFace) + { + LV_LOG_ERROR("NULL pointer given !"); + return; + } + + if(!watchFace->display) return; + + update_watch_hands_angles(watchFace, 0); +} diff --git a/src/W800_SDK_v1.00.10/app/persistency/watch_settings.c b/src/W800_SDK_v1.00.10/app/persistency/watch_settings.c index f861ddf..cc02475 100644 --- a/src/W800_SDK_v1.00.10/app/persistency/watch_settings.c +++ b/src/W800_SDK_v1.00.10/app/persistency/watch_settings.c @@ -4,7 +4,7 @@ static WatchSettings_t watchSettings = { .timeAndDate = {.hour_format = 0, .date_format = 0, .automatic_time_and_date = 0}, - .display = {.brightness = 255, .sleep_timeout = 0,}, + .display = {.brightness = 255, .sleep_delay = 0,}, }; WatchSettings_t *persistency_get_settings(void) diff --git a/src/W800_SDK_v1.00.10/app/persistency/watch_settings.h b/src/W800_SDK_v1.00.10/app/persistency/watch_settings.h index c6625db..1b18abb 100644 --- a/src/W800_SDK_v1.00.10/app/persistency/watch_settings.h +++ b/src/W800_SDK_v1.00.10/app/persistency/watch_settings.h @@ -15,7 +15,7 @@ typedef struct TimeAndDate typedef struct Display { uint8_t brightness; - uint8_t sleep_timeout; + uint8_t sleep_delay; uint8_t orientation:2; } Display_t;