At the moment there's no 'built-in' calibration, so it all has to be done by your own code anyway.
A lot of code does something like this:
var zero = Puck.mag();
var doorOpen = false;
function onMag(p) {
p.x -= zero.x;
p.y -= zero.y;
p.z -= zero.z;
var s = Math.sqrt(p.x*p.x + p.y*p.y + p.z*p.z);
var open = s<1000;
if (open!=doorOpen) {
doorOpen = open;
digitalPulse(open ? LED1 : LED2, 1,1000);
}
}
Puck.on('mag', onMag);
Puck.magOn();
So in that case, the calibration value is stored in the zero variable. If you want to reset the magnetometer value, all you have to do is run zero = Puck.mag(); again.
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.
At the moment there's no 'built-in' calibration, so it all has to be done by your own code anyway.
A lot of code does something like this:
So in that case, the calibration value is stored in the
zero
variable. If you want to reset the magnetometer value, all you have to do is runzero = Puck.mag();
again.