Skip to content

Commit

Permalink
Merge pull request espruino#167 from DerGuteWolf/patch-1
Browse files Browse the repository at this point in the history
marioclock: use short date format from locale, take timeout from sett…
  • Loading branch information
gfwilliams committed Mar 31, 2020
2 parents 7ff958a + 0e8f940 commit 3c21bc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@
{ "id": "marioclock",
"name": "Mario Clock",
"icon": "marioclock.png",
"version":"0.02",
"version":"0.03",
"description": "Animated Mario clock, jumps to change the time!",
"tags": "clock,mario,retro",
"type": "clock",
Expand Down
1 change: 1 addition & 0 deletions apps/marioclock/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0.01: Create mario app
0.02: Fix day of the week and add padding
0.03: use short date format from locale, take timeout from settings
13 changes: 6 additions & 7 deletions apps/marioclock/marioclock-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
**********************************/

var locale = require("locale");
const storage = require('Storage');
const settings = (storage.readJSON('setting.json',1)||{});
const timeout = settings.timeout||10;

// Screen dimensions
let W, H;
Expand Down Expand Up @@ -280,14 +283,10 @@ function drawTime() {
}

function drawDate() {
const date = new Date();
const day = locale.dow(date).substr(0, 3);
const dayNum = ("0" + date.getDate()).substr(-2);
const month = locale.month(date).substr(0, 3);

g.setFont("6x8");
g.setColor(LIGHTEST);
g.drawString(`${day} ${dayNum} ${month}`, 10, 0, true);
const dateStr = locale.date(new Date(), true);
g.drawString(dateStr, (W - g.stringWidth(dateStr))/2, 0, true);
}

function redraw() {
Expand Down Expand Up @@ -322,7 +321,7 @@ function resetDisplayTimeout() {
displayTimeoutRef = setInterval(() => {
if (Bangle.isLCDOn()) Bangle.setLCDPower(false);
clearTimers();
}, ONE_SECOND * 10);
}, ONE_SECOND * timeout);
}

function startTimers(){
Expand Down

0 comments on commit 3c21bc6

Please sign in to comment.