Skip to content

Commit

Permalink
Implemented suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aperture32GLaDOS committed Dec 30, 2024
1 parent 7e2f2a1 commit ee2e868
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 61 deletions.
10 changes: 10 additions & 0 deletions src/components/datetime/DateTimeController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ using namespace Pinetime::Controllers;
namespace {
constexpr const char* const DaysStringShort[] = {"--", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
constexpr const char* const DaysStringShortLow[] = {"--", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
constexpr const char* const DaysString[] = {"--", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"};
constexpr const char* const DaysStringLow[] = {"--", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
constexpr const char* const MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
constexpr const char* const MonthsStringLow[] =
{"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
Expand Down Expand Up @@ -144,6 +146,10 @@ const char* DateTime::DayOfWeekShortToString() const {
return DaysStringShort[static_cast<uint8_t>(DayOfWeek())];
}

const char* DateTime::DayOfWeekToString() const {
return DaysString[static_cast<uint8_t>(DayOfWeek())];
}

const char* DateTime::MonthShortToStringLow(Months month) {
return MonthsStringLow[static_cast<uint8_t>(month)];
}
Expand All @@ -152,6 +158,10 @@ const char* DateTime::DayOfWeekShortToStringLow(Days day) {
return DaysStringShortLow[static_cast<uint8_t>(day)];
}

const char* DateTime::DayOfWeekToStringLow(Days day) {
return DaysStringLow[static_cast<uint8_t>(day)];
}

void DateTime::Register(Pinetime::System::SystemTask* systemTask) {
this->systemTask = systemTask;
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/datetime/DateTimeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ namespace Pinetime {

const char* MonthShortToString() const;
const char* DayOfWeekShortToString() const;
const char* DayOfWeekToString() const;
static const char* MonthShortToStringLow(Months month);
static const char* DayOfWeekShortToStringLow(Days day);
static const char* DayOfWeekToStringLow(Days day);

std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime();

Expand Down
87 changes: 30 additions & 57 deletions src/displayapp/screens/WatchFaceTrans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController,
topBlueBackground = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(topBlueBackground, LV_HOR_RES, LV_VER_RES / 5);
lv_obj_set_pos(topBlueBackground, 0, 0);
lv_obj_set_style_local_bg_color(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00bff3));
lv_obj_set_style_local_bg_color(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue);
lv_obj_set_style_local_radius(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);
topPinkBackground = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(topPinkBackground, LV_HOR_RES, LV_VER_RES / 5);
lv_obj_set_pos(topPinkBackground, 0, LV_VER_RES / 5);
lv_obj_set_style_local_bg_color(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf49ac1));
lv_obj_set_style_local_bg_color(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink);
lv_obj_set_style_local_radius(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);
whiteBackground = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(whiteBackground, LV_HOR_RES, LV_VER_RES / 5);
lv_obj_set_pos(whiteBackground, 0, 2 * LV_VER_RES / 5);
lv_obj_set_style_local_bg_color(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
lv_obj_set_style_local_bg_color(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_radius(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);
bottomPinkBackground = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(bottomPinkBackground, LV_HOR_RES, LV_VER_RES / 5);
lv_obj_set_pos(bottomPinkBackground, 0, 3 * LV_VER_RES / 5);
lv_obj_set_style_local_bg_color(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf49ac1));
lv_obj_set_style_local_bg_color(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink);
lv_obj_set_style_local_radius(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);
bottomBlueBackground = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_size(bottomBlueBackground, LV_HOR_RES, LV_VER_RES / 5);
lv_obj_set_pos(bottomBlueBackground, 0, 4 * LV_VER_RES / 5);
lv_obj_set_style_local_bg_color(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00bff3));
lv_obj_set_style_local_bg_color(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue);
lv_obj_set_style_local_radius(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0);

bluetoothStatus = lv_label_create(lv_scr_act(), nullptr);
Expand All @@ -62,26 +62,26 @@ WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController,

notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));

label_date = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label_date, true);
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, -48);
lv_label_set_align(label_date, LV_LABEL_ALIGN_CENTER);
lv_obj_set_auto_realign(label_date, true);

label_time = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label_time, true);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_obj_set_auto_realign(label_time, true);

label_day = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label_day, true);
lv_obj_align(label_day, lv_scr_act(), LV_ALIGN_CENTER, 0, 48);
lv_label_set_align(label_day, LV_LABEL_ALIGN_CENTER);
lv_obj_set_auto_realign(label_day, true);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);

