Ring will only be redrawn of it needs changing since its last update

master
David Volovskiy 2025-05-04 10:32:55 -04:00
parent 109c10f960
commit 78e7df2256
2 changed files with 9 additions and 3 deletions

View File

@ -23,7 +23,7 @@ See [#1248](https://github.com/espruino/BangleApps/issues/1248)
* In the settings, the ring can be set to:
* Hours - Displays the ring as though it's the hour hand on an analog clock.
* Minutes - Displays the ring as though it's the minute hand on an analog clock.
* Seconds - Displays the ring as though it's the seconds hand on an analog clock.
* Seconds - Displays the ring as though it's the seconds hand on an analog clock. This option uses far more battery than any other option as it updates the screen 60 times more often.
* Day - Displays the ring as how much of the day is left. Functionally, it fills the ring half as quickly as the Hours option.
* Steps - Displays the ring as the amount of steps taken that day out of Step Target setting.
* Battery - Displays the ring as the amount of battery percentage left.

View File

@ -21,8 +21,11 @@ let pal2; // palette for 50-100%
const infoLine = (3*h/4) - 6;
const infoWidth = 56;
const infoHeight = 11;
const textStartWidth = 28;
const textStartHeight = 44;
const sec_update = 1000; // This ms between updates when the ring is in Seconds mode
var drawingSteps = false;
var prevRing = {start: null, end: null, max: null};
function log_debug(o) {
//print(o);
@ -322,7 +325,10 @@ function drawGaugeImage(date) {
start = max - end;
end = max;
}
drawRing(start, end, ring_max);
if (end !== prevRing.end || start !== prevRing.start || ring_max !== prevRing.max) {
drawRing(start, end, ring_max);
prevRing = {start: start, end: end, max: ring_max};
}
log_debug("Start: "+ start + " end: " +end);
}
@ -340,7 +346,7 @@ function drawClock() {
g.reset();
g.setColor(g.theme.bg);
g.fillRect(0, 0, w, h);
g.fillRect(textStartWidth, textStartHeight, w-textStartWidth, h-textStartHeight); // Clears the text within the circle
drawGaugeImage(date);
setLargeFont();