Negative numbers and touch functionality
Added the ability to count down (including going negative), and touchscreen input.master
parent
a135a17f0d
commit
6ece6931d8
|
|
@ -6,22 +6,41 @@ function updateScreen() {
|
||||||
g.clearRect(0, 50, 250, 150);
|
g.clearRect(0, 50, 250, 150);
|
||||||
g.setFont("Vector",40).setFontAlign(0,0);
|
g.setFont("Vector",40).setFontAlign(0,0);
|
||||||
g.drawString(Math.floor(counter), g.getWidth()/2, 100);
|
g.drawString(Math.floor(counter), g.getWidth()/2, 100);
|
||||||
|
g.drawString('-', 45, 100);
|
||||||
|
g.drawString('+', 185, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// add a count by using BTN1
|
// add a count by using BTN1 or BTN5
|
||||||
setWatch(() => {
|
setWatch(() => {
|
||||||
counter += 1;
|
counter += 1;
|
||||||
updateScreen();
|
updateScreen();
|
||||||
}, BTN1, {repeat:true});
|
}, BTN1, {repeat:true});
|
||||||
|
|
||||||
setWatch(() => {
|
setWatch(() => {
|
||||||
counter = 0;
|
counter += 1;
|
||||||
|
updateScreen();
|
||||||
|
}, BTN5, {repeat:true});
|
||||||
|
|
||||||
|
// subtract a count by using BTN3 or BTN4
|
||||||
|
setWatch(() => {
|
||||||
|
counter -= 1;
|
||||||
|
updateScreen();
|
||||||
|
}, BTN4, {repeat:true});
|
||||||
|
|
||||||
|
setWatch(() => {
|
||||||
|
counter -= 1;
|
||||||
updateScreen();
|
updateScreen();
|
||||||
}, BTN3, {repeat:true});
|
}, BTN3, {repeat:true});
|
||||||
|
|
||||||
|
// reset by using BTN2
|
||||||
|
setWatch(() => {
|
||||||
|
counter = 0;
|
||||||
|
updateScreen();
|
||||||
|
}, BTN2, {repeat:true});
|
||||||
|
|
||||||
g.clear(1).setFont("6x8");
|
g.clear(1).setFont("6x8");
|
||||||
g.drawString('Use BTN1 to increase\nthe counter by one.\nUse BTN3 to reset counter.', 25, 200);
|
g.drawString('Tap right or BTN1 to increase\nTap left or BTN3 to decrease\nPress BTN2 to reset.', 25, 200);
|
||||||
|
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue