You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • One thing you might be hitting is the timeout is a 32 bit integer, and 99999999999 is greater than can be stored in an int. If you want to disable the lock timeout, just use 0

    However if you leave the watch unlocked the touchscreen stays on which draws a lot of power - it'll run the Bangle's battery down in about a week.

    If the device is locked or the screen is off, the button event that unlocks the screen gets 'eaten', because in most cases you don't want a button press to (for instance) immediately start the launcher.

    What I'd suggest is you just respond to the watch being unlocked as well as handling the button press:

    function buttonPressed() { 
     //   console.log("trigger");  
    }
    
    Bangle.on("lock", locked => {
      if (!locked) buttonPressed();
    });
    setWatch(buttonPressed, (process.env.HWVERSION==2) ? BTN1 : BTN2, { repeat: true, edge: 'rising' });
    

    On 2v20 (when released) or cutting edge firmwares you can even go one further and ensure that the watch can be woken up by other things (like twisting) but only a button press fires your function:

    Bangle.on("lock", (locked,reason) => {
      if (!locked && reason=="button") buttonPressed();
    });
    
About

Avatar for Gordon @Gordon started