The code posted above does a calculation called level and that uses the accelerometer in the chip I'm using, not the magnetometer. Sorry about that.
The code expects -Z to be down and if +Y points North the heading is 0.0 degrees.
You may need to swap the axis in the formulas if you want to orient the Puck differently
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.
The code posted above does a calculation called level and that uses the accelerometer in the chip I'm using, not the magnetometer. Sorry about that.
The code expects -Z to be down and if +Y points North the heading is 0.0 degrees.
You may need to swap the axis in the formulas if you want to orient the Puck differently