diff --git a/apps.json b/apps.json index 48428fb76..0fb69b9cf 100644 --- a/apps.json +++ b/apps.json @@ -1918,5 +1918,18 @@ {"name":"magnav.img","url":"magnav-icon.js","evaluate":true} ], "data":[{"name":"magnav.json"}] + }, + { "id": "gpspoilog", + "name": "GPS POI Logger", + "shortName":"GPS POI Log", + "icon": "app.png", + "version":"0.01", + "description": "A simple app to log points of interest with their GPS coordinates and read them back onto your PC. Based on the https://www.espruino.com/Bangle.js+Storage tutorial", + "tags": "outdoors", + "interface": "interface.html", + "storage": [ + {"name":"gpspoilog.app.js","url":"app.js"}, + {"name":"gpspoilog.img","url":"app-icon.js","evaluate":true} + ] } ] diff --git a/apps/gpspoilog/ChangeLog b/apps/gpspoilog/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/gpspoilog/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/gpspoilog/app-icon.js b/apps/gpspoilog/app-icon.js new file mode 100644 index 000000000..89f8d1bd7 --- /dev/null +++ b/apps/gpspoilog/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AEeGAAwttGMotLGMItPGLwuTGDQuVGDIfHq9RAAgvfDw+AFwtRq4weFZYAIwAvYJIguPSowvavl8F8qpFF6wwSF44AFvl9vo3GF8l80+t1unGAovkvovDvovrAAQvqR4IACR9TviGAovHABIuXF/4vgGAmAFx+AFzDxGACYvVGDAuWF+AwWFzAvwGCguaGCYucF+AwQFzwvwGBwugGBouiF+AwKF0gwJF0wwHF1AvwGAguqGAYusAH4A/AFI=")) diff --git a/apps/gpspoilog/app.js b/apps/gpspoilog/app.js new file mode 100644 index 000000000..2da0c0e7e --- /dev/null +++ b/apps/gpspoilog/app.js @@ -0,0 +1,67 @@ +var menuItems = { + "":{title:"GPS POI Log"}, + " ":{value:"No Fix"}, + "Tree" : ()=>addItem("Tree"), + "Gate" : ()=>addItem("Gate"), + "Flower" : ()=>addItem("Flower"), + "Plant" : ()=>addItem("Plant"), + "Bus Stop" : ()=>addItem("Bus Stop"), + "Pub" : ()=>addItem("Pub") +}; + +var menu = E.showMenu(menuItems); +var gps = { fix : 0}; +var gpsCount = 0; +var file = require("Storage").open("gpspoilog.csv","a"); + +function setStatus(msg) { + menuItems[" "].value = msg; + menu.draw(); +} + +Bangle.on('GPS',function(g) { + gps = g; + gpsCount++; + var msg; + if (g.fix) { + msg = g.satellites + " Satellites"; + } else { + msg = "No Fix"; + } + setStatus(msg+" "+"-\\|/"[gpsCount&3]); +}); + + +function addItem(name) { + if (!gps.fix) { + setStatus("Ignored - no fix"); + return; // don't do anything as no fix + } + // The fields we want to put in out CSV file + var csv = [ + 0|getTime(), // Time to the nearest second + gps.lat, + gps.lon, + gps.alt, + name + ]; + // Write data here + file.write(csv.join(",")+"\n"); + setStatus("Written"); +} + + +Bangle.loadWidgets(); +Bangle.drawWidgets(); +Bangle.setGPSPower(1); + + + +function getData(callback) { + var f = require("Storage").open("gpspoilog.csv","r"); + var l = f.readLine(); + while (l!==undefined) { + callback(l); + l = f.readLine(); + } +} diff --git a/apps/gpspoilog/app.png b/apps/gpspoilog/app.png new file mode 100644 index 000000000..b323bb283 Binary files /dev/null and b/apps/gpspoilog/app.png differ diff --git a/apps/gpspoilog/interface.html b/apps/gpspoilog/interface.html new file mode 100644 index 000000000..ef3cc7688 --- /dev/null +++ b/apps/gpspoilog/interface.html @@ -0,0 +1,69 @@ + + + + + +
+ + + + + + +