Replaced template String with concatenation. Performed code indentation. Enabled settings again.
parent
17d5e1a1c4
commit
bcea5326a5
|
|
@ -887,7 +887,7 @@
|
||||||
{ "id": "berlinc",
|
{ "id": "berlinc",
|
||||||
"name": "Berlin Clock",
|
"name": "Berlin Clock",
|
||||||
"icon": "berlin-clock.png",
|
"icon": "berlin-clock.png",
|
||||||
"version":"0.03.02",
|
"version":"0.03.03",
|
||||||
"description": "Berlin Clock (see https://en.wikipedia.org/wiki/Mengenlehreuhr)",
|
"description": "Berlin Clock (see https://en.wikipedia.org/wiki/Mengenlehreuhr)",
|
||||||
"tags": "clock",
|
"tags": "clock",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
|
|
@ -898,6 +898,7 @@
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"berlinc.app.js","url":"berlin-clock.js"},
|
{"name":"berlinc.app.js","url":"berlin-clock.js"},
|
||||||
{"name":"berlinc.img","url":"berlin-clock-icon.js","evaluate":true},
|
{"name":"berlinc.img","url":"berlin-clock-icon.js","evaluate":true},
|
||||||
|
{"name":"berlinc.settings.js","url":"settings.js"},
|
||||||
{"name":"berlin-clock.json","url":"berlin-clock.json"}
|
{"name":"berlin-clock.json","url":"berlin-clock.json"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// Berlin Clock see https://en.wikipedia.org/wiki/Mengenlehreuhr
|
// Berlin Clock see https://en.wikipedia.org/wiki/Mengenlehreuhr
|
||||||
const fields = [ 4 , 4 , 11 , 4 ];
|
const fields = [4, 4, 11, 4];
|
||||||
const offset = 20;
|
const offset = 20;
|
||||||
const width = g.getWidth() - 2*offset;
|
const width = g.getWidth() - 2 * offset;
|
||||||
const height = g.getHeight() - 2*offset;
|
const height = g.getHeight() - 2 * offset;
|
||||||
const rowHeight = height/4;
|
const rowHeight = height / 4;
|
||||||
|
|
||||||
const show_date = (require('Storage').readJSON('berlin-clock.json', 1) || {})['showdate'];
|
const show_date = (require('Storage').readJSON('berlin-clock.json', 1) || {})['showdate'];
|
||||||
|
|
||||||
|
|
@ -14,44 +14,46 @@ function drawBerlinClock() {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
if (show_date) {
|
if (show_date) {
|
||||||
var yr = now.getFullYear();
|
var yr = now.getFullYear();
|
||||||
var month = now.getMonth()+1;
|
var month = now.getMonth() + 1;
|
||||||
var day = now.getDate();
|
var day = now.getDate();
|
||||||
var dateString=`${yr}-${month<10?'0':''}${month}-${day<10?'0':''}${day}`;
|
//var dateString = `${yr}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day}`;
|
||||||
|
var monthZero = month < 10 ? '0' : '';
|
||||||
|
var dayZero = day < 10 ? '0' : '';
|
||||||
|
var dateString = yr + "-" + monthZero + month + "-" + dayZero + day;
|
||||||
var strWidth = g.stringWidth(dateString);
|
var strWidth = g.stringWidth(dateString);
|
||||||
g.setColor(1,1,1);
|
g.setColor(1, 1, 1);
|
||||||
g.drawString(dateString,(g.getWidth()-strWidth)/2,height+offset+2);
|
g.drawString(dateString, (g.getWidth() - strWidth) / 2, height + offset + 2);
|
||||||
}
|
}
|
||||||
rowlights[0] = Math.floor(now.getHours() / 5);
|
rowlights[0] = Math.floor(now.getHours() / 5);
|
||||||
rowlights[1] = now.getHours() % 5;
|
rowlights[1] = now.getHours() % 5;
|
||||||
rowlights[2] = Math.floor(now.getMinutes() / 5);
|
rowlights[2] = Math.floor(now.getMinutes() / 5);
|
||||||
rowlights[3] = now.getMinutes() % 5;
|
rowlights[3] = now.getMinutes() % 5;
|
||||||
|
|
||||||
g.drawRect(offset,offset,width+offset,height+offset);
|
g.drawRect(offset, offset, width + offset, height + offset);
|
||||||
for (row = 0 ; row < 4 ; row++) {
|
for (row = 0; row < 4; row++) {
|
||||||
nfields = fields[row];
|
nfields = fields[row];
|
||||||
boxWidth = width/nfields;
|
boxWidth = width / nfields;
|
||||||
|
|
||||||
for (col = 0 ; col < nfields ; col++) {
|
for (col = 0; col < nfields; col++) {
|
||||||
x1 = col*boxWidth + offset ;
|
x1 = col * boxWidth + offset;
|
||||||
y1 = row*rowHeight + offset;
|
y1 = row * rowHeight + offset;
|
||||||
x2 = (col+1)*boxWidth + offset;
|
x2 = (col + 1) * boxWidth + offset;
|
||||||
y2 = (row+1)*rowHeight + offset;
|
y2 = (row + 1) * rowHeight + offset;
|
||||||
|
|
||||||
g.setColor(1,1,1);
|
g.setColor(1, 1, 1);
|
||||||
g.drawRect(x1,y1,x2,y2);
|
g.drawRect(x1, y1, x2, y2);
|
||||||
if (col<rowlights[row]) {
|
if (col < rowlights[row]) {
|
||||||
|
|
||||||
if (row === 2 ) {
|
if (row === 2) {
|
||||||
if (((col+1) % 3) === 0) {
|
if (((col + 1) % 3) === 0) {
|
||||||
g.setColor(1,0,0);
|
g.setColor(1, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
g.setColor(1,1,0);
|
g.setColor(1, 1, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g.setColor(1,0,0);
|
g.setColor(1, 0, 0);
|
||||||
}
|
}
|
||||||
|
g.fillRect(x1 + 2, y1 + 2, x2 - 2, y2 - 2);
|
||||||
g.fillRect(x1+2,y1+2,x2-2,y2-2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +66,8 @@ Bangle.on('lcdPower', (on) => {
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
// call your app function here
|
// call your app function here
|
||||||
drawBerlinClock();
|
drawBerlinClock();
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// refesh every 15 sec
|
// refesh every 15 sec
|
||||||
setInterval(drawBerlinClock, 15E3);
|
setInterval(drawBerlinClock, 15E3);
|
||||||
|
|
@ -74,4 +77,4 @@ Bangle.loadWidgets();
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
drawBerlinClock();
|
drawBerlinClock();
|
||||||
// Show launcher when middle button pressed
|
// Show launcher when middle button pressed
|
||||||
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue