gipy: eta + zoom changes

master
frederic wagner 2022-12-19 20:42:54 +01:00
parent 60fc2d6d88
commit 8b11c8f4d9
2 changed files with 33 additions and 31 deletions

View File

@ -69,5 +69,4 @@
* Rescale display if lost and too far. * Rescale display if lost and too far.
* New setting to hide points and increase display speed. * New setting to hide points and increase display speed.
* Speed optimisations. * Speed optimisations.
* Display small arrow symbol if going backwards. * Estimated time of Arrival/Going back.
* Estimated time of Arrival.

View File

@ -11,20 +11,6 @@ var settings = Object.assign(
require("Storage").readJSON("gipy.json", true) || {} require("Storage").readJSON("gipy.json", true) || {}
); );
let back_arrow = `
*****
* *****
* *****
** *****
**************
***************
*************
**
*
*
`;
let back_arrow_img = Graphics.createImage(back_arrow);
let profile_start_times = []; let profile_start_times = [];
function start_profiling() { function start_profiling() {
@ -285,7 +271,7 @@ class Status {
let distance_to_projection = this.position.distance(projection); let distance_to_projection = this.position.distance(projection);
if (distance_to_projection > 50) { if (distance_to_projection > 50) {
this.scale_factor = this.scale_factor =
Math.min(66.0 / distance_to_projection, 1.0) * 40000.0; Math.min(88.0 / distance_to_projection, 1.0) * 40000.0;
return true; return true;
} else { } else {
this.scale_factor = 40000.0; this.scale_factor = 40000.0;
@ -336,8 +322,10 @@ class Status {
} }
} }
display_stats(orientation) { display_stats(orientation) {
let remaining_distance = this.remaining_distance(orientation); let remaining_forward_distance = this.remaining_distance(0);
let rounded_distance = Math.round(remaining_distance / 100) / 10; let remaining_backward_distance = this.remaining_distance(1);
let rounded_forward_distance =
Math.round(remaining_forward_distance / 100) / 10;
let total = Math.round(this.remaining_distances[0] / 100) / 10; let total = Math.round(this.remaining_distances[0] / 100) / 10;
let now = new Date(); let now = new Date();
let minutes = now.getMinutes().toString(); let minutes = now.getMinutes().toString();
@ -345,11 +333,7 @@ class Status {
minutes = "0" + minutes; minutes = "0" + minutes;
} }
let hours = now.getHours().toString(); let hours = now.getHours().toString();
g.setFont("6x8:2") // now, distance to next point in meters
.setFontAlign(-1, -1, 0)
.setColor(g.theme.fg)
.drawString(hours + ":" + minutes, 0, 30);
g.setFont("6x8:2").drawString( g.setFont("6x8:2").drawString(
"" + this.distance_to_next_point + "m", "" + this.distance_to_next_point + "m",
0, 0,
@ -362,20 +346,37 @@ class Status {
(this.advanced_distance * 3.6) / done_in (this.advanced_distance * 3.6) / done_in
); );
let eta = compute_eta( let forward_eta = compute_eta(
now.getHours(), now.getHours(),
now.getMinutes(), now.getMinutes(),
approximate_speed, approximate_speed,
remaining_distance / 1000 remaining_forward_distance / 1000
); );
let backward_eta = compute_eta(
now.getHours(),
now.getMinutes(),
approximate_speed,
remaining_backward_distance / 1000
);
// display backward ETA
g.setFont("6x8:2") g.setFont("6x8:2")
.setFontAlign(-1, -1, 0) .setFontAlign(-1, -1, 0)
.setColor(g.theme.fg) .setColor(g.theme.fg)
.drawString(eta, 0, 48); .drawString(backward_eta, 0, 30);
if (orientation == 1) { // display the clock
g.drawImage(back_arrow_img, 62, 32); g.setFont("6x8:2")
} .setFontAlign(-1, -1, 0)
.setColor(g.theme.fg)
.drawString(hours + ":" + minutes, 0, 48);
// now display ETA
g.setFont("6x8:2")
.setFontAlign(-1, -1, 0)
.setColor(g.theme.fg)
.drawString(forward_eta, 0, 66);
// display speed (avg and instant)
let approximate_instant_speed = Math.round(this.instant_speed * 3.6); let approximate_instant_speed = Math.round(this.instant_speed * 3.6);
g.setFont("6x8:2") g.setFont("6x8:2")
.setFontAlign(-1, -1, 0) .setFontAlign(-1, -1, 0)
@ -385,12 +386,14 @@ class Status {
g.getHeight() - 15 g.getHeight() - 15
); );
// display distance on path
g.setFont("6x8:2").drawString( g.setFont("6x8:2").drawString(
"" + rounded_distance + "/" + total, "" + rounded_forward_distance + "/" + total,
0, 0,
g.getHeight() - 32 g.getHeight() - 32
); );
// display various indicators
if (this.distance_to_next_point <= 100) { if (this.distance_to_next_point <= 100) {
if (this.path.is_waypoint(this.reaching)) { if (this.path.is_waypoint(this.reaching)) {
g.setColor(0.0, 1.0, 0.0) g.setColor(0.0, 1.0, 0.0)