From 928ce68f9e26ae3a97b40911e41d676960064151 Mon Sep 17 00:00:00 2001 From: doudar Date: Tue, 9 Mar 2021 08:28:18 -0600 Subject: [PATCH] Fixed CPS math order of operations. ++ loop speed --- include/settings.h | 6 +++--- src/sensors/CyclePowerData.cpp | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/settings.h b/include/settings.h index defd094d..29d0068d 100644 --- a/include/settings.h +++ b/include/settings.h @@ -85,11 +85,11 @@ //Give up scanning for the lost connection after this many tries: #define MAX_SCAN_RETRIES 1 -//loop speed for the SmartSpin2k BLE Server -#define BLE_NOTIFY_DELAY 699 +//loop speed for the SmartSpin2k BLE communications +#define BLE_NOTIFY_DELAY 999 //loop speed for the SmartSpin2k BLE Client reconnect -#define BLE_CLIENT_DELAY 700 +#define BLE_CLIENT_DELAY 1000 //Number of devices that can be connected to the Client #define NUM_BLE_DEVICES 4 diff --git a/src/sensors/CyclePowerData.cpp b/src/sensors/CyclePowerData.cpp index 484485a1..8faef074 100644 --- a/src/sensors/CyclePowerData.cpp +++ b/src/sensors/CyclePowerData.cpp @@ -75,14 +75,13 @@ void CyclePowerData::decode(uint8_t *data, size_t length) this->crankEventTime = bytes_to_int(data[cPos + 3], data[cPos + 2]); if (this->crankRev > this->lastCrankRev && this->crankEventTime - this->lastCrankEventTime != 0) { - int cadence = abs(this->crankRev - this->lastCrankRev * 1024) / abs(this->crankEventTime - this->lastCrankEventTime) * 60; + int cadence = ((abs(this->crankRev - this->lastCrankRev) * 1024) / abs(this->crankEventTime - this->lastCrankEventTime)) * 60; if (cadence > 1) { if (cadence > 200) //Cadence Error { cadence = 0; } - this->cadence = cadence; this->missedReadingCount = 0; }