1
0
Fork 0

pebbled: prevent exceptions halting the draw cycle

master
Rob Pilling 2023-10-30 08:24:39 +00:00
parent a6a6e5fb4e
commit 3bef99cfc4
3 changed files with 9 additions and 8 deletions

View File

@ -3,3 +3,4 @@
0.03: Swipe down to see widgets 0.03: Swipe down to see widgets
Support for fast loading Support for fast loading
0.04: Localisation request: added Miles and AM/PM 0.04: Localisation request: added Miles and AM/PM
0.05: Prevent exceptions from halting the draw cycle

View File

@ -2,7 +2,7 @@
"id": "pebbled", "id": "pebbled",
"name": "Pebble Clock with distance", "name": "Pebble Clock with distance",
"shortName": "Pebble + distance", "shortName": "Pebble + distance",
"version": "0.04", "version": "0.05",
"description": "Fork of Pebble Clock with distance in KM. Both step count and the distance are on the main screen. Default step length = 0.75m (can be changed in settings).", "description": "Fork of Pebble Clock with distance in KM. Both step count and the distance are on the main screen. Default step length = 0.75m (can be changed in settings).",
"readme": "README.md", "readme": "README.md",
"icon": "pebbled.png", "icon": "pebbled.png",

View File

@ -37,6 +37,13 @@ const h3 = 7*h/8 - 10;
let batteryWarning = false; let batteryWarning = false;
let draw = function() { let draw = function() {
// queue next draw
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, 60000 - (Date.now() % 60000));
let date = new Date(); let date = new Date();
let da = date.toString().split(" "); let da = date.toString().split(" ");
let timeStr = settings.localization === "US" ? tConv24(da[4].substr(0,5)) : da[4].substr(0,5); let timeStr = settings.localization === "US" ? tConv24(da[4].substr(0,5)) : da[4].substr(0,5);
@ -101,13 +108,6 @@ let draw = function() {
else else
g.setColor('#000'); // otherwise black regardless of theme g.setColor('#000'); // otherwise black regardless of theme
g.drawString(distanceStr, w/2, ha + 107); g.drawString(distanceStr, w/2, ha + 107);
// queue next draw
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, 60000 - (Date.now() % 60000));
}; };
// at x,y width:wi thicknes:th // at x,y width:wi thicknes:th