From 9edfa63f58ae5ddf23a68e1e613750ddf8150727 Mon Sep 17 00:00:00 2001 From: j14273 Date: Fri, 12 Sep 2025 18:51:44 +1000 Subject: [PATCH] Add battery voltage within battery icon Add battery voltage within battery icon and reduce size of battery indicator to a small bar --- examples/companion_radio/ui-new/UITask.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 1e03f086..07dd8196 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -111,9 +111,15 @@ class HomeScreen : public UIScreen { // battery "cap" display.fillRect(iconX + iconWidth, iconY + (iconHeight / 4), 3, iconHeight / 2); - // fill the battery based on the percentage + // fill the battery based on the percentage as a small bar int fillWidth = (batteryPercentage * (iconWidth - 4)) / 100; - display.fillRect(iconX + 2, iconY + 2, fillWidth, iconHeight - 4); + display.fillRect(iconX + 2, iconY + 8, fillWidth, iconHeight - 8); + + // write the voltage + char voltStr[10]; + snprintf(voltStr, sizeof(voltStr), "%.1fV", batteryMilliVolts / 1000.0f); + display.drawTextCentered(iconX + (iconWidth / 2), iconY, voltStr); + } CayenneLPP sensors_lpp;