diff --git a/.gitignore b/.gitignore index be33fbc90..757619ec5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ package-lock.json .DS_Store *.js.bak appdates.csv +.vscode diff --git a/apps.json b/apps.json index fde4aeba0..652f8c508 100644 --- a/apps.json +++ b/apps.json @@ -95,7 +95,7 @@ { "id": "gbridge", "name": "Gadgetbridge", "icon": "app.png", - "version":"0.10", + "version":"0.11", "description": "The default notification handler for Gadgetbridge notifications from Android", "tags": "tool,system,android,widget", "type":"widget", @@ -168,7 +168,7 @@ "name": "Image background clock", "shortName":"Image Clock", "icon": "app.png", - "version":"0.06", + "version":"0.07", "description": "A clock with an image as a background", "tags": "clock", "type" : "clock", @@ -331,10 +331,11 @@ { "id": "gpsnav", "name": "GPS Navigation", "icon": "icon.png", - "version":"0.01", - "description": "Displays GPS Course and Speed, + Directions to waypoint and waypoint recording", + "version":"0.03", + "description": "Displays GPS Course and Speed, + Directions to waypoint and waypoint recording, now with waypoint editor", "tags": "tool,outdoors,gps", "readme": "README.md", + "interface":"waypoints.html", "storage": [ {"name":"gpsnav.app.js","url":"app.js"}, {"name":"waypoints.json","url":"waypoints.json","evaluate":false}, @@ -1632,7 +1633,7 @@ "id": "simpletimer", "name": "Timer", "icon": "app.png", - "version": "0.02", + "version": "0.03", "description": "Simple timer, useful when playing board games or cooking", "tags": "timer", "readme": "README.md", @@ -1760,5 +1761,17 @@ { "name": "jbm8b.img", "url": "app-icon.js", "evaluate": true } ], "version": "0.03" + }, + { "id": "widviz", + "name": "Widget Visibility Widget", + "shortName":"Viz Widget", + "icon": "eye.png", + "version":"0.02", + "description": "Swipe left to hide top bar widgets, swipe right to redisplay.", + "tags": "widget", + "type": "widget", + "storage": [ + {"name":"widviz.wid.js","url":"widget.js"} + ] } ] diff --git a/apps/gbridge/ChangeLog b/apps/gbridge/ChangeLog index f23a4eb6d..f66040388 100644 --- a/apps/gbridge/ChangeLog +++ b/apps/gbridge/ChangeLog @@ -9,3 +9,4 @@ 0.08: Don't turn on LCD at start of every song 0.09: Update Bluetooth connection state automatically 0.10: Make widget play well with other Gadgetbridge widgets/apps +0.11: Report battery status on connect and at regular intervals diff --git a/apps/gbridge/widget.js b/apps/gbridge/widget.js index a87b9d1ec..ae7d0f8fa 100644 --- a/apps/gbridge/widget.js +++ b/apps/gbridge/widget.js @@ -13,6 +13,7 @@ }; function gbSend(message) { + Bluetooth.println(""); Bluetooth.println(JSON.stringify(message)); } @@ -196,5 +197,11 @@ WIDGETS["gbridgew"] = { area: "tl", width: 24, draw: draw }; - gbSend({ t: "status", bat: E.getBattery() }); + function sendBattery() { + gbSend({ t: "status", bat: E.getBattery() }); + } + + NRF.on("connect", () => setTimeout(sendBattery, 2000)); + setInterval(sendBattery, 10*60*1000); + sendBattery(); })(); diff --git a/apps/gpsnav/ChangeLog b/apps/gpsnav/ChangeLog index 5560f00bc..d28ad53ac 100644 --- a/apps/gpsnav/ChangeLog +++ b/apps/gpsnav/ChangeLog @@ -1 +1,4 @@ 0.01: New App! +0.02: Add SCREENACCESS interface +0.03: Add Waypoint Editor + diff --git a/apps/gpsnav/README.md b/apps/gpsnav/README.md index 80c6c1d00..af239b233 100644 --- a/apps/gpsnav/README.md +++ b/apps/gpsnav/README.md @@ -26,22 +26,19 @@ The app indicates that WP2 is now marked by adding the prefix @ to it's name. Th ### Waypoint JSON file -When the app is loaded from the app loader, a file named waypoints.json is loaded along with the javascript etc. The file has the following contents: +When the app is loaded from the app loader, a file named `waypoints.json` is loaded along with the javascript etc. The file has the following contents: -~~~ +``` [ { - "mark":0, "name":"NONE" }, { - "mark":1, "name":"No10", "lat":51.5032, "lon":-0.1269 }, { - "mark":1, "name":"Stone", "lat":51.1788, "lon":-1.8260 @@ -52,15 +49,14 @@ When the app is loaded from the app loader, a file named waypoints.json is loade { "name":"WP3" }, { "name":"WP4" } ] -~~~ +``` The file contains the initial NONE waypoint which is useful if you just want to display course and speed. The next two entries are waypoints to No 10 Downing Street and to Stone Henge - obtained from Google Maps. The last five entries are entries which can be *marked*. You add and delete entries using the Web IDE to load and then save the file from and to watch storage. The app itself does not limit the number of entries although it does load the entire file into RAM which will obviously limit this. -I plan to release an accompanying watch app to edit waypoint files in the near future and a way to download your own waypoint file using the app loader. - - - +### Waypoint Editor +Clicking on the download icon of gpsnav in the app loader invokes the waypoint editor. The editor downloads and displays the current `waypoints.json` file. Clicking the `Edit` button beside an entry causes the entry to be deleted from the list and displayed in the edit boxes. It can be restored - by clicking the `Add waypoint` button. A new markable entry is created by using the `Add name` button. The edited `waypoints.json` file is uploaded to the Bangle by clicking the `Upload` button. +*Please report bugs etc. by raising an issue [here](https://github.com/jeffmer/JeffsBangleAppsDev). * \ No newline at end of file diff --git a/apps/gpsnav/app.js b/apps/gpsnav/app.js index 2a480410c..5a6319385 100644 --- a/apps/gpsnav/app.js +++ b/apps/gpsnav/app.js @@ -1,6 +1,7 @@ const Yoff = 40; var pal2color = new Uint16Array([0x0000,0xffff,0x07ff,0xC618],0,2); var buf = Graphics.createArrayBuffer(240,50,2,{msb:true}); +var candraw = true; function flip(b,y) { g.drawImage({width:240,height:50,bpp:2,buffer:b.buffer, palette:pal2color},0,y); @@ -12,6 +13,7 @@ var wpindex=0; const labels = ["N","NE","E","SE","S","SW","W","NW"]; function drawCompass(course) { + if (!candraw) return; buf.setColor(1); buf.setFont("Vector",16); var start = course-90; @@ -143,7 +145,7 @@ function onGPS(fix) { speed = isNaN(fix.speed) ? speed : fix.speed; satellites = fix.satellites; } - if (Bangle.isLCDOn()) { + if (candraw) { if (fix!==undefined && fix.fix==1){ dist = distance(fix,wp); if (isNaN(dist)) dist = 0; @@ -156,28 +158,19 @@ function onGPS(fix) { var intervalRef; -function clearTimers() { +function stopdraw() { + candraw=false; if(intervalRef) {clearInterval(intervalRef);} } function startTimers() { + candraw=true; intervalRefSec = setInterval(function() { newHeading(course,heading); if (course!=heading) drawCompass(heading); },200); } -Bangle.on('lcdPower',function(on) { - if (on) { - g.clear(); - Bangle.drawWidgets(); - startTimers(); - drawAll(); - }else { - clearTimers(); - } -}); - function drawAll(){ g.setColor(1,0.5,0.5); g.fillPoly([120,Yoff+50,110,Yoff+70,130,Yoff+70]); @@ -186,6 +179,42 @@ function drawAll(){ drawCompass(heading); } +function startdraw(){ + g.clear(); + Bangle.drawWidgets(); + startTimers(); + drawAll(); +} + +function setButtons(){ + setWatch(nextwp.bind(null,-1), BTN1, {repeat:true,edge:"falling"}); + setWatch(doselect, BTN2, {repeat:true,edge:"falling"}); + setWatch(nextwp.bind(null,1), BTN3, {repeat:true,edge:"falling"}); +}; + +var SCREENACCESS = { + withApp:true, + request:function(){ + this.withApp=false; + stopdraw(); + clearWatch(); + }, + release:function(){ + this.withApp=true; + startdraw(); + setButtons(); + } +} + +Bangle.on('lcdPower',function(on) { + if (!SCREENACCESS.withApp) return; + if (on) { + startdraw(); + } else { + stopdraw(); + } +}); + var waypoints = require("Storage").readJSON("waypoints.json")||[{name:"NONE"}]; wp=waypoints[0]; @@ -199,8 +228,8 @@ function nextwp(inc){ } function doselect(){ - if (selected && waypoints[wpindex].mark===undefined && savedfix.fix) { - waypoints[wpindex] ={mark:1, name:"@"+wp.name, lat:savedfix.lat, lon:savedfix.lon}; + if (selected && waypoints[wpindex].lat===undefined && savedfix.fix) { + waypoints[wpindex] ={name:"@"+wp.name, lat:savedfix.lat, lon:savedfix.lon}; wp = waypoints[wpindex]; require("Storage").writeJSON("waypoints.json", waypoints); } @@ -218,7 +247,4 @@ drawAll(); startTimers(); Bangle.on('GPS', onGPS); // Toggle selected -setWatch(nextwp.bind(null,-1), BTN1, {repeat:true,edge:"falling"}); -setWatch(doselect, BTN2, {repeat:true,edge:"falling"}); -setWatch(nextwp.bind(null,1), BTN3, {repeat:true,edge:"falling"}); - +setButtons(); diff --git a/apps/gpsnav/waypoints.html b/apps/gpsnav/waypoints.html new file mode 100644 index 000000000..483b933f4 --- /dev/null +++ b/apps/gpsnav/waypoints.html @@ -0,0 +1,170 @@ + +
+ + + + + +| Name | +Lat. | +Long. | +Actions | +
|---|