diff options
author | Riku Isokoski <riksu9000@gmail.com> | 2022-12-18 19:14:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-18 18:14:36 +0100 |
commit | afea7ca0d1d670bdee04cfe80a1d8c36efa4fca0 (patch) | |
tree | f1a4196755f85af4490c44f6b2c8784f9eb48669 /src/components/heartrate/Ppg.cpp | |
parent | bfedf47d1a8ac6d5df1d0ad4d4071323366d22e8 (diff) |
Update clang-tidy configuration and fix some warnings (#1474)
Don't enable coding conventions from unrelated projects. Only enable
generic checks.
Diffstat (limited to 'src/components/heartrate/Ppg.cpp')
-rw-r--r-- | src/components/heartrate/Ppg.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/components/heartrate/Ppg.cpp b/src/components/heartrate/Ppg.cpp index a5d83696..900b1c22 100644 --- a/src/components/heartrate/Ppg.cpp +++ b/src/components/heartrate/Ppg.cpp @@ -29,8 +29,9 @@ namespace { auto z1 = CompareShift(d, mn - 1, size); for (int i = mn; i < mx + 1; i++) { auto z = CompareShift(d, i, size); - if (z2 > z1 && z1 < z) + if (z2 > z1 && z1 < z) { return i; + } z2 = z1; z1 = z; } @@ -52,41 +53,48 @@ int8_t Ppg::Preprocess(float spl) { auto spl_int = static_cast<int8_t>(spl); - if (dataIndex < 200) + if (dataIndex < 200) { data[dataIndex++] = spl_int; + } return spl_int; } -float Ppg::HeartRate() { - if (dataIndex < 200) +int Ppg::HeartRate() { + if (dataIndex < 200) { return 0; + } NRF_LOG_INFO("PREPROCESS, offset = %d", offset); auto hr = ProcessHeartRate(); dataIndex = 0; return hr; } -float Ppg::ProcessHeartRate() { - auto t0 = Trough(data.data(), dataIndex, 7, 48); - if (t0 < 0) + +int Ppg::ProcessHeartRate() { + int t0 = Trough(data.data(), dataIndex, 7, 48); + if (t0 < 0) { return 0; + } - float t1 = t0 * 2; + int t1 = t0 * 2; t1 = Trough(data.data(), dataIndex, t1 - 5, t1 + 5); - if (t1 < 0) + if (t1 < 0) { return 0; + } - float t2 = static_cast<int>(t1 * 3) / 2; + int t2 = (t1 * 3) / 2; t2 = Trough(data.data(), dataIndex, t2 - 5, t2 + 5); - if (t2 < 0) + if (t2 < 0) { return 0; + } - float t3 = static_cast<int>(t2 * 4) / 3; + int t3 = (t2 * 4) / 3; t3 = Trough(data.data(), dataIndex, t3 - 4, t3 + 4); - if (t3 < 0) - return static_cast<int>(60 * 24 * 3) / static_cast<int>(t2); + if (t3 < 0) { + return (60 * 24 * 3) / t2; + } - return static_cast<int>(60 * 24 * 4) / static_cast<int>(t3); + return (60 * 24 * 4) / t3; } void Ppg::SetOffset(uint16_t offset) { |