From 123d4814696eafc50062b774a62b7fdc90b80518 Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Mon, 4 Apr 2022 12:22:04 -0500 Subject: [PATCH 01/33] Running setScan with active: true --- apps/bthrm/settings.js | 2 +- apps/health/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/bthrm/settings.js b/apps/bthrm/settings.js index 4b564d670..9f409880a 100644 --- a/apps/bthrm/settings.js +++ b/apps/bthrm/settings.js @@ -127,7 +127,7 @@ }); }; } - }, { filters: [{services: [ "180d" ]}]}); + }, { active: true, filters: [{services: [ "180d" ]}]}); } diff --git a/apps/health/README.md b/apps/health/README.md index f44854e3e..e3a84068b 100644 --- a/apps/health/README.md +++ b/apps/health/README.md @@ -2,7 +2,7 @@ Logs health data to a file every 10 minutes, and provides an app to view it -**BETA - requires firmware 2v11** +**BETA - requires firmware 2v11 or later** ## Usage From d27deac8aadfa6f9393e31aa26c4c69bb4f39dd2 Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Mon, 4 Apr 2022 14:47:17 -0500 Subject: [PATCH 02/33] Adding 'active: true' to NRF.requestDevice call made when btname is set --- apps/bthrm/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index 3a1f1cc4c..93e72b83b 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -370,7 +370,7 @@ filters = [{name: settings.btname}]; } log("Requesting device with filters", filters); - promise = NRF.requestDevice({ filters: filters }); + promise = NRF.requestDevice({ filters: filters, active: true }); if (settings.gracePeriodRequest){ log("Add " + settings.gracePeriodRequest + "ms grace period after request"); From d89db8f7d7f680c11aa73780c50483364972059b Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Mon, 4 Apr 2022 15:55:14 -0500 Subject: [PATCH 03/33] Removing call to function that doesn't exist --- apps/bthrm/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index 93e72b83b..227f78c1a 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -108,7 +108,7 @@ var sensorContact; if (flags & 2){ - sensorContact = (flags & 4) ? true : false; + sensorContact = !!(flags & 4); } var idx = 2 + (flags&1); @@ -297,7 +297,7 @@ }); } else if (newCharacteristic.read){ result = result.then(()=>{ - readData(newCharacteristic); + // readData(newCharacteristic); log("Reading data for " + newCharacteristic); return newCharacteristic.read().then((data)=>{ supportedCharacteristics[newCharacteristic.uuid].handler(data); From 75c4e5b54b54181c054bbb2a68603435f02761cf Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Mon, 4 Apr 2022 16:48:15 -0500 Subject: [PATCH 04/33] bthrm fixes for reading characteristics generally and displaying location --- apps/bthrm/boot.js | 17 +++++++++-------- apps/bthrm/bthrm.js | 13 +++++++++++-- typescript/types/globals.d.ts | 6 +++--- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index 227f78c1a..dd25634e5 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -168,14 +168,14 @@ //Body sensor location handler: function(data){ if (!lastReceivedData["0x180d"]) lastReceivedData["0x180d"] = {}; - if (!lastReceivedData["0x180d"]["0x2a38"]) lastReceivedData["0x180d"]["0x2a38"] = data.target.value; + lastReceivedData["0x180d"]["0x2a38"] = parseInt(data.buffer, 10); } }, "0x2a19": { //Battery handler: function (event){ - if (!lastReceivedData["0x180f"]) lastReceivedData["0x180f"] = {}; - if (!lastReceivedData["0x180f"]["0x2a19"]) lastReceivedData["0x180f"]["0x2a19"] = event.target.value.getUint8(0); + if (!lastReceivedData["0x180f"]) lastReceivedData["0x180f"] = { "0x2a19": null }; + lastReceivedData["0x180f"]["0x2a19"] = event.target.value.getUint8(0); } } @@ -295,12 +295,13 @@ } return startPromise; }); - } else if (newCharacteristic.read){ + } else if (newCharacteristic.readValue){ result = result.then(()=>{ - // readData(newCharacteristic); - log("Reading data for " + newCharacteristic); - return newCharacteristic.read().then((data)=>{ - supportedCharacteristics[newCharacteristic.uuid].handler(data); + log("Reading data for " + JSON.stringify(newCharacteristic)); + return newCharacteristic.readValue().then((data)=>{ + if (supportedCharacteristics[newCharacteristic.uuid] && supportedCharacteristics[newCharacteristic.uuid].handler) { + supportedCharacteristics[newCharacteristic.uuid].handler(data); + } }); }); } diff --git a/apps/bthrm/bthrm.js b/apps/bthrm/bthrm.js index cc533eedd..5ab3b0018 100644 --- a/apps/bthrm/bthrm.js +++ b/apps/bthrm/bthrm.js @@ -1,7 +1,16 @@ -var btm = g.getHeight()-1; var intervalInt; var intervalBt; +var BODY_LOCS = { + 0: 'Other', + 1: 'Chest', + 2: 'Wrist', + 3: 'Finger', + 4: 'Hand', + 5: 'Ear Lobe', + 6: 'Foot', +} + function clear(y){ g.reset(); g.clearRect(0,y,g.getWidth(),y+75); @@ -25,7 +34,7 @@ function draw(y, type, event) { if (event.battery) str += " Bat: " + (event.battery ? event.battery : ""); g.setFontVector(12).drawString(str,px,y+40); str= ""; - if (event.location) str += "Loc: " + event.location.toFixed(0) + "ms"; + if (event.location) str += "Loc: " + BODY_LOCS[event.location]; if (event.rr && event.rr.length > 0) str += " RR: " + event.rr.join(","); g.setFontVector(12).drawString(str,px,y+50); str= ""; diff --git a/typescript/types/globals.d.ts b/typescript/types/globals.d.ts index 2ef52dcdf..442140e70 100644 --- a/typescript/types/globals.d.ts +++ b/typescript/types/globals.d.ts @@ -158,9 +158,9 @@ declare type Image = { }; declare type GraphicsApi = { - reset: () => void; + reset: () => GraphicsApi; flip: () => void; - setColor: (color: string) => void; // TODO we can most likely type color more usefully than this + setColor: (color: string) => GraphicsApi; // TODO we can most likely type color more usefully than this drawImage: ( image: string | Image | ArrayBuffer, xOffset: number, @@ -169,7 +169,7 @@ declare type GraphicsApi = { rotate?: number; scale?: number; } - ) => void; + ) => GraphicsApi; // TODO add more }; From d19a68e5117904689b9a35706fceeb64f3bd04fc Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Mon, 4 Apr 2022 17:29:20 -0500 Subject: [PATCH 05/33] Fix how events and reads were handled differently --- apps/bthrm/boot.js | 55 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index dd25634e5..0a6af55b6 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -31,7 +31,7 @@ function addNotificationHandler(characteristic){ log("Setting notification handler: " + supportedCharacteristics[characteristic.uuid].handler); - characteristic.on('characteristicvaluechanged', supportedCharacteristics[characteristic.uuid].handler); + characteristic.on('characteristicvaluechanged', (ev) => supportedCharacteristics[characteristic.uuid].handler(ev.target.value)); } function writeCache(cache){ @@ -92,15 +92,14 @@ services: [ "180d" ] }]; - supportedServices = [ + var supportedServices = [ "0x180d", "0x180f" ]; var supportedCharacteristics = { "0x2a37": { //Heart rate measurement - handler: function (event){ - var dv = event.target.value; + handler: function (dv){ var flags = dv.getUint8(0); var bpm = (flags & 1) ? (dv.getUint16(1) / 100 /* ? */ ) : dv.getUint8(1); // 8 or 16 bit @@ -121,7 +120,7 @@ var interval; if (flags & 16) { interval = []; - maxIntervalBytes = (dv.byteLength - idx); + var maxIntervalBytes = (dv.byteLength - idx); log("Found " + (maxIntervalBytes / 2) + " rr data fields"); for(var i = 0 ; i < maxIntervalBytes / 2; i++){ interval[i] = dv.getUint16(idx,1); // in milliseconds @@ -140,14 +139,14 @@ } if (settings.replace){ - var newEvent = { + var repEvent = { bpm: bpm, confidence: (sensorContact || sensorContact === undefined)? 100 : 0, src: "bthrm" }; - log("Emitting HRM: ", newEvent); - Bangle.emit("HRM", newEvent); + log("Emitting HRM: ", repEvent); + Bangle.emit("HRM", repEvent); } var newEvent = { @@ -159,23 +158,23 @@ if (energyExpended) newEvent.energy = energyExpended; if (battery) newEvent.battery = battery; if (sensorContact) newEvent.contact = sensorContact; - + log("Emitting BTHRM: ", newEvent); Bangle.emit("BTHRM", newEvent); } }, "0x2a38": { //Body sensor location - handler: function(data){ + handler: function(dv){ if (!lastReceivedData["0x180d"]) lastReceivedData["0x180d"] = {}; - lastReceivedData["0x180d"]["0x2a38"] = parseInt(data.buffer, 10); + lastReceivedData["0x180d"]["0x2a38"] = parseInt(dv.buffer, 10); } }, "0x2a19": { //Battery - handler: function (event){ - if (!lastReceivedData["0x180f"]) lastReceivedData["0x180f"] = { "0x2a19": null }; - lastReceivedData["0x180f"]["0x2a19"] = event.target.value.getUint8(0); + handler: function (dv){ + if (!lastReceivedData["0x180f"]) lastReceivedData["0x180f"] = {}; + lastReceivedData["0x180f"]["0x2a19"] = dv.getUint8(0); } } @@ -282,6 +281,18 @@ function createCharacteristicPromise(newCharacteristic){ log("Create characteristic promise: ", newCharacteristic); var result = Promise.resolve(); + // For values that can be read, go ahead and read them, even if we might be notified in the future + // Allows for getting initial state of infrequently updating characteristics, like battery + if (newCharacteristic.readValue){ + result = result.then(()=>{ + log("Reading data for " + JSON.stringify(newCharacteristic)); + return newCharacteristic.readValue().then((data)=>{ + if (supportedCharacteristics[newCharacteristic.uuid] && supportedCharacteristics[newCharacteristic.uuid].handler) { + supportedCharacteristics[newCharacteristic.uuid].handler(data); + } + }); + }); + } if (newCharacteristic.properties.notify){ result = result.then(()=>{ log("Starting notifications for: ", newCharacteristic); @@ -295,15 +306,6 @@ } return startPromise; }); - } else if (newCharacteristic.readValue){ - result = result.then(()=>{ - log("Reading data for " + JSON.stringify(newCharacteristic)); - return newCharacteristic.readValue().then((data)=>{ - if (supportedCharacteristics[newCharacteristic.uuid] && supportedCharacteristics[newCharacteristic.uuid].handler) { - supportedCharacteristics[newCharacteristic.uuid].handler(data); - } - }); - }); } return result.then(()=>log("Handled characteristic: ", newCharacteristic)); } @@ -526,10 +528,9 @@ } }; } - - + var fallbackInterval; - + function switchInternalHrm(){ if (settings.allowFallback && !fallbackInterval){ log("Fallback to HRM enabled"); @@ -558,7 +559,7 @@ } switchInternalHrm(); } - + E.on("kill", ()=>{ if (gatt && gatt.connected){ log("Got killed, trying to disconnect"); From d9908ee6a2a77eab3b6371ade461a1ea449eec87 Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Tue, 5 Apr 2022 09:53:52 -0500 Subject: [PATCH 06/33] Switch from setScan to findDevices --- apps/bthrm/boot.js | 8 +-- apps/bthrm/settings.js | 110 +++++++++++++---------------------------- 2 files changed, 38 insertions(+), 80 deletions(-) diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index 0a6af55b6..ad3c85591 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -24,7 +24,7 @@ function getCache(){ var cache = require('Storage').readJSON("bthrm.cache.json", true) || {}; - if (settings.btname && settings.btname == cache.name) return cache; + if (settings.btid && settings.btid == cache.id) return cache; clearCache(); return {}; } @@ -368,9 +368,9 @@ if (!device){ var filters = serviceFilters; - if (settings.btname){ - log("Configured device name", settings.btname); - filters = [{name: settings.btname}]; + if (settings.btid){ + log("Configured device id", settings.btid); + filters = [{id: settings.btid }]; } log("Requesting device with filters", filters); promise = NRF.requestDevice({ filters: filters, active: true }); diff --git a/apps/bthrm/settings.js b/apps/bthrm/settings.js index 9f409880a..b376d6a2d 100644 --- a/apps/bthrm/settings.js +++ b/apps/bthrm/settings.js @@ -5,14 +5,14 @@ require('Storage').writeJSON(FILE, s); readSettings(); } - + function readSettings(){ settings = Object.assign( require('Storage').readJSON("bthrm.default.json", true) || {}, require('Storage').readJSON(FILE, true) || {} ); } - + var FILE="bthrm.json"; var settings; readSettings(); @@ -61,12 +61,13 @@ } }; - if (settings.btname){ - var name = "Clear " + settings.btname; + if (settings.btname || settings.btid){ + var name = "Clear " + (settings.btname || settings.btid); mainmenu[name] = function() { - E.showPrompt("Clear current device name?").then((r)=>{ + E.showPrompt("Clear current device?").then((r)=>{ if (r) { writeSettings("btname",undefined); + writeSettings("btid",undefined); } E.showMenu(buildMainMenu()); }); @@ -78,9 +79,7 @@ mainmenu.Debug = function() { E.showMenu(submenu_debug); }; return mainmenu; } - - var submenu_debug = { '' : { title: "Debug"}, '< Back': function() { E.showMenu(buildMainMenu()); }, @@ -103,35 +102,39 @@ function createMenuFromScan(){ E.showMenu(); - E.showMessage("Scanning"); + E.showMessage("Scanning for 4 seconds"); var submenu_scan = { - '' : { title: "Scan"}, '< Back': function() { E.showMenu(buildMainMenu()); } }; - var packets=10; - var scanStart=Date.now(); - NRF.setScan(function(d) { - packets--; - if (packets<=0 || Date.now() - scanStart > 5000){ - NRF.setScan(); - E.showMenu(submenu_scan); - } else if (d.name){ - print("Found device", d); - submenu_scan[d.name] = function(){ - E.showPrompt("Set "+d.name+"?").then((r)=>{ - if (r) { - writeSettings("btname",d.name); - } - E.showMenu(buildMainMenu()); + NRF.findDevices(function(devices) { + submenu_scan[''] = { title: `Scan (${devices.length} found)`}; + if (devices.length === 0) { + E.showAlert("No devices found") + .then(() => E.showMenu(buildMainMenu())); + return; + } else { + devices.forEach((d) => { + print("Found device", d); + var shown = (d.name || d.id.substr(0, 17)); + submenu_scan[shown] = function () { + E.showPrompt("Set " + shown + "?").then((r) => { + if (r) { + writeSettings("btid", d.id); + // Store the name for displaying later. Will connect by ID + if (d.name) { + writeSettings("btname", d.name); + } + } + E.showMenu(buildMainMenu()); + }); + }; }); - }; } - }, { active: true, filters: [{services: [ "180d" ]}]}); + E.showMenu(submenu_scan); + }, { timeout: 4000, active: true, filters: [{services: [ "180d" ]}]}); } - - var submenu_custom = { '' : { title: "Custom mode"}, '< Back': function() { E.showMenu(buildMainMenu()); }, @@ -167,7 +170,7 @@ } }, }; - + var submenu_grace = { '' : { title: "Grace periods"}, '< Back': function() { E.showMenu(submenu_debug); }, @@ -212,51 +215,6 @@ } } }; - - var submenu = { - '' : { title: "Grace periods"}, - '< Back': function() { E.showMenu(buildMainMenu()); }, - 'Request': { - value: settings.gracePeriodRequest, - min: 0, - max: 3000, - step: 100, - format: v=>v+"ms", - onchange: v => { - writeSettings("gracePeriodRequest",v); - } - }, - 'Connect': { - value: settings.gracePeriodConnect, - min: 0, - max: 3000, - step: 100, - format: v=>v+"ms", - onchange: v => { - writeSettings("gracePeriodConnect",v); - } - }, - 'Notification': { - value: settings.gracePeriodNotification, - min: 0, - max: 3000, - step: 100, - format: v=>v+"ms", - onchange: v => { - writeSettings("gracePeriodNotification",v); - } - }, - 'Service': { - value: settings.gracePeriodService, - min: 0, - max: 3000, - step: 100, - format: v=>v+"ms", - onchange: v => { - writeSettings("gracePeriodService",v); - } - } - }; - + E.showMenu(buildMainMenu()); -}) +}); From 88a785df7f7d0e05023fbcd69b7ae71e85a6fb8b Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Tue, 5 Apr 2022 20:58:33 -0500 Subject: [PATCH 07/33] Update some types --- typescript/types/globals.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/types/globals.d.ts b/typescript/types/globals.d.ts index 442140e70..7af19700b 100644 --- a/typescript/types/globals.d.ts +++ b/typescript/types/globals.d.ts @@ -140,7 +140,7 @@ declare const require: ((module: 'heatshrink') => { declare const Bangle: { // functions - buzz: () => void; + buzz: (duration: number, intensity: number) => Promise; drawWidgets: () => void; isCharging: () => boolean; // events From 908a41d5237f2b6e30eca2c2bfd00954dd329051 Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Tue, 5 Apr 2022 20:58:47 -0500 Subject: [PATCH 08/33] Try to bond --- apps/bthrm/boot.js | 79 ++++++++++++++++++++++++--------------------- apps/bthrm/bthrm.js | 6 ++-- 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index ad3c85591..8e18b3e34 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -3,7 +3,7 @@ require('Storage').readJSON("bthrm.default.json", true) || {}, require('Storage').readJSON("bthrm.json", true) || {} ); - + var log = function(text, param){ if (settings.debuglog){ var logline = new Date().toISOString() + " - " + text; @@ -13,9 +13,9 @@ print(logline); } }; - + log("Settings: ", settings); - + if (settings.enabled){ function clearCache(){ @@ -24,25 +24,24 @@ function getCache(){ var cache = require('Storage').readJSON("bthrm.cache.json", true) || {}; - if (settings.btid && settings.btid == cache.id) return cache; + if (settings.btid && settings.btid === cache.id) return cache; clearCache(); return {}; } - + function addNotificationHandler(characteristic){ log("Setting notification handler: " + supportedCharacteristics[characteristic.uuid].handler); characteristic.on('characteristicvaluechanged', (ev) => supportedCharacteristics[characteristic.uuid].handler(ev.target.value)); } - + function writeCache(cache){ var oldCache = getCache(); - if (oldCache != cache) { + if (oldCache !== cache) { log("Writing cache"); require('Storage').writeJSON("bthrm.cache.json", cache) } else { log("No changes, don't write cache"); } - } function characteristicsToCache(characteristics){ @@ -177,7 +176,6 @@ lastReceivedData["0x180f"]["0x2a19"] = dv.getUint8(0); } } - }; var device; @@ -185,7 +183,7 @@ var characteristics = []; var blockInit = false; var currentRetryTimeout; - var initialRetryTime = 40; + var initialRetryTime = 1000; var maxRetryTime = 60000; var retryTime = initialRetryTime; @@ -214,7 +212,6 @@ }; } - if (settings.replace){ var origIsHRMOn = Bangle.isHRMOn; @@ -309,14 +306,14 @@ } return result.then(()=>log("Handled characteristic: ", newCharacteristic)); } - + function attachCharacteristicPromise(promise, characteristic){ return promise.then(()=>{ log("Handling characteristic:", characteristic); return createCharacteristicPromise(characteristic); }); } - + function createCharacteristicsPromise(newCharacteristics){ log("Create characteristics promise: ", newCharacteristics); var result = Promise.resolve(); @@ -327,12 +324,12 @@ if (c.properties.notify){ addNotificationHandler(c); } - + result = attachCharacteristicPromise(result, c); } return result.then(()=>log("Handled characteristics")); } - + function createServicePromise(service){ log("Create service promise: ", service); var result = Promise.resolve(); @@ -342,11 +339,11 @@ }); return result.then(()=>log("Handled service" + service.uuid)); } - + function attachServicePromise(promise, service){ return promise.then(()=>createServicePromise(service)); } - + var reUseCounter = 0; function initBt() { @@ -363,9 +360,9 @@ gatt=undefined; reUseCounter = 0; } - + var promise; - + if (!device){ var filters = serviceFilters; if (settings.btid){ @@ -374,27 +371,26 @@ } log("Requesting device with filters", filters); promise = NRF.requestDevice({ filters: filters, active: true }); - + if (settings.gracePeriodRequest){ log("Add " + settings.gracePeriodRequest + "ms grace period after request"); } - + promise = promise.then((d)=>{ log("Got device: ", d); d.on('gattserverdisconnected', onDisconnect); device = d; }); - + promise = promise.then(()=>{ log("Wait after request"); return waitingPromise(settings.gracePeriodRequest); }); - } else { promise = Promise.resolve(); log("Reuse device: ", device); } - + promise = promise.then(()=>{ if (gatt){ log("Reuse GATT: ", gatt); @@ -402,7 +398,7 @@ log("GATT is new: ", gatt); characteristics = []; var cachedName = getCache().name; - if (device.name != cachedName){ + if (device.name !== cachedName){ log("Device name changed from " + cachedName + " to " + device.name + ", clearing cache"); clearCache(); } @@ -411,10 +407,10 @@ writeCache(newCache); gatt = device.gatt; } - + return Promise.resolve(gatt); }); - + promise = promise.then((gatt)=>{ if (!gatt.connected){ var connectPromise = gatt.connect(connectSettings); @@ -430,16 +426,28 @@ return Promise.resolve(); } }); - + + promise = promise.then(() => { + log(JSON.stringify(gatt.getSecurityStatus())); + if (gatt.getSecurityStatus()['bonded']) { + log("Already bonded"); + return Promise.resolve(); + } else { + log("Start bonding"); + return gatt.startBonding() + .then(() => console.log(gatt.getSecurityStatus())); + } + }); + promise = promise.then(()=>{ - if (!characteristics || characteristics.length == 0){ + if (!characteristics || characteristics.length === 0){ characteristics = characteristicsFromCache(); } }); promise = promise.then(()=>{ var characteristicsPromise = Promise.resolve(); - if (characteristics.length == 0){ + if (characteristics.length === 0){ characteristicsPromise = characteristicsPromise.then(()=>{ log("Getting services"); return gatt.getPrimaryServices(); @@ -462,17 +470,16 @@ } return result; }); - } else { for (var characteristic of characteristics){ characteristicsPromise = attachCharacteristicPromise(characteristicsPromise, characteristic, true); } } - + return characteristicsPromise; }); - promise = promise.then(()=>{ + return promise.then(()=>{ log("Connection established, waiting for notifications"); reUseCounter = 0; characteristicsToCache(characteristics); @@ -490,7 +497,7 @@ if (Bangle._PWR===undefined) Bangle._PWR={}; if (Bangle._PWR.BTHRM===undefined) Bangle._PWR.BTHRM=[]; if (isOn && !Bangle._PWR.BTHRM.includes(app)) Bangle._PWR.BTHRM.push(app); - if (!isOn && Bangle._PWR.BTHRM.includes(app)) Bangle._PWR.BTHRM = Bangle._PWR.BTHRM.filter(a=>a!=app); + if (!isOn && Bangle._PWR.BTHRM.includes(app)) Bangle._PWR.BTHRM = Bangle._PWR.BTHRM.filter(a=>a!==app); isOn = Bangle._PWR.BTHRM.length; // so now we know if we're really on if (isOn) { @@ -513,7 +520,7 @@ } } }; - + var origSetHRMPower = Bangle.setHRMPower; if (settings.startWithHrm){ @@ -563,7 +570,7 @@ E.on("kill", ()=>{ if (gatt && gatt.connected){ log("Got killed, trying to disconnect"); - var promise = gatt.disconnect().then(()=>log("Disconnected on kill")).catch((e)=>log("Error during disconnnect on kill", e)); + gatt.disconnect().then(()=>log("Disconnected on kill")).catch((e)=>log("Error during disconnnect on kill", e)); } }); } diff --git a/apps/bthrm/bthrm.js b/apps/bthrm/bthrm.js index 5ab3b0018..dd9230386 100644 --- a/apps/bthrm/bthrm.js +++ b/apps/bthrm/bthrm.js @@ -24,13 +24,13 @@ function draw(y, type, event) { g.setFontAlign(0,0); g.setFontVector(40).drawString(str,px,y+20); str = "Event: " + type; - if (type == "HRM") { + if (type === "HRM") { str += " Confidence: " + event.confidence; g.setFontVector(12).drawString(str,px,y+40); str = " Source: " + (event.src ? event.src : "internal"); g.setFontVector(12).drawString(str,px,y+50); } - if (type == "BTHRM"){ + if (type === "BTHRM"){ if (event.battery) str += " Bat: " + (event.battery ? event.battery : ""); g.setFontVector(12).drawString(str,px,y+40); str= ""; @@ -54,7 +54,7 @@ function onBtHrm(e) { firstEventBt = false; } draw(100, "BTHRM", e); - if (e.bpm == 0){ + if (e.bpm === 0){ Bangle.buzz(100,0.2); } if (intervalBt){ From 31fd2344a8ffb7e9ec9bf97635a155e8f75bf429 Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Tue, 5 Apr 2022 21:05:03 -0500 Subject: [PATCH 09/33] Fix for buzz type updated in previous commit --- typescript/types/globals.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/types/globals.d.ts b/typescript/types/globals.d.ts index 7af19700b..e82c3da3d 100644 --- a/typescript/types/globals.d.ts +++ b/typescript/types/globals.d.ts @@ -140,7 +140,7 @@ declare const require: ((module: 'heatshrink') => { declare const Bangle: { // functions - buzz: (duration: number, intensity: number) => Promise; + buzz: (duration?: number, intensity?: number) => Promise; drawWidgets: () => void; isCharging: () => boolean; // events From 9eb4d8eb73684eca9ee4d0eadc8aec94bf467d6c Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Thu, 7 Apr 2022 15:58:39 -0500 Subject: [PATCH 10/33] Remove bonding for now --- apps/bthrm/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index 8e18b3e34..f9de2ee5d 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -427,7 +427,7 @@ } }); - promise = promise.then(() => { +/* promise = promise.then(() => { log(JSON.stringify(gatt.getSecurityStatus())); if (gatt.getSecurityStatus()['bonded']) { log("Already bonded"); @@ -437,7 +437,7 @@ return gatt.startBonding() .then(() => console.log(gatt.getSecurityStatus())); } - }); + });*/ promise = promise.then(()=>{ if (!characteristics || characteristics.length === 0){ From 7eeeca52ca25b2c633aed8a99c7fa12701e6d69c Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Thu, 7 Apr 2022 22:04:47 -0500 Subject: [PATCH 11/33] Update README and follow linting instructions --- apps/bthrm/README.md | 13 ++-- apps/bthrm/boot.js | 124 ++++++++++++++++++--------------------- apps/bthrm/metadata.json | 2 +- 3 files changed, 66 insertions(+), 73 deletions(-) diff --git a/apps/bthrm/README.md b/apps/bthrm/README.md index 42ad619bd..8d5872670 100644 --- a/apps/bthrm/README.md +++ b/apps/bthrm/README.md @@ -2,7 +2,7 @@ When this app is installed it overrides Bangle.js's build in heart rate monitor with an external Bluetooth one. -HRM is requested it searches on Bluetooth for a heart rate monitor, connects, and sends data back using the `Bangle.on('HRM'` event as if it came from the on board monitor. +HRM is requested it searches on Bluetooth for a heart rate monitor, connects, and sends data back using the `Bangle.on('HRM')` event as if it came from the on board monitor. This means it's compatible with many Bangle.js apps including: @@ -16,19 +16,23 @@ as that requires live sensor data (rather than just BPM readings). Just install the app, then install an app that uses the heart rate monitor. -Once installed it'll automatically try and connect to the first bluetooth -heart rate monitor it finds. +Once installed you will have to go into this app's settings while your heart rate monitor + is available for bluetooth pairing and scan for devices. **To disable this and return to normal HRM, uninstall the app** ## Compatible Heart Rate Monitors This works with any heart rate monitor providing the standard Bluetooth -Heart Rate Service (`180D`) and characteristic (`2A37`). +Heart Rate Service (`180D`) and characteristic (`2A37`). It additionally supports +the location (`2A38`) characteristic and the Battery Service (`180F`), reporting +that information in the `BTHRM` event when they are available. So far it has been tested on: * CooSpo Bluetooth Heart Rate Monitor +* Polar H10 +* Polar OH1 * Wahoo TICKR X 2 ## Internals @@ -38,7 +42,6 @@ This replaces `Bangle.setHRMPower` with its own implementation. ## TODO * A widget to show connection state? -* Specify a specific device by address? ## Creator diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index f9de2ee5d..064f65eac 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -18,33 +18,33 @@ if (settings.enabled){ - function clearCache(){ + var clearCache = function() { return require('Storage').erase("bthrm.cache.json"); - } + }; - function getCache(){ + var getCache = function() { var cache = require('Storage').readJSON("bthrm.cache.json", true) || {}; if (settings.btid && settings.btid === cache.id) return cache; clearCache(); return {}; - } + }; - function addNotificationHandler(characteristic){ + var addNotificationHandler = function(characteristic) { log("Setting notification handler: " + supportedCharacteristics[characteristic.uuid].handler); characteristic.on('characteristicvaluechanged', (ev) => supportedCharacteristics[characteristic.uuid].handler(ev.target.value)); - } + }; - function writeCache(cache){ + var writeCache = function(cache) { var oldCache = getCache(); if (oldCache !== cache) { log("Writing cache"); - require('Storage').writeJSON("bthrm.cache.json", cache) + require('Storage').writeJSON("bthrm.cache.json", cache); } else { log("No changes, don't write cache"); } - } + }; - function characteristicsToCache(characteristics){ + var characteristicsToCache = function(characteristics) { log("Cache characteristics"); var cache = getCache(); if (!cache.characteristics) cache.characteristics = {}; @@ -59,9 +59,9 @@ }; } writeCache(cache); - } + }; - function characteristicsFromCache(){ + var characteristicsFromCache = function() { log("Read cached characteristics"); var cache = getCache(); if (!cache.characteristics) return []; @@ -80,19 +80,16 @@ restored.push(r); } return restored; - } + }; log("Start"); var lastReceivedData={ }; - var serviceFilters = [{ - services: [ "180d" ] - }]; - var supportedServices = [ - "0x180d", "0x180f" + "0x180d", // Heart Rate + "0x180f", // Battery ]; var supportedCharacteristics = { @@ -100,17 +97,17 @@ //Heart rate measurement handler: function (dv){ var flags = dv.getUint8(0); - + var bpm = (flags & 1) ? (dv.getUint16(1) / 100 /* ? */ ) : dv.getUint8(1); // 8 or 16 bit - + var sensorContact; - + if (flags & 2){ sensorContact = !!(flags & 4); } - + var idx = 2 + (flags&1); - + var energyExpended; if (flags & 8){ energyExpended = dv.getUint16(idx,1); @@ -123,7 +120,7 @@ log("Found " + (maxIntervalBytes / 2) + " rr data fields"); for(var i = 0 ; i < maxIntervalBytes / 2; i++){ interval[i] = dv.getUint16(idx,1); // in milliseconds - idx += 2 + idx += 2; } } @@ -143,7 +140,7 @@ confidence: (sensorContact || sensorContact === undefined)? 100 : 0, src: "bthrm" }; - + log("Emitting HRM: ", repEvent); Bangle.emit("HRM", repEvent); } @@ -151,7 +148,7 @@ var newEvent = { bpm: bpm }; - + if (location) newEvent.location = location; if (interval) newEvent.rr = interval; if (energyExpended) newEvent.energy = energyExpended; @@ -183,7 +180,7 @@ var characteristics = []; var blockInit = false; var currentRetryTimeout; - var initialRetryTime = 1000; + var initialRetryTime = 40; var maxRetryTime = 60000; var retryTime = initialRetryTime; @@ -192,7 +189,7 @@ maxInterval: 1500 }; - function waitingPromise(timeout) { + var waitingPromise = function(timeout) { return new Promise(function(resolve){ log("Start waiting for " + timeout); setTimeout(()=>{ @@ -200,7 +197,7 @@ resolve(); }, timeout); }); - } + }; if (settings.enabled){ Bangle.isBTHRMOn = function(){ @@ -225,15 +222,15 @@ }; } - function clearRetryTimeout(){ + var clearRetryTimeout = function() { if (currentRetryTimeout){ log("Clearing timeout " + currentRetryTimeout); clearTimeout(currentRetryTimeout); currentRetryTimeout = undefined; } - } + }; - function retry(){ + var retry = function() { log("Retry"); if (!currentRetryTimeout){ @@ -255,10 +252,10 @@ } else { log("Already in retry..."); } - } + }; var buzzing = false; - function onDisconnect(reason) { + var onDisconnect = function(reason) { log("Disconnect: " + reason); log("GATT: ", gatt); log("Characteristics: ", characteristics); @@ -273,9 +270,9 @@ if (Bangle.isBTHRMOn()){ retry(); } - } + }; - function createCharacteristicPromise(newCharacteristic){ + var createCharacteristicPromise = function(newCharacteristic) { log("Create characteristic promise: ", newCharacteristic); var result = Promise.resolve(); // For values that can be read, go ahead and read them, even if we might be notified in the future @@ -298,23 +295,23 @@ log("Add " + settings.gracePeriodNotification + "ms grace period after starting notifications"); startPromise = startPromise.then(()=>{ log("Wait after connect"); - waitingPromise(settings.gracePeriodNotification) + return waitingPromise(settings.gracePeriodNotification); }); } return startPromise; }); } return result.then(()=>log("Handled characteristic: ", newCharacteristic)); - } + }; - function attachCharacteristicPromise(promise, characteristic){ + var attachCharacteristicPromise = function(promise, characteristic) { return promise.then(()=>{ log("Handling characteristic:", characteristic); return createCharacteristicPromise(characteristic); }); - } + }; - function createCharacteristicsPromise(newCharacteristics){ + var createCharacteristicsPromise = function(newCharacteristics) { log("Create characteristics promise: ", newCharacteristics); var result = Promise.resolve(); for (var c of newCharacteristics){ @@ -328,9 +325,9 @@ result = attachCharacteristicPromise(result, c); } return result.then(()=>log("Handled characteristics")); - } + }; - function createServicePromise(service){ + var createServicePromise = function(service) { log("Create service promise: ", service); var result = Promise.resolve(); result = result.then(()=>{ @@ -338,15 +335,13 @@ return service.getCharacteristics().then((c)=>createCharacteristicsPromise(c)); }); return result.then(()=>log("Handled service" + service.uuid)); - } + }; - function attachServicePromise(promise, service){ + var attachServicePromise = function(promise, service) { return promise.then(()=>createServicePromise(service)); - } + }; - var reUseCounter = 0; - - function initBt() { + var initBt = function () { log("initBt with blockInit: " + blockInit); if (blockInit){ retry(); @@ -355,19 +350,15 @@ blockInit = true; - if (reUseCounter > 10){ - log("Reuse counter to high"); - gatt=undefined; - reUseCounter = 0; - } - var promise; + var filters; if (!device){ - var filters = serviceFilters; if (settings.btid){ log("Configured device id", settings.btid); - filters = [{id: settings.btid }]; + filters = [{ id: settings.btid }]; + } else { + return; } log("Requesting device with filters", filters); promise = NRF.requestDevice({ filters: filters, active: true }); @@ -397,13 +388,13 @@ } else { log("GATT is new: ", gatt); characteristics = []; - var cachedName = getCache().name; - if (device.name !== cachedName){ - log("Device name changed from " + cachedName + " to " + device.name + ", clearing cache"); + var cachedId = getCache().id; + if (device.id !== cachedId){ + log("Device ID changed from " + cachedId + " to " + device.id + ", clearing cache"); clearCache(); } var newCache = getCache(); - newCache.name = device.name; + newCache.id = device.id; writeCache(newCache); gatt = device.gatt; } @@ -465,7 +456,7 @@ log("Add " + settings.gracePeriodService + "ms grace period after services"); result = result.then(()=>{ log("Wait after services"); - return waitingPromise(settings.gracePeriodService) + return waitingPromise(settings.gracePeriodService); }); } return result; @@ -478,10 +469,9 @@ return characteristicsPromise; }); - + return promise.then(()=>{ log("Connection established, waiting for notifications"); - reUseCounter = 0; characteristicsToCache(characteristics); clearRetryTimeout(); }).catch((e) => { @@ -489,7 +479,7 @@ log("Error:", e); onDisconnect(e); }); - } + }; Bangle.setBTHRMPower = function(isOn, app) { // Do app power handling @@ -538,7 +528,7 @@ var fallbackInterval; - function switchInternalHrm(){ + var switchInternalHrm = function() { if (settings.allowFallback && !fallbackInterval){ log("Fallback to HRM enabled"); origSetHRMPower(1, "bthrm_fallback"); @@ -551,7 +541,7 @@ } }, settings.fallbackTimeout); } - } + }; if (settings.replace){ log("Replace HRM event"); diff --git a/apps/bthrm/metadata.json b/apps/bthrm/metadata.json index b35ebd6af..faff72d0f 100644 --- a/apps/bthrm/metadata.json +++ b/apps/bthrm/metadata.json @@ -6,7 +6,7 @@ "description": "Overrides Bangle.js's build in heart rate monitor with an external Bluetooth one.", "icon": "app.png", "type": "app", - "tags": "health,bluetooth", + "tags": "health,bluetooth,hrm", "supports": ["BANGLEJS","BANGLEJS2"], "readme": "README.md", "storage": [ From ab11b7068115b6678d69e70c21b7787bba778ece Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Tue, 19 Apr 2022 16:54:27 -0500 Subject: [PATCH 12/33] Default custom values to the same as default mode so you can choose which pieces to change knowing the rest is the same --- apps/bthrm/default.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/bthrm/default.json b/apps/bthrm/default.json index 64e638b8a..fb284bcd2 100644 --- a/apps/bthrm/default.json +++ b/apps/bthrm/default.json @@ -7,10 +7,10 @@ "allowFallback": true, "warnDisconnect": false, "fallbackTimeout": 10, - "custom_replace": false, + "custom_replace": true, "custom_debuglog": false, - "custom_startWithHrm": false, - "custom_allowFallback": false, + "custom_startWithHrm": true, + "custom_allowFallback": true, "custom_warnDisconnect": false, "custom_fallbackTimeout": 10, "gracePeriodNotification": 0, From dbecd1ae6f009220f84b989d2bfc3666ebf27ca2 Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Tue, 19 Apr 2022 16:54:50 -0500 Subject: [PATCH 13/33] Adding tag to find 'hrm' more easily --- apps/bthrm/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/bthrm/metadata.json b/apps/bthrm/metadata.json index faff72d0f..85c19ab33 100644 --- a/apps/bthrm/metadata.json +++ b/apps/bthrm/metadata.json @@ -6,7 +6,7 @@ "description": "Overrides Bangle.js's build in heart rate monitor with an external Bluetooth one.", "icon": "app.png", "type": "app", - "tags": "health,bluetooth,hrm", + "tags": "health,bluetooth,hrm,bthrm", "supports": ["BANGLEJS","BANGLEJS2"], "readme": "README.md", "storage": [ From 650d2bd288e47bbf95f94aef62949ad22aefdd32 Mon Sep 17 00:00:00 2001 From: Salim Blume Date: Tue, 19 Apr 2022 16:55:04 -0500 Subject: [PATCH 14/33] Scaled retryTime for clampedTime instead of itself --- apps/bthrm/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/bthrm/boot.js b/apps/bthrm/boot.js index 064f65eac..e9e640563 100644 --- a/apps/bthrm/boot.js +++ b/apps/bthrm/boot.js @@ -245,7 +245,7 @@ initBt(); }, clampedTime); - retryTime = Math.pow(retryTime, 1.1); + retryTime = Math.pow(clampedTime, 1.1); if (retryTime > maxRetryTime){ retryTime = maxRetryTime; } From b6366761fc23af86dc689e9924764504ea68f8af Mon Sep 17 00:00:00 2001 From: nujw Date: Mon, 23 May 2022 16:13:52 +1200 Subject: [PATCH 15/33] Update app.js --- apps/speedalt2/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/speedalt2/app.js b/apps/speedalt2/app.js index ed16131a4..4cdf71913 100644 --- a/apps/speedalt2/app.js +++ b/apps/speedalt2/app.js @@ -5,8 +5,9 @@ Mike Bennett mike[at]kereru.com 1.14 : Add VMG screen 1.34 : Add bluetooth data stream for Droidscript 1.43 : Keep GPS in SuperE mode while using Droiscript screen mirroring +1.50 : Add cfg.wptSfx one char suffix to append to waypoints.json filename. Protects speedalt2 waypoints from other apps that use the same file name for waypoints. */ -var v = '1.49'; +var v = '1.50'; var vDroid = '1.50'; // Required DroidScript program version /*kalmanjs, Wouter Bulten, MIT, https://github.com/wouterbulten/kalmanjs */ @@ -209,7 +210,7 @@ function nxtWp(){ } function loadWp() { - var w = require("Storage").readJSON('waypoints.json')||[{name:"NONE"}]; + var w = require("Storage").readJSON('waypoints'+cfg.wptSfx+'.json')||[{name:"NONE"}]; if (cfg.wp>=w.length) cfg.wp=0; if (cfg.wp<0) cfg.wp = w.length-1; savSettings(); @@ -718,6 +719,7 @@ cfg.primSpd = cfg.primSpd||0; // 1 = Spd in primary, 0 = Spd in secondary cfg.spdFilt = cfg.spdFilt==undefined?true:cfg.spdFilt; cfg.altFilt = cfg.altFilt==undefined?true:cfg.altFilt; cfg.touch = cfg.touch==undefined?true:cfg.touch; +cfg.wptSfx = cfg.wptSfx==undefined?'':cfg.wptSfx; if ( cfg.spdFilt ) var spdFilter = new KalmanFilter({R: 0.1 , Q: 1 }); if ( cfg.altFilt ) var altFilter = new KalmanFilter({R: 0.01, Q: 2 }); From 864fa672aba173fd7082fe9f1c8e3e2f1f5a13cb Mon Sep 17 00:00:00 2001 From: nujw Date: Mon, 23 May 2022 16:17:40 +1200 Subject: [PATCH 16/33] Update ChangeLog --- apps/speedalt2/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/speedalt2/ChangeLog b/apps/speedalt2/ChangeLog index 73e9bfc40..fe20dcf3d 100644 --- a/apps/speedalt2/ChangeLog +++ b/apps/speedalt2/ChangeLog @@ -13,3 +13,4 @@ 1.14: Add VMG and coordinates screens 1.43: Adds mirroring of the watch face to an Android device. See README.md 1.49: Droidscript mirroring prog automatically uses last connection address. Auto connects when run. +1.50: Add configuration item Waypoints Suffix. A one character suffix to append to the waypoints.json file. A number of other apps also use this file name. Using the file name suffix allows the speedalt2 waypoints to be retained if one of these other apps is installed for a different use. From 1ac9864bae22ec6aa82fe8a1ba9496e5aa55e766 Mon Sep 17 00:00:00 2001 From: nujw Date: Mon, 23 May 2022 16:35:04 +1200 Subject: [PATCH 17/33] Update settings.js --- apps/speedalt2/settings.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/speedalt2/settings.js b/apps/speedalt2/settings.js index babb03061..1bdb58f9d 100644 --- a/apps/speedalt2/settings.js +++ b/apps/speedalt2/settings.js @@ -30,6 +30,11 @@ writeSettings(); } + function setSfx(s) { + settings.wptSfx = s; + writeSettings(); + } + const appMenu = { '': {'title': 'GPS Adv Sprt II'}, @@ -38,6 +43,7 @@ 'Units' : function() { E.showMenu(unitsMenu); }, 'Colours' : function() { E.showMenu(colMenu); }, 'Kalman Filter' : function() { E.showMenu(kalMenu); }, + 'Wpt File Suffix' : function() { E.showMenu(sfxMenu); }, 'Touch' : { value : settings.touch, format : v => v?"On":"Off", @@ -69,6 +75,15 @@ 'Inverted' : function() { setColour(3); } }; + const sfxMenu = { + '': {'title': 'Wpt File Suffix'}, + '< Back': function() { E.showMenu(appMenu); }, + 'Default' : function() { setSfx(''); }, + '1' : function() { setSfx('1'); }, + '2' : function() { setSfx('2'); }, + '3' : function() { setSfx('3'); } + }; + const kalMenu = { '': {'title': 'Kalman Filter'}, '< Back': function() { E.showMenu(appMenu); }, From 445b21fc076c3272d2cef95c7672ae5c86fd24d5 Mon Sep 17 00:00:00 2001 From: nujw Date: Mon, 23 May 2022 16:36:11 +1200 Subject: [PATCH 18/33] Update metadata.json --- apps/speedalt2/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/speedalt2/metadata.json b/apps/speedalt2/metadata.json index 4ace46854..801d65fb0 100644 --- a/apps/speedalt2/metadata.json +++ b/apps/speedalt2/metadata.json @@ -2,7 +2,7 @@ "id": "speedalt2", "name": "GPS Adventure Sports II", "shortName":"GPS Adv Sport II", - "version":"1.49", + "version":"1.50", "description": "GPS speed, altitude and distance to waypoint display. Designed for easy viewing and use during outdoor activities such as para-gliding, hang-gliding, sailing, cycling etc.", "icon": "app.png", "type": "app", From 824705203842e6f93297164ba0852900e7468880 Mon Sep 17 00:00:00 2001 From: nujw Date: Mon, 23 May 2022 16:53:56 +1200 Subject: [PATCH 19/33] Update ChangeLog --- apps/speedalt2/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/speedalt2/ChangeLog b/apps/speedalt2/ChangeLog index fe20dcf3d..9e2abb4ef 100644 --- a/apps/speedalt2/ChangeLog +++ b/apps/speedalt2/ChangeLog @@ -13,4 +13,4 @@ 1.14: Add VMG and coordinates screens 1.43: Adds mirroring of the watch face to an Android device. See README.md 1.49: Droidscript mirroring prog automatically uses last connection address. Auto connects when run. -1.50: Add configuration item Waypoints Suffix. A one character suffix to append to the waypoints.json file. A number of other apps also use this file name. Using the file name suffix allows the speedalt2 waypoints to be retained if one of these other apps is installed for a different use. +1.50: Add configuration item Wpt File Suffix. A one character suffix to append to the waypoints.json file. A number of other apps also use this file name. Using the file name suffix allows the speedalt2 waypoints to be retained if one of these other apps is installed for a different use. From fa77e25b103432830bad03d469dd870e113896f3 Mon Sep 17 00:00:00 2001 From: nujw Date: Mon, 23 May 2022 17:00:01 +1200 Subject: [PATCH 20/33] Update README.md --- apps/speedalt2/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/speedalt2/README.md b/apps/speedalt2/README.md index e1c6b0a5a..76532bc40 100644 --- a/apps/speedalt2/README.md +++ b/apps/speedalt2/README.md @@ -80,6 +80,8 @@ The [GPS Navigation](https://banglejs.com/apps/#gps%20navigation) app in the App Sample waypoints.json (My sailing waypoints) +**Note** : The waypoints.json file is used by a number of different gps apps. The setting 'Wpt File Suffix' allows one of waypoints1.json, waypoints2.json or waypoints3.json to be used instead. This allows the other apps to be used with a different set of waypoints without losing the speedalt2 waypoint set. +
 [
   {

From c6f45f06a0a0b5b8fcdb9749e3005814347fd1e3 Mon Sep 17 00:00:00 2001
From: nujw 
Date: Mon, 23 May 2022 17:02:25 +1200
Subject: [PATCH 21/33] Update README.md

---
 apps/speedalt2/README.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/apps/speedalt2/README.md b/apps/speedalt2/README.md
index 76532bc40..c124e0c00 100644
--- a/apps/speedalt2/README.md
+++ b/apps/speedalt2/README.md
@@ -78,9 +78,11 @@ Waypoints are used in Distance and VMG modes. Create a file waypoints.json and w
 
 The [GPS Navigation](https://banglejs.com/apps/#gps%20navigation) app in the App Loader has a really nice waypoints file editor. (Must be connected to your Bangle.JS and then click on the Download icon.)
 
-Sample waypoints.json (My sailing waypoints)
+By default the waypoints file is called waypoints.json
 
 **Note** : The waypoints.json file is used by a number of different gps apps. The setting 'Wpt File Suffix' allows one of waypoints1.json, waypoints2.json or waypoints3.json to be used instead. This allows the other apps to be used with a different set of waypoints without losing the speedalt2 waypoint set. 
+ 
+Sample waypoints.json (My sailing waypoints)
 
 
 [

From 1abe720645aa33ac0f87e979f13fd56aa9a6ba4a Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Mon, 23 May 2022 15:20:32 +0100
Subject: [PATCH 22/33] Allow spaces to be typed in search terms

---
 core | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core b/core
index 147892754..404e98183 160000
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 147892754eaf50c8581ebfb4d8651b9ec24aa44e
+Subproject commit 404e981834f2e8df9c505a8fab12ae12fe3bd562

From 54920af066c1c7bbed836f4b3852a388501994ef Mon Sep 17 00:00:00 2001
From: Gordon Williams 
Date: Mon, 23 May 2022 16:54:00 +0100
Subject: [PATCH 23/33] android webview teaks

---
 android.html | 352 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 352 insertions(+)
 create mode 100644 android.html

diff --git a/android.html b/android.html
new file mode 100644
index 000000000..93999008f
--- /dev/null
+++ b/android.html
@@ -0,0 +1,352 @@
+
+
+  
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    Bangle.js App Loader
+  
+  
+
+
+    
+
+    
+ +
+ + + + +
+
+ +
+ + +
+
+
+ + +
+
+
+
+
+ + + + + +
+ + +
+ + + + + + + + + + + + + + + + + From 9973435b69f744bbdc420d02f20cd9f96f12b97e Mon Sep 17 00:00:00 2001 From: nujw Date: Tue, 24 May 2022 09:37:47 +1200 Subject: [PATCH 24/33] Update metadata.json --- apps/speedalt2/metadata.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/speedalt2/metadata.json b/apps/speedalt2/metadata.json index 801d65fb0..0de0b28bb 100644 --- a/apps/speedalt2/metadata.json +++ b/apps/speedalt2/metadata.json @@ -15,5 +15,10 @@ {"name":"speedalt2.img","url":"app-icon.js","evaluate":true}, {"name":"speedalt2.settings.js","url":"settings.js"} ], - "data": [{"name":"speedalt2.json"}] + "data": [ + {"name":"speedalt2.json"}, + {"name":"waypoints1.json"}, + {"name":"waypoints2.json"}, + {"name":"waypoints3.json"} + ] } From a7c9c124eac162a76aa58dd3e58b6005c4d59403 Mon Sep 17 00:00:00 2001 From: frigis1 <63980066+frigis1@users.noreply.github.com> Date: Mon, 23 May 2022 17:05:34 -0700 Subject: [PATCH 25/33] Update ChangeLog --- apps/multitimer/ChangeLog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/multitimer/ChangeLog b/apps/multitimer/ChangeLog index 624f1b0fb..9b60f403a 100644 --- a/apps/multitimer/ChangeLog +++ b/apps/multitimer/ChangeLog @@ -1 +1,2 @@ -0.01: Initial version \ No newline at end of file +0.01: Initial version +0.02: Update for time_utils module From 5330784b3fc0bef3d04b1b3e6b09bf91de148f42 Mon Sep 17 00:00:00 2001 From: frigis1 <63980066+frigis1@users.noreply.github.com> Date: Mon, 23 May 2022 17:05:59 -0700 Subject: [PATCH 26/33] Update alarm.js --- apps/multitimer/alarm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/multitimer/alarm.js b/apps/multitimer/alarm.js index fc0195455..97cbaa5fa 100644 --- a/apps/multitimer/alarm.js +++ b/apps/multitimer/alarm.js @@ -73,7 +73,7 @@ function showAlarm(alarm) { const settings = require("sched").getSettings(); let msg = ""; - msg += require("sched").formatTime(alarm.timer); + if (alarm.timer) msg += require("time_utils").formatTime(alarm.timer); if (alarm.msg) { msg += "\n"+alarm.msg; } @@ -86,7 +86,7 @@ function showAlarm(alarm) { if (alarm.data.hm && alarm.data.hm == true) { //hard mode extends auto-snooze time - buzzCount = buzzCount * 2; + buzzCount = buzzCount * 3; startHM(); } From 5854217f1ccc166dcf2f64fe1f6ca40117a41a53 Mon Sep 17 00:00:00 2001 From: frigis1 <63980066+frigis1@users.noreply.github.com> Date: Mon, 23 May 2022 17:06:31 -0700 Subject: [PATCH 27/33] Update app.js --- apps/multitimer/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/multitimer/app.js b/apps/multitimer/app.js index becaf6169..e5d77d860 100644 --- a/apps/multitimer/app.js +++ b/apps/multitimer/app.js @@ -258,7 +258,7 @@ function editTimer(idx, a) { a.last = 0; a.data.ot = a.timer; a.appid = "multitimer"; - a.js = "load('multitimer.alarm.js')"; + a.js = "(require('Storage').read('multitimer.alarm.js') !== undefined) ? load('multitimer.alarm.js') : load('sched.js')"; if (idx < 0) alarms.push(a); else alarms[timerIdx[idx]] = a; require("sched").setAlarms(alarms); @@ -585,7 +585,7 @@ function editAlarm(idx, a) { var menu = { "": { "title": "Alarm" }, "< Back": () => { - if (a.data.hm == true) a.js = "load('multitimer.alarm.js')"; + if (a.data.hm == true) a.js = "(require('Storage').read('multitimer.alarm.js') !== undefined) ? load('multitimer.alarm.js') : load('sched.js')"; if (a.data.hm == false && a.js) delete a.js; if (idx >= 0) alarms[alarmIdx[idx]] = a; else alarms.push(a); From b56eff48c6e57e1f84b0675fba2ce59c14949244 Mon Sep 17 00:00:00 2001 From: frigis1 <63980066+frigis1@users.noreply.github.com> Date: Mon, 23 May 2022 17:06:55 -0700 Subject: [PATCH 28/33] Update metadata.json --- apps/multitimer/metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/multitimer/metadata.json b/apps/multitimer/metadata.json index 6e53e2c8c..abb958b90 100644 --- a/apps/multitimer/metadata.json +++ b/apps/multitimer/metadata.json @@ -1,7 +1,7 @@ { "id": "multitimer", "name": "Multi Timer", - "version": "0.01", + "version": "0.02", "description": "Set timers and chronographs (stopwatches) and watch them count down in real time. Pause, create, edit, and delete timers and chronos, and add custom labels/messages. Also sets alarms.", "icon": "app.png", "screenshots": [ @@ -19,4 +19,4 @@ ], "data": [{"name":"multitimer.json"}], "dependencies": {"scheduler":"type"} -} \ No newline at end of file +} From 3bdcc55c9b40dfcc28125dfc033e7fd3c8ca970a Mon Sep 17 00:00:00 2001 From: Lubomir Date: Tue, 24 May 2022 10:18:26 +1000 Subject: [PATCH 29/33] iconlaunch: Release app --- apps/iconlaunch/ChangeLog | 1 + apps/iconlaunch/README.md | 12 ++ apps/iconlaunch/app.js | 201 ++++++++++++++++++++++++++++++++ apps/iconlaunch/app.png | Bin 0 -> 888 bytes apps/iconlaunch/metadata.json | 18 +++ apps/iconlaunch/screenshot1.png | Bin 0 -> 4689 bytes apps/iconlaunch/screenshot2.png | Bin 0 -> 4752 bytes apps/iconlaunch/settings.js | 28 +++++ 8 files changed, 260 insertions(+) create mode 100644 apps/iconlaunch/ChangeLog create mode 100644 apps/iconlaunch/README.md create mode 100644 apps/iconlaunch/app.js create mode 100644 apps/iconlaunch/app.png create mode 100644 apps/iconlaunch/metadata.json create mode 100644 apps/iconlaunch/screenshot1.png create mode 100644 apps/iconlaunch/screenshot2.png create mode 100644 apps/iconlaunch/settings.js diff --git a/apps/iconlaunch/ChangeLog b/apps/iconlaunch/ChangeLog new file mode 100644 index 000000000..af7f83942 --- /dev/null +++ b/apps/iconlaunch/ChangeLog @@ -0,0 +1 @@ +0.01: Initial release diff --git a/apps/iconlaunch/README.md b/apps/iconlaunch/README.md new file mode 100644 index 000000000..0d36fdeb4 --- /dev/null +++ b/apps/iconlaunch/README.md @@ -0,0 +1,12 @@ +# Icon launcher + +A launcher inspired by smartphones, with an icon-only scrollable menu. + +This launcher shows 9 apps per screen, making it much faster to navigate versus the default launcher. + +![A screenshot](screenshot1.png) +![Another screenshot](screenshot2.png) + +## Technical note + +The app uses `E.showScroller`'s code in the app but not the function itself because `E.showScroller` doesn't report the position of a press to the select function. diff --git a/apps/iconlaunch/app.js b/apps/iconlaunch/app.js new file mode 100644 index 000000000..5dec33284 --- /dev/null +++ b/apps/iconlaunch/app.js @@ -0,0 +1,201 @@ +const s = require("Storage"); +const settings = s.readJSON("launch.json", true) || { showClocks: true, fullscreen: false }; + +if (!settings.fullscreen) { + Bangle.loadWidgets(); + Bangle.drawWidgets(); +} + +var apps = s + .list(/\.info$/) + .map((app) => { + var a = s.readJSON(app, 1); + return ( + a && { + name: a.name, + type: a.type, + icon: a.icon, + sortorder: a.sortorder, + src: a.src, + } + ); + }) + .filter( + (app) => + app && + (app.type == "app" || + (app.type == "clock" && settings.showClocks) || + !app.type) + ); +apps.sort((a, b) => { + var n = (0 | a.sortorder) - (0 | b.sortorder); + if (n) return n; // do sortorder first + if (a.name < b.name) return -1; + if (a.name > b.name) return 1; + return 0; +}); +apps.forEach((app) => { + if (app.icon) app.icon = s.read(app.icon); // should just be a link to a memory area +}); + +let scroll = 0; +let selectedItem = -1; +const R = Bangle.appRect; + +const iconSize = 48; + +const appsN = Math.floor(R.w / iconSize); +const whitespace = (R.w - appsN * iconSize) / (appsN + 1); + +const itemSize = iconSize + whitespace; + +function drawItem(itemI, r) { + g.clearRect(r.x, r.y, r.x + r.w - 1, r.y + r.h - 1); + let x = 0; + for (let i = itemI * appsN; i < appsN * (itemI + 1); i++) { + if (!apps[i]) break; + x += whitespace; + if (!apps[i].icon) { + g.setFontAlign(0,0,0).setFont("12x20:2").drawString("?", x + r.x+iconSize/2, r.y + iconSize/2); + } else { + g.drawImage(apps[i].icon, x + r.x, r.y); + } + if (selectedItem == i) { + g.drawRect( + x + r.x - 1, + r.y - 1, + x + r.x + iconSize + 1, + r.y + iconSize + 1 + ); + } + x += iconSize; + } + drawText(itemI); +} + +function drawItemAuto(i) { + var y = idxToY(i); + g.reset().setClipRect(R.x, y, R.x2, y + itemSize); + drawItem(i, { + x: R.x, + y: y, + w: R.w, + h: itemSize + }); + g.setClipRect(0, 0, g.getWidth() - 1, g.getHeight() - 1); +} + +let lastIsDown = false; + +function drawText(i) { + const selectedApp = apps[selectedItem]; + const idy = (selectedItem - (selectedItem % 3)) / 3; + if (!selectedApp || i != idy) return; + const appY = idxToY(idy) + iconSize / 2; + g.setFontAlign(0, 0, 0); + g.setFont("12x20"); + const rect = g.stringMetrics(selectedApp.name); + g.clearRect( + R.w / 2 - rect.width / 2, + appY - rect.height / 2, + R.w / 2 + rect.width / 2, + appY + rect.height / 2 + ); + g.drawString(selectedApp.name, R.w / 2, appY); +} + +function selectItem(id, e) { + const iconN = E.clip(Math.floor((e.x - R.x) / itemSize), 0, appsN - 1); + const appId = id * appsN + iconN; + if (appId == selectedItem && apps[appId]) { + const app = apps[appId]; + if (!app.src || s.read(app.src) === undefined) { + E.showMessage( /*LANG*/ "App Source\nNot found"); + } else { + load(app.src); + } + } + selectedItem = appId; + drawItems(); +} + +function idxToY(i) { + return i * itemSize + R.y - (scroll & ~1); +} + +function YtoIdx(y) { + return Math.floor((y + (scroll & ~1) - R.y) / itemSize); +} + +function drawItems() { + g.reset().clearRect(R.x, R.y, R.x2, R.y2); + g.setClipRect(R.x, R.y, R.x2, R.y2); + var a = YtoIdx(R.y); + var b = Math.min(YtoIdx(R.y2), 99); + for (var i = a; i <= b; i++) + drawItem(i, { + x: R.x, + y: idxToY(i), + w: R.w, + h: itemSize, + }); + g.setClipRect(0, 0, g.getWidth() - 1, g.getHeight() - 1); +} + +drawItems(); +g.flip(); + +const itemsN = Math.ceil(apps.length / appsN); + +Bangle.setUI({ + mode: "custom", + drag: (e) => { + let dy = e.dy; + if (scroll + R.h - dy > itemsN * itemSize) { + dy = scroll + R.h - itemsN * itemSize; + } + if (scroll - dy < 0) { + dy = scroll; + } + scroll -= dy; + scroll = E.clip(scroll, 0, itemSize * (itemsN - 1)); + g.setClipRect(R.x, R.y, R.x2, R.y2); + g.scroll(0, dy); + if (dy < 0) { + g.setClipRect(R.x, R.y2 - (1 - dy), R.x2, R.y2); + let i = YtoIdx(R.y2 - (1 - dy)); + let y = idxToY(i); + while (y < R.y2) { + drawItem(i, { + x: R.x, + y: y, + w: R.w, + h: itemSize, + }); + i++; + y += itemSize; + } + } else { + // d>0 + g.setClipRect(R.x, R.y, R.x2, R.y + dy); + let i = YtoIdx(R.y + dy); + let y = idxToY(i); + while (y > R.y - itemSize) { + drawItem(i, { + x: R.x, + y: y, + w: R.w, + h: itemSize, + }); + y -= itemSize; + i--; + } + } + g.setClipRect(0, 0, g.getWidth() - 1, g.getHeight() - 1); + }, + touch: (_, e) => { + if (e.y < R.y - 4) return; + var i = YtoIdx(e.y); + selectItem(i, e); + }, +}); diff --git a/apps/iconlaunch/app.png b/apps/iconlaunch/app.png new file mode 100644 index 0000000000000000000000000000000000000000..6f498aa20f592305a7a0788fa67a46d7a12f0d6f GIT binary patch literal 888 zcmV-;1Bd*HP) zZzpt+A8*GQfBgk^aKE|P3BZfO@zVI9=EjxRI)G(s9l)}69YCKf$tdF%u8TlFTBCke-#!7@j;O-i{ff1$hzaIOB^;s0|EpzsVSg@_VQCFuaIpPWXA7 zxdX~crl=m$SH}S48P>t$SS`&ip_=->YU=xkhld?W zmHhenxx2rx_qK!5>i)vz=L$dIS>M-GegEj_sFftiKvKiZDtR*-Z*6V0Pft%vJbUk2 z1S5BU;AZ@dHkTiM!9Df|k|Y@bp=0s@O-bQsG@9)XY>evr12^L*<^F)(qP}m1`hLD_ zy!dXnJLxa%z3q^C_80bF-=80lv{UouoqWFLJ^5hm2UbGs0G6#s6TpM|0ZDP1rg!rb zvME2{S>M-GeZSl7F3d}c&d$!t{e}HEi;r(X#J7+4>jySBH*0xGF%X4eILA+Hw8>1B zdwf$w(s1~Jn)<$K>ic8aPQ~$Umsj2sTs+7eEsye{J=jkd15E9S~5)l O0000oY_o zvKvpt$QEKIWy$*W`2)V^^TX$!bMHO(ywADko_p@OulKo$7UssB5K#yK0N^yaZGb-Y z)&HaHtf#iBX%TzsSOU?;`T+75vDMSyOrXAr75k|~vb!Vz0K5k#26|SZ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Ly&XXmd2@a+qv3i%x}8D3e5BKI2vg`ltYgMph7n@Hj|Je+O0@KK0 zi|jv_jeoZbIwA2IsrN4B?<;6C1qVa1Vd+|q9L#B`x`f}S!LVf#+w6v`M-|)gnve(q zSd@Czq~+gb&=5okT#Ys_pNryrS`x)BER z4;m~hLP#$~-!h}FKfej1yFYeO|4S`tM)0t;bug10*iSAG+T9Y#`yp5Jvv^wLKr79>$DASam@yixWFKF(4%dB{>d6@zvIxz>D= z7Xdku5wwjv3hbQGI&NiWo2KhZvp~7wE_+aejzfZVUNE!^He1wQfo-YVW-Oc>MjxA! uHU(7R>^RiJ7cn6!3F{FTR+>AHK_?fgGM}h{_)gD4024!V1G2tT%>M)X?(Yl$ literal 0 HcmV?d00001 diff --git a/apps/iconlaunch/screenshot2.png b/apps/iconlaunch/screenshot2.png new file mode 100644 index 0000000000000000000000000000000000000000..b17efa78b87d432dac7a0c80be616cb7a1e74452 GIT binary patch literal 4752 zcmZWNS5%V?tY3>oXpucCOA(o6>W?f1MP(FOEqm0;UNS_W45d|M$kHDRC|jUxD3(o? zPliBI0YN}nm8l>ylqKu(Kirplb23hnlbj?cFG;+)slf@jFdP7Y6Gn#DFh`R5AF;6> z@#=w9;VGQ(us*j>Sj+A3TdPbIPM-a*88V3NpT1MBdSQ2o{+3^o5N;qSRrw;S` z8c9gLSKP8gf5w|GIlYq3ZB@)PMh;&y>d> zCxb&x)Su}Dy&`TFLM+bjxR05oV)5s;kkvv*1tvm9jY+ro zF>FdzU@7Q`e*d;hY(?b4kP_SJmjD^Qieem69ZdCiST#8AV?0D@&dd<8fu=ALEL`Mkg&<3k8b(KgiPI%41sH08T z8oD@F)iBn=-+M=tX$8xWLi@NC4o7x=%=E=@7eUnnoXhObjY}d1_$D!S5y}|D#9cdL zFOu-b&2vgo&fGcv_|tPjk1jTU6&Rq#VpaXCeIH7(-VYXDM!~akB`-4{nRnxc zU&X?PT=XQ{V(yIRgV#6|f+&sy=zJzQAorK2g0@HgIVoSVJ4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|75S1!1@M0&oa)6B83~pJz8a~#9&zc1m#16^9h-dXtBn#n z09|8oYQ66WH?^bI)O;u7o}V69sUQDI&75}kG}C^jT+%DEvwy!XOyQ<4Gs@uYyrLZR S?|(lh!05W^wJJUQgZ}~Ti1d*F literal 0 HcmV?d00001 diff --git a/apps/iconlaunch/settings.js b/apps/iconlaunch/settings.js new file mode 100644 index 000000000..9fbc7ae6a --- /dev/null +++ b/apps/iconlaunch/settings.js @@ -0,0 +1,28 @@ +// make sure to enclose the function in parentheses +(function(back) { + let settings = Object.assign({ + showClocks: true, + fullscreen: false + }, require("Storage").readJSON("launch.json", true) || {}); + + let fonts = g.getFonts(); + function save(key, value) { + settings[key] = value; + require("Storage").write("launch.json",settings); + } + const appMenu = { + "": { "title": /*LANG*/"Launcher" }, + /*LANG*/"< Back": back, + /*LANG*/"Show Clocks": { + value: settings.showClocks == true, + format: v => v ? /*LANG*/"Yes" : /*LANG*/"No", + onchange: (m) => { save("showClocks", m) } + }, + /*LANG*/"Fullscreen": { + value: settings.fullscreen == true, + format: v => v ? /*LANG*/"Yes" : /*LANG*/"No", + onchange: (m) => { save("fullscreen", m) } + } + }; + E.showMenu(appMenu); +}); From 2ef59c470fdd35c0559a2b648a5b0d050af27c70 Mon Sep 17 00:00:00 2001 From: Rarder44 Date: Tue, 24 May 2022 10:18:03 +0200 Subject: [PATCH 30/33] implemented "direct launch" and "one click exit" settings --- apps/iconlaunch/ChangeLog | 1 + apps/iconlaunch/app.js | 10 +++++++++- apps/iconlaunch/metadata.json | 2 +- apps/iconlaunch/settings.js | 10 ++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/iconlaunch/ChangeLog b/apps/iconlaunch/ChangeLog index af7f83942..4a72a9f28 100644 --- a/apps/iconlaunch/ChangeLog +++ b/apps/iconlaunch/ChangeLog @@ -1 +1,2 @@ 0.01: Initial release +0.02: implemented "direct launch" and "one click exit" settings \ No newline at end of file diff --git a/apps/iconlaunch/app.js b/apps/iconlaunch/app.js index 5dec33284..4eeaff589 100644 --- a/apps/iconlaunch/app.js +++ b/apps/iconlaunch/app.js @@ -1,5 +1,8 @@ const s = require("Storage"); -const settings = s.readJSON("launch.json", true) || { showClocks: true, fullscreen: false }; +const settings = s.readJSON("launch.json", true) || { showClocks: true, fullscreen: false,direct:false,oneClickExit:false }; + +if( settings.oneClickExit) + setWatch(_=> load(), BTN1); if (!settings.fullscreen) { Bangle.loadWidgets(); @@ -107,6 +110,11 @@ function drawText(i) { function selectItem(id, e) { const iconN = E.clip(Math.floor((e.x - R.x) / itemSize), 0, appsN - 1); const appId = id * appsN + iconN; + if( settings.direct && apps[appId]) + { + load(apps[appId].src); + return; + } if (appId == selectedItem && apps[appId]) { const app = apps[appId]; if (!app.src || s.read(app.src) === undefined) { diff --git a/apps/iconlaunch/metadata.json b/apps/iconlaunch/metadata.json index 1dddb66b4..01e447672 100644 --- a/apps/iconlaunch/metadata.json +++ b/apps/iconlaunch/metadata.json @@ -2,7 +2,7 @@ "id": "iconlaunch", "name": "Icon Launcher", "shortName" : "Icon launcher", - "version": "0.01", + "version": "0.02", "icon": "app.png", "description": "A launcher inspired by smartphones, with an icon-only scrollable menu.", "tags": "tool,system,launcher", diff --git a/apps/iconlaunch/settings.js b/apps/iconlaunch/settings.js index 9fbc7ae6a..e9667047c 100644 --- a/apps/iconlaunch/settings.js +++ b/apps/iconlaunch/settings.js @@ -22,6 +22,16 @@ value: settings.fullscreen == true, format: v => v ? /*LANG*/"Yes" : /*LANG*/"No", onchange: (m) => { save("fullscreen", m) } + }, + /*LANG*/"Direct launch": { + value: settings.direct == true, + format: v => v ? /*LANG*/"Yes" : /*LANG*/"No", + onchange: (m) => { save("direct", m) } + }, + /*LANG*/"One click exit": { + value: settings.oneClickExit == true, + format: v => v ? /*LANG*/"Yes" : /*LANG*/"No", + onchange: (m) => { save("oneClickExit", m) } } }; E.showMenu(appMenu); From 9ef9137bc060757c491117d08a9effe26337029f Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 24 May 2022 09:50:10 +0100 Subject: [PATCH 31/33] update after https://github.com/espruino/BangleApps/pull/1868 since we use waypoints.json too --- apps/speedalt2/metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/speedalt2/metadata.json b/apps/speedalt2/metadata.json index 0de0b28bb..2a111af28 100644 --- a/apps/speedalt2/metadata.json +++ b/apps/speedalt2/metadata.json @@ -17,6 +17,7 @@ ], "data": [ {"name":"speedalt2.json"}, + {"name":"waypoints.json"}, {"name":"waypoints1.json"}, {"name":"waypoints2.json"}, {"name":"waypoints3.json"} From 4ded6c844ac4e8ecbbf4ee1a5d85b57ddc1e0baa Mon Sep 17 00:00:00 2001 From: Lubomir Date: Tue, 24 May 2022 22:54:16 +1000 Subject: [PATCH 32/33] iconlaunch: Change icon to one by icons8 This doesn't bump the version, as it doesn't change anything on the watch, just the website --- apps/iconlaunch/app.png | Bin 888 -> 1395 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/apps/iconlaunch/app.png b/apps/iconlaunch/app.png index 6f498aa20f592305a7a0788fa67a46d7a12f0d6f..1c8068c50d528badf72b8b3355668c55feb377f7 100644 GIT binary patch delta 1376 zcmV-m1)uu(2J;G#B!32COGiWi{{a60|De66lK=n(C`m*?RA_nwDFa5?mTXX^@)+0xcR-V}wvKQR9P2jRsMOf|@9=zR&^@QZ>4T#At%m zN?WufUMK}&W7{mD*0xZMQp{M zA^zQ9w5A!h23Q#s09iXu+KRh+pi%%7zCU6s&i~x>7|xQNV7pMHFp3mTs_#o>U7UZy zOI_JHTXWbGkXH-KK8Ly66LwYPFbx%ZIa0ZsG&z*8|JLFjGMyS*OS)}Qa@gvfQw4H5 zo^a0kNIZaJcZO`ruLza~)R z8%JhlB`j%&C2cUX0>E-7-ur103mdE1e`XN?#FQLYz)-7-78pM&vJ+_z5!*N$P z8QA*{*hC`YQ}{1nLbBcU*(zI!e(%N>0jYPfQ6#(r0>NU}Dh%LUe+vea|Bxk%sDn-B z4kZ*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dXnJLxa%z3q^C_80bF-=80lv{Uou zoqWFLJ^5hm2UbGs0G6#s6TpM|0ZDP1rg!rbvME2{S>M-GeZSl7F3d}c&d$!t{e}HE zi&~FwLBzL@_v;5XH#ci}Nih(GVK~Q6Y_!Qtm3w?sMAC5hftvchYU=xWhMmi&Y1+HE rxNz_1_g^1eC#f09dVKx#xctCBF?nJquv#)r00000NkvXXu0mjfF}Jb| From c3468fc0e91c4454d2e932deeeb5ce9dba7c8cf2 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 24 May 2022 16:28:22 +0100 Subject: [PATCH 33/33] bthrm 0.09: Misc Fixes and improvements (https://github.com/espruino/BangleApps/pull/1655) --- apps/bthrm/ChangeLog | 1 + apps/bthrm/metadata.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/bthrm/ChangeLog b/apps/bthrm/ChangeLog index 41eec666a..7ca8319b6 100644 --- a/apps/bthrm/ChangeLog +++ b/apps/bthrm/ChangeLog @@ -21,3 +21,4 @@ Adds some preset modes and a custom one Restructure the settings menu 0.08: Allow scanning for devices in settings +0.09: Misc Fixes and improvements (https://github.com/espruino/BangleApps/pull/1655) diff --git a/apps/bthrm/metadata.json b/apps/bthrm/metadata.json index 85c19ab33..39c1ff8bb 100644 --- a/apps/bthrm/metadata.json +++ b/apps/bthrm/metadata.json @@ -2,7 +2,7 @@ "id": "bthrm", "name": "Bluetooth Heart Rate Monitor", "shortName": "BT HRM", - "version": "0.08", + "version": "0.09", "description": "Overrides Bangle.js's build in heart rate monitor with an external Bluetooth one.", "icon": "app.png", "type": "app",