Maybe implementing calculations, averaging, sensor fusion or whatever else is needed for the state changes is best done in a library. Then build an app or widget around that library which is able to keep state all the time and handles persisting on reloads etc..
Some months ago I had implemented a version of the van Hees method for detecting inactivitiy by checking changes in the direction of accelerometer values. Maybe you can use that or parts of it. https://github.com/halemmerich/BangleApps/blob/libvanhees/apps/libvanhees/lib.js
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.
Maybe implementing calculations, averaging, sensor fusion or whatever else is needed for the state changes is best done in a library. Then build an app or widget around that library which is able to keep state all the time and handles persisting on reloads etc..
Some months ago I had implemented a version of the van Hees method for detecting inactivitiy by checking changes in the direction of accelerometer values. Maybe you can use that or parts of it. https://github.com/halemmerich/BangleApps/blob/libvanhees/apps/libvanhees/lib.js