Skip to content

Commit

Permalink
Merge pull request #3064 from bobrippling/pebbled-redraw
Browse files Browse the repository at this point in the history
pebbled: prevent exceptions halting the draw cycle
  • Loading branch information
gfwilliams authored Oct 30, 2023
2 parents a6a6e5f + 3bef99c commit 752ef55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions apps/pebbled/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
0.03: Swipe down to see widgets
Support for fast loading
0.04: Localisation request: added Miles and AM/PM
0.05: Prevent exceptions from halting the draw cycle
2 changes: 1 addition & 1 deletion apps/pebbled/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "pebbled",
"name": "Pebble Clock with 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).",
"readme": "README.md",
"icon": "pebbled.png",
Expand Down
14 changes: 7 additions & 7 deletions apps/pebbled/pebbled.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ const h3 = 7*h/8 - 10;
let batteryWarning = false;

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 da = date.toString().split(" ");
let timeStr = settings.localization === "US" ? tConv24(da[4].substr(0,5)) : da[4].substr(0,5);
Expand Down Expand Up @@ -101,13 +108,6 @@ let draw = function() {
else
g.setColor('#000'); // otherwise black regardless of theme
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
Expand Down

0 comments on commit 752ef55

Please sign in to comment.