turn gps off

master
frederic wagner 2022-07-26 09:44:42 +02:00
parent e26aafc4fa
commit 84e9d12a09
3 changed files with 20 additions and 9 deletions

View File

@ -37,3 +37,4 @@
* Better fonts (more free space, still readable).
* Display direction to nearest point when lost.
* Display average speed.
* Turn off gps when locked and between points

View File

@ -2,16 +2,13 @@
* bugs
- meters seem to be a bit too long
- direction is still shitty on gps ?
- segment detection could be better ?
* additional features
- turn off gps when moving to next waypoint
- display distance to next water/toilet
- display distance to next water/toilet ?
- dynamic map rescale
- display scale (100m)
- get waypoints from osm
- compress path ?

View File

@ -124,6 +124,16 @@ class Status {
this.distance_to_next_point = Math.ceil(
this.position.distance(this.path.point(next_point))
);
// disable gps when far from next point and locked
if (Bangle.isLocked()) {
let time_to_next_point = this.distance_to_next_point / 9.7; // 30km/h is 8.3 m/s
if (time_to_next_point > 30) {
Bangle.setGPSPower(false, "gipy");
setTimeout(function () {
Bangle.setGPSPower(true, "gipy");
}, time_to_next_point);
}
}
if (this.reaching != next_point && this.distance_to_next_point <= 20) {
this.reaching = next_point;
let reaching_waypoint = this.path.is_waypoint(next_point);
@ -134,10 +144,8 @@ class Status {
}
}
}
// re-display unless locked
if (!Bangle.isLocked() || simulated) {
this.display();
}
// re-display
this.display();
}
remaining_distance() {
return (
@ -610,6 +618,11 @@ function start(fn) {
Bangle.setGPSPower(true, "gipy");
Bangle.on("GPS", set_coordinates);
Bangle.on("lock", function (on) {
if (!on) {
Bangle.setGPSPower(true, "gipy"); // activate gps when unlocking
}
});
}
}