summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/WatchFaceDigital.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens/WatchFaceDigital.cpp')
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp141
1 files changed, 118 insertions, 23 deletions
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index ad328e1..a5cbac3 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -22,8 +22,10 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
- Controllers::MotionController& motionController)
+ Controllers::MotionController& motionController,
+ System::SystemTask& systemTask)
: Screen(app),
+ systemTask {systemTask},
currentDateTime {{}},
dateTimeController {dateTimeController},
batteryController {batteryController},
@@ -35,12 +37,25 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
- lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
+ lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000));
lv_label_set_text_static(batteryPlug, Symbols::plug);
- lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, 0, 0);
+
+ batteryPercentLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color( batteryPercentLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
+ lv_obj_set_style_local_text_font( batteryPercentLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont1);
+ lv_label_set_text_static( batteryPercentLabel, battery_percent_label_text);
+ lv_obj_align( batteryPercentLabel, batteryIcon, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0);
+ lv_label_set_align( batteryPercentLabel, LV_LABEL_ALIGN_RIGHT);
+
+ batteryVoltageLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font( batteryVoltageLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont1);
+ lv_obj_set_style_local_text_color( batteryVoltageLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
+ lv_label_set_text_static( batteryVoltageLabel, battery_voltage_label_text);
+ lv_obj_align( batteryVoltageLabel, batteryPercentLabel, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC));
@@ -53,17 +68,34 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
label_date = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
+ lv_obj_align(label_date, nullptr, LV_ALIGN_CENTER, 0, 60);
+ lv_obj_set_auto_realign(label_date, true);
lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
+ label_temp = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color( label_temp, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x555555));
+ lv_label_set_text_fmt(label_temp, "??°C");
+ lv_obj_align(label_temp, lv_scr_act(), LV_ALIGN_CENTER, 60, -60);
+
label_time = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed);
+ lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont3);
+ lv_label_set_text_fmt(label_time, hhmm_label_text);
+ lv_obj_align(label_time, nullptr, LV_ALIGN_CENTER, 0, 0);
+ lv_label_set_long_mode(label_time, LV_LABEL_LONG_CROP);
+ lv_label_set_align(label_time, LV_LABEL_ALIGN_RIGHT);
- lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
+ label_time_pm = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(label_time_pm, "P ");
+ lv_obj_align(label_time_pm, label_time, LV_ALIGN_OUT_LEFT_TOP, 0, 0);
- label_time_ampm = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(label_time_ampm, "");
- lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
+ label_time_seconds = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(label_time_seconds, seconds_label_text);
+ lv_obj_align(label_time_seconds, label_time, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, 0);
+
+ label_time_deciseconds = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(label_time_deciseconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont1);
+ lv_label_set_text_static(label_time_deciseconds, seconds_label_text);
+ lv_obj_align(label_time_deciseconds, label_time_seconds, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, 0);
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_click(backgroundLabel, true);
@@ -102,6 +134,8 @@ WatchFaceDigital::~WatchFaceDigital() {
}
void WatchFaceDigital::Refresh() {
+ bool batteryRefreshed = false;
+
powerPresent = batteryController.IsPowerPresent();
if (powerPresent.IsUpdated()) {
lv_label_set_text_static(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
@@ -109,6 +143,7 @@ void WatchFaceDigital::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) {
+ batteryRefreshed = true;
auto batteryPercent = batteryPercentRemaining.Get();
if (batteryPercent == 100) {
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
@@ -119,8 +154,7 @@ void WatchFaceDigital::Refresh() {
}
bleState = bleController.IsConnected();
- bleRadioEnabled = bleController.IsRadioEnabled();
- if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
+ if (bleState.IsUpdated()) {
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
}
lv_obj_realign(batteryIcon);
@@ -132,6 +166,37 @@ void WatchFaceDigital::Refresh() {
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
+#ifndef INFINISIM
+ temperature = systemTask.motionSensor.temperature_last_read_value+23;
+ if (temperature.IsUpdated()) {
+ lv_obj_set_style_local_text_color( label_temp, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
+ lv_label_set_text_fmt(label_temp, "%d°C", temperature.Get());
+#if 0
+ lv_label_set_text_fmt(label_temp, "T%d [%d,%d]",
+ ((int)(systemTask.motionSensor.temperature_last_read_value+23)),
+ ((int)(systemTask.motionSensor.temperature_last_result)),
+ ((int)(systemTask.motionSensor.temperature_read_counter))
+ );
+#endif
+ }
+#endif
+
+ uint8_t second = dateTimeController.Seconds();
+ uint8_t decisecond = dateTimeController.Deciseconds();
+
+ if (second != displayedSecond) {
+ displayedSecond = second;
+ seconds_label_text[1] = '0' + (second / 10);
+ seconds_label_text[2] = '0' + (second % 10);
+ lv_label_set_text_static(label_time_seconds, seconds_label_text);
+ }
+
+ if (decisecond != displayedDecisecond) {
+ displayedDecisecond = decisecond;
+ deciseconds_label_text[0] = '0' + decisecond;
+ lv_label_set_text_static(label_time_deciseconds, deciseconds_label_text);
+ }
+
currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) {
@@ -150,26 +215,30 @@ void WatchFaceDigital::Refresh() {
uint8_t minute = time.minutes().count();
if (displayedHour != hour || displayedMinute != minute) {
+ refreshBatteryInfo = true;
displayedHour = hour;
displayedMinute = minute;
-
+ bool hide_pm = true;
+ uint8_t h0;
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
- char ampmChar[3] = "AM";
if (hour == 0) {
hour = 12;
} else if (hour == 12) {
- ampmChar[0] = 'P';
+ hide_pm = false;
} else if (hour > 12) {
- hour = hour - 12;
- ampmChar[0] = 'P';
+ hour -= 12;
+ hide_pm = false;
}
- lv_label_set_text(label_time_ampm, ampmChar);
- lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
- lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
+ h0 = hour < 10 ? ' ' : '1';
} else {
- lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
- lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
+ h0 = '0' + (hour / 10);
}
+ hhmm_label_text[0] = h0;
+ hhmm_label_text[1] = '0' + (hour%10);
+ hhmm_label_text[3] = '0' + (minute / 10);
+ hhmm_label_text[4] = '0' + (minute % 10);
+ lv_label_set_text_static(label_time, hhmm_label_text);
+ lv_obj_set_hidden(label_time_pm, hide_pm);
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
@@ -180,7 +249,6 @@ void WatchFaceDigital::Refresh() {
lv_label_set_text_fmt(
label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
}
- lv_obj_realign(label_date);
currentYear = year;
currentMonth = month;
@@ -194,7 +262,12 @@ void WatchFaceDigital::Refresh() {
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());
+ auto v = heartbeat.Get();
+ if (v) {
+ lv_label_set_text_fmt(heartbeatValue, "%d", v);
+ } else {
+ lv_label_set_text_static(heartbeatValue, "");
+ }
} 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, "");
@@ -211,4 +284,26 @@ void WatchFaceDigital::Refresh() {
lv_obj_realign(stepValue);
lv_obj_realign(stepIcon);
}
+
+ if (batteryRefreshed || refreshBatteryInfo) {
+ if (refreshBatteryInfo) {
+ batteryController.MeasureVoltage();
+ refreshBatteryInfo = false;
+ }
+ {
+ auto x = batteryController.Voltage();
+ battery_voltage_label_text[3] = '0' + (x%10); x /= 10;
+ battery_voltage_label_text[2] = '0' + (x%10); x /= 10;
+ battery_voltage_label_text[1] = '0' + (x%10); x /= 10;
+ battery_voltage_label_text[0] = '0' + (x%10);
+ }
+ lv_label_set_text_static(batteryVoltageLabel, battery_voltage_label_text);
+ {
+ uint8_t x = batteryController.PercentRemaining();
+ battery_percent_label_text[2] = '0' + (x%10); x /= 10;
+ battery_percent_label_text[1] = '0' + (x%10); x /= 10;
+ battery_percent_label_text[0] = x ? '0' + (x%10): ' ';
+ }
+ lv_label_set_text_static(batteryPercentLabel, battery_percent_label_text);
+ }
}