Merge branch 'espruino:master' into master

pull/939/head
Ronin0000 2021-11-23 15:15:57 -08:00 committed by GitHub
commit 431824f828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -1698,13 +1698,13 @@
{ {
"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"}],
"type": "clock", "type": "clock",
"tags": "clock", "tags": "clock",
"supports": ["BANGLEJS"], "supports": ["BANGLEJS","BANGLEJS2"],
"readme": "README.md", "readme": "README.md",
"allow_emulator": true, "allow_emulator": true,
"storage": [ "storage": [

View File

@ -5,4 +5,5 @@
0.05: Clock does not start if app Languages is not installed 0.05: Clock does not start if app Languages is not installed
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();