mirror of https://github.com/espruino/BangleApps
stepo BTN2 switches to launcher
parent
72c60dbfa7
commit
3a591b85d7
|
@ -1,2 +1,2 @@
|
|||
0.01: First version
|
||||
0.02: Speeded up first draw, ensure timer is stopped and started depending on screen event
|
||||
0.02: Speeded up draw, start stop timer, long press BTN2 to switch to the launcher
|
||||
|
|
|
@ -10,6 +10,7 @@ A large font watch, displays step count in a doughnut guage and warns of low bat
|
|||
- The guage show percentage of steps out of a goal of 10000 steps
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
- When the battery is less than 25% the doughnut turns red
|
||||
|
@ -17,8 +18,14 @@ A large font watch, displays step count in a doughnut guage and warns of low bat
|
|||

|
||||
|
||||
|
||||
# Notes
|
||||
## BTN2 Long press to start the launcher
|
||||
|
||||
BTN2 is confiured to respond to a 1.5 second press in order to switch
|
||||
to the launcher App. Simply press and hold until you hear a buzz and
|
||||
release. This avoids accidently switching out of the watch app when
|
||||
clothing catches it.
|
||||
|
||||
## Notes
|
||||
|
||||
* Uses an arrayBuffer to prepare the doughnut guage. The arrayBuffer
|
||||
is 160*160 and is larger than required. The reason for this is that
|
||||
|
|
|
@ -108,9 +108,40 @@ Bangle.on('lcdPower', function(on) {
|
|||
stopTimer();
|
||||
});
|
||||
|
||||
let firstPress = 0;
|
||||
var pressTimer;
|
||||
|
||||
// start a timer and buzz whenn held long enough
|
||||
function firstPressed() {
|
||||
firstPress = getTime();
|
||||
pressTimer = setInterval(longPressCheck, 1500);
|
||||
}
|
||||
|
||||
// if you release too soon there is no buzz as timer is cleared
|
||||
function thenReleased() {
|
||||
var dur = getTime() - firstPress;
|
||||
if (pressTimer) {
|
||||
clearInterval(pressTimer);
|
||||
pressTimer = undefined;
|
||||
}
|
||||
if ( dur >= 1.5 ) Bangle.showLauncher();
|
||||
}
|
||||
|
||||
// when you feel the buzzer you know you have done a long press
|
||||
function longPressCheck() {
|
||||
Bangle.buzz();
|
||||
if (pressTimer) {
|
||||
clearInterval(pressTimer);
|
||||
pressTimer = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// make BTN require a long press (1.5 seconds) to switch to launcher
|
||||
setWatch(firstPressed, BTN2,{repeat:true,edge:"rising"});
|
||||
setWatch(thenReleased, BTN2,{repeat:true,edge:"falling"});
|
||||
|
||||
g.reset();
|
||||
g.clear();
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
startTimer();
|
||||
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|
||||
|
|
Loading…
Reference in New Issue