diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-03-30 20:50:42 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-03-30 20:50:42 (GMT) |
| commit | 5db030547eeb0aae422447ddb63f0bd2f9d5f384 (patch) | |
| tree | 648bdc9654a3d826eaef1cefaa4b329495016569 /src/components/heartrate/Biquad.cpp | |
| parent | e1cb4f64097a7d084f178f762546cecb5bd3c6be (diff) | |
Revert "sans heart"ultraredux-heart
This reverts commit 6ef420d2407a4685b56a233f6b0f849e90c6cf49.
Diffstat (limited to 'src/components/heartrate/Biquad.cpp')
| -rw-r--r-- | src/components/heartrate/Biquad.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/components/heartrate/Biquad.cpp b/src/components/heartrate/Biquad.cpp new file mode 100644 index 0000000..b7edd40 --- /dev/null +++ b/src/components/heartrate/Biquad.cpp @@ -0,0 +1,26 @@ +/* + SPDX-License-Identifier: LGPL-3.0-or-later + Original work Copyright (C) 2020 Daniel Thompson + C++ port Copyright (C) 2021 Jean-François Milants +*/ + +#include "components/heartrate/Biquad.h" + +using namespace Pinetime::Controllers; + +/** Original implementation from wasp-os : https://github.com/daniel-thompson/wasp-os/blob/master/wasp/ppg.py */ +Biquad::Biquad(float b0, float b1, float b2, float a1, float a2) : b0 {b0}, b1 {b1}, b2 {b2}, a1 {a1}, a2 {a2} { +} + +float Biquad::Step(float x) { + auto v1 = this->v1; + auto v2 = this->v2; + + auto v = x - (a1 * v1) - (a2 * v2); + auto y = (b0 * v) + (b1 * v1) + (b2 * v2); + + this->v2 = v1; + this->v1 = v; + + return y; +} |
