Merge pull request #66 from eska-muc/berlin-clock

Berlin clock
master
Gordon Williams 2019-12-16 08:55:10 +00:00 committed by GitHub
commit 64d547b12d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 97 additions and 0 deletions

View File

@ -623,5 +623,16 @@
{"name":"-blobclk","url":"clock-blob.js"},
{"name":"*blobclk","url":"clock-blob-icon.js","evaluate":true}
]
},
{ "id": "berlinc",
"name": "Berlin Clock",
"icon": "berlin-clock.png",
"description": "Berlin Clock (see https://en.wikipedia.org/wiki/Mengenlehreuhr)",
"tags": "",
"storage": [
{"name":"+berlinc","url":"berlin-clock.json"},
{"name":"-berlinc","url":"berlin-clock.js"},
{"name":"*berlinc","url":"berlin-clock-icon.js","evaluate":true}
]
}
]

View File

@ -0,0 +1,12 @@
// Create an entry in apps.json as follows:
{ "id": "berlinc",
"name": "Berlin Clock",
"icon": "berlin-clock.png",
"description": "Berlin Clock (see https://en.wikipedia.org/wiki/Mengenlehreuhr)",
"tags": "",
"storage": [
{"name":"+berlinc","url":"berlin-clock.json"},
{"name":"-berlinc","url":"berlin-clock.js"},
{"name":"*berlinc","url":"berlin-clock-icon.js","evaluate":true}
]
}

View File

@ -0,0 +1,4 @@
var img = {
width : 48, height : 48, bpp : 4,
buffer : require("heatshrink").decompress(atob("xAAWxOZAAeP/4ADApX4C/4X/C/4XvxAAWF4o1QI4wX/C/4X/C9OIAC2L3e7AQQvBzAEBFAP4FoYEFC/4X/C/4XvxAAWFIIADApYsBAAX4C/4X/C/4XXf54AH"))
}

View File

@ -0,0 +1,65 @@
(() => {
// place your const, vars, functions or classes here
fields = [ 4 , 4 , 11 , 4 ];
width = g.getWidth();
height = g.getHeight();
rowHeight = height/4;
rowlights = [];
function drawBerlinClock() {
var now = new Date();
rowlights[0] = Math.floor(now.getHours() / 5);
rowlights[1] = now.getHours() % 5;
rowlights[2] = Math.floor(now.getMinutes() / 5);
rowlights[3] = now.getMinutes() % 5;
g.clear();
g.drawRect(0,0,width,height);
for (row = 0 ; row < 4 ; row++) {
nfields = fields[row];
boxWidth = width/nfields;
for (col = 0 ; col < nfields ; col++) {
x1 = col*boxWidth;
y1 = row*rowHeight;
x2 = (col+1)*boxWidth;
y2 = (row+1)*rowHeight;
g.setColor(1,1,1);
g.drawRect(x1,y1,x2,y2);
if (col<rowlights[row]) {
if (row === 2 ) {
if (((col+1) % 3) === 0) {
g.setColor(1,0,0);
} else {
g.setColor(1,1,0);
}
} else {
g.setColor(1,0,0);
}
g.fillRect(x1+2,y1+2,x2-2,y2-2);
}
}
}
}
// special function to handle display switch on
Bangle.on('lcdPower', (on) => {
if (on) {
drawWidgets();
// call your app function here
drawBerlinClock();
}});
// call your app function here
// refesh every 15 sec
setInterval(drawBerlinClock, 15E3);
drawBerlinClock();
})();

View File

@ -0,0 +1,5 @@
{
"name":"Berlin Clock",
"icon":"*berlinc",
"src":"-berlinc"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B