Skip to content

Commit

Permalink
Add option for relative battery scale and set limit for battery arc
Browse files Browse the repository at this point in the history
  • Loading branch information
Kampi committed Aug 4, 2024
1 parent 7094253 commit fa035e8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
7 changes: 7 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/boards/debug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion app/boards/release.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
CONFIG_MISC_ENABLE_SYSTEM_RESET=n
CONFIG_APPLICATIONS_CONFIGURATION_BATTERY_USE_RELATIVE=y
8 changes: 2 additions & 6 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
12 changes: 12 additions & 0 deletions app/src/ui/watchfaces/0_digital/zsw_watchface_digital_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fa035e8

Please sign in to comment.