Add tiltfix() for compensation on given sensor values
master
Erik Andresen 2023-02-16 19:05:45 +01:00
parent cb8e733738
commit cc57c42a17
3 changed files with 13 additions and 6 deletions

View File

@ -4,3 +4,4 @@
0.04: Fix Font size
0.05: Initial portable version
0.06: Outsource tilt compensation to library
0.07: Add tiltfix() for compensation on given sensor values

View File

@ -22,11 +22,10 @@ exports.calibrate = () => {
});
}
exports.tiltfixread = (O,S) => {
"ram"
var m = Bangle.getCompass();
var g = Bangle.getAccel();
m.dx =(m.x-O.x)*S.x; m.dy=(m.y-O.y)*S.y; m.dz=(m.z-O.z)*S.z;
exports.tiltfix = (m,g,O,S) => {
if (O & S) {
m.dx =(m.x-O.x)*S.x; m.dy=(m.y-O.y)*S.y; m.dz=(m.z-O.z)*S.z;
}
var d = Math.atan2(-m.dx,m.dy)*180/Math.PI;
if (d<0) d+=360;
var phi = Math.atan(-g.x/-g.z);
@ -39,3 +38,10 @@ exports.tiltfixread = (O,S) => {
if (psi<0) psi+=360;
return psi;
}
exports.tiltfixread = (O,S) => {
"ram"
var m = Bangle.getCompass({noTiltComp: true});
var g = Bangle.getAccel();
return exports.tiltfix(m,g,O,S);
}

View File

@ -1,7 +1,7 @@
{
"id": "magnav",
"name": "Navigation Compass",
"version": "0.06",
"version": "0.07",
"description": "Compass with linear display as for GPSNAV. Has Tilt compensation and remembers calibration.",
"screenshots": [{"url":"screenshot-b2.png"},{"url":"screenshot-light-b2.png"}],
"icon": "magnav.png",