Enable 12/24h functionality
This commit is contained in:
parent
607af27ba8
commit
266573deff
|
@ -83,6 +83,12 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
lv_label_set_text(timeDD2, "34");
|
lv_label_set_text(timeDD2, "34");
|
||||||
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);
|
||||||
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
|
||||||
|
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
|
||||||
|
lv_label_set_text(timeAMPM, "");
|
||||||
|
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 */
|
||||||
|
|
||||||
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
sidebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
|
@ -257,7 +263,25 @@ bool PineTimeStyle::Refresh() {
|
||||||
sprintf(minutesChar, "%02d", static_cast<int>(minute));
|
sprintf(minutesChar, "%02d", static_cast<int>(minute));
|
||||||
|
|
||||||
char hoursChar[3];
|
char hoursChar[3];
|
||||||
sprintf(hoursChar, "%02d", hour);
|
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] || hoursChar[1] != displayedChar[1] || minutesChar[0] != displayedChar[2] ||
|
if (hoursChar[0] != displayedChar[0] || hoursChar[1] != displayedChar[1] || minutesChar[0] != displayedChar[2] ||
|
||||||
minutesChar[1] != displayedChar[3]) {
|
minutesChar[1] != displayedChar[3]) {
|
||||||
|
@ -269,6 +293,10 @@ bool PineTimeStyle::Refresh() {
|
||||||
char hourStr[3];
|
char hourStr[3];
|
||||||
char minStr[3];
|
char minStr[3];
|
||||||
|
|
||||||
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||||
|
lv_label_set_text(timeAMPM, ampmChar);
|
||||||
|
}
|
||||||
|
|
||||||
/* Display the time as 2 pairs of digits */
|
/* Display the time as 2 pairs of digits */
|
||||||
sprintf(hourStr, "%c%c", hoursChar[0], hoursChar[1]);
|
sprintf(hourStr, "%c%c", hoursChar[0], hoursChar[1]);
|
||||||
lv_label_set_text(timeDD1, hourStr);
|
lv_label_set_text(timeDD1, hourStr);
|
||||||
|
|
|
@ -53,6 +53,7 @@ namespace Pinetime {
|
||||||
lv_obj_t* sidebar;
|
lv_obj_t* sidebar;
|
||||||
lv_obj_t* timeDD1;
|
lv_obj_t* timeDD1;
|
||||||
lv_obj_t* timeDD2;
|
lv_obj_t* timeDD2;
|
||||||
|
lv_obj_t* timeAMPM;
|
||||||
lv_obj_t* dateDayOfWeek;
|
lv_obj_t* dateDayOfWeek;
|
||||||
lv_obj_t* dateDay;
|
lv_obj_t* dateDay;
|
||||||
lv_obj_t* dateMonth;
|
lv_obj_t* dateMonth;
|
||||||
|
|
Loading…
Reference in a new issue