Merge branch 'master' of github.com:espruino/BangleApps

pull/383/head
Gordon Williams 2020-05-05 11:39:31 +01:00
commit 69a4c7ce74
3 changed files with 31 additions and 24 deletions

View File

@ -167,7 +167,7 @@
{ "id": "impwclock",
"name": "Imprecise Word Clock",
"icon": "clock-impword.png",
"version":"0.01",
"version":"0.02",
"description": "Imprecise word clock for vacations, weekends, and those who never need accurate time.",
"tags": "clock",
"type":"clock",

2
apps/impwclock/ChangeLog Normal file
View File

@ -0,0 +1,2 @@
0.01: New App!
0.02: Stopped watchface from flashing every interval

View File

@ -46,6 +46,8 @@ const passivColor = 0x3186 /*grey*/ ;
const activeColorNight = 0xF800 /*red*/ ;
const activeColorDay = 0xFFFF /* white */;
var hidxPrev;
function drawWordClock() {
@ -65,19 +67,6 @@ function drawWordClock() {
g.setColor(passivColor);
g.setFontAlign(0, -1, 0);
// draw allWords
var c;
var y = ys;
var x = xs;
allWords.forEach((line) => {
x = xs;
for (c in line) {
g.drawString(line[c], x, y);
x += dx;
}
y += dy;
});
// Switch case isn't good for this in Js apparently so...
if(h < 3){
@ -125,24 +114,40 @@ function drawWordClock() {
hidx = 10;
}
// write hour in active color
g.setColor(activeColor);
timeOfDay[hidx][0].split('').forEach((c, pos) => {
x = xs + (timeOfDay[hidx][pos + 1] / 10 | 0) * dx;
y = ys + (timeOfDay[hidx][pos + 1] % 10) * dy;
g.drawString(c, x, y);
});
// check whether we need to redraw the watchface
if (hidx !== hidxPrev) {
// draw allWords
var c;
var y = ys;
var x = xs;
allWords.forEach((line) => {
x = xs;
for (c in line) {
g.drawString(line[c], x, y);
x += dx;
}
y += dy;
});
// write hour in active color
g.setColor(activeColor);
timeOfDay[hidx][0].split('').forEach((c, pos) => {
x = xs + (timeOfDay[hidx][pos + 1] / 10 | 0) * dx;
y = ys + (timeOfDay[hidx][pos + 1] % 10) * dy;
g.drawString(c, x, y);
});
hidxPrev = hidx;
}
// Display digital time while button 1 is pressed
g.clearRect(0, 215, 240, 240);
if (BTN1.read()){
g.setColor(activeColor);
g.clearRect(0, 215, 240, 240);
g.drawString(time, 120, 215);
} else { g.clearRect(0, 215, 240, 240); }
}
}
Bangle.on('lcdPower', function(on) {
if (on) drawWordClock();
});