You are reading a single comment by @Ganblejs and its replies. Click here to read the full conversation.
  • 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
    

    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_Obje­ct_removeListener

    I hope I'm not leading you astray with this :P

About

Avatar for Ganblejs @Ganblejs started