I believe you should remove the listener used for selecting mode once you've made the selection, in your example function(n, event). I don't know, but I suspect you might need to break function(n, event) out into a function with it's own name to make it work, maybe
function selectOnTouch(n, event) { ... }
...
Bangle.removeListener('touch', selectOnTouch);
and then your code would be something like
function selectOnTouch(n, event) {
if(event.y<60){
walking_subactivity();
Bangle.removeListener('touch', selectOnTouch);
}
else if(event.y>=60 && event.y<120){
jogging_subactivity();
Bangle.removeListener('touch', selectOnTouch);
}
else
{
cycling_subactivity();
Bangle.removeListener('touch', selectOnTouch);
}
});
Bangle.on('touch', selectOnTouch); //start the listener for touch input here
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.
I believe you should remove the listener used for selecting mode once you've made the selection, in your example function(n, event). I don't know, but I suspect you might need to break function(n, event) out into a function with it's own name to make it work, maybe
and then your code would be something like
I'm not 100% on these things though - but I think that's basically how it works. This is relevant I think: http://www.espruino.com/Reference#l_Object_removeListener
I hope I'm not leading you astray with this :P