Skip to content

Commit a48d4e0

Browse files
committed
Power optimization - Enable HRS3300 (heart rate sensor) sleep mode.
Put the HRS3300 to sleep mode when InfiniTime is going to sleep. This change reduces the power consumption by 130µA when the heart rate sensor is disabled.
1 parent 32a9fff commit a48d4e0

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/drivers/Hrs3300.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
using namespace Pinetime::Drivers;
1616

17+
namespace {
18+
static constexpr uint8_t ledDriveCurrentValue = 0x2f;
19+
}
20+
1721
/** Driver for the HRS3300 heart rate sensor.
1822
* Original implementation from wasp-os : https://github.com/daniel-thompson/wasp-os/blob/master/wasp/drivers/hrs3300.py
1923
*
@@ -35,7 +39,7 @@ void Hrs3300::Init() {
3539
// Note: Setting low nibble to 0x8 per the datasheet results in
3640
// modulated LED driver output. Setting to 0xF results in clean,
3741
// steady output during the ADC conversion period.
38-
WriteRegister(static_cast<uint8_t>(Registers::PDriver), 0x2f);
42+
WriteRegister(static_cast<uint8_t>(Registers::PDriver), ledDriveCurrentValue);
3943

4044
// HRS and ALS both in 15-bit mode results in ~50ms LED drive period
4145
// and presumably ~50ms ADC conversion period.
@@ -50,13 +54,17 @@ void Hrs3300::Enable() {
5054
auto value = ReadRegister(static_cast<uint8_t>(Registers::Enable));
5155
value |= 0x80;
5256
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
57+
58+
WriteRegister(static_cast<uint8_t>(Registers::PDriver), ledDriveCurrentValue);
5359
}
5460

5561
void Hrs3300::Disable() {
5662
NRF_LOG_INFO("DISABLE");
5763
auto value = ReadRegister(static_cast<uint8_t>(Registers::Enable));
5864
value &= ~0x80;
5965
WriteRegister(static_cast<uint8_t>(Registers::Enable), value);
66+
67+
WriteRegister(static_cast<uint8_t>(Registers::PDriver), 0);
6068
}
6169

6270
uint32_t Hrs3300::ReadHrs() {

0 commit comments

Comments
 (0)