https://pastebin.com/BahN25YL
This was my solution, but I only just read the above post by Gordon, so might not be needing it. My code is comparing orientation in space 5 minutes apart, if they are equal it calls softOff. So not completely fool-proof, uses magnetometer and accelerometer dot product, magnetometer only stays on for the 1 sec it's needed.
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.
https://pastebin.com/BahN25YL
This was my solution, but I only just read the above post by Gordon, so might not be needing it. My code is comparing orientation in space 5 minutes apart, if they are equal it calls softOff. So not completely fool-proof, uses magnetometer and accelerometer dot product, magnetometer only stays on for the 1 sec it's needed.