From 397908afcd060ee7d22f0991d20934f72719a4b7 Mon Sep 17 00:00:00 2001 From: kyleplo <31634240+kyleplo@users.noreply.github.com> Date: Mon, 26 Sep 2022 19:13:42 -0400 Subject: [PATCH 1/6] [Power Saver] Remove accelerometer interval adjustment, fix bugs --- apps/powersave/ChangeLog | 2 ++ apps/powersave/README.md | 2 -- apps/powersave/boot.js | 12 ++++++------ apps/powersave/metadata.json | 5 ++++- apps/powersave/screen.js | 6 +++--- 5 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 apps/powersave/ChangeLog diff --git a/apps/powersave/ChangeLog b/apps/powersave/ChangeLog new file mode 100644 index 000000000..a0e6da646 --- /dev/null +++ b/apps/powersave/ChangeLog @@ -0,0 +1,2 @@ +0.01: Initial release +0.02: Removed accelerometer poll interval adjustment, fixed a few issues with detecting the current app \ No newline at end of file diff --git a/apps/powersave/README.md b/apps/powersave/README.md index 5be5e32b5..51ba044e1 100644 --- a/apps/powersave/README.md +++ b/apps/powersave/README.md @@ -6,7 +6,6 @@ Save your watch's battery power by halting foreground app execution while the sc - Stops foreground app processes - Background processes still run - Clears screen -- Decreases accelerometer polls - Foreground app is returned to when screen is turned back on (app state is not preserved) ## Controls @@ -14,7 +13,6 @@ Save your watch's battery power by halting foreground app execution while the sc - Deactivates when screen is turned back on ## Warnings -- Due to an Espruino bug, this does not take affect immediately when installed. Switch apps for these features to take affect. - This is not compatible with apps that need to run in the foreground even while the screen is off, such as most stopwatch apps and some health trackers. - If you check your watch super often (like multiple times per minute), this may end of costing you more power than it saves since the app you are using will have to restart everytime you check it. diff --git a/apps/powersave/boot.js b/apps/powersave/boot.js index d170e9d59..b8c2c3f78 100644 --- a/apps/powersave/boot.js +++ b/apps/powersave/boot.js @@ -1,15 +1,15 @@ var Storage = Storage || require("Storage"); Bangle.on("lock", locked => { if(locked){ - g.clear().reset(); - Bangle.setLCDBrightness(0); - Bangle.setPollInterval(1000); load("powersave.screen.js"); }else{ - load(Storage.read("resumeaftersleep") || JSON.parse(Storage.read("setting.json")).clock); + const data = JSON.parse(Storage.read("powersave.json") || Storage.read("setting.json")); + load(data.app || data.clock); } }); E.on("init", () => { - if(__FILE__ && __FILE__ !== "powersave.screen.js") - Storage.write("resumeaftersleep", __FILE__); + if("__FILE__" in global && __FILE__ !== "powersave.screen.js") + Storage.write("powersave.json", { + app: __FILE__ + }); }); \ No newline at end of file diff --git a/apps/powersave/metadata.json b/apps/powersave/metadata.json index 50603b2c2..cb2ad9456 100644 --- a/apps/powersave/metadata.json +++ b/apps/powersave/metadata.json @@ -1,7 +1,7 @@ { "id": "powersave", "name": "Power Save", - "version": "0.01", + "version": "0.02", "description": "Halts foreground app execution while screen is off while still allowing background processes.", "readme": "README.md", "icon": "powersave.png", @@ -11,5 +11,8 @@ "storage": [ {"name":"powersave.boot.js","url":"boot.js"}, {"name":"powersave.screen.js","url":"boot.js"} + ], + "data": [ + {"name": "powersave.json"} ] } \ No newline at end of file diff --git a/apps/powersave/screen.js b/apps/powersave/screen.js index f987f0bbb..c920b205d 100644 --- a/apps/powersave/screen.js +++ b/apps/powersave/screen.js @@ -1,7 +1,7 @@ -var Storage = Storage || require("Storage"); g.clear(); Bangle.setLCDBrightness(0); -Bangle.setPollInterval(1000); if(!Bangle.isLocked()){ - load(Storage.read("resumeaftersleep") || JSON.parse(Storage.read("setting.json")).clock); + var Storage = Storage || require("Storage"); + const data = JSON.parse(Storage.read("powersave.json") || Storage.read("setting.json")); + load(data.app || data.clock); } \ No newline at end of file From b1f0b9af1bbe60cd4a792f3fa3bc460146a76c17 Mon Sep 17 00:00:00 2001 From: Marco H Date: Tue, 27 Sep 2022 08:44:14 +0200 Subject: [PATCH 2/6] Do not load AGPS data on boot Increase minimum interval to 12 hours --- apps/agpsdata/ChangeLog | 2 ++ apps/agpsdata/boot.js | 7 ------- apps/agpsdata/metadata.json | 2 +- apps/agpsdata/settings.js | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/agpsdata/ChangeLog b/apps/agpsdata/ChangeLog index ae26512de..c9f074b60 100644 --- a/apps/agpsdata/ChangeLog +++ b/apps/agpsdata/ChangeLog @@ -1,2 +1,4 @@ 0.01: First, proof of concept 0.02: Load AGPS data on app start and automatically in background +0.03: Do not load AGPS data on boot + Increase minimum interval to 12 hours diff --git a/apps/agpsdata/boot.js b/apps/agpsdata/boot.js index 6415f0b52..2b1e6819c 100644 --- a/apps/agpsdata/boot.js +++ b/apps/agpsdata/boot.js @@ -16,13 +16,6 @@ } if (settings.enabled) { - let lastUpdate = settings.lastUpdate; - if (!lastUpdate || lastUpdate + settings.refresh * 1000 * 60 < Date.now()){ - if (!waiting){ - waiting = true; - require("agpsdata").pull(successCallback, errorCallback); - } - } setInterval(() => { if (!waiting && NRF.getSecurityStatus().connected){ waiting = true; diff --git a/apps/agpsdata/metadata.json b/apps/agpsdata/metadata.json index e2f818d97..1ce299532 100644 --- a/apps/agpsdata/metadata.json +++ b/apps/agpsdata/metadata.json @@ -2,7 +2,7 @@ "name": "A-GPS Data Downloader App", "shortName":"A-GPS Data", "icon": "agpsdata.png", - "version":"0.02", + "version":"0.03", "description": "Once installed, this app allows you to download assisted GPS (A-GPS) data directly to your Bangle.js **via Gadgetbridge on an Android phone** when you run the app. If you just want to upload the latest AGPS data from this app loader, please use the `Assisted GPS Update (AGPS)` app.", "tags": "boot,tool,assisted,gps,agps,http", "allow_emulator":true, diff --git a/apps/agpsdata/settings.js b/apps/agpsdata/settings.js index 80a2f3956..fc87f1bc0 100644 --- a/apps/agpsdata/settings.js +++ b/apps/agpsdata/settings.js @@ -35,7 +35,7 @@ function buildMainMenu() { }, "Refresh every" : { value : settings.refresh / 60, - min : 1, + min : 12, max : 168, step : 1, format : v => v + "h", From 83e5f681c2ac2bbfbeb8609313a4da46b95c9a01 Mon Sep 17 00:00:00 2001 From: kyleplo <31634240+kyleplo@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:19:40 -0400 Subject: [PATCH 3/6] Default to clock --- apps/powersave/boot.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/powersave/boot.js b/apps/powersave/boot.js index b8c2c3f78..5c37dcc56 100644 --- a/apps/powersave/boot.js +++ b/apps/powersave/boot.js @@ -8,8 +8,13 @@ Bangle.on("lock", locked => { } }); E.on("init", () => { - if("__FILE__" in global && __FILE__ !== "powersave.screen.js") - Storage.write("powersave.json", { - app: __FILE__ - }); + if("__FILE__" in global && __FILE__ !== "powersave.screen.js"){ + Storage.write("powersave.json", { + app: __FILE__ + }); + }else{ + Storage.write("powersave.json", { + app: null + }); + } }); \ No newline at end of file From aa6885b3156dc405e54c23a30856fdcc7f214463 Mon Sep 17 00:00:00 2001 From: Marco H Date: Wed, 28 Sep 2022 09:41:32 +0200 Subject: [PATCH 4/6] Set minimum to 6 hours --- apps/agpsdata/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/agpsdata/settings.js b/apps/agpsdata/settings.js index fc87f1bc0..64fa25330 100644 --- a/apps/agpsdata/settings.js +++ b/apps/agpsdata/settings.js @@ -35,7 +35,7 @@ function buildMainMenu() { }, "Refresh every" : { value : settings.refresh / 60, - min : 12, + min : 6, max : 168, step : 1, format : v => v + "h", From c5349441384364aa6416c5a3256b99fb16bb7d8c Mon Sep 17 00:00:00 2001 From: Marco H Date: Wed, 28 Sep 2022 09:43:34 +0200 Subject: [PATCH 5/6] Update changelog --- apps/agpsdata/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/agpsdata/ChangeLog b/apps/agpsdata/ChangeLog index c9f074b60..89844a132 100644 --- a/apps/agpsdata/ChangeLog +++ b/apps/agpsdata/ChangeLog @@ -1,4 +1,4 @@ 0.01: First, proof of concept 0.02: Load AGPS data on app start and automatically in background 0.03: Do not load AGPS data on boot - Increase minimum interval to 12 hours + Increase minimum interval to 6 hours From 1b20bb6af88b2fa4591c1f81bbb6cd996a1a32a1 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 28 Sep 2022 09:15:04 +0100 Subject: [PATCH 6/6] 0.16: Bangle.http now fails immediately if there is no Bluetooth connection (fix #2152) --- apps/android/ChangeLog | 1 + apps/android/boot.js | 2 ++ apps/android/metadata.json | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/android/ChangeLog b/apps/android/ChangeLog index 0cc7aedd4..a65326941 100644 --- a/apps/android/ChangeLog +++ b/apps/android/ChangeLog @@ -13,3 +13,4 @@ 0.13: Added Bangle.http function (see Readme file for more info) 0.14: Fix timeout of http function not being cleaned up 0.15: Allow method/body/headers to be specified for `http` (needs Gadgetbridge 0.68.0b or later) +0.16: Bangle.http now fails immediately if there is no Bluetooth connection (fix #2152) diff --git a/apps/android/boot.js b/apps/android/boot.js index bc8e3032d..0d1edae99 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -139,6 +139,8 @@ // options = {id,timeout,xpath} Bangle.http = (url,options)=>{ options = options||{}; + if (!NRF.getSecurityStatus().connected) + return Promise.reject("Not connected to Bluetooth"); if (Bangle.httpRequest === undefined) Bangle.httpRequest={}; if (options.id === undefined) { diff --git a/apps/android/metadata.json b/apps/android/metadata.json index 5d1b2f561..ab340340c 100644 --- a/apps/android/metadata.json +++ b/apps/android/metadata.json @@ -2,7 +2,7 @@ "id": "android", "name": "Android Integration", "shortName": "Android", - "version": "0.15", + "version": "0.16", "description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.", "icon": "app.png", "tags": "tool,system,messages,notifications,gadgetbridge",