blecsc 0.04: Added support for <1 wheel/crank event/second (using idle counters) (ref #3434)

pull/3446/head
Gordon Williams 2024-06-04 10:26:18 +01:00
parent 8742e68e2e
commit 050cd914fa
3 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,4 @@
0.01: Initial version
0.02: Minor code improvements
0.03: Moved from cycling app, fixed connection issues and cadence
0.04: Added support for <1 wheel/crank event/second (using idle counters) (ref #3434)

View File

@ -47,6 +47,8 @@ class BLECSC {
this.kph = undefined;
this.wrps = 0; // wheel revs per second
this.crps = 0; // crank revs per second
this.widle = 0; // wheel idle counter
this.cidle = 0; // crank idle counter
//this.batteryLevel = undefined;
}
@ -117,7 +119,12 @@ class BLECSC {
if (this.lastLwet === undefined) this.lastLwet = this.lwet;
if (this.lwet < this.lastLwet) this.lastLwet -= 65536;
let secs = (this.lwet - this.lastLwet) / 1024;
this.wrps = (this.cwr - this.lastCwr) / (secs?secs:1);
if (secs)
this.wrps = (this.cwr - this.lastCwr) / secs;
else {
if (this.widle<5) this.widle++;
else this.wrps = 0;
}
this.kph = this.wrps * this.settings.circum / 3600;
Object.assign(data, { // Notify the 'wheelEvent' handler
cwr: this.cwr, // cumulative wheel revolutions
@ -138,7 +145,12 @@ class BLECSC {
if (this.lastLcet === undefined) this.lastLcet = this.lcet;
if (this.lcet < this.lastLcet) this.lastLcet -= 65536;
let secs = (this.lcet - this.lastLcet) / 1024;
this.crps = (this.ccr - this.lastCcr) / (secs?secs:1);
if (secs)
this.crps = (this.ccr - this.lastCcr) / secs;
else {
if (this.cidle<5) this.cidle++;
else this.crps = 0;
}
Object.assign(data, { // Notify the 'crankEvent' handler
ccr: this.ccr, // cumulative crank revolutions
lcet: this.lcet, // last crank event time

View File

@ -2,7 +2,7 @@
"id": "blecsc",
"name": "BLE Cycling Speed Sensor Library",
"shortName": "BLE CSC",
"version": "0.03",
"version": "0.04",
"description": "Module to get live values from a BLE Cycle Speed (CSC) sensor. Includes recorder and clockinfo plugins",
"icon": "icons8-cycling-48.png",
"tags": "outdoors,exercise,ble,bluetooth,clkinfo",