Proper fix for the race condition

master
deirdreobyrne 2022-06-10 05:14:22 +01:00
parent f4721afc97
commit 53cbb2bb32
3 changed files with 5 additions and 5 deletions

View File

@ -2,3 +2,4 @@
0.02: setTimeout bug fix; no leading zero on date; lightmode; 12 hour format; cleanup 0.02: setTimeout bug fix; no leading zero on date; lightmode; 12 hour format; cleanup
0.03: Internationalisation; bug fix - battery icon responds promptly to charging state 0.03: Internationalisation; bug fix - battery icon responds promptly to charging state
0.04: bug fix 0.04: bug fix
0.05: proper fix for the race condition in queueDraw()

View File

@ -12,13 +12,12 @@ Graphics.prototype.setFontOpenSans = function(scale) {
var drawTimeout; var drawTimeout;
// schedule a draw for the next minute function queueDraw(millis_now) {
function queueDraw() {
if (drawTimeout) clearTimeout(drawTimeout); if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function () { drawTimeout = setTimeout(function () {
drawTimeout = undefined; drawTimeout = undefined;
draw(); draw();
}, 60300 - (Date.now() % 60000)); // We aim for 300ms into the next minute to ensure we make it! }, 60000 - (millis_now % 60000));
} }
function draw() { function draw() {
@ -70,7 +69,7 @@ function draw() {
// widget redraw // widget redraw
Bangle.drawWidgets(); Bangle.drawWidgets();
queueDraw(); queueDraw(date.getTime());
} }
Bangle.on('lcdPower', on => { Bangle.on('lcdPower', on => {

View File

@ -1,7 +1,7 @@
{ "id": "bigdclock", { "id": "bigdclock",
"name": "Big digit clock containing just the essentials", "name": "Big digit clock containing just the essentials",
"shortName":"Big digit clk", "shortName":"Big digit clk",
"version":"0.04", "version":"0.05",
"description": "A clock containing just the essentials, made as easy to read as possible for those of us that need glasses. It contains the time, the day-of-week, the day-of-month, and the current battery state-of-charge.", "description": "A clock containing just the essentials, made as easy to read as possible for those of us that need glasses. It contains the time, the day-of-week, the day-of-month, and the current battery state-of-charge.",
"icon": "bigdclock.png", "icon": "bigdclock.png",
"type": "clock", "type": "clock",