this is the simplest code that I am using:
var Vec3 = require("Vec3"); var vmin = new Vec3(Puck.mag()); var vmax = vmin; function onMag(xyz) { vmin = vmin.min(xyz); vmax = vmax.max(xyz); var c = vmin.add(vmax).mul(0.5).sub(xyz); var a = (Math.atan2(c.x,c.y)*180/Math.PI); if(a <0) a+=360; console.log( vmin); console.log( vmax); console.log( c); console.log( a.toFixed(0) ); } Puck.on('mag', onMag); Puck.magOn(10);
I get consistent 0 to 360 degree measurements, but with 0 to 270 actually between 0 and 350 and 270 to 360 occuring in the last 10 degrees.
@user158028 started
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.
this is the simplest code that I am using:
I get consistent 0 to 360 degree measurements, but with 0 to 270 actually between 0 and 350 and 270 to 360 occuring in the last 10 degrees.