Merge pull request #1785 from nxdefiant/waypointer

waypointer
pull/1790/head
Gordon Williams 2022-05-03 09:17:26 +01:00 committed by GitHub
commit 0460948541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 5 deletions

View File

@ -1,2 +1,3 @@
0.01: New app!
0.02: Make Bangle.js 2 compatible
0.03: Silently use built in heading when no magnav calibration file is present

View File

@ -74,11 +74,14 @@ function newHeading(m,h){
return hd;
}
var CALIBDATA = require("Storage").readJSON("magnav.json",1)||null;
var CALIBDATA = require("Storage").readJSON("magnav.json",1) || {};
function tiltfixread(O,S){
var start = Date.now();
var m = Bangle.getCompass();
if (O === undefined || S === undefined) {
// no valid calibration from magnav, use built in
return 360-m.heading;
}
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;
var d = Math.atan2(-m.dx,m.dy)*180/Math.PI;
@ -97,6 +100,7 @@ function tiltfixread(O,S){
// Note actual mag is 360-m, error in firmware
function read_compass() {
var d = tiltfixread(CALIBDATA.offset,CALIBDATA.scale);
if (isNaN(d)) return; // built in compass heading can return NaN when uncalibrated
heading = newHeading(d,heading);
direction = wp_bearing - heading;
if (direction < 0) direction += 360;

View File

@ -1,7 +1,7 @@
{
"id": "waypointer",
"name": "Way Pointer",
"version": "0.02",
"version": "0.03",
"description": "Navigate to a waypoint using the GPS for bearing and compass to point way, uses the same waypoint interface as GPS Navigation",
"icon": "waypointer.png",
"tags": "tool,outdoors,gps",

View File

@ -73,8 +73,8 @@
event.preventDefault()
var name = $name.value.trim()
if(!name) return;
var lat = parseFloat($latitude.value).toPrecision(5);
var lon = parseFloat($longtitude.value).toPrecision(5);
var lat = parseFloat($latitude.value);
var lon = parseFloat($longtitude.value);
waypoints.push({
name, lat,lon,