forked from FOSS/BangleApps
Add theme support
parent
38f23be5b4
commit
c3b1a973c0
|
@ -3,3 +3,4 @@
|
||||||
0.17: Fix hours
|
0.17: Fix hours
|
||||||
0.18: Code cleanup and major changes with seconds timing. New feature: if watch is locked, seconds get refreshed every 10 seconds.
|
0.18: Code cleanup and major changes with seconds timing. New feature: if watch is locked, seconds get refreshed every 10 seconds.
|
||||||
0.19: Fix PM Hours
|
0.19: Fix PM Hours
|
||||||
|
0.20: Add theme support
|
|
@ -82,7 +82,7 @@ var drawTimeout;
|
||||||
var drawTimeoutSeconds;
|
var drawTimeoutSeconds;
|
||||||
var secondsTimeout;
|
var secondsTimeout;
|
||||||
|
|
||||||
g.setBgColor(0, 0, 0);
|
g.setBgColor(g.theme.bg);
|
||||||
|
|
||||||
// schedule a draw for the next minute
|
// schedule a draw for the next minute
|
||||||
function queueDraw() {
|
function queueDraw() {
|
||||||
|
@ -128,7 +128,7 @@ function drawSeconds() {
|
||||||
|
|
||||||
// default draw styles
|
// default draw styles
|
||||||
g.reset();
|
g.reset();
|
||||||
g.setBgColor(0, 0, 0);
|
g.setBgColor(g.theme.bg);
|
||||||
|
|
||||||
// drawSting centered
|
// drawSting centered
|
||||||
g.setFontAlign(0, 0);
|
g.setFontAlign(0, 0);
|
||||||
|
@ -138,7 +138,11 @@ function drawSeconds() {
|
||||||
var seconds = time[2];
|
var seconds = time[2];
|
||||||
|
|
||||||
g.setFont("5x9Numeric7Seg",primaryTimeFontSize - 3);
|
g.setFont("5x9Numeric7Seg",primaryTimeFontSize - 3);
|
||||||
g.setColor("#22ff05");
|
if (g.theme.dark) {
|
||||||
|
g.setColor("#22ff05");
|
||||||
|
} else {
|
||||||
|
g.setColor(g.theme.fg);
|
||||||
|
}
|
||||||
//console.log("---");
|
//console.log("---");
|
||||||
//console.log(seconds);
|
//console.log(seconds);
|
||||||
if (Bangle.isLocked()) seconds = seconds.slice(0, -1) + ':::'; // we use :: as the font does not have an x
|
if (Bangle.isLocked()) seconds = seconds.slice(0, -1) + ':::'; // we use :: as the font does not have an x
|
||||||
|
@ -155,7 +159,7 @@ function draw() {
|
||||||
|
|
||||||
// default draw styles
|
// default draw styles
|
||||||
g.reset();
|
g.reset();
|
||||||
g.setBgColor(0, 0, 0);
|
g.setBgColor(g.theme.bg);
|
||||||
|
|
||||||
// drawSting centered
|
// drawSting centered
|
||||||
g.setFontAlign(0, 0);
|
g.setFontAlign(0, 0);
|
||||||
|
@ -179,7 +183,11 @@ function draw() {
|
||||||
|
|
||||||
//g.setFont(font, primaryTimeFontSize);
|
//g.setFont(font, primaryTimeFontSize);
|
||||||
g.setFont("5x9Numeric7Seg",primaryTimeFontSize);
|
g.setFont("5x9Numeric7Seg",primaryTimeFontSize);
|
||||||
g.setColor("#22ff05");
|
if (g.theme.dark) {
|
||||||
|
g.setColor("#22ff05");
|
||||||
|
} else {
|
||||||
|
g.setColor(g.theme.fg);
|
||||||
|
}
|
||||||
g.drawString(`${hours}:${minutes}`, xyCenter-10, yposTime, true);
|
g.drawString(`${hours}:${minutes}`, xyCenter-10, yposTime, true);
|
||||||
|
|
||||||
// am / PM ?
|
// am / PM ?
|
||||||
|
@ -187,7 +195,6 @@ function draw() {
|
||||||
//do 12 hour stuff
|
//do 12 hour stuff
|
||||||
//var ampm = require("locale").medidian(new Date()); Not working
|
//var ampm = require("locale").medidian(new Date()); Not working
|
||||||
g.setFont("Vector", 17);
|
g.setFont("Vector", 17);
|
||||||
g.setColor("#22ff05");
|
|
||||||
g.drawString(ampm, xyCenterSeconds, yAmPm, true);
|
g.drawString(ampm, xyCenterSeconds, yAmPm, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,33 +294,7 @@ if (!Bangle.isLocked()) { // Initial state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Stop updates when LCD is off, restart when on
|
|
||||||
Bangle.on('lcdPower',on=>{
|
|
||||||
if (on) {
|
|
||||||
if (PosInterval != 0) clearInterval(PosInterval);
|
|
||||||
|
|
||||||
PosInterval = setInterval(updatePos, 60*10E3); // refesh every 10 mins
|
|
||||||
secondsTimeout = 1000;
|
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
|
||||||
if (drawTimeoutSeconds) clearTimeout(drawTimeoutSeconds);
|
|
||||||
drawTimeout = undefined;
|
|
||||||
drawTimeoutSeconds = undefined;
|
|
||||||
draw(); // draw immediately, queue redraw
|
|
||||||
updatePos();
|
|
||||||
} else { // stop draw timer
|
|
||||||
|
|
||||||
secondsTimeout = 1000 * 60;
|
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
|
||||||
if (drawTimeoutSeconds) clearTimeout(drawTimeoutSeconds);
|
|
||||||
drawTimeout = undefined;
|
|
||||||
drawTimeoutSeconds = undefined;
|
|
||||||
|
|
||||||
if (PosInterval != 0) clearInterval(PosInterval);
|
|
||||||
PosInterval = setInterval(updatePos, 60*60E3); // refesh every 60 mins
|
|
||||||
draw(); // draw immediately, queue redraw
|
|
||||||
updatePos();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Bangle.on('lock',on=>{
|
Bangle.on('lock',on=>{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "hworldclock",
|
"id": "hworldclock",
|
||||||
"name": "Hanks World Clock",
|
"name": "Hanks World Clock",
|
||||||
"shortName": "Hanks World Clock",
|
"shortName": "Hanks World Clock",
|
||||||
"version": "0.19",
|
"version": "0.20",
|
||||||
"description": "Current time zone plus up to three others",
|
"description": "Current time zone plus up to three others",
|
||||||
"allow_emulator":true,
|
"allow_emulator":true,
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
|
|
Loading…
Reference in New Issue