diff --git a/apps/gipy/README.md b/apps/gipy/README.md new file mode 100644 index 000000000..f28a2ed46 --- /dev/null +++ b/apps/gipy/README.md @@ -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 diff --git a/apps/gipy/app.js b/apps/gipy/app.js new file mode 100644 index 000000000..92ec0ccfc --- /dev/null +++ b/apps/gipy/app.js @@ -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); + diff --git a/apps/gipy/gipy.img b/apps/gipy/gipy.img new file mode 100644 index 000000000..9d6a7a921 Binary files /dev/null and b/apps/gipy/gipy.img differ diff --git a/apps/gipy/gipy.png b/apps/gipy/gipy.png new file mode 100644 index 000000000..e9e472f5c Binary files /dev/null and b/apps/gipy/gipy.png differ diff --git a/apps/gipy/metadata.json b/apps/gipy/metadata.json new file mode 100644 index 000000000..9f31726d8 --- /dev/null +++ b/apps/gipy/metadata.json @@ -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"} + ] +}