barclock: Fix time/date disappearing after fullscreen notification

By forcing a complete redraw at lcdPower-on
master
Richard de Boer 2021-11-23 19:42:12 +01:00
parent 32e3d326aa
commit 6b05d92875
3 changed files with 10 additions and 5 deletions

View File

@ -1690,7 +1690,7 @@
{ {
"id": "barclock", "id": "barclock",
"name": "Bar Clock", "name": "Bar Clock",
"version": "0.08", "version": "0.09",
"description": "A simple digital clock showing seconds as a bar", "description": "A simple digital clock showing seconds as a bar",
"icon": "clock-bar.png", "icon": "clock-bar.png",
"screenshots": [{"url":"screenshot.png"},{"url":"screenshot_pm.png"}], "screenshots": [{"url":"screenshot.png"},{"url":"screenshot_pm.png"}],

View File

@ -6,3 +6,4 @@
0.06: Improve accuracy 0.06: Improve accuracy
0.07: Update to use Bangle.setUI instead of setWatch 0.07: Update to use Bangle.setUI instead of setWatch
0.08: Use theme colors, Layout library 0.08: Use theme colors, Layout library
0.09: Fix time/date disappearing after fullscreen notification

View File

@ -24,7 +24,7 @@ function renderBar(l) {
return; return;
} }
const width = this.fraction*l.w; const width = this.fraction*l.w;
g.fillRect(l.x, l.y, width-1, l.y+l.height-1); g.fillRect(l.x, l.y, l.x+width-1, l.y+l.height-1);
} }
const Layout = require("Layout"); const Layout = require("Layout");
@ -78,7 +78,7 @@ function dateText(date) {
return `${dayName} ${dayMonth}`; return `${dayName} ${dayMonth}`;
} }
draw = function draw() { draw = function draw(force) {
if (!Bangle.isLCDOn()) {return;} // no drawing, also no new update scheduled if (!Bangle.isLCDOn()) {return;} // no drawing, also no new update scheduled
const date = new Date(); const date = new Date();
layout.time.label = timeText(date); layout.time.label = timeText(date);
@ -86,6 +86,10 @@ draw = function draw() {
layout.date.label = dateText(date); layout.date.label = dateText(date);
const SECONDS_PER_MINUTE = 60; const SECONDS_PER_MINUTE = 60;
layout.bar.fraction = date.getSeconds()/SECONDS_PER_MINUTE; layout.bar.fraction = date.getSeconds()/SECONDS_PER_MINUTE;
if (force) {
Bangle.drawWidgets();
layout.forgetLazyState();
}
layout.render(); layout.render();
// schedule update at start of next second // schedule update at start of next second
const millis = date.getMilliseconds(); const millis = date.getMilliseconds();
@ -96,7 +100,7 @@ draw = function draw() {
Bangle.setUI("clock"); Bangle.setUI("clock");
Bangle.on("lcdPower", function(on) { Bangle.on("lcdPower", function(on) {
if (on) { if (on) {
draw(); draw(true);
} }
}); });
g.reset().clear(); g.reset().clear();