From 540bf2fef87ec405a774617a5c491e9363cc8512 Mon Sep 17 00:00:00 2001 From: frederic wagner Date: Sat, 23 Jul 2022 11:00:59 +0200 Subject: [PATCH] minor improvements display direction to next point if lost bugfix: menu --- apps/gipy/ChangeLog | 1 + apps/gipy/TODO | 2 -- apps/gipy/app.js | 15 +++++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/gipy/ChangeLog b/apps/gipy/ChangeLog index eeb484394..4a49e98ea 100644 --- a/apps/gipy/ChangeLog +++ b/apps/gipy/ChangeLog @@ -35,3 +35,4 @@ 0.11: * Better fonts (more free space, still readable). + * Display direction to nearest point when lost. diff --git a/apps/gipy/TODO b/apps/gipy/TODO index 3316412a4..599e1196a 100644 --- a/apps/gipy/TODO +++ b/apps/gipy/TODO @@ -3,11 +3,9 @@ - meters seem to be a bit too long - direction is still shitty on gps ? -- menu is still active below map * additional features -- display direction to nearest point - turn off gps when moving to next waypoint - display distance to next water/toilet - display distance to next waypoint diff --git a/apps/gipy/app.js b/apps/gipy/app.js index 8c8d6af65..8ece4aee4 100644 --- a/apps/gipy/app.js +++ b/apps/gipy/app.js @@ -211,8 +211,8 @@ class Status { // while lowering the cost a lot // // note that all code is inlined here to speed things up from 400ms to 200ms - let start = Math.max(this.current_segment - 3, 0); - let end = Math.min(this.current_segment + 5, this.path.len); + let start = Math.max(this.current_segment - 4, 0); + let end = Math.min(this.current_segment + 6, this.path.len); let pos = this.position; let cos = this.cos_direction; let sin = this.sin_direction; @@ -268,6 +268,16 @@ class Status { // now display ourselves g.setColor(g.theme.fgH); g.fillCircle(half_width, half_height, 5); + + // display direction to next point if lost + if (!this.on_path) { + let next_point = this.path.point(this.current_segment + 1); + let diff = next_point.minus(this.position); + let angle = Math.atan2(diff.lat, diff.lon); + let x = Math.cos(angle) * 30.0 + half_width; + let y = Math.sin(angle) * 30.0 + half_height; + g.setColor(g.theme.fgH).drawLine(half_width, half_height, x, y); + } } } @@ -511,6 +521,7 @@ function drawMenu() { } function start(fn) { + E.showMenu(); console.log("loading", fn); let path = new Path(fn);