BangleApps/apps/verticalface/app.js

74 lines
1.9 KiB
JavaScript
Raw Normal View History

// Set color
g.setColor('#27ae60');
2020-05-27 04:12:45 +00:00
// draw the current time (4x size 7 segment)
2020-05-27 06:37:44 +00:00
g.setFont("8x12",9);
2020-05-27 03:58:47 +00:00
g.setFontAlign(-1,0); // align right bottom
2020-05-27 06:37:44 +00:00
g.drawString(hours, 25, 65, true /*clear background*/);
g.drawString(mins, 25, 155, true /*clear background*/);
2020-05-27 03:58:47 +00:00
// draw the date (2x size 7 segment)
2020-05-27 04:12:45 +00:00
g.setFont("6x8",2);
2020-05-27 03:58:47 +00:00
g.setFontAlign(-1,0); // align right bottom
2020-05-27 06:37:44 +00:00
g.drawString(date, 20, 215, true /*clear background*/);
2020-05-27 03:58:47 +00:00
}
//We will create custom "Widgets" for our face.
function drawSteps() {
//Reset to defaults.
g.reset();
// draw the date (2x size 7 segment)
g.setColor('#7f8c8d');
g.setFont("8x12",2);
g.setFontAlign(-1,0); // align right bottom
g.drawString("STEPS", 145, 40, true /*clear background*/);
g.setColor('#bdc3c7');
g.drawString("1234", 145, 70, true /*clear background*/);
}
function drawBPM() {
//Reset to defaults.
g.reset();
// draw the date (2x size 7 segment)
g.setColor('#7f8c8d');
g.setFont("8x12",2);
g.setFontAlign(-1,0); // align right bottom
g.drawString("BPM", 145, 120, true /*clear background*/);
g.setColor('#bdc3c7');
g.drawString("1234", 145, 150, true /*clear background*/);
}
2020-05-27 03:58:47 +00:00
// Clear the screen once, at startup
g.clear();
// draw immediately at first
2020-05-27 06:37:44 +00:00
drawTimeDate();
drawSteps();
drawBPM();
var secondInterval = setInterval(()=>{
drawTimeDate();
}, 5000);
2020-05-27 03:58:47 +00:00
// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower',on=>{
if (secondInterval) clearInterval(secondInterval);
secondInterval = undefined;
if (on) {
2020-05-27 06:37:44 +00:00
setInterval(drawTimeDate, 5000);
drawTimeDate(); // draw immediately
2020-05-27 03:58:47 +00:00
}
});
2020-05-27 06:37:44 +00:00
2020-05-27 03:58:47 +00:00
// Load widgets
2020-05-27 06:37:44 +00:00
//Bangle.loadWidgets();
//Bangle.drawWidgets();
2020-05-27 03:58:47 +00:00
// Show launcher when middle button pressed
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
2020-05-27 04:58:21 +00:00
2020-05-27 04:44:45 +00:00
Bangle.on('touch', function(button) {
if(button == 1 || button == 2) Bangle.showLauncher();
});