Analog: include heart and step info
This commit is contained in:
parent
c78e210f3c
commit
904749654a
2 changed files with 67 additions and 4 deletions
|
@ -5,6 +5,8 @@
|
||||||
#include "displayapp/screens/BleIcon.h"
|
#include "displayapp/screens/BleIcon.h"
|
||||||
#include "displayapp/screens/Symbols.h"
|
#include "displayapp/screens/Symbols.h"
|
||||||
#include "displayapp/screens/NotificationIcon.h"
|
#include "displayapp/screens/NotificationIcon.h"
|
||||||
|
#include "components/heartrate/HeartRateController.h"
|
||||||
|
#include "components/motion/MotionController.h"
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
#include "displayapp/InfiniTimeTheme.h"
|
#include "displayapp/InfiniTimeTheme.h"
|
||||||
|
|
||||||
|
@ -45,14 +47,18 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
Controllers::NotificationManager& notificationManager,
|
Controllers::NotificationManager& notificationManager,
|
||||||
Controllers::Settings& settingsController)
|
Controllers::Settings& settingsController,
|
||||||
|
Controllers::HeartRateController& heartRateController,
|
||||||
|
Controllers::MotionController& motionController)
|
||||||
: currentDateTime {{}},
|
: currentDateTime {{}},
|
||||||
batteryIcon(true),
|
batteryIcon(true),
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
notificationManager {notificationManager},
|
notificationManager {notificationManager},
|
||||||
settingsController {settingsController} {
|
settingsController {settingsController},
|
||||||
|
heartRateController {heartRateController},
|
||||||
|
motionController {motionController} {
|
||||||
|
|
||||||
sHour = 99;
|
sHour = 99;
|
||||||
sMinute = 99;
|
sMinute = 99;
|
||||||
|
@ -159,6 +165,26 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
|
||||||
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false);
|
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false);
|
||||||
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
|
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
|
||||||
|
|
||||||
|
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
|
||||||
|
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
|
||||||
|
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||||
|
|
||||||
|
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
|
||||||
|
lv_label_set_text_static(heartbeatValue, "");
|
||||||
|
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
||||||
|
|
||||||
|
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
|
||||||
|
lv_label_set_text_static(stepIcon, Symbols::shoe);
|
||||||
|
lv_obj_align(stepIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
||||||
|
|
||||||
|
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
|
||||||
|
lv_label_set_text_static(stepValue, "0");
|
||||||
|
lv_obj_align(stepValue, stepIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||||
|
|
||||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
|
@ -268,4 +294,26 @@ void WatchFaceAnalog::Refresh() {
|
||||||
lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0);
|
lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heartbeat = heartRateController.HeartRate();
|
||||||
|
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
||||||
|
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
|
||||||
|
if (heartbeatRunning.Get()) {
|
||||||
|
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
|
||||||
|
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
|
||||||
|
} else {
|
||||||
|
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
|
||||||
|
lv_label_set_text_static(heartbeatValue, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_realign(heartbeatIcon);
|
||||||
|
lv_obj_realign(heartbeatValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
stepCount = motionController.NbSteps();
|
||||||
|
if (stepCount.IsUpdated()) {
|
||||||
|
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
||||||
|
lv_obj_realign(stepValue);
|
||||||
|
lv_obj_realign(stepIcon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace Pinetime {
|
||||||
class Battery;
|
class Battery;
|
||||||
class Ble;
|
class Ble;
|
||||||
class NotificationManager;
|
class NotificationManager;
|
||||||
|
class HeartRateController;
|
||||||
|
class MotionController;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
|
@ -29,7 +31,9 @@ namespace Pinetime {
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
Controllers::NotificationManager& notificationManager,
|
Controllers::NotificationManager& notificationManager,
|
||||||
Controllers::Settings& settingsController);
|
Controllers::Settings& settingsController,
|
||||||
|
Controllers::HeartRateController& heartRateController,
|
||||||
|
Controllers::MotionController& motionController);
|
||||||
|
|
||||||
~WatchFaceAnalog() override;
|
~WatchFaceAnalog() override;
|
||||||
|
|
||||||
|
@ -42,6 +46,9 @@ namespace Pinetime {
|
||||||
Utility::DirtyValue<bool> isCharging {};
|
Utility::DirtyValue<bool> isCharging {};
|
||||||
Utility::DirtyValue<bool> bleState {};
|
Utility::DirtyValue<bool> bleState {};
|
||||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
|
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
|
||||||
|
Utility::DirtyValue<uint32_t> stepCount {};
|
||||||
|
Utility::DirtyValue<uint8_t> heartbeat {};
|
||||||
|
Utility::DirtyValue<bool> heartbeatRunning {};
|
||||||
Utility::DirtyValue<bool> notificationState {false};
|
Utility::DirtyValue<bool> notificationState {false};
|
||||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
||||||
|
|
||||||
|
@ -74,6 +81,10 @@ namespace Pinetime {
|
||||||
lv_obj_t* plugIcon;
|
lv_obj_t* plugIcon;
|
||||||
lv_obj_t* notificationIcon;
|
lv_obj_t* notificationIcon;
|
||||||
lv_obj_t* bleIcon;
|
lv_obj_t* bleIcon;
|
||||||
|
lv_obj_t* heartbeatIcon;
|
||||||
|
lv_obj_t* heartbeatValue;
|
||||||
|
lv_obj_t* stepIcon;
|
||||||
|
lv_obj_t* stepValue;
|
||||||
|
|
||||||
BatteryIcon batteryIcon;
|
BatteryIcon batteryIcon;
|
||||||
|
|
||||||
|
@ -82,6 +93,8 @@ namespace Pinetime {
|
||||||
const Controllers::Ble& bleController;
|
const Controllers::Ble& bleController;
|
||||||
Controllers::NotificationManager& notificationManager;
|
Controllers::NotificationManager& notificationManager;
|
||||||
Controllers::Settings& settingsController;
|
Controllers::Settings& settingsController;
|
||||||
|
Controllers::HeartRateController& heartRateController;
|
||||||
|
Controllers::MotionController& motionController;
|
||||||
|
|
||||||
void UpdateClock();
|
void UpdateClock();
|
||||||
void SetBatteryIcon();
|
void SetBatteryIcon();
|
||||||
|
@ -100,7 +113,9 @@ namespace Pinetime {
|
||||||
controllers.batteryController,
|
controllers.batteryController,
|
||||||
controllers.bleController,
|
controllers.bleController,
|
||||||
controllers.notificationManager,
|
controllers.notificationManager,
|
||||||
controllers.settingsController);
|
controllers.settingsController,
|
||||||
|
controllers.heartRateController,
|
||||||
|
controllers.motionController);
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {
|
||||||
|
|
Loading…
Reference in a new issue