marioclock: use short date format from locale, take timeout from settings
parent
7ff958ad2c
commit
6176c16712
|
|
@ -6,6 +6,9 @@
|
||||||
**********************************/
|
**********************************/
|
||||||
|
|
||||||
var locale = require("locale");
|
var locale = require("locale");
|
||||||
|
const storage = require('Storage');
|
||||||
|
const settings = (storage.readJSON('setting.json',1)||{});
|
||||||
|
const timeout = settings.timeout||10;
|
||||||
|
|
||||||
// Screen dimensions
|
// Screen dimensions
|
||||||
let W, H;
|
let W, H;
|
||||||
|
|
@ -280,14 +283,10 @@ function drawTime() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawDate() {
|
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.setFont("6x8");
|
||||||
g.setColor(LIGHTEST);
|
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() {
|
function redraw() {
|
||||||
|
|
@ -322,7 +321,7 @@ function resetDisplayTimeout() {
|
||||||
displayTimeoutRef = setInterval(() => {
|
displayTimeoutRef = setInterval(() => {
|
||||||
if (Bangle.isLCDOn()) Bangle.setLCDPower(false);
|
if (Bangle.isLCDOn()) Bangle.setLCDPower(false);
|
||||||
clearTimers();
|
clearTimers();
|
||||||
}, ONE_SECOND * 10);
|
}, ONE_SECOND * timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startTimers(){
|
function startTimers(){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue