From fa035e85b102e296bb3cecdd4b6b5e3b30b1f52a Mon Sep 17 00:00:00 2001 From: Daniel Kampert Date: Sun, 4 Aug 2024 15:28:39 +0200 Subject: [PATCH] Add option for relative battery scale and set limit for battery arc --- app/Kconfig | 7 +++++++ app/boards/debug.conf | 1 + app/boards/release.conf | 3 ++- app/prj.conf | 8 ++------ .../watchfaces/0_digital/zsw_watchface_digital_ui.c | 12 ++++++++++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index e8142fa0..f08ab2a9 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -67,6 +67,13 @@ menu "ZSWatch" default n menu "Configuration" + menu "Battery" + config APPLICATIONS_CONFIGURATION_BATTERY_USE_RELATIVE + bool + prompt "Use a percent based battery scale" + default y + endmenu + menu "Compass" depends on APPLICATIONS_USE_COMPASS diff --git a/app/boards/debug.conf b/app/boards/debug.conf index d9090c8e..5de92246 100644 --- a/app/boards/debug.conf +++ b/app/boards/debug.conf @@ -26,6 +26,7 @@ CONFIG_ZSW_BLE_LOG_LEVEL_WRN=y CONFIG_ZSW_SETTINGS_APP_LOG_LEVEL_WRN=y CONFIG_ZSW_APP_LOG_LEVEL_DBG=y CONFIG_MISC_ENABLE_SYSTEM_RESET=y +CONFIG_APPLICATIONS_CONFIGURATION_BATTERY_USE_RELATIVE=n CONFIG_LV_USE_LOG=y CONFIG_LV_LOG_LEVEL_WARN=y diff --git a/app/boards/release.conf b/app/boards/release.conf index 08bfe779..82d4d16d 100644 --- a/app/boards/release.conf +++ b/app/boards/release.conf @@ -17,4 +17,5 @@ CONFIG_TASK_WDT=y CONFIG_TASK_WDT_MIN_TIMEOUT=1000 CONFIG_TASK_WDT_HW_FALLBACK=y -CONFIG_MISC_ENABLE_SYSTEM_RESET=n \ No newline at end of file +CONFIG_MISC_ENABLE_SYSTEM_RESET=n +CONFIG_APPLICATIONS_CONFIGURATION_BATTERY_USE_RELATIVE=y \ No newline at end of file diff --git a/app/prj.conf b/app/prj.conf index 47a4ed9b..eb26fb8c 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -166,6 +166,7 @@ CONFIG_ZBUS=y CONFIG_ZBUS_RUNTIME_OBSERVERS=y CONFIG_ZBUS_CHANNEL_NAME=y CONFIG_ZBUS_OBSERVER_NAME=y +CONFIG_ZBUS_CHANNELS_SYS_INIT_PRIORITY=1 # Choose one or many of below CONFIG_WATCHFACE_ANALOG=n @@ -191,10 +192,6 @@ CONFIG_INPUT_MODIFIED_CST816S=y CONFIG_BMI270_PLUS=y CONFIG_BMI270_PLUS_TRIGGER_GLOBAL_THREAD=y -# Uncomment for BME688 IAQ using Bosch BSEC -#CONFIG_BME680=n -#CONFIG_EXTERNAL_USE_BOSCH_BSEC=y - CONFIG_RESET_ON_FATAL_ERROR=y CONFIG_DEBUG_COREDUMP=y @@ -203,6 +200,5 @@ CONFIG_RETENTION_MUTEX_FORCE_DISABLE=y CONFIG_RETAINED_MEM_MUTEX_FORCE_DISABLE=y CONFIG_RETENTION_BUFFER_SIZE=256 -CONFIG_ZBUS_CHANNELS_SYS_INIT_PRIORITY=1 - CONFIG_CJSON_LIB=y +CONFIG_APPLICATIONS_CONFIGURATION_BATTERY_USE_RELATIVE=y \ No newline at end of file diff --git a/app/src/ui/watchfaces/0_digital/zsw_watchface_digital_ui.c b/app/src/ui/watchfaces/0_digital/zsw_watchface_digital_ui.c index 98f852bb..0d8a91e1 100644 --- a/app/src/ui/watchfaces/0_digital/zsw_watchface_digital_ui.c +++ b/app/src/ui/watchfaces/0_digital/zsw_watchface_digital_ui.c @@ -312,6 +312,12 @@ static void watchface_show(lv_obj_t *parent, watchface_app_evt_listener evt_cb, LV_OBJ_FLAG_SCROLL_CHAIN | LV_OBJ_FLAG_CLICKABLE); lv_obj_set_style_arc_width(ui_battery_arc, 3, LV_PART_MAIN | LV_STATE_DEFAULT); +#if CONFIG_APPLICATIONS_CONFIGURATION_BATTERY_USE_RELATIVE + lv_arc_set_range(ui_battery_arc, 0, 100); +#else + lv_arc_set_range(ui_battery_arc, 3500, 4200); +#endif + lv_obj_set_style_arc_color(ui_battery_arc, lv_color_hex(0xFFB140), LV_PART_INDICATOR | LV_STATE_DEFAULT); lv_obj_set_style_arc_opa(ui_battery_arc, 255, LV_PART_INDICATOR | LV_STATE_DEFAULT); lv_obj_set_style_arc_width(ui_battery_arc, 3, LV_PART_INDICATOR | LV_STATE_DEFAULT); @@ -484,8 +490,14 @@ static void watchface_set_battery_percent(int32_t percent, int32_t battery) if (!root_page) { return; } + +#if CONFIG_APPLICATIONS_CONFIGURATION_BATTERY_USE_RELATIVE lv_arc_set_value(ui_battery_arc, percent); + lv_label_set_text_fmt(ui_battery_percent_label, "%d%%", percent); +#else + lv_arc_set_value(ui_battery_arc, battery); lv_label_set_text_fmt(ui_battery_percent_label, "%d", battery); +#endif } static void watchface_set_hrm(int32_t bpm, int32_t oxygen)