Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hrs driver changes #876

Merged
merged 2 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/drivers/Hrs3300.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ void Hrs3300::Disable() {
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
}

uint16_t Hrs3300::ReadHrs() {
uint32_t Hrs3300::ReadHrs() {
auto m = ReadRegister(static_cast<uint8_t>(Registers::C0DataM));
auto h = ReadRegister(static_cast<uint8_t>(Registers::C0DataH));
auto l = ReadRegister(static_cast<uint8_t>(Registers::C0dataL));
return (m << 8) | ((h & 0x0f) << 4) | (l & 0x0f) | ((l & 0x30) << 12);
return ((l & 0x30) << 12) | (m << 8) | ((h & 0x0f) << 4) | (l & 0x0f);
}

uint16_t Hrs3300::ReadAls() {
uint32_t Hrs3300::ReadAls() {
auto m = ReadRegister(static_cast<uint8_t>(Registers::C1dataM));
auto h = ReadRegister(static_cast<uint8_t>(Registers::C1dataH));
auto l = ReadRegister(static_cast<uint8_t>(Registers::C1dataL));
return (m << 3) | ((h & 0x3f) << 11) | (l & 0x07);
return ((h & 0x3f) << 11) | (m << 3) | (l & 0x07);
}

void Hrs3300::SetGain(uint8_t gain) {
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/Hrs3300.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/heartratetask/HeartRateTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ void HeartRateTask::Work() {
}

if (measurementStarted) {
auto hrs = heartRateSensor.ReadHrs();
ppg.Preprocess(hrs);
ppg.Preprocess(static_cast<float>(heartRateSensor.ReadHrs()));
auto bpm = ppg.HeartRate();

if (lastBpm == 0 && bpm == 0)
Expand Down