2020-01-17 11:43:26 +00:00
|
|
|
// place your const, vars, functions or classes here
|
|
|
|
fields = [ 4 , 4 , 11 , 4 ];
|
|
|
|
width = g.getWidth();
|
|
|
|
height = g.getHeight();
|
|
|
|
rowHeight = height/4;
|
|
|
|
rowlights = [];
|
2019-12-09 21:06:47 +00:00
|
|
|
|
2020-01-17 11:43:26 +00:00
|
|
|
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;
|
2019-12-09 21:06:47 +00:00
|
|
|
|
2020-01-17 11:43:26 +00:00
|
|
|
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);
|
2019-12-09 21:06:47 +00:00
|
|
|
}
|
2020-01-17 11:43:26 +00:00
|
|
|
} else {
|
|
|
|
g.setColor(1,0,0);
|
2019-12-09 21:06:47 +00:00
|
|
|
}
|
2020-01-17 11:43:26 +00:00
|
|
|
|
|
|
|
g.fillRect(x1+2,y1+2,x2-2,y2-2);
|
2019-12-09 21:06:47 +00:00
|
|
|
}
|
2020-01-17 11:43:26 +00:00
|
|
|
}
|
2019-12-09 21:06:47 +00:00
|
|
|
}
|
2020-01-17 11:43:26 +00:00
|
|
|
}
|
2019-12-09 21:06:47 +00:00
|
|
|
|
2020-01-17 11:43:26 +00:00
|
|
|
// special function to handle display switch on
|
|
|
|
Bangle.on('lcdPower', (on) => {
|
|
|
|
g.clear();
|
|
|
|
if (on) {
|
|
|
|
Bangle.drawWidgets();
|
|
|
|
// call your app function here
|
|
|
|
drawBerlinClock();
|
|
|
|
}});
|
2019-12-09 21:06:47 +00:00
|
|
|
|
2020-01-17 11:43:26 +00:00
|
|
|
// refesh every 15 sec
|
|
|
|
setInterval(drawBerlinClock, 15E3);
|
2019-12-09 21:06:47 +00:00
|
|
|
|
2020-01-17 11:43:26 +00:00
|
|
|
g.clear();
|
|
|
|
Bangle.loadWidgets();
|
|
|
|
Bangle.drawWidgets();
|
|
|
|
drawBerlinClock();
|
|
|
|
// Show launcher when middle button pressed
|
|
|
|
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|