clang-format corrections

This commit is contained in:
Brendan M. Sleight 2022-09-15 16:55:00 +00:00
parent 1ca2c2ad34
commit 6ae0d47461
3 changed files with 89 additions and 129 deletions

View File

@ -14,7 +14,6 @@
#include "displayapp/screens/WatchFacePineTimeStyle.h" #include "displayapp/screens/WatchFacePineTimeStyle.h"
#include "displayapp/screens/WatchFaceAccurateWords.h" #include "displayapp/screens/WatchFaceAccurateWords.h"
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
Clock::Clock(DisplayApp* app, Clock::Clock(DisplayApp* app,
@ -111,11 +110,11 @@ std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {
std::unique_ptr<Screen> Clock::WatchFaceAccurateWordsScreen() { std::unique_ptr<Screen> Clock::WatchFaceAccurateWordsScreen() {
return std::make_unique<Screens::WatchFaceAccurateWords>(app, return std::make_unique<Screens::WatchFaceAccurateWords>(app,
dateTimeController, dateTimeController,
batteryController, batteryController,
bleController, bleController,
notificatioManager, notificatioManager,
settingsController, settingsController,
heartRateController, heartRateController,
motionController); motionController);
} }

View File

@ -15,13 +15,13 @@
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
WatchFaceAccurateWords::WatchFaceAccurateWords(DisplayApp* app, WatchFaceAccurateWords::WatchFaceAccurateWords(DisplayApp* app,
Controllers::DateTime& dateTimeController, Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController, Controllers::Battery& batteryController,
Controllers::Ble& bleController, Controllers::Ble& bleController,
Controllers::NotificationManager& notificatioManager, Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController, Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController) Controllers::MotionController& motionController)
: Screen(app), : Screen(app),
currentDateTime {{}}, currentDateTime {{}},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
@ -109,142 +109,103 @@ void WatchFaceAccurateWords::Refresh() {
uint8_t hour_adjusted; uint8_t hour_adjusted;
char words[78]; char words[78];
char part_day[20]; char part_day[20];
const char hour_word_array[26][10] = { const char hour_word_array[26][10] = {"midnight", "one", "two", "three", "four", "five", "six", "seven", "eight",
"midnight", "one", "two", "nine", "ten", "eleven", "twelve", "one", "two", "three", "four", "five",
"three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "midnight"};
"six", "seven", "eight", const char part_day_word_array[9][20] = {" at night",
"nine", "ten", "eleven", " in the early hours",
"twelve", " in the morning",
"one", "two", " in the morning",
"three", "four", "five", " in the afternoon",
"six", "seven", "eight", " in the afternoon",
"nine", "ten", "eleven", " in the evening",
"midnight" " at night"};
}; const char minutes_rough_array[14][18] = {"",
const char part_day_word_array[9][20] = { "five past ",
" at night", "ten past ",
" in the early hours", "quarter past ",
" in the morning", "twenty past ",
" in the morning", "twenty-five past ",
" in the afternoon", "half past ",
" in the afternoon", "twenty-five to ",
" in the evening", "twenty to ",
" at night" "quarter to ",
}; "ten to ",
const char minutes_rough_array[14][18] = { "five to "
"", "five past ", ""};
"ten past ", "quarter past ", const char minutes_accurate_array[6][16] = {"", "just gone ", "a little after ", "coming up to ", "almost "};
"twenty past ", "twenty-five past ", const char days_array[9][10] = {"", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
"half past ", "twenty-five to ", const char months_array[13][10] =
"twenty to ", "quarter to ", "ten to ", {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
"five to "
""
};
const char minutes_accurate_array[6][16] = {
"", "just gone ", "a little after ",
"coming up to ", "almost "
};
const char days_array[9][10] = {
"",
"Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday"
};
const char months_array[13][10] = {
"",
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November",
"December"
};
const char months_numbers_array[32][15] = { const char months_numbers_array[32][15] = {
"zero", "first", "second", "third", "zero", "first", "second", "third", "fourth", "fifth", "sixth", "seventh",
"fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth",
"eighth", "ninth", "tenth", "eleventh", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth", "twenty-first", "twenty-second", "twenty-third",
"twelfth", "thirteenth", "fourteenth", "twenty-fourth", "twenty-fifth", "twenty-sixth", "twenty-seventh", "twenty-eighth", "twenty-ninth", "thirtieth", "thirty-first"};
"fifteenth", "sixteenth", "seventeenth",
"eighteenth", "nineteenth", "twentieth",
"twenty-first", "twenty-second",
"twenty-third", "twenty-fourth",
"twenty-fifth", "twenty-sixth",
"twenty-seventh", "twenty-eighth",
"twenty-ninth", "thirtieth",
"thirty-first"
};
if (displayedHour != hour || displayedMinute != minute) { if (displayedHour != hour || displayedMinute != minute) {
displayedHour = hour; displayedHour = hour;
displayedMinute = minute; displayedMinute = minute;
if(minute>32) { if (minute > 32) {
hour_adjusted = (hour+1) % 24; hour_adjusted = (hour + 1) % 24;
} else {
hour_adjusted = hour;
} }
else {
hour_adjusted = hour;
}
if (hour_adjusted != 0 && hour_adjusted != 12) { if (hour_adjusted != 0 && hour_adjusted != 12) {
sprintf(part_day, "%s", part_day_word_array[hour_adjusted/3]); sprintf(part_day, "%s", part_day_word_array[hour_adjusted / 3]);
} } else {
else {
sprintf(part_day, ""); sprintf(part_day, "");
} }
sprintf(words, "%s%s%s%s", sprintf(words,
minutes_accurate_array[(minute)%5], "%s%s%s%s",
minutes_rough_array[(minute+2)/5], minutes_accurate_array[(minute) % 5],
hour_word_array[hour_adjusted], minutes_rough_array[(minute + 2) / 5],
part_day); hour_word_array[hour_adjusted],
part_day);
// Make first letter Uppercase // Make first letter Uppercase
words[0]=words[0]-32; words[0] = words[0] - 32;
lv_label_set_text_fmt(label_time, "%s", words); lv_label_set_text_fmt(label_time, "%s", words);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, -40); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, -40);
lv_label_set_text_fmt(label_date,"%s, %s of %s", lv_label_set_text_fmt(label_date,
"%s, %s of %s",
days_array[static_cast<uint8_t>(dayOfWeek)], days_array[static_cast<uint8_t>(dayOfWeek)],
months_numbers_array[static_cast<uint8_t>(day)], months_numbers_array[static_cast<uint8_t>(day)],
months_array[static_cast<uint8_t>(month)] months_array[static_cast<uint8_t>(month)]);
);
// Specific dates have specific names // Specific dates have specific names
if (static_cast<uint8_t>(month) == 1 & static_cast<uint8_t>(day) == 1) { if (static_cast<uint8_t>(month) == 1 & static_cast<uint8_t>(day) == 1) {
lv_label_set_text_fmt(label_date,"%s, New Year's Day", lv_label_set_text_fmt(label_date, "%s, New Year's Day", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
if (static_cast<uint8_t>(month) == 3 & static_cast<uint8_t>(day) == 15) { if (static_cast<uint8_t>(month) == 3 & static_cast<uint8_t>(day) == 15) {
lv_label_set_text_fmt(label_date,"%s on the Ides of March", lv_label_set_text_fmt(label_date, "%s on the Ides of March", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
if (static_cast<uint8_t>(month) == 4 & static_cast<uint8_t>(day) == 1) { if (static_cast<uint8_t>(month) == 4 & static_cast<uint8_t>(day) == 1) {
lv_label_set_text_fmt(label_date,"%s, ERROR C Nonsense in BASIC", lv_label_set_text_fmt(label_date, "%s, ERROR C Nonsense in BASIC", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
if (static_cast<uint8_t>(month) == 7 & static_cast<uint8_t>(day) == 1) { if (static_cast<uint8_t>(month) == 7 & static_cast<uint8_t>(day) == 1) {
lv_label_set_text_fmt(label_date,"%s - O'Canada", lv_label_set_text_fmt(label_date, "%s - O'Canada", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
if (static_cast<uint8_t>(month) == 10 & static_cast<uint8_t>(day) == 31) { if (static_cast<uint8_t>(month) == 10 & static_cast<uint8_t>(day) == 31) {
lv_label_set_text_fmt(label_date,"%s on Halloween", lv_label_set_text_fmt(label_date, "%s on Halloween", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
if (static_cast<uint8_t>(month) == 12 & static_cast<uint8_t>(day) == 24) { if (static_cast<uint8_t>(month) == 12 & static_cast<uint8_t>(day) == 24) {
lv_label_set_text_fmt(label_date,"%s, Christmas Eve", lv_label_set_text_fmt(label_date, "%s, Christmas Eve", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
if (static_cast<uint8_t>(month) == 12 & static_cast<uint8_t>(day) == 25) { if (static_cast<uint8_t>(month) == 12 & static_cast<uint8_t>(day) == 25) {
lv_label_set_text_fmt(label_date,"%s, Christmas Day", lv_label_set_text_fmt(label_date, "%s, Christmas Day", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
if (static_cast<uint8_t>(month) == 12 & static_cast<uint8_t>(day) == 26) { if (static_cast<uint8_t>(month) == 12 & static_cast<uint8_t>(day) == 26) {
lv_label_set_text_fmt(label_date,"%s, Boxing Day", lv_label_set_text_fmt(label_date, "%s, Boxing Day", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
if (static_cast<uint8_t>(month) == 12 & static_cast<uint8_t>(day) == 31) { if (static_cast<uint8_t>(month) == 12 & static_cast<uint8_t>(day) == 31) {
lv_label_set_text_fmt(label_date,"%s, New Year's Eve", lv_label_set_text_fmt(label_date, "%s, New Year's Eve", days_array[static_cast<uint8_t>(dayOfWeek)]);
days_array[static_cast<uint8_t>(dayOfWeek)]); }
}
// Maximum lenght of date in words // Maximum lenght of date in words
// lv_label_set_text_fmt(label_date,"Wednesday, twenty-seventh of September"); // 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); lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);

View File

@ -25,13 +25,13 @@ namespace Pinetime {
class WatchFaceAccurateWords : public Screen { class WatchFaceAccurateWords : public Screen {
public: public:
WatchFaceAccurateWords(DisplayApp* app, WatchFaceAccurateWords(DisplayApp* app,
Controllers::DateTime& dateTimeController, Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController, Controllers::Battery& batteryController,
Controllers::Ble& bleController, Controllers::Ble& bleController,
Controllers::NotificationManager& notificatioManager, Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController, Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController); Controllers::MotionController& motionController);
~WatchFaceAccurateWords() override; ~WatchFaceAccurateWords() override;
void Refresh() override; void Refresh() override;