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 // place your const, vars, functions or classes here
// special function to handle display switch on // clear the screen
Bangle.on('lcdPower', (on) => { g.clear();
if (on) {
// call your app function here var n = 0;
// If you clear the screen, do Bangle.drawWidgets();
// 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(); // First draw...
// call your app function here draw();
// Load widgets
Bangle.loadWidgets();
Bangle.drawWidgets();