forked from FOSS/BangleApps
v008
parent
dafca51365
commit
b70bebdbac
|
@ -7,11 +7,16 @@
|
|||
* We display remaining distance to next point.
|
||||
|
||||
0.06:
|
||||
* Special display for points with steep turns
|
||||
* Buzz on points with steep turns and unlock
|
||||
* Losing gps is now displayed
|
||||
* Special display for points with steep turns.
|
||||
* Buzz on points with steep turns and unlock.
|
||||
* Losing gps is now displayed.
|
||||
|
||||
0.07:
|
||||
* We now use orientation to detect current segment
|
||||
when segments overlap going in both directions.
|
||||
* File format is now versioned.
|
||||
|
||||
0.08:
|
||||
* Don't use gps course anymore but figure it from previous positions.
|
||||
* Bugfix: path colors are back.
|
||||
* Always buzz when reaching waypoint even if unlocked.
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
- gps direction is weak when speed is low
|
||||
|
||||
- water points
|
||||
---> we group them following path by groups of cst_size and record segments ids marking limits
|
||||
|
||||
- turn off gps when moving to next waypoint
|
||||
|
||||
- meters seem to be a bit too long
|
||||
|
||||
- buzzing does not work nicely
|
||||
-> is_list seems fishy
|
||||
|
||||
- store several tracks
|
||||
- display average speed
|
||||
- dynamic map rescale
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
let simulated = false;
|
||||
let code_version = 7;
|
||||
let file_version = 1;
|
||||
let code_key = 47490;
|
||||
|
||||
class Status {
|
||||
|
@ -46,12 +46,10 @@ class Status {
|
|||
}
|
||||
// now check if we strayed away from path or back to it
|
||||
let lost = this.is_lost(next_segment);
|
||||
if (this.on_path == lost) {
|
||||
if (this.on_path == lost) { // if status changes
|
||||
if (lost) {
|
||||
Bangle.buzz(); // we lost path
|
||||
setTimeout(()=>Bangle.buzz(), 300);
|
||||
} else {
|
||||
Bangle.buzz(); // we found path back
|
||||
setTimeout(()=>Bangle.buzz(), 500);
|
||||
}
|
||||
this.on_path = !lost;
|
||||
}
|
||||
|
@ -63,9 +61,10 @@ class Status {
|
|||
this.distance_to_next_point = Math.ceil(this.position.distance(this.path.point(next_point)));
|
||||
if (this.reaching != next_point && this.distance_to_next_point <= 20) {
|
||||
this.reaching = next_point;
|
||||
if (Bangle.isLocked()) {
|
||||
if (this.path.is_waypoint(next_point)) {
|
||||
let reaching_waypoint = this.path.is_waypoint(next_point);
|
||||
if (reaching_waypoint) {
|
||||
Bangle.buzz();
|
||||
if (Bangle.isLocked()) {
|
||||
Bangle.setLocked(false);
|
||||
}
|
||||
}
|
||||
|
@ -113,8 +112,9 @@ class Status {
|
|||
let sin = this.sin_direction;
|
||||
|
||||
// segments
|
||||
let current_segment = this.current_segment;
|
||||
this.path.on_segments(function(p1, p2, i) {
|
||||
if (i == this.current_segment + 1) {
|
||||
if (i == current_segment + 1) {
|
||||
g.setColor(0.0, 1.0, 0.0);
|
||||
} else {
|
||||
g.setColor(1.0, 0.0, 0.0);
|
||||
|
@ -153,7 +153,7 @@ class Path {
|
|||
let key = header[0];
|
||||
let version = header[1];
|
||||
let points_number = header[2];
|
||||
if ((key != code_key)||(version>code_version)) {
|
||||
if ((key != code_key)||(version>file_version)) {
|
||||
E.showMessage("Invalid gpc file");
|
||||
return;
|
||||
}
|
||||
|
@ -305,14 +305,41 @@ let path = new Path("test.gpc");
|
|||
let status = new Status(path);
|
||||
|
||||
let frame = 0;
|
||||
let old_points = []; // remember the at most 3 previous points
|
||||
function set_coordinates(data) {
|
||||
frame += 1;
|
||||
let valid_coordinates = !isNaN(data.lat) && !isNaN(data.lon);
|
||||
if (valid_coordinates) {
|
||||
// we try to figure out direction by looking at previous points
|
||||
// instead of the gps course which is not very nice.
|
||||
let direction = data.course * Math.PI / 180.0;
|
||||
let position = new Point(data.lon, data.lat);
|
||||
if (old_points.length == 0) {
|
||||
old_points.push(position);
|
||||
} else {
|
||||
let last_point = old_points[old_points.length-1];
|
||||
if (last_point.x != position.x || last_point.y != position.y) {
|
||||
if (old_points.length == 4) {
|
||||
old_points.shift();
|
||||
}
|
||||
old_points.push(position);
|
||||
}
|
||||
}
|
||||
if (old_points.length == 4) {
|
||||
// let's just take average angle of 3 previous segments
|
||||
let angles_sum = 0;
|
||||
for(let i = 0 ; i < 3 ; i++) {
|
||||
let p1 = old_points[i];
|
||||
let p2 = old_points[i+1];
|
||||
let diff = p2.minus(p1);
|
||||
let angle = Math.atan2(diff.lat, diff.lon);
|
||||
angles_sum += angle;
|
||||
}
|
||||
status.update_position(position, angles_sum / 3.0);
|
||||
} else {
|
||||
status.update_position(position, direction);
|
||||
}
|
||||
}
|
||||
let gps_status_color;
|
||||
if ((frame % 2 == 0)||valid_coordinates) {
|
||||
gps_status_color = g.theme.bg;
|
||||
|
|
|
@ -11,7 +11,7 @@ mod osm;
|
|||
use osm::InterestPoint;
|
||||
|
||||
const KEY: u16 = 47490;
|
||||
const VERSION: u16 = 7;
|
||||
const FILE_VERSION: u16 = 1;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
pub struct Point {
|
||||
|
@ -332,7 +332,7 @@ fn save_coordinates<P: AsRef<Path>>(path: P, points: &[Point]) -> std::io::Resul
|
|||
|
||||
eprintln!("saving {} points", points.len());
|
||||
writer.write_all(&KEY.to_le_bytes())?;
|
||||
writer.write_all(&VERSION.to_le_bytes())?;
|
||||
writer.write_all(&FILE_VERSION.to_le_bytes())?;
|
||||
writer.write_all(&(points.len() as u16).to_le_bytes())?;
|
||||
points
|
||||
.iter()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "gipy",
|
||||
"name": "Gipy",
|
||||
"shortName": "Gipy",
|
||||
"version": "0.07",
|
||||
"version": "0.08",
|
||||
"description": "Follow gpx files",
|
||||
"allow_emulator":false,
|
||||
"icon": "gipy.png",
|
||||
|
|
Loading…
Reference in New Issue