From e8e52a5e9c55645217b36a4647aadfa06b2cbc21 Mon Sep 17 00:00:00 2001 From: czeppi Date: Thu, 6 Mar 2025 07:27:41 +0100 Subject: [PATCH] draw text red, if battery is low --- apps/cc_clock24/app.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/cc_clock24/app.js b/apps/cc_clock24/app.js index 7c7931c0e..b075a41b6 100644 --- a/apps/cc_clock24/app.js +++ b/apps/cc_clock24/app.js @@ -86,12 +86,19 @@ const drawHands = function(date) { const drawText = function(date) { g.setFont("Vector", 10); g.setBgColor(0, 0, 0); - g.setColor(1, 1, 1); + + const batteryState = E.getBattery(); + if (batteryState < 20){ + g.setColor(1, 0, 0); // draw in red, if battery is low + } else { + g.setColor(1, 1, 1); + } const dateStr = require("locale").date(date); g.drawString(dateStr, center.x, center.y + 20, true); - const batteryStr = Math.round(E.getBattery()/5) * 5 + "%"; + + const batteryStr = batteryState + "%"; if (Bangle.isCharging()) { g.setBgColor(1, 0, 0);