mirror of https://github.com/espruino/BangleApps
parent
1398cea7b8
commit
a3a7ef58bf
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue