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.cpp77
1 files changed, 58 insertions, 19 deletions
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index dc16f60..03750be 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},
@@ -53,17 +55,29 @@ 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(0x222222));
+ 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, &neofont2);
+ 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);
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_click(backgroundLabel, true);
@@ -119,8 +133,7 @@ void WatchFaceDigital::Refresh() {
}
bleState = bleController.IsConnected();
- bleRadioEnabled = bleController.IsRadioEnabled();
- if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
+ if (bleState.IsUpdated()) {
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
}
lv_obj_realign(batteryIcon);
@@ -132,6 +145,30 @@ 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();
+
+ 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);
+ }
+
currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) {
@@ -152,24 +189,27 @@ void WatchFaceDigital::Refresh() {
if (displayedHour != hour || displayedMinute != minute) {
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 +220,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;