From 167a32fbdc0d237a1508dd687102cac95529787c Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Tue, 18 Aug 2026 10:40:16 +0700 Subject: [PATCH] Fixed to show d h, h m and m for BLE companions --- examples/companion_radio/ui-new/UITask.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index bcc94d63..f842baa1 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -143,13 +143,17 @@ class HomeScreen : public UIScreen { uptime_last_millis = now; uint64_t uptimeMinutes = uptime_millis / 60000ULL; + + unsigned long days = uptimeMinutes / 1440; + unsigned long hours = (uptimeMinutes % 1440) / 60; + unsigned long minutes = uptimeMinutes % 60; char uptime[16]; - if (uptimeMinutes < 60) { - snprintf(uptime, sizeof(uptime), "%lum", (unsigned long)uptimeMinutes); - } else if (uptimeMinutes < 1440) { - snprintf(uptime, sizeof(uptime), "%luh", (unsigned long)(uptimeMinutes / 60)); + if (days > 0) { + snprintf(uptime, sizeof(uptime), "%lud %luh", days, hours); + } else if (hours > 0) { + snprintf(uptime, sizeof(uptime), "%luh %lum", hours, minutes); } else { - snprintf(uptime, sizeof(uptime), "%lud", (unsigned long)(uptimeMinutes / 1440)); + snprintf(uptime, sizeof(uptime), "%lum", minutes); } display.setTextSize(1);