From 464b689a03bca06099fba316b4c6c66c619d5521 Mon Sep 17 00:00:00 2001 From: Yehoshua Pesach Wallach Date: Mon, 13 Dec 2021 12:47:52 +0200 Subject: [PATCH] changed ReadHrs and ReadAls to uint32, and did static_cast instead of hidden cast when using it --- src/drivers/Hrs3300.cpp | 4 ++-- src/drivers/Hrs3300.h | 4 ++-- src/heartratetask/HeartRateTask.cpp | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/drivers/Hrs3300.cpp b/src/drivers/Hrs3300.cpp index 45458adc..cfc476cb 100644 --- a/src/drivers/Hrs3300.cpp +++ b/src/drivers/Hrs3300.cpp @@ -54,14 +54,14 @@ void Hrs3300::Disable() { WriteRegister(static_cast(Registers::Enable), value); } -uint16_t Hrs3300::ReadHrs() { +uint32_t Hrs3300::ReadHrs() { auto m = ReadRegister(static_cast(Registers::C0DataM)); auto h = ReadRegister(static_cast(Registers::C0DataH)); auto l = ReadRegister(static_cast(Registers::C0dataL)); return ((l & 0x30) << 12) | (m << 8) | ((h & 0x0f) << 4) | (l & 0x0f); } -uint16_t Hrs3300::ReadAls() { +uint32_t Hrs3300::ReadAls() { auto m = ReadRegister(static_cast(Registers::C1dataM)); auto h = ReadRegister(static_cast(Registers::C1dataH)); auto l = ReadRegister(static_cast(Registers::C1dataL)); diff --git a/src/drivers/Hrs3300.h b/src/drivers/Hrs3300.h index 01310c62..8bbdc69a 100644 --- a/src/drivers/Hrs3300.h +++ b/src/drivers/Hrs3300.h @@ -30,8 +30,8 @@ namespace Pinetime { void Init(); void Enable(); void Disable(); - uint16_t ReadHrs(); - uint16_t ReadAls(); + uint32_t ReadHrs(); + uint32_t ReadAls(); void SetGain(uint8_t gain); void SetDrive(uint8_t drive); diff --git a/src/heartratetask/HeartRateTask.cpp b/src/heartratetask/HeartRateTask.cpp index 213ab4a7..2f689b9b 100644 --- a/src/heartratetask/HeartRateTask.cpp +++ b/src/heartratetask/HeartRateTask.cpp @@ -65,8 +65,7 @@ void HeartRateTask::Work() { } if (measurementStarted) { - auto hrs = heartRateSensor.ReadHrs(); - ppg.Preprocess(hrs); + ppg.Preprocess(static_cast(heartRateSensor.ReadHrs())); auto bpm = ppg.HeartRate(); if (lastBpm == 0 && bpm == 0)