Merge pull request #948 from Riksu9000/watchfacecleanup
PTS and digital watchface code cleanups
This commit is contained in:
commit
cc01d6ca17
4 changed files with 79 additions and 118 deletions
|
@ -60,12 +60,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
motionController {motionController} {
|
motionController {motionController} {
|
||||||
|
|
||||||
displayedChar[0] = 0;
|
|
||||||
displayedChar[1] = 0;
|
|
||||||
displayedChar[2] = 0;
|
|
||||||
displayedChar[3] = 0;
|
|
||||||
displayedChar[4] = 0;
|
|
||||||
|
|
||||||
// Create a 200px wide background rectangle
|
// Create a 200px wide background rectangle
|
||||||
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
|
||||||
|
@ -77,19 +71,19 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_label_set_text(timeDD1, "00");
|
lv_label_set_text_static(timeDD1, "00");
|
||||||
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
|
||||||
|
|
||||||
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
|
||||||
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_label_set_text(timeDD2, "00");
|
lv_label_set_text_static(timeDD2, "00");
|
||||||
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
|
||||||
|
|
||||||
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||||
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
||||||
lv_label_set_text(timeAMPM, "");
|
lv_label_set_text_static(timeAMPM, "");
|
||||||
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
|
||||||
|
|
||||||
// Create a 40px wide bar down the right side of the screen
|
// Create a 40px wide bar down the right side of the screen
|
||||||
|
@ -102,17 +96,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
// Display icons
|
// Display icons
|
||||||
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_label_set_text(batteryIcon, Symbols::batteryFull);
|
lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
|
||||||
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
|
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
|
||||||
lv_obj_set_auto_realign(batteryIcon, true);
|
lv_obj_set_auto_realign(batteryIcon, true);
|
||||||
|
|
||||||
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
lv_label_set_text(bleIcon, "");
|
lv_label_set_text_static(bleIcon, "");
|
||||||
|
|
||||||
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
||||||
lv_label_set_text(notificationIcon, "");
|
lv_label_set_text_static(notificationIcon, "");
|
||||||
|
|
||||||
// Calendar icon
|
// Calendar icon
|
||||||
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
@ -154,17 +148,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
// Display date
|
// Display date
|
||||||
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_label_set_text(dateDayOfWeek, "THU");
|
lv_label_set_text_static(dateDayOfWeek, "THU");
|
||||||
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
|
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
|
||||||
|
|
||||||
dateDay = lv_label_create(lv_scr_act(), nullptr);
|
dateDay = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_label_set_text(dateDay, "25");
|
lv_label_set_text_static(dateDay, "25");
|
||||||
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
|
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
|
||||||
|
|
||||||
dateMonth = lv_label_create(lv_scr_act(), nullptr);
|
dateMonth = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_label_set_text(dateMonth, "MAR");
|
lv_label_set_text_static(dateMonth, "MAR");
|
||||||
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
|
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
|
||||||
|
|
||||||
// Step count gauge
|
// Step count gauge
|
||||||
|
@ -199,7 +193,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
|
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
|
||||||
lv_obj_set_size(backgroundLabel, 240, 240);
|
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||||
lv_label_set_text(backgroundLabel, "");
|
lv_label_set_text_static(backgroundLabel, "");
|
||||||
|
|
||||||
btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
|
btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnNextTime->user_data = this;
|
btnNextTime->user_data = this;
|
||||||
|
@ -339,7 +333,7 @@ bool PineTimeStyle::OnButtonPushed() {
|
||||||
|
|
||||||
void PineTimeStyle::SetBatteryIcon() {
|
void PineTimeStyle::SetBatteryIcon() {
|
||||||
auto batteryPercent = batteryPercentRemaining.Get();
|
auto batteryPercent = batteryPercentRemaining.Get();
|
||||||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PineTimeStyle::AlignIcons() {
|
void PineTimeStyle::AlignIcons() {
|
||||||
|
@ -357,7 +351,7 @@ void PineTimeStyle::Refresh() {
|
||||||
isCharging = batteryController.IsCharging();
|
isCharging = batteryController.IsCharging();
|
||||||
if (isCharging.IsUpdated()) {
|
if (isCharging.IsUpdated()) {
|
||||||
if (isCharging.Get()) {
|
if (isCharging.Get()) {
|
||||||
lv_label_set_text(batteryIcon, Symbols::plug);
|
lv_label_set_text_static(batteryIcon, Symbols::plug);
|
||||||
} else {
|
} else {
|
||||||
SetBatteryIcon();
|
SetBatteryIcon();
|
||||||
}
|
}
|
||||||
|
@ -371,13 +365,13 @@ void PineTimeStyle::Refresh() {
|
||||||
|
|
||||||
bleState = bleController.IsConnected();
|
bleState = bleController.IsConnected();
|
||||||
if (bleState.IsUpdated()) {
|
if (bleState.IsUpdated()) {
|
||||||
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||||
AlignIcons();
|
AlignIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationState = notificatioManager.AreNewNotificationsAvailable();
|
notificationState = notificatioManager.AreNewNotificationsAvailable();
|
||||||
if (notificationState.IsUpdated()) {
|
if (notificationState.IsUpdated()) {
|
||||||
lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
||||||
AlignIcons();
|
AlignIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,45 +388,31 @@ void PineTimeStyle::Refresh() {
|
||||||
auto day = static_cast<unsigned>(yearMonthDay.day());
|
auto day = static_cast<unsigned>(yearMonthDay.day());
|
||||||
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
||||||
|
|
||||||
int hour = time.hours().count();
|
uint8_t hour = time.hours().count();
|
||||||
auto minute = time.minutes().count();
|
uint8_t minute = time.minutes().count();
|
||||||
|
|
||||||
char minutesChar[3];
|
if (displayedHour != hour || displayedMinute != minute) {
|
||||||
sprintf(minutesChar, "%02d", static_cast<int>(minute));
|
displayedHour = hour;
|
||||||
|
displayedMinute = minute;
|
||||||
char hoursChar[3];
|
|
||||||
char ampmChar[5];
|
|
||||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
|
|
||||||
sprintf(hoursChar, "%02d", hour);
|
|
||||||
} else {
|
|
||||||
if (hour == 0 && hour != 12) {
|
|
||||||
hour = 12;
|
|
||||||
sprintf(ampmChar, "A\nM");
|
|
||||||
} else if (hour == 12 && hour != 0) {
|
|
||||||
hour = 12;
|
|
||||||
sprintf(ampmChar, "P\nM");
|
|
||||||
} else if (hour < 12 && hour != 0) {
|
|
||||||
sprintf(ampmChar, "A\nM");
|
|
||||||
} else if (hour > 12 && hour != 0) {
|
|
||||||
hour = hour - 12;
|
|
||||||
sprintf(ampmChar, "P\nM");
|
|
||||||
}
|
|
||||||
sprintf(hoursChar, "%02d", hour);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hoursChar[0] != displayedChar[0] or hoursChar[1] != displayedChar[1] or minutesChar[0] != displayedChar[2] or
|
|
||||||
minutesChar[1] != displayedChar[3]) {
|
|
||||||
displayedChar[0] = hoursChar[0];
|
|
||||||
displayedChar[1] = hoursChar[1];
|
|
||||||
displayedChar[2] = minutesChar[0];
|
|
||||||
displayedChar[3] = minutesChar[1];
|
|
||||||
|
|
||||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||||
|
char ampmChar[4] = "A\nM";
|
||||||
|
if (hour == 0) {
|
||||||
|
hour = 12;
|
||||||
|
} else if (hour == 12) {
|
||||||
|
ampmChar[0] = 'P';
|
||||||
|
} else if (hour > 12) {
|
||||||
|
hour = hour - 12;
|
||||||
|
ampmChar[0] = 'P';
|
||||||
|
}
|
||||||
lv_label_set_text(timeAMPM, ampmChar);
|
lv_label_set_text(timeAMPM, ampmChar);
|
||||||
|
// Should be padded with blank spaces, but the space character doesn't exist in the font
|
||||||
|
lv_label_set_text_fmt(timeDD1, "%02d", hour);
|
||||||
|
lv_label_set_text_fmt(timeDD2, "%02d", minute);
|
||||||
|
} else {
|
||||||
|
lv_label_set_text_fmt(timeDD1, "%02d", hour);
|
||||||
|
lv_label_set_text_fmt(timeDD2, "%02d", minute);
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_label_set_text_fmt(timeDD1, "%s", hoursChar);
|
|
||||||
lv_label_set_text_fmt(timeDD2, "%s", minutesChar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
|
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
|
||||||
|
|
|
@ -39,7 +39,8 @@ namespace Pinetime {
|
||||||
void UpdateSelected(lv_obj_t *object, lv_event_t event);
|
void UpdateSelected(lv_obj_t *object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char displayedChar[5];
|
uint8_t displayedHour = -1;
|
||||||
|
uint8_t displayedMinute = -1;
|
||||||
|
|
||||||
uint16_t currentYear = 1970;
|
uint16_t currentYear = 1970;
|
||||||
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
|
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
|
||||||
|
|
|
@ -35,22 +35,22 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
|
||||||
settingsController.SetClockFace(0);
|
settingsController.SetClockFace(0);
|
||||||
|
|
||||||
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_text(batteryIcon, Symbols::batteryFull);
|
lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
|
||||||
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||||
|
|
||||||
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
|
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000));
|
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000));
|
||||||
lv_label_set_text(batteryPlug, Symbols::plug);
|
lv_label_set_text_static(batteryPlug, Symbols::plug);
|
||||||
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||||
|
|
||||||
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC));
|
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC));
|
||||||
lv_label_set_text(bleIcon, Symbols::bluetooth);
|
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
|
||||||
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||||
|
|
||||||
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
|
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
|
||||||
lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
|
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
|
||||||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||||
|
|
||||||
label_date = lv_label_create(lv_scr_act(), nullptr);
|
label_date = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
@ -71,26 +71,26 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
|
||||||
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
|
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
|
||||||
lv_obj_set_size(backgroundLabel, 240, 240);
|
lv_obj_set_size(backgroundLabel, 240, 240);
|
||||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||||
lv_label_set_text(backgroundLabel, "");
|
lv_label_set_text_static(backgroundLabel, "");
|
||||||
|
|
||||||
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
|
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_text(heartbeatIcon, Symbols::heartBeat);
|
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
|
||||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
|
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
|
||||||
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||||
|
|
||||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
|
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
|
||||||
lv_label_set_text(heartbeatValue, "");
|
lv_label_set_text_static(heartbeatValue, "");
|
||||||
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
||||||
|
|
||||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
|
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
|
||||||
lv_label_set_text(stepValue, "0");
|
lv_label_set_text_static(stepValue, "0");
|
||||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
||||||
|
|
||||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
|
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
|
||||||
lv_label_set_text(stepIcon, Symbols::shoe);
|
lv_label_set_text_static(stepIcon, Symbols::shoe);
|
||||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||||
|
|
||||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
|
@ -105,7 +105,7 @@ WatchFaceDigital::~WatchFaceDigital() {
|
||||||
void WatchFaceDigital::Refresh() {
|
void WatchFaceDigital::Refresh() {
|
||||||
powerPresent = batteryController.IsPowerPresent();
|
powerPresent = batteryController.IsPowerPresent();
|
||||||
if (powerPresent.IsUpdated()) {
|
if (powerPresent.IsUpdated()) {
|
||||||
lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
|
lv_label_set_text_static(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||||
|
@ -116,20 +116,20 @@ void WatchFaceDigital::Refresh() {
|
||||||
} else {
|
} else {
|
||||||
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
}
|
}
|
||||||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
||||||
}
|
}
|
||||||
|
|
||||||
bleState = bleController.IsConnected();
|
bleState = bleController.IsConnected();
|
||||||
if (bleState.IsUpdated()) {
|
if (bleState.IsUpdated()) {
|
||||||
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||||
}
|
}
|
||||||
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
lv_obj_realign(batteryIcon);
|
||||||
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
lv_obj_realign(batteryPlug);
|
||||||
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
lv_obj_realign(bleIcon);
|
||||||
|
|
||||||
notificationState = notificatioManager.AreNewNotificationsAvailable();
|
notificationState = notificatioManager.AreNewNotificationsAvailable();
|
||||||
if (notificationState.IsUpdated()) {
|
if (notificationState.IsUpdated()) {
|
||||||
lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDateTime = dateTimeController.CurrentDateTime();
|
currentDateTime = dateTimeController.CurrentDateTime();
|
||||||
|
@ -146,62 +146,41 @@ void WatchFaceDigital::Refresh() {
|
||||||
auto day = static_cast<unsigned>(yearMonthDay.day());
|
auto day = static_cast<unsigned>(yearMonthDay.day());
|
||||||
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
|
||||||
|
|
||||||
int hour = time.hours().count();
|
uint8_t hour = time.hours().count();
|
||||||
auto minute = time.minutes().count();
|
uint8_t minute = time.minutes().count();
|
||||||
|
|
||||||
char minutesChar[3];
|
if (displayedHour != hour || displayedMinute != minute) {
|
||||||
sprintf(minutesChar, "%02d", static_cast<int>(minute));
|
displayedHour = hour;
|
||||||
|
displayedMinute = minute;
|
||||||
char hoursChar[3];
|
|
||||||
char ampmChar[3];
|
|
||||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
|
|
||||||
sprintf(hoursChar, "%02d", hour);
|
|
||||||
} else {
|
|
||||||
if (hour == 0 && hour != 12) {
|
|
||||||
hour = 12;
|
|
||||||
sprintf(ampmChar, "AM");
|
|
||||||
} else if (hour == 12 && hour != 0) {
|
|
||||||
hour = 12;
|
|
||||||
sprintf(ampmChar, "PM");
|
|
||||||
} else if (hour < 12 && hour != 0) {
|
|
||||||
sprintf(ampmChar, "AM");
|
|
||||||
} else if (hour > 12 && hour != 0) {
|
|
||||||
hour = hour - 12;
|
|
||||||
sprintf(ampmChar, "PM");
|
|
||||||
}
|
|
||||||
sprintf(hoursChar, "%02d", hour);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((hoursChar[0] != displayedChar[0]) or (hoursChar[1] != displayedChar[1]) or (minutesChar[0] != displayedChar[2]) or
|
|
||||||
(minutesChar[1] != displayedChar[3])) {
|
|
||||||
displayedChar[0] = hoursChar[0];
|
|
||||||
displayedChar[1] = hoursChar[1];
|
|
||||||
displayedChar[2] = minutesChar[0];
|
|
||||||
displayedChar[3] = minutesChar[1];
|
|
||||||
|
|
||||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||||
lv_label_set_text(label_time_ampm, ampmChar);
|
char ampmChar[3] = "AM";
|
||||||
if (hoursChar[0] == '0') {
|
if (hour == 0) {
|
||||||
hoursChar[0] = ' ';
|
hour = 12;
|
||||||
|
} else if (hour == 12) {
|
||||||
|
ampmChar[0] = 'P';
|
||||||
|
} else if (hour > 12) {
|
||||||
|
hour = hour - 12;
|
||||||
|
ampmChar[0] = 'P';
|
||||||
}
|
}
|
||||||
}
|
lv_label_set_text(label_time_ampm, ampmChar);
|
||||||
|
lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
|
||||||
lv_label_set_text_fmt(label_time, "%s:%s", hoursChar, minutesChar);
|
|
||||||
|
|
||||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
|
||||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
|
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
|
||||||
} else {
|
} 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);
|
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
|
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
|
||||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
|
||||||
lv_label_set_text_fmt(label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
|
lv_label_set_text_fmt(
|
||||||
|
label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_fmt(label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
|
lv_label_set_text_fmt(
|
||||||
|
label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
|
||||||
}
|
}
|
||||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
|
lv_obj_realign(label_date);
|
||||||
|
|
||||||
currentYear = year;
|
currentYear = year;
|
||||||
currentMonth = month;
|
currentMonth = month;
|
||||||
|
@ -221,15 +200,15 @@ void WatchFaceDigital::Refresh() {
|
||||||
lv_label_set_text_static(heartbeatValue, "");
|
lv_label_set_text_static(heartbeatValue, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
lv_obj_realign(heartbeatIcon);
|
||||||
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
lv_obj_realign(heartbeatValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
stepCount = motionController.NbSteps();
|
stepCount = motionController.NbSteps();
|
||||||
motionSensorOk = motionController.IsSensorOk();
|
motionSensorOk = motionController.IsSensorOk();
|
||||||
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
|
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
|
||||||
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
||||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
lv_obj_realign(stepValue);
|
||||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
lv_obj_realign(stepIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ namespace Pinetime {
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char displayedChar[5] {};
|
uint8_t displayedHour = -1;
|
||||||
|
uint8_t displayedMinute = -1;
|
||||||
|
|
||||||
uint16_t currentYear = 1970;
|
uint16_t currentYear = 1970;
|
||||||
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
|
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
|
||||||
|
|
Loading…
Reference in a new issue