From 96bafd8bd79603279139296cd4062e8013b2a52b Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sun, 8 Dec 2019 01:32:26 +0200 Subject: [PATCH] nyx: Use color when battery voltage < 3200mV For status bar and Battery Info. --- nyx/nyx_gui/frontend/gui.c | 4 +++- nyx/nyx_gui/frontend/gui_info.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index 6cfaed2..a613ccc 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -828,7 +828,9 @@ static void _update_status_bar(void *params) else s_printf(label, "#FF3C28 -%d", (~batt_curr + 1) / 1000); - s_printf(label + strlen(label), " mA# (%d mV)", batt_volt); + bool voltage_empty = batt_volt < 3200; + s_printf(label + strlen(label), " mA# (%s%d mV%s)", + voltage_empty ? "FFF8000" : "", batt_volt, voltage_empty ? "#" : ""); lv_label_set_array_text(status_bar.battery_more, label, 64); lv_obj_realign(status_bar.battery_more); diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 1fb55fb..a3d84b9 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -886,7 +886,9 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn) s_printf(txt_buf + strlen(txt_buf), "-%d mA\n", (~value + 1) / 1000); max17050_get_property(MAX17050_VCELL, &value); - s_printf(txt_buf + strlen(txt_buf), "%d mV\n", value); + bool voltage_empty = value < 3200; + s_printf(txt_buf + strlen(txt_buf), "%s%d mV%s\n", + voltage_empty ? "FFF8000" : "", value, voltage_empty ? " (Empty!)#" : ""); max17050_get_property(MAX17050_OCVInternal, &value); s_printf(txt_buf + strlen(txt_buf), "%d mV\n", value);