Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marioclock: use short date format from locale, take timeout from sett… #167

Merged
merged 3 commits into from
Mar 31, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
marioclock: use short date format from locale, take timeout from sett…
…ings
  • Loading branch information
DerGuteWolf committed Mar 30, 2020
commit 6176c16712136a9ca5d09830bb12a0b4ae88d5bb
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