waypoints: Allow compass rotation.

master
Pavel Machek 2024-11-23 10:22:01 +01:00
parent 673bcc35d5
commit f462f87e11
1 changed files with 12 additions and 11 deletions

View File

@ -191,6 +191,7 @@ let sun = {}; /* To get rid of warnings */
let arrow = { let arrow = {
name: "(unset)", name: "(unset)",
waypoint: { lat: 0, lon: 0 }, waypoint: { lat: 0, lon: 0 },
north: 0,
updateWaypoint: function(lat, lon) { updateWaypoint: function(lat, lon) {
this.waypoint.lat = lat; this.waypoint.lat = lat;
this.waypoint.lon = lon; this.waypoint.lon = lon;
@ -204,10 +205,17 @@ let arrow = {
let waypointBearing = fmt.bearing(currentPos, this.waypoint); let waypointBearing = fmt.bearing(currentPos, this.waypoint);
let distance = fmt.distance(currentPos, this.waypoint); let distance = fmt.distance(currentPos, this.waypoint);
this.north = 0;
let compass = Bangle.getCompass();
if (compass) {
let c = compass.heading;
this.north = c;
print("Compass:", c);
this.drawArrow(c, "Up", 1);
}
northHeading = 0;
// Draw compass arrow for north // Draw compass arrow for north
this.drawArrow(northHeading, "N", 1); this.drawArrow(0, "N", 1);
let s = fmt.fmtDist(distance/1000); let s = fmt.fmtDist(distance/1000);
// Draw arrow towards waypoint // Draw arrow towards waypoint
@ -220,13 +228,6 @@ let arrow = {
this.drawArrow(currentHeading, s, 1); this.drawArrow(currentHeading, s, 1);
} }
let compass = Bangle.getCompass();
if (compass) {
let c = compass.heading;
print("Compass:", c);
this.drawArrow(c, "C", 1);
}
if (0) { if (0) {
let s; let s;
s = sun.sunPos(); s = sun.sunPos();
@ -249,7 +250,7 @@ let arrow = {
drawArrow: function(angle, label, width) { drawArrow: function(angle, label, width) {
// Convert angle to radians // Convert angle to radians
let rad = angle * Math.PI / 180; let rad = (angle - this.north) * Math.PI / 180;
// Arrow parameters // Arrow parameters
let centerX = 88; let centerX = 88;