You are reading a single comment by @rigrig and its replies. Click here to read the full conversation.
  • Another idea: just look at the accelerometer with a timeout?

    (function(){
            let timeout;
            function setWorn(worn) {
                 worn = !!worn; // undefined -> false
                 if (timeout) clearTimeout(timeout);
                 if (Bangle.isWorn === worn) return; // no change
                 Bangle.isWorn = worn;
                 Bangle.emit('worn', worn);
            }
            Bangle.on('accel', xyz => {
                if (Bangle.isCharging()) {
                    setWorn(false);
               }
                else if (xyz.diff) {  // or Math.abs(xyz.diff) > 0.01?
                     setWorn(true);
                     // no movement for 1 minute
                     timeout = setTimeout(setWorn, 60000);
                }
            });
            Bangle.on('charging', charging => {
                // assume charging ends = watch picked up
                setWorn(!charging);
            });
    })()
    

    But I guess constantly running code for accell events might not be great for battery life :-(

About

Avatar for rigrig @rigrig started