gipy : initial commit

pull/2234/head
frederic wagner 2022-07-11 16:51:03 +02:00
parent c68fb80071
commit f32ab8383b
5 changed files with 120 additions and 0 deletions

13
apps/gipy/README.md Normal file
View File

@ -0,0 +1,13 @@
# Gipy
Development still in progress. Follow compressed gpx traces.
Warns you before reaching intersections and tries to turn off gps.
## Usage
WIP.
## Creator
frederic.wagner@imag.fr

85
apps/gipy/app.js Normal file
View File

@ -0,0 +1,85 @@
// screen size is 172x172
// we want to show 100 meters ahead
// 86 pixels is 100 meters
// 10 meters is 8.6 pixels
// 1 integer unit is 1.1 meter
// 8.6 pixels is 10 / 1.1 integers
// int = 8.6 pix * 1.1 / 10
// int = 0.946 pixels
var lat = null;
var lon = null;
class Path {
constructor(filename) {
let buffer = require("Storage").readArrayBuffer(filename);
this.points_number = (buffer.byteLength - 2*8)/4;
this.view = DataView(buffer);
this.min_lon = this.view.getFloat64(0);
this.min_lat = this.view.getFloat64(8);
this.current_start = 0; // index of first point to be displayed
this.current_x = 0;
this.current_y = 0;
}
get len() {
return this.points_number;
}
}
class Point {
constructor(lon, lat) {
this.lon = lon;
this.lat = lat;
}
screen_x() {
return 192/2 + Math.round((this.lon - lon) * 100000.0);
}
screen_y() {
return 192/2 + Math.round((this.lat - lat) * 100000.0);
}
}
function display(path) {
g.clear();
let previous_point = null;
let current_x = path.current_x;
let current_y = path.current_y;
for (let i = path.current_start ; i < path.len ; i++) {
current_x += path.view.getInt16(2*8+4*i);
current_y += path.view.getInt16(2*8+4*i+2);
let point = new Point(current_x/100000.0 + path.min_lon, current_y/100000.0 + path.min_lat);
if (previous_point !== null) {
g.drawLine(
previous_point.screen_x(),
previous_point.screen_y(),
point.screen_x(),
point.screen_y()
);
}
previous_point = point;
}
g.setColor(1.0, 0.0, 0.0);
g.fillCircle(192/2, 192/2, 5);
}
let path = new Path("test.gpc");
lat = path.min_lat;
lon = path.min_lon;
function set_coordinates(data) {
if (!isNaN(data.lat)) {
lat = data.lat;
}
if (!isNaN(data.lon)) {
lon = data.lon;
}
}
Bangle.setGPSPower(true, "gipy");
Bangle.on('GPS', set_coordinates);
setInterval(display, 1000, path);

BIN
apps/gipy/gipy.img Normal file

Binary file not shown.

BIN
apps/gipy/gipy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

22
apps/gipy/metadata.json Normal file
View File

@ -0,0 +1,22 @@
{
"id": "gipy",
"name": "Gipy",
"shortName": "Gipy",
"version": "0.01",
"description": "Follow gpx files",
"allow_emulator":false,
"icon": "gipy.img",
"type": "app",
"tags": "tool,outdoors,gps",
"screenshots": [{"url":"screenshot_gipy.png"}],
"supports": ["BANGLEJS2"],
"readme": "README.md",
"storage": [
{"name":"gipy.app.js","url":"app.js"},
{"name":"gipy.img","url":"gipy-icon.js","evaluate":true},
{"name":"gipy.settings.js","url":"settings.js"}
],
"data": [
{"name":"gipy.gpc"}
]
}