From f03c566ee28e9b66587c6704dc3bd1fa0e498ce9 Mon Sep 17 00:00:00 2001 From: Hilmar Strauch <56518493+HilmarSt@users.noreply.github.com> Date: Mon, 17 Jan 2022 16:38:44 +0100 Subject: [PATCH 1/8] Update gps-info.js Show satellites "in view" separated by GNS-system --- apps/gpsinfo/gps-info.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/apps/gpsinfo/gps-info.js b/apps/gpsinfo/gps-info.js index f4521f265..d26e1575c 100644 --- a/apps/gpsinfo/gps-info.js +++ b/apps/gpsinfo/gps-info.js @@ -16,9 +16,8 @@ var lastFix = { time: 0, satellites: 0 }; -var SATinView = 0; -var nofBD = 0; -var nofGP = 0; +var SATinView = 0, lastSATinView = -1, nofGP = 0, nofBD = 0, nofGL = 0; +const leaveNofixLayout = 1; // 0 = stay on initial screen for debugging (default = 1) var listenerGPSraw = 0; function formatTime(now) { @@ -63,7 +62,7 @@ function getMaidenHead(param1,param2){ function onGPS(fix) { if (lastFix.fix != fix.fix) { // if fix is different, change the layout - if (fix.fix) { + if (fix.fix && leaveNofixLayout) { layout = new Layout( { type:"v", c: [ {type:"txt", font:"6x8:2", label:"GPS Info" }, @@ -92,11 +91,11 @@ function onGPS(fix) { g.clearRect(0,24,g.getWidth(),g.getHeight()); layout.render(); } - //lastFix = fix; - if (fix.fix) { + if (fix.fix && leaveNofixLayout) { if (listenerGPSraw == 1) { Bangle.removeListener('GPS-raw', onGPSraw); listenerGPSraw = 0; + lastSATinView = -1; } var locale = require("locale"); var satellites = fix.satellites; @@ -115,27 +114,31 @@ function onGPS(fix) { layout.sat.label = fix.satellites; layout.render(layout.sat); } - if (SATinView != lastFix.SATinView) { + if (SATinView != lastSATinView) { + if (!leaveNofixLayout) SATinView = -1; + lastSATinView = SATinView; layout.clear(layout.progress); - layout.progress.label = "in view: " + SATinView; + layout.progress.label = "in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL; + // console.log("in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL); layout.render(layout.progress); } } - //layout.render(); if (listenerGPSraw == 0 && !fix.fix) { setTimeout(() => Bangle.on('GPS-raw', onGPSraw), 10); listenerGPSraw = 1; } - lastFix = fix; - lastFix.SATinView = SATinView; } function onGPSraw(nmea) { - if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13)); - if (nmea.slice(0,7) == "$GPGSV,") nofGP = Number(nmea.slice(11,13)); - SATinView = nofBD + nofGP; + if (nmea.slice(3,6) == "GSV") { + // console.log(nmea.slice(1,3) + " " + nmea.slice(11,13)); + if (nmea.slice(0,7) == "$GPGSV,") nofGP = Number(nmea.slice(11,13)); + if (nmea.slice(0,7) == "$BDGSV,") nofBD = Number(nmea.slice(11,13)); + if (nmea.slice(0,7) == "$GLGSV,") nofGL = Number(nmea.slice(11,13)); + SATinView = nofGP + nofBD + nofGL; + } } From a253aaa148daaa1be8ef35862afa8186759af7b0 Mon Sep 17 00:00:00 2001 From: Hilmar Strauch <56518493+HilmarSt@users.noreply.github.com> Date: Mon, 17 Jan 2022 16:39:16 +0100 Subject: [PATCH 2/8] Update ChangeLog --- apps/gpsinfo/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/gpsinfo/ChangeLog b/apps/gpsinfo/ChangeLog index 414b9d9fb..5bb531bc7 100644 --- a/apps/gpsinfo/ChangeLog +++ b/apps/gpsinfo/ChangeLog @@ -6,3 +6,4 @@ 0.07: Resolve one FIFO_FULL case and exit App with button press 0.08: Leave GPS power switched on on exit (will switch off after 0.5 seconds anyway) 0.09: Fix FIFO_FULL error +0.10: Show satellites "in view" separated by GNS-system From 1fbc8a643a6ec9230a12f7abfb52ffa70a7d2dec Mon Sep 17 00:00:00 2001 From: Hilmar Strauch <56518493+HilmarSt@users.noreply.github.com> Date: Mon, 17 Jan 2022 16:39:54 +0100 Subject: [PATCH 3/8] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 2e11e37f6..0ee6eb62b 100644 --- a/apps.json +++ b/apps.json @@ -1541,7 +1541,7 @@ { "id": "gpsinfo", "name": "GPS Info", - "version": "0.09", + "version": "0.10", "description": "An application that displays information about altitude, lat/lon, satellites and time", "icon": "gps-info.png", "type": "app", From 97fb4d77dcc08056e6ba356f19e7f0f5936a6aa9 Mon Sep 17 00:00:00 2001 From: Hilmar Strauch <56518493+HilmarSt@users.noreply.github.com> Date: Mon, 17 Jan 2022 16:46:41 +0100 Subject: [PATCH 4/8] debug mode --- apps/gpsinfo/gps-info.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/gpsinfo/gps-info.js b/apps/gpsinfo/gps-info.js index d26e1575c..1ee3cd6cc 100644 --- a/apps/gpsinfo/gps-info.js +++ b/apps/gpsinfo/gps-info.js @@ -17,7 +17,7 @@ var lastFix = { satellites: 0 }; var SATinView = 0, lastSATinView = -1, nofGP = 0, nofBD = 0, nofGL = 0; -const leaveNofixLayout = 1; // 0 = stay on initial screen for debugging (default = 1) +const leaveNofixLayout = 0; // 0 = stay on initial screen for debugging (default = 1) var listenerGPSraw = 0; function formatTime(now) { @@ -119,7 +119,7 @@ function onGPS(fix) { lastSATinView = SATinView; layout.clear(layout.progress); layout.progress.label = "in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL; - // console.log("in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL); + console.log("in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL); layout.render(layout.progress); } } From feef089abac9dab0b07bac9a5de52220346e7319 Mon Sep 17 00:00:00 2001 From: Hilmar Strauch <56518493+HilmarSt@users.noreply.github.com> Date: Tue, 18 Jan 2022 11:44:31 +0100 Subject: [PATCH 5/8] Update gps-info.js --- apps/gpsinfo/gps-info.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/gpsinfo/gps-info.js b/apps/gpsinfo/gps-info.js index 1ee3cd6cc..0eca2ccf5 100644 --- a/apps/gpsinfo/gps-info.js +++ b/apps/gpsinfo/gps-info.js @@ -17,7 +17,7 @@ var lastFix = { satellites: 0 }; var SATinView = 0, lastSATinView = -1, nofGP = 0, nofBD = 0, nofGL = 0; -const leaveNofixLayout = 0; // 0 = stay on initial screen for debugging (default = 1) +const leaveNofixLayout = 1; // 0 = stay on initial screen for debugging (default = 1) var listenerGPSraw = 0; function formatTime(now) { @@ -96,6 +96,7 @@ function onGPS(fix) { Bangle.removeListener('GPS-raw', onGPSraw); listenerGPSraw = 0; lastSATinView = -1; + Bangle.buzz(50); } var locale = require("locale"); var satellites = fix.satellites; @@ -119,7 +120,7 @@ function onGPS(fix) { lastSATinView = SATinView; layout.clear(layout.progress); layout.progress.label = "in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL; - console.log("in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL); + // console.log("in view GP/BD/GL: " + nofGP + " " + nofBD + " " + nofGL); layout.render(layout.progress); } } From 96b11df930aa9f5dd3096fac0e26f35c1ea2988f Mon Sep 17 00:00:00 2001 From: Hilmar Strauch <56518493+HilmarSt@users.noreply.github.com> Date: Tue, 18 Jan 2022 13:01:36 +0100 Subject: [PATCH 6/8] Update ChangeLog --- apps/slevel/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/slevel/ChangeLog b/apps/slevel/ChangeLog index 3a6431e50..63a4d34d5 100644 --- a/apps/slevel/ChangeLog +++ b/apps/slevel/ChangeLog @@ -1,2 +1,3 @@ 0.01: New App! 0.02: Updated to work with both Bangle.js 1 and 2. +0.03: Now also visible on Bangle.js 2 From e539013c8ee843311d155e0c2d5ccf4fe66adc18 Mon Sep 17 00:00:00 2001 From: Hilmar Strauch <56518493+HilmarSt@users.noreply.github.com> Date: Tue, 18 Jan 2022 13:02:43 +0100 Subject: [PATCH 7/8] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 0ee6eb62b..758c4ca78 100644 --- a/apps.json +++ b/apps.json @@ -839,7 +839,7 @@ { "id": "slevel", "name": "Spirit Level", - "version": "0.02", + "version": "0.03", "description": "Show the current angle of the watch, so you can use it to make sure something is absolutely flat", "icon": "spiritlevel.png", "tags": "tool", From 6d5df8019e3e3b9affc846021ce373d8b24d4f4e Mon Sep 17 00:00:00 2001 From: Hilmar Strauch <56518493+HilmarSt@users.noreply.github.com> Date: Tue, 18 Jan 2022 13:05:09 +0100 Subject: [PATCH 8/8] Update spiritlevel.js Now also visible on Bangle.js 2 --- apps/slevel/spiritlevel.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/slevel/spiritlevel.js b/apps/slevel/spiritlevel.js index 9db54b825..be56f3c11 100644 --- a/apps/slevel/spiritlevel.js +++ b/apps/slevel/spiritlevel.js @@ -2,6 +2,13 @@ g.clear(); var old = {x:0,y:0}; var W = g.getWidth(); var H = g.getHeight(); + +// colour definitions for Bangle.js 2 +const RED = "#ff0000"; +const GRN = "#00ff00"; +const BLU = "#0000ff"; +const HwVer = process.env.HWVERSION; + Bangle.on('accel',function(v) { var max = Math.max(Math.abs(v.x),Math.abs(v.y),Math.abs(v.z)); if (Math.abs(v.y)==max) { @@ -12,7 +19,8 @@ Bangle.on('accel',function(v) { var d = Math.sqrt(v.x*v.x+v.y*v.y); var ang = Math.atan2(d,Math.abs(v.z))*180/Math.PI; - + + if (2 == HwVer) g.setColor(RED); else g.setColor(1,1,1); g.setFont("6x8",2); g.setFontAlign(0,-1); @@ -22,11 +30,19 @@ Bangle.on('accel',function(v) { x:E.clip(W/2+v.x*256,4,W-4), y:E.clip(H/2+v.y*256,4,H-4)}; g.clearRect(old.x-3,old.y-3,old.x+6,old.y+6); + if (2 == HwVer) g.setColor(GRN); else g.setColor(1,1,1); g.fillRect(n.x-3,n.y-3,n.x+6,n.y+6); + if (2 == HwVer) g.setColor(BLU); else g.setColor(1,0,0); g.drawCircle(W/2,H/2,W*(1/12)); g.drawCircle(W/2,H/2,W*(1/4)); g.drawCircle(W/2,H/2,W*(5/12)); old = n; }); + +setWatch(_=>load(), BTN1); +if (global.BTN2) { + setWatch(_=>load(), BTN2); + setWatch(_=>load(), BTN3); +}