Skip to content
Open
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
12 changes: 11 additions & 1 deletion src/components/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ namespace Pinetime {
return (settings.dfuAndFsEnabledOnBoot ? DfuAndFsMode::Enabled : DfuAndFsMode::Disabled);
};

void SetHeartRateRebootMode(bool enabled) {
settingsChanged = settingsChanged || (enabled != settings.heartRateEnabledOnBoot);
settings.heartRateEnabledOnBoot = enabled;
}

bool GetHeartRateRebootMode() {
return settings.heartRateEnabledOnBoot;
}

std::optional<uint16_t> GetHeartRateBackgroundMeasurementInterval() const {
if (settings.heartRateBackgroundPeriod == std::numeric_limits<uint16_t>::max()) {
return std::nullopt;
Expand All @@ -354,7 +363,7 @@ namespace Pinetime {
private:
Pinetime::Controllers::FS& fs;

static constexpr uint32_t settingsVersion = 0x000a;
static constexpr uint32_t settingsVersion = 0x000b;

struct SettingsData {
uint32_t version = settingsVersion;
Expand Down Expand Up @@ -383,6 +392,7 @@ namespace Pinetime {

bool dfuAndFsEnabledOnBoot = false;
uint16_t heartRateBackgroundPeriod = std::numeric_limits<uint16_t>::max(); // Disabled by default
bool heartRateEnabledOnBoot = false;
};

SettingsData settings;
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/HeartRate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ HeartRate::HeartRate(Controllers::HeartRateController& heartRateController, Syst
HeartRate::~HeartRate() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
heartRateController.SaveSettings();
}

void HeartRate::Refresh() {
Expand Down
9 changes: 9 additions & 0 deletions src/heartratetask/HeartRateTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ void HeartRateTask::Start() {

if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 1, &taskHandle)) {
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
} else {
if (settings.GetHeartRateRebootMode())
controller.Enable();
}
}

Expand Down Expand Up @@ -147,9 +150,11 @@ void HeartRateTask::Work() {
// will self-resolve at the next screen on event
newState = States::ForegroundMeasuring;
valueCurrentlyShown = false;
settings.SetHeartRateRebootMode(true);
break;
case Messages::Disable:
newState = States::Disabled;
settings.SetHeartRateRebootMode(false);
break;
}
}
Expand All @@ -176,6 +181,10 @@ void HeartRateTask::Work() {
}
}

void HeartRateTask::SaveSettings() {
settings.SaveSettings();
}

void HeartRateTask::PushMessage(HeartRateTask::Messages msg) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(messageQueue, &msg, &xHigherPriorityTaskWoken);
Expand Down
1 change: 1 addition & 0 deletions src/heartratetask/HeartRateTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace Pinetime {
void Start();
void Work();
void PushMessage(Messages msg);
void SaveSettings();

private:
enum class States : uint8_t { Disabled, Waiting, BackgroundMeasuring, ForegroundMeasuring };
Expand Down