From 248cdd9aeb964c84ad8f4e1713df599c0ffb1806 Mon Sep 17 00:00:00 2001 From: Michele Bini Date: Sun, 10 Apr 2022 14:32:18 +0200 Subject: Display deciseconds in digital watchface diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index cf9d52c..2126ca1 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -60,6 +60,11 @@ namespace Pinetime { uint8_t Seconds() const { return second; } + uint8_t Deciseconds() const { + uint16_t x = subsecondTicks; + x *= 10; + return x >> 10; + } const char* MonthShortToString() const; const char* DayOfWeekShortToString() const; diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 03750be..cf8f659 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -79,6 +79,10 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, 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_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); lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); @@ -161,6 +165,7 @@ void WatchFaceDigital::Refresh() { #endif uint8_t second = dateTimeController.Seconds(); + uint8_t decisecond = dateTimeController.Deciseconds(); if (second != displayedSecond) { displayedSecond = second; @@ -169,6 +174,12 @@ void WatchFaceDigital::Refresh() { 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()) { diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index c59b7b4..0bf5eec 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -42,6 +42,7 @@ namespace Pinetime { uint8_t displayedHour = -1; uint8_t displayedMinute = -1; uint8_t displayedSecond = -1; + uint8_t displayedDecisecond = -1; uint16_t currentYear = 1970; Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown; @@ -49,7 +50,8 @@ namespace Pinetime { uint8_t currentDay = 0; char hhmm_label_text[6] = { '?', '?', ':', '?', '?', 0 }; - char seconds_label_text[4] = { ':', '?', '?', 0 }; + char seconds_label_text[5] = { ':', '?', '?', '.', 0 }; + char deciseconds_label_text[2] = { '?', 0 }; DirtyValue batteryPercentRemaining {}; DirtyValue powerPresent {}; @@ -66,6 +68,7 @@ namespace Pinetime { lv_obj_t* label_time; lv_obj_t* label_time_pm; lv_obj_t* label_time_seconds; + lv_obj_t* label_time_deciseconds; lv_obj_t* label_date; lv_obj_t* backgroundLabel; lv_obj_t* batteryIcon; -- cgit v0.10.2