summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-05-02 14:55:43 +0200
committerGitHub <noreply@github.com>2021-05-02 14:55:43 +0200
commite3ead332b9db3ad7b6acde933b6a7943b3ac81e2 (patch)
tree3a135cc153081ee3bdc17e4b0bc52b5c2c57e828 /src
parent65e4fe0310c2bb89e0710e8e3da2a206673a783d (diff)
parenta62b81da3dca80b96c33b702b4265bcfa694d051 (diff)
Merge pull request #319 from DavidVentura/use-byte-for-ppg
Use int8_t for PPG data array
Diffstat (limited to 'src')
-rw-r--r--src/components/heartrate/Ppg.cpp10
-rw-r--r--src/components/heartrate/Ppg.h6
2 files changed, 8 insertions, 8 deletions
diff --git a/src/components/heartrate/Ppg.cpp b/src/components/heartrate/Ppg.cpp
index 578e2895..da0789e0 100644
--- a/src/components/heartrate/Ppg.cpp
+++ b/src/components/heartrate/Ppg.cpp
@@ -11,7 +11,7 @@ using namespace Pinetime::Controllers;
/** Original implementation from wasp-os : https://github.com/daniel-thompson/wasp-os/blob/master/wasp/ppg.py */
namespace {
- int Compare(int* d1, int* d2, size_t count) {
+ int Compare(int8_t* d1, int8_t* d2, size_t count) {
int e = 0;
for (size_t i = 0; i < count; i++) {
auto d = d1[i] - d2[i];
@@ -20,11 +20,11 @@ namespace {
return e;
}
- int CompareShift(int* d, int shift, size_t count) {
+ int CompareShift(int8_t* d, int shift, size_t count) {
return Compare(d + shift, d, count - shift);
}
- int Trough(int* d, size_t size, float mn, float mx) {
+ int Trough(int8_t* d, size_t size, uint8_t mn, uint8_t mx) {
auto z2 = CompareShift(d, mn - 2, size);
auto z1 = CompareShift(d, mn - 1, size);
for (int i = mn; i < mx + 1; i++) {
@@ -45,13 +45,13 @@ Ppg::Ppg(float spl)
lpf {0.11595249, 0.23190498, 0.11595249, -0.72168143, 0.18549138} {
}
-int Ppg::Preprocess(float spl) {
+int8_t Ppg::Preprocess(float spl) {
spl -= offset;
spl = hpf.Step(spl);
spl = agc.Step(spl);
spl = lpf.Step(spl);
- auto spl_int = static_cast<int>(spl);
+ auto spl_int = static_cast<int8_t>(spl);
if (dataIndex < 200)
data[dataIndex++] = spl_int;
diff --git a/src/components/heartrate/Ppg.h b/src/components/heartrate/Ppg.h
index 6a2fcf18..ee07dfcf 100644
--- a/src/components/heartrate/Ppg.h
+++ b/src/components/heartrate/Ppg.h
@@ -10,14 +10,14 @@ namespace Pinetime {
public:
explicit Ppg(float spl);
- int Preprocess(float spl);
+ int8_t Preprocess(float spl);
float HeartRate();
void SetOffset(uint16_t i);
void Reset();
private:
- std::array<int, 200> data;
+ std::array<int8_t, 200> data;
size_t dataIndex = 0;
float offset;
Biquad hpf;
@@ -27,4 +27,4 @@ namespace Pinetime {
float ProcessHeartRate();
};
}
-} \ No newline at end of file
+}