From ac93d51090fe6b4cacb987f1ed3acf193ef60cf1 Mon Sep 17 00:00:00 2001 From: "Brendan M. Sleight" Date: Thu, 15 Sep 2022 19:27:55 +0000 Subject: [PATCH] Correcting ampersand. Update date only on date change --- .../screens/WatchFaceAccurateWords.cpp | 88 ++++++++++--------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/src/displayapp/screens/WatchFaceAccurateWords.cpp b/src/displayapp/screens/WatchFaceAccurateWords.cpp index 8e97e0fe..2ec0e2b3 100644 --- a/src/displayapp/screens/WatchFaceAccurateWords.cpp +++ b/src/displayapp/screens/WatchFaceAccurateWords.cpp @@ -169,50 +169,52 @@ void WatchFaceAccurateWords::Refresh() { lv_label_set_text_fmt(label_time, "%s", words); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, -40); - lv_label_set_text_fmt(label_date, - "%s, %s of %s", - days_array[static_cast(dayOfWeek)], - months_numbers_array[static_cast(day)], - months_array[static_cast(month)]); - - // Specific dates have specific names - if (static_cast(month) == 1 & static_cast(day) == 1) { - lv_label_set_text_fmt(label_date, "%s, New Year's Day", days_array[static_cast(dayOfWeek)]); + if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { + lv_label_set_text_fmt(label_date, + "%s, %s of %s", + days_array[static_cast(dayOfWeek)], + months_numbers_array[static_cast(day)], + months_array[static_cast(month)]); + + // Specific dates have specific names + if (static_cast(month) == 1 && static_cast(day) == 1) { + lv_label_set_text_fmt(label_date, "%s, New Year's Day", days_array[static_cast(dayOfWeek)]); + } + if (static_cast(month) == 3 && static_cast(day) == 15) { + lv_label_set_text_fmt(label_date, "%s on the Ides of March", days_array[static_cast(dayOfWeek)]); + } + if (static_cast(month) == 4 && static_cast(day) == 1) { + lv_label_set_text_fmt(label_date, "%s, ERROR C Nonsense in BASIC", days_array[static_cast(dayOfWeek)]); + } + if (static_cast(month) == 7 && static_cast(day) == 1) { + lv_label_set_text_fmt(label_date, "%s - O'Canada", days_array[static_cast(dayOfWeek)]); + } + if (static_cast(month) == 10 && static_cast(day) == 31) { + lv_label_set_text_fmt(label_date, "%s on Halloween", days_array[static_cast(dayOfWeek)]); + } + if (static_cast(month) == 12 && static_cast(day) == 24) { + lv_label_set_text_fmt(label_date, "%s, Christmas Eve", days_array[static_cast(dayOfWeek)]); + } + if (static_cast(month) == 12 && static_cast(day) == 25) { + lv_label_set_text_fmt(label_date, "%s, Christmas Day", days_array[static_cast(dayOfWeek)]); + } + if (static_cast(month) == 12 && static_cast(day) == 26) { + lv_label_set_text_fmt(label_date, "%s, Boxing Day", days_array[static_cast(dayOfWeek)]); + } + if (static_cast(month) == 12 && static_cast(day) == 31) { + lv_label_set_text_fmt(label_date, "%s, New Year's Eve", days_array[static_cast(dayOfWeek)]); + } + + // Maximum lenght of date in words + // lv_label_set_text_fmt(label_date,"Wednesday, twenty-seventh of September"); + + lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); + + currentYear = year; + currentMonth = month; + currentDayOfWeek = dayOfWeek; + currentDay = day; } - if (static_cast(month) == 3 & static_cast(day) == 15) { - lv_label_set_text_fmt(label_date, "%s on the Ides of March", days_array[static_cast(dayOfWeek)]); - } - if (static_cast(month) == 4 & static_cast(day) == 1) { - lv_label_set_text_fmt(label_date, "%s, ERROR C Nonsense in BASIC", days_array[static_cast(dayOfWeek)]); - } - if (static_cast(month) == 7 & static_cast(day) == 1) { - lv_label_set_text_fmt(label_date, "%s - O'Canada", days_array[static_cast(dayOfWeek)]); - } - if (static_cast(month) == 10 & static_cast(day) == 31) { - lv_label_set_text_fmt(label_date, "%s on Halloween", days_array[static_cast(dayOfWeek)]); - } - if (static_cast(month) == 12 & static_cast(day) == 24) { - lv_label_set_text_fmt(label_date, "%s, Christmas Eve", days_array[static_cast(dayOfWeek)]); - } - if (static_cast(month) == 12 & static_cast(day) == 25) { - lv_label_set_text_fmt(label_date, "%s, Christmas Day", days_array[static_cast(dayOfWeek)]); - } - if (static_cast(month) == 12 & static_cast(day) == 26) { - lv_label_set_text_fmt(label_date, "%s, Boxing Day", days_array[static_cast(dayOfWeek)]); - } - if (static_cast(month) == 12 & static_cast(day) == 31) { - lv_label_set_text_fmt(label_date, "%s, New Year's Eve", days_array[static_cast(dayOfWeek)]); - } - - // Maximum lenght of date in words - // lv_label_set_text_fmt(label_date,"Wednesday, twenty-seventh of September"); - - lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); - - currentYear = year; - currentMonth = month; - currentDayOfWeek = dayOfWeek; - currentDay = day; } }