From a7114f21b7d1f8ae29e0e005757b42882917ac3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sun, 18 Apr 2021 13:50:38 +0200 Subject: [PATCH] Fix display consistency with the HR measurement when measurements are already running when the app is open. --- src/displayapp/screens/HeartRate.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp index 0bc3c352..e735c18d 100644 --- a/src/displayapp/screens/HeartRate.cpp +++ b/src/displayapp/screens/HeartRate.cpp @@ -29,11 +29,16 @@ namespace { HeartRate::HeartRate(Pinetime::Applications::DisplayApp *app, Controllers::HeartRateController& heartRateController, System::SystemTask &systemTask) : Screen(app), heartRateController{heartRateController}, systemTask{systemTask} { - + bool isHrRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; label_hr = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); - lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + + if(isHrRunning) + lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + else + lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_label_set_text(label_hr, "000"); lv_obj_align(label_hr, nullptr, LV_ALIGN_CENTER, 0, -40); @@ -41,7 +46,6 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp *app, Controllers::Heart lv_label_set_text(label_bpm, "Heart rate BPM"); lv_obj_align(label_bpm, label_hr, LV_ALIGN_OUT_TOP_MID, 0, -20); - label_status = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(label_status, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222)); lv_label_set_text(label_status, ToString(Pinetime::Controllers::HeartRateController::States::NotEnoughData)); @@ -55,7 +59,9 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp *app, Controllers::Heart lv_obj_align(btn_startStop, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0); label_startStop = lv_label_create(btn_startStop, nullptr); - UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped); + UpdateStartStopButton(isHrRunning); + if(isHrRunning) + systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping); } HeartRate::~HeartRate() {