waypoints: implement goto functionality.
parent
de755fc78b
commit
5219dc25df
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
var Layout = require("Layout");
|
var Layout = require("Layout");
|
||||||
|
|
||||||
/* fmt library v0.2.2 */
|
/* fmt library v0.2.3 */
|
||||||
let fmt = {
|
let fmt = {
|
||||||
icon_alt : "\0\x08\x1a\1\x00\x00\x00\x20\x30\x78\x7C\xFE\xFF\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00",
|
icon_alt : "\0\x08\x1a\1\x00\x00\x00\x20\x30\x78\x7C\xFE\xFF\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||||
icon_m : "\0\x08\x1a\1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00",
|
icon_m : "\0\x08\x1a\1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||||
|
|
@ -89,6 +89,7 @@ let fmt = {
|
||||||
x = -x;
|
x = -x;
|
||||||
}
|
}
|
||||||
let s = c+this.fmtAngle(x) + "\n";
|
let s = c+this.fmtAngle(x) + "\n";
|
||||||
|
x = pos.lon;
|
||||||
c = "E";
|
c = "E";
|
||||||
if (x<0) {
|
if (x<0) {
|
||||||
c = "W";
|
c = "W";
|
||||||
|
|
@ -183,8 +184,9 @@ let gps = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* arrow library v0.0.1 */
|
/* arrow library v0.0.2 */
|
||||||
let arrow = {
|
let arrow = {
|
||||||
|
name: "(unset)",
|
||||||
waypoint: { lat: 0, lon: 0 },
|
waypoint: { lat: 0, lon: 0 },
|
||||||
updateWaypoint: function(lat, lon) {
|
updateWaypoint: function(lat, lon) {
|
||||||
this.waypoint.lat = lat;
|
this.waypoint.lat = lat;
|
||||||
|
|
@ -207,7 +209,7 @@ let arrow = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Display function to show arrows for waypoint, north, and sun
|
// Display function to show arrows for waypoint, north, and sun
|
||||||
displayNavigation: function(currentPos, currentHeading) {
|
draw: function(currentPos, currentHeading) {
|
||||||
g.clear().setFont("Vector", 22).setFontAlign(0, 0);
|
g.clear().setFont("Vector", 22).setFontAlign(0, 0);
|
||||||
|
|
||||||
// Calculate bearings
|
// Calculate bearings
|
||||||
|
|
@ -218,7 +220,7 @@ let arrow = {
|
||||||
// Format distance
|
// Format distance
|
||||||
let distStr = fmt.fmtDist(distance/1000);
|
let distStr = fmt.fmtDist(distance/1000);
|
||||||
|
|
||||||
northHeading = 45;
|
northHeading = 0;
|
||||||
// Draw compass arrow for north
|
// Draw compass arrow for north
|
||||||
this.drawArrow(northHeading, "N", 1);
|
this.drawArrow(northHeading, "N", 1);
|
||||||
|
|
||||||
|
|
@ -226,17 +228,18 @@ let arrow = {
|
||||||
if (1)
|
if (1)
|
||||||
this.drawArrow(waypointBearing, `${distStr}`, 3);
|
this.drawArrow(waypointBearing, `${distStr}`, 3);
|
||||||
|
|
||||||
let s;
|
if (0) {
|
||||||
|
let s;
|
||||||
s = sun.sunPos();
|
s = sun.sunPos();
|
||||||
// Draw sun arrow if sun is visible
|
// Draw sun arrow if sun is visible
|
||||||
if (s.altitude > 0) {
|
if (s.altitude > 0) {
|
||||||
this.drawArrow(s.azimuth, "Sun", 1);
|
this.drawArrow(s.azimuth, "Sun", 1);
|
||||||
}
|
}
|
||||||
s = sun.moonPos();
|
s = sun.moonPos();
|
||||||
// Draw sun arrow if sun is visible
|
// Draw sun arrow if sun is visible
|
||||||
if (s.altitude > 0) {
|
if (s.altitude > 0) {
|
||||||
this.drawArrow(s.azimuth, "Moon", 1);
|
this.drawArrow(s.azimuth, "Moon", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -359,6 +362,40 @@ function updateGps() {
|
||||||
setTimeout(updateGps, 1000);
|
setTimeout(updateGps, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateGoto() {
|
||||||
|
let have = false, lat = "lat ", alt = "?",
|
||||||
|
speed = "speed ", hdop = "?", adelta = "adelta ",
|
||||||
|
tdelta = "tdelta ";
|
||||||
|
|
||||||
|
if (cancel_gps)
|
||||||
|
return;
|
||||||
|
fix = gps.getGPSFix();
|
||||||
|
|
||||||
|
if (fix && fix.fix && fix.lat) {
|
||||||
|
lat = "" + fmt.fmtPos(fix);
|
||||||
|
alt = "" + fix.alt.toFixed(0);
|
||||||
|
speed = "" + fix.speed.toFixed(1);
|
||||||
|
hdop = "" + fix.hdop.toFixed(0);
|
||||||
|
have = true;
|
||||||
|
} else {
|
||||||
|
lat = "NO FIX\n"
|
||||||
|
+ "" + (getTime() - gps_start).toFixed(0) + "s ";
|
||||||
|
}
|
||||||
|
|
||||||
|
let msg = arrow.name + "\n";
|
||||||
|
msg = lat + "\n"+ alt + "m";
|
||||||
|
if (!have) {
|
||||||
|
g.reset().setFont("Vector", 31)
|
||||||
|
.setColor(1,1,1)
|
||||||
|
.fillRect(0, 24, 176, 100)
|
||||||
|
.setColor(0,0,0)
|
||||||
|
.drawString(msg, 3, 25);
|
||||||
|
} else {
|
||||||
|
arrow.draw(fix, fix.course);
|
||||||
|
}
|
||||||
|
setTimeout(updateGoto, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
function stopGps() {
|
function stopGps() {
|
||||||
cancel_gps=true;
|
cancel_gps=true;
|
||||||
Bangle.setGPSPower(0, "waypoints");
|
Bangle.setGPSPower(0, "waypoints");
|
||||||
|
|
@ -372,10 +409,10 @@ function confirmGps(s) {
|
||||||
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
|
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
|
||||||
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
|
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
|
||||||
{type:"h", c: [
|
{type:"h", c: [
|
||||||
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "YES", cb:l=>{
|
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "Yes", cb:l=>{
|
||||||
print("should mark", key, fix); createWP(fix.lat, fix.lon, fix.alt, key); cancel_gps=true; mainMenu();
|
print("should mark", key, fix); createWP(fix.lat, fix.lon, fix.alt, key); cancel_gps=true; mainMenu();
|
||||||
}},
|
}},
|
||||||
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: " NO", cb:l=>{ cancel_gps=true; mainMenu(); }}
|
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: " No", cb:l=>{ cancel_gps=true; mainMenu(); }}
|
||||||
]}
|
]}
|
||||||
], lazy:true});
|
], lazy:true});
|
||||||
g.clear();
|
g.clear();
|
||||||
|
|
@ -460,15 +497,46 @@ function showNumpad(text, key_, callback) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function goTo() {
|
||||||
|
cancel_gps = false;
|
||||||
|
Bangle.setGPSPower(1, "waypoints");
|
||||||
|
gps.gps_start = getTime();
|
||||||
|
gps_start = getTime();
|
||||||
|
|
||||||
|
var la = new Layout (
|
||||||
|
{type:"v", c: [
|
||||||
|
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
|
||||||
|
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
|
||||||
|
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
|
||||||
|
{type:"h", c: [
|
||||||
|
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: " Done", cb:l=>{ cancel_gps=true; mainMenu(); }}
|
||||||
|
]}
|
||||||
|
], lazy:true});
|
||||||
|
g.clear();
|
||||||
|
la.render();
|
||||||
|
|
||||||
|
|
||||||
|
updateGoto();
|
||||||
|
}
|
||||||
|
|
||||||
function show(pin) {
|
function show(pin) {
|
||||||
var i = wp[pin];
|
var i = wp[pin];
|
||||||
var l = fmt.fmtPos(i);
|
var l = fmt.fmtPos(i);
|
||||||
E.showPrompt(l,{
|
arrow.name = i.name;
|
||||||
title:i["name"],
|
arrow.waypoint = i;
|
||||||
buttons : {"Ok":true}
|
|
||||||
}).then(function(v) {
|
var la = new Layout (
|
||||||
mainMenu();
|
{type:"v", c: [
|
||||||
});
|
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:arrow.name },
|
||||||
|
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:l },
|
||||||
|
{type:"txt", font:"15%", pad:1, fillx:1, filly:1, label:""},
|
||||||
|
{type:"h", c: [
|
||||||
|
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "Go", cb:l=>{ goTo(); }},
|
||||||
|
{type:"btn", font:"15%", pad:1, fillx:1, filly:1, label: "Ok", cb:l=>{ mainMenu(); }}
|
||||||
|
]}
|
||||||
|
], lazy:true});
|
||||||
|
g.clear();
|
||||||
|
la.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCard() {
|
function showCard() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue