Thanks - to be honest I'm not sure quite what can be done about this, short of changing the battery percentage meter.
Basically the magnetometer will run down to 1.95v, and the 0% battery voltage from Puck.getBatteryPercentage() is 2v.
That should be fine, but when Puck.js is executing code it'll be drawing more power, which will drop the battery voltage more, which could then reset the magnetometer - and the Puck won't be aware that it has happened.
The problem with a check in Puck.magOn is that you could have called it when the battery was fine, and then the battery slowly runs down. It even depends on the code you execute on the Puck.mag handler - if you were doing something quick it'd be better than if you did loads of calculations (as those could cause the battery level to drop).
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.
Thanks - to be honest I'm not sure quite what can be done about this, short of changing the battery percentage meter.
Basically the magnetometer will run down to 1.95v, and the 0% battery voltage from
Puck.getBatteryPercentage()
is 2v.That should be fine, but when Puck.js is executing code it'll be drawing more power, which will drop the battery voltage more, which could then reset the magnetometer - and the Puck won't be aware that it has happened.
The problem with a check in
Puck.magOn
is that you could have called it when the battery was fine, and then the battery slowly runs down. It even depends on the code you execute on thePuck.mag
handler - if you were doing something quick it'd be better than if you did loads of calculations (as those could cause the battery level to drop).