From e908552a0e7b8c82d6b7a8f68261641f05ece5f9 Mon Sep 17 00:00:00 2001 From: marko Date: Mon, 28 Sep 2020 13:46:53 -0400 Subject: [PATCH] Manually reconnect with button 3 push --- apps/cscsensor/README.md | 2 ++ apps/cscsensor/cscsensor.app.js | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/cscsensor/README.md b/apps/cscsensor/README.md index 8ba862241..a31a4dc28 100644 --- a/apps/cscsensor/README.md +++ b/apps/cscsensor/README.md @@ -9,8 +9,10 @@ Currently the app displays the following data: - maximum speed - trip distance traveled - total distance traveled +- an icon with the battery status of the remote sensor Button 1 resets all measurements except total distance traveled. The latter gets preserved by being written to storage every 0.1 miles and upon exiting the app. +If the watch app has not received an update from the sensor for at least 10 seconds, pushing button 3 will attempt to reconnect to the sensor. I do not have access to a cadence sensor at the moment, so only the speed part is currently implemented. Values displayed are imperial or metric (depending on locale), the wheel circumference can be adjusted in the global settings app. diff --git a/apps/cscsensor/cscsensor.app.js b/apps/cscsensor/cscsensor.app.js index 5be9e1591..c402c06da 100644 --- a/apps/cscsensor/cscsensor.app.js +++ b/apps/cscsensor/cscsensor.app.js @@ -146,7 +146,7 @@ class CSCSensor { } } this.lastSpeed = this.speed; - if (this.speed>this.maxSpeed && (this.movingTime>3 || this.speed<20)) this.maxSpeed = this.speed; + if (this.speed>this.maxSpeed && (this.movingTime>3 || this.speed<20) && this.speed<50) this.maxSpeed = this.speed; } if (qChanged && this.qUpdateScreen) this.updateScreen(); } @@ -189,14 +189,16 @@ function parseDevice(d) { function connection_setup() { NRF.setScan(); + mySensor.screenInit = true; NRF.setScan(parseDevice, { filters: [{services:["1816"]}], timeout: 2000}); - g.clearRect(0, 60, 239, 239).setFontVector(18).setFontAlign(0, 0, 0).setColor(0, 1, 0); + g.clearRect(0, 48, 239, 239).setFontVector(18).setFontAlign(0, 0, 0).setColor(0, 1, 0); g.drawString("Scanning for CSC sensor...", 120, 120); } 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();