From 54b1f3fcd7ee705bdf7c13bbd9c9996c611fb86f Mon Sep 17 00:00:00 2001 From: poolitzer Date: Wed, 19 Jun 2024 21:46:04 +0200 Subject: [PATCH] Feat: Convert hours > 24 to days --- apps/daisy/app.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/daisy/app.js b/apps/daisy/app.js index d64c9b31e..7f6370044 100644 --- a/apps/daisy/app.js +++ b/apps/daisy/app.js @@ -118,8 +118,10 @@ function batteryString(){ if (settings.batt_hours) { var batt_usage = 200000/E.getPowerUsage().total; let rounded; - if (batt_usage > 99) { - rounded = Math.round(batt_usage); + if (batt_usage > 24) { + var days = Math.floor(batt_usage/24); + var hours = Math.round((batt_usage/24 - days) * 24); + stringToInsert = '\n' + days + ((days < 2) ? 'd' : 'ds') + ' ' + hours + ((hours < 2) ? 'h' : 'hs'); } else if (batt_usage > 9) { rounded = Math.round(200000/E.getPowerUsage().total * 10) / 10; @@ -127,7 +129,9 @@ function batteryString(){ else { rounded = Math.round(200000/E.getPowerUsage().total * 100) / 100; } - stringToInsert = '\n' + rounded + ' ' + ((batt_usage < 2) ? 'h' : 'hs'); + if (batt_usage < 24) { + stringToInsert = '\n' + rounded + ' ' + ((batt_usage < 2) ? 'h' : 'hs'); + } } else{ stringToInsert = ' ' + E.getBattery() + '%';