Yes, as far as 'magOn' is concerned it thinks the magnetometer is still on because the power to it has always stayed on. I'm wondering what the best way of handling that is...
I could make magOn read back the data in the magnetometer, which would help it know if the magnetometer had got reset, but I wonder of that really helps. Just Puck.magOff();Puck.magOn(); would fix it.
You could do:
var magReadings = 0;
setInterval(function() {
if (!magReadings) { Puck.magOff();Puck.magOn(5); }
magReadings=0;
}, 1000);
Puck.magOn(5);
Puck.on("mag", function() {magReadings++})
Potentially I could do that internally, but then it ends up using up more battery power in all cases.
In your case, if it always stops working after 5 samples it's not going to help you a great deal.
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.
Yes, as far as 'magOn' is concerned it thinks the magnetometer is still on because the power to it has always stayed on. I'm wondering what the best way of handling that is...
I could make
magOn
read back the data in the magnetometer, which would help it know if the magnetometer had got reset, but I wonder of that really helps. JustPuck.magOff();Puck.magOn();
would fix it.You could do:
Potentially I could do that internally, but then it ends up using up more battery power in all cases.
In your case, if it always stops working after 5 samples it's not going to help you a great deal.