paste code into emulator editor pane (right-hand pane)
upload code
run it with typing r() into console (left-hand pane)
click on button 1,2,3 -to the right of the graphics area
click into the left or right half side of the graphics
var btns = [BTN1,BTN2,BTN3,BTN4,BTN5], wIds;
function onInit() {
if (wIds) return;
wIds = [];
btns.forEach(function(btn,i) {
var lab = "BTN"+(i+1);
wIds.push(setWatch(function(e) {
e.btn=lab;
console.log(e);
},btn,{repeat:true,edge:"both"}));
});
Bangle.on("swipe",function(dir) { // ???
console.log((dir) ? "-->" : "<--"); });
}
function h() {
if (wIds) wIds.forEach(function(wId) {
clearWatch(wId); });
wIds = null;
}
function r() { onInit(); } // r() : run
function h() { halt(); } // h() : halt
Results:
a) activities on BTN5 also falsely(?) reports BTN4 activities
b) 'swipe' - moving pointer with mousedown not supported
Would be nice to see the swipe working... with setWatche()-s on the buttons 4 and 5 AND with - for example - Bangle.on("swipe",function(dir){...} (or alike).
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Wrote a small test program for the bangle.js emulator testing the buttons... pretty neat!
Proceed as follows:
r()
into console (left-hand pane)click into the left or right half side of the graphics
Results:
Would be nice to see the swipe working... with setWatche()-s on the buttons 4 and 5 AND with - for example -
Bangle.on("swipe",function(dir){...}
(or alike).Output 'formatted' to fit:
1 Attachment