better example app

pull/1658/head
Gordon Williams 2022-04-05 16:48:56 +01:00
parent 070376cbed
commit d4d6d48471
1 changed files with 29 additions and 7 deletions

View File

@ -1,12 +1,34 @@
// place your const, vars, functions or classes here
// special function to handle display switch on
Bangle.on('lcdPower', (on) => {
if (on) {
// call your app function here
// If you clear the screen, do Bangle.drawWidgets();
// clear the screen
g.clear();
var n = 0;
// redraw the screen
function draw() {
g.reset().clearRect(Bangle.appRect);
g.setFont("6x8").setFontAlign(0,0).drawString("Up / Down",g.getWidth()/2,g.getHeight()/2 - 20);
g.setFont("Vector",60).setFontAlign(0,0).drawString(n,g.getWidth()/2,g.getHeight()/2 + 30);
}
// Respond to user input
Bangle.setUI({mode: "updown"}, function(dir) {
if (dir<0) {
n--;
draw();
} else if (dir>0) {
n++;
draw();
} else {
n = 0;
draw();
}
});
g.clear();
// call your app function here
// First draw...
draw();
// Load widgets
Bangle.loadWidgets();
Bangle.drawWidgets();