labelDate = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(labelDate, true);
lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48);
lv_label_set_align(labelDate, LV_LABEL_ALIGN_CENTER);
lv_obj_set_auto_realign(labelDate, true);

labelTime = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(labelTime, true);
lv_obj_align(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
lv_label_set_align(labelTime, LV_LABEL_ALIGN_CENTER);
lv_obj_set_style_local_text_font(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_obj_set_auto_realign(labelTime, true);

labelDay = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(labelDay, true);
lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48);
lv_label_set_align(labelDay, LV_LABEL_ALIGN_CENTER);
lv_obj_set_auto_realign(labelDay, true);

stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(stepValue, true);
Expand All @@ -103,7 +103,7 @@ void WatchFaceTrans::Refresh() {
bleState = bleController.IsConnected();
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
lv_label_set_text_fmt(batteryValue, "#ffffff %d%%", batteryPercentRemaining.Get());
lv_label_set_text_fmt(batteryValue, "#ffffff %d%%#", batteryPercentRemaining.Get());
if (batteryController.IsPowerPresent()) {
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
}
Expand Down Expand Up @@ -141,9 +141,9 @@ void WatchFaceTrans::Refresh() {
hour = hour - 12;
ampmChar[0] = 'P';
}
lv_label_set_text_fmt(label_time, "#000000 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
} else {
lv_label_set_text_fmt(label_time, "#000000 %02d:%02d:%02d", hour, minute, second);
lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second);
}

currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
Expand All @@ -152,35 +152,8 @@ void WatchFaceTrans::Refresh() {
Controllers::DateTime::Months month = dateTimeController.Month();
uint8_t day = dateTimeController.Day();
Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek();
lv_label_set_text_fmt(label_date, "#ffffff %02d-%02d-%04d#", short(day), char(month), year);
const char* dayString;
switch (dayOfWeek) {
case Controllers::DateTime::Days::Monday:
dayString = "Monday";
break;
case Controllers::DateTime::Days::Tuesday:
dayString = "Tuesday";
break;
case Controllers::DateTime::Days::Wednesday:
dayString = "Wednesday";
break;
case Controllers::DateTime::Days::Thursday:
dayString = "Thursday";
break;
case Controllers::DateTime::Days::Friday:
dayString = "Friday";
break;
case Controllers::DateTime::Days::Saturday:
dayString = "Saturday";
break;
case Controllers::DateTime::Days::Sunday:
dayString = "Sunday";
break;
default:
dayString = "?";
break;
}
lv_label_set_text_fmt(label_day, "#ffffff %s", dayString);
lv_label_set_text_fmt(labelDate, "#ffffff %02d-%02d-%04d#", day, static_cast<uint8_t>(month), year);
lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek));
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/displayapp/screens/WatchFaceTrans.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Pinetime {
void Refresh() override;

private:
Utility::DirtyValue<int> batteryPercentRemaining {};
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
Utility::DirtyValue<bool> powerPresent {};
Utility::DirtyValue<bool> bleState {};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>> currentDateTime {};
Expand All @@ -50,13 +50,16 @@ namespace Pinetime {
lv_obj_t* bottomPinkBackground;
lv_obj_t* bottomBlueBackground;
lv_obj_t* bluetoothStatus;
lv_obj_t* label_time;
lv_obj_t* label_date;
lv_obj_t* label_day;
lv_obj_t* labelTime;
lv_obj_t* labelDate;
lv_obj_t* labelDay;
lv_obj_t* batteryValue;
lv_obj_t* stepValue;
lv_obj_t* notificationIcon;

static constexpr lv_color_t lightBlue = LV_COLOR_MAKE(0x00, 0xbf, 0xf3);
static constexpr lv_color_t lightPink = LV_COLOR_MAKE(0xf4, 0x9a, 0xc1);

Controllers::DateTime& dateTimeController;
const Controllers::Battery& batteryController;
const Controllers::Ble bleController;
Expand Down

0 comments on commit ee2e868

Please sign in to comment.