From e54ad090b3652e46f7e614980a88fb4312ec68b7 Mon Sep 17 00:00:00 2001 From: marko Date: Mon, 29 Nov 2021 19:19:57 -0500 Subject: [PATCH 001/865] Display menu of available BLE devices --- apps/cscsensor/cscsensor.app.js | 52 ++++++++++++++++++++++++--------- apps/cscsensor/settings.js | 6 ++++ apps/dsdrelay/dsdrelay.app.js | 25 +++++++++++++--- 3 files changed, 66 insertions(+), 17 deletions(-) diff --git a/apps/cscsensor/cscsensor.app.js b/apps/cscsensor/cscsensor.app.js index c402c06da..8f6c58577 100644 --- a/apps/cscsensor/cscsensor.app.js +++ b/apps/cscsensor/cscsensor.app.js @@ -165,10 +165,10 @@ function getSensorBatteryLevel(gatt) { function parseDevice(d) { device = d; - g.clearRect(0, 60, 239, 239).setFontAlign(0, 0, 0).setColor(0, 1, 0).drawString("Found device", 120, 120).flip(); + g.clearRect(0, 24, 239, 239).setFontAlign(0, 0, 0).setColor(0, 1, 0).drawString("Found device", 120, 120).flip(); device.gatt.connect().then(function(ga) { gatt = ga; - g.clearRect(0, 60, 239, 239).setFontAlign(0, 0, 0).setColor(0, 1, 0).drawString("Connected", 120, 120).flip(); + g.clearRect(0, 24, 239, 239).setFontAlign(0, 0, 0).setColor(0, 1, 0).drawString("Connected", 120, 120).flip(); return gatt.getPrimaryService("1816"); }).then(function(s) { service = s; @@ -179,26 +179,52 @@ function parseDevice(d) { return characteristic.startNotifications(); }).then(function() { console.log("Done!"); - g.clearRect(0, 60, 239, 239).setColor(1, 1, 1).flip(); - getSensorBatteryLevel(gatt); + g.clearRect(0, 24, 239, 239).setColor(1, 1, 1).flip(); + setWatch(function() { mySensor.reset(); g.clearRect(0, 24, 239, 239); mySensor.updateScreen(); }, BTN1, {repeat:true, debounce:20}); + E.on('kill',()=>{ if (gatt!=undefined) gatt.disconnect(); mySensor.settings.totaldist = mySensor.totaldist; storage.writeJSON(SETTINGS_FILE, mySensor.settings); }); + setWatch(function() { if (Date.now()-mySensor.lastBangleTime>10000) connection_setup(); }, BTN3, {repeat:true, debounce:20}); getSensorBatteryLevel(gatt); mySensor.updateScreen(); }).catch(function(e) { - g.clearRect(0, 60, 239, 239).setColor(1, 0, 0).setFontAlign(0, 0, 0).drawString("ERROR"+e, 120, 120).flip(); + g.clearRect(0, 24, 239, 239).setColor(1, 0, 0).setFontAlign(0, 0, 0).drawString("ERROR"+e, 120, 120).flip(); console.log(e); })} +function scan() { + menu = { + "": { "title": "Select sensor" }, + "re-scan": () => scan() + }; + waitMessage(); + NRF.findDevices(devices => { + devices.forEach(device =>{ + let deviceName = device.id.substring(0,17); + if (device.name) { + deviceName = device.name; + } + if (device.services!=undefined && device.services.find(e => e=="1816")) deviceName = "* "+deviceName; + menu[deviceName] = () => { E.showMenu(); parseDevice(device); } + }); + E.showMenu(menu); + }, { active: true }); +} + +function waitMessage() { + E.showMenu(); + E.showMessage("scanning"); +} + function connection_setup() { - NRF.setScan(); - mySensor.screenInit = true; - NRF.setScan(parseDevice, { filters: [{services:["1816"]}], timeout: 2000}); - g.clearRect(0, 48, 239, 239).setFontVector(18).setFontAlign(0, 0, 0).setColor(0, 1, 0); - g.drawString("Scanning for CSC sensor...", 120, 120); + if (mySensor.settings.autoconnect) { + NRF.setScan(); + mySensor.screenInit = true; + NRF.setScan(parseDevice, { filters: [{services:["1816"]}], timeout: 2000}); + g.clearRect(0, 24, 239, 239).setFontVector(18).setFontAlign(0, 0, 0).setColor(0, 1, 0); + g.drawString("Scanning for CSC sensor...", 120, 120); + } + else scan(); } connection_setup(); -setWatch(function() { mySensor.reset(); g.clearRect(0, 48, 239, 239); mySensor.updateScreen(); }, BTN1, {repeat:true, debounce:20}); -E.on('kill',()=>{ if (gatt!=undefined) gatt.disconnect(); mySensor.settings.totaldist = mySensor.totaldist; storage.writeJSON(SETTINGS_FILE, mySensor.settings); }); -setWatch(function() { if (Date.now()-mySensor.lastBangleTime>10000) connection_setup(); }, BTN3, {repeat:true, debounce:20}); NRF.on('disconnect', connection_setup); Bangle.loadWidgets(); diff --git a/apps/cscsensor/settings.js b/apps/cscsensor/settings.js index d7a7d565d..cc08da146 100644 --- a/apps/cscsensor/settings.js +++ b/apps/cscsensor/settings.js @@ -6,6 +6,7 @@ const SETTINGS_FILE = 'cscsensor.json' // initialize with default settings... let s = { + 'autoconnect': true, 'wheelcirc': 2230, } // ...and overwrite them with any saved values @@ -32,6 +33,11 @@ step: 5, onchange: save('wheelcirc'), }, + 'Auto connect': { + value: s.autoconnect, + format: boolFormat, + onchange: save('autoconnect'), + }, 'Reset total distance': function() { E.showPrompt("Zero total distance?", {buttons: {"No":false, "Yes":true}}).then(function(v) { if (v) { diff --git a/apps/dsdrelay/dsdrelay.app.js b/apps/dsdrelay/dsdrelay.app.js index 18e7293aa..ddfb935e6 100644 --- a/apps/dsdrelay/dsdrelay.app.js +++ b/apps/dsdrelay/dsdrelay.app.js @@ -78,10 +78,27 @@ function parseDevice(d) { })} function connection_setup() { - NRF.setScan(); - NRF.setScan(parseDevice, { filters: [{services:["FFE0"]}], timeout: 2000}); - g.clearRect(0, 60, 239, 239).setFontVector(18).setFontAlign(0, 0, 0).setColor(0, 1, 0); - g.drawString("Scanning for relay...", 120, 120); + menu = { + "": { "title": "Select relay board" }, + "re-scan": () => connection_setup() + }; + waitMessage(); + NRF.findDevices(devices => { + devices.forEach(device =>{ + let deviceName = device.id.substring(0,17); + if (device.name) { + deviceName = device.name; + } + if (device.services!=undefined && device.services.find(e => e.toLowerCase()=="ffe0")) deviceName = "* "+deviceName; + menu[deviceName] = () => { E.showMenu(); parseDevice(device); } + }); + E.showMenu(menu); + }, { active: true }); +} + +function waitMessage() { + E.showMenu(); + E.showMessage("scanning"); } function moveChannelFrame(oldc, newc) { From bfc228e50cf631afef6c6393d17b0ae75a67483d Mon Sep 17 00:00:00 2001 From: marko Date: Thu, 2 Dec 2021 11:13:02 -0500 Subject: [PATCH 002/865] revert to 64x64 tiles --- apps/openstmap/custom.html | 40 ++++++++++++++------------------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/apps/openstmap/custom.html b/apps/openstmap/custom.html index 88d94ed37..95a4ff0a6 100644 --- a/apps/openstmap/custom.html +++ b/apps/openstmap/custom.html @@ -32,7 +32,7 @@
-

3 bit
+

3 bit