summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/PineTimeStyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens/PineTimeStyle.cpp')
-rw-r--r--src/displayapp/screens/PineTimeStyle.cpp96
1 files changed, 34 insertions, 62 deletions
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp
index 0efb4dc3..7a712f43 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/PineTimeStyle.cpp
@@ -23,6 +23,7 @@
#include <date/date.h>
#include <lvgl/lvgl.h>
#include <cstdio>
+#include <displayapp/Colors.h>
#include "BatteryIcon.h"
#include "BleIcon.h"
#include "NotificationIcon.h"
@@ -52,7 +53,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
settingsController {settingsController},
motionController {motionController} {
- /* This sets the watchface number to return to after leaving the menu */
+ // This sets the watchface number to return to after leaving the menu
settingsController.SetClockFace(2);
displayedChar[0] = 0;
@@ -61,44 +62,40 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
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);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(timebar, 200, 240);
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
- /* Display the time */
-
+ // Display the time
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_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD1, "12");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
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_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD2, "34");
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_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_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);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(sidebar, 40, 240);
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
- /* Display icons */
-
+ // Display icons
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_hex(0x000000));
lv_label_set_text(batteryIcon, Symbols::batteryFull);
@@ -116,8 +113,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40);
- /* Calendar icon */
-
+ // Calendar icon
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -154,8 +150,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_size(calendarCrossBar2, 8, 3);
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
- /* Display date */
-
+ // Display date
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_hex(0x000000));
lv_label_set_text(dateDayOfWeek, "THU");
@@ -191,7 +186,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
+ lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
@@ -200,13 +195,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text(backgroundLabel, "");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+ Refresh();
}
PineTimeStyle::~PineTimeStyle() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool PineTimeStyle::Refresh() {
+void PineTimeStyle::Refresh() {
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get();
@@ -223,26 +222,17 @@ bool PineTimeStyle::Refresh() {
bleState = bleController.IsConnected();
if (bleState.IsUpdated()) {
- if (bleState.Get() == true) {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(true));
- lv_obj_realign(bleIcon);
- } else {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(false));
- }
+ lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
+ lv_obj_realign(bleIcon);
}
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- if (notificationState.Get() == true) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
- lv_obj_realign(notificationIcon);
- } else {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
- }
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_obj_realign(notificationIcon);
}
currentDateTime = dateTimeController.CurrentDateTime();
-
if (currentDateTime.IsUpdated()) {
auto newDateTime = currentDateTime.Get();
@@ -250,9 +240,9 @@ bool PineTimeStyle::Refresh() {
auto time = date::make_time(newDateTime - dp);
auto yearMonthDay = date::year_month_day(dp);
- auto year = (int) yearMonthDay.year();
- auto month = static_cast<Pinetime::Controllers::DateTime::Months>((unsigned) yearMonthDay.month());
- auto day = (unsigned) yearMonthDay.day();
+ auto year = static_cast<int>(yearMonthDay.year());
+ auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
+ auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
int hour = time.hours().count();
@@ -263,9 +253,8 @@ bool PineTimeStyle::Refresh() {
char hoursChar[3];
char ampmChar[5];
-
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(hoursChar, "%02d", hour);
+ sprintf(hoursChar, "%02d", hour);
} else {
if (hour == 0 && hour != 12) {
hour = 12;
@@ -282,41 +271,26 @@ bool PineTimeStyle::Refresh() {
sprintf(hoursChar, "%02d", hour);
}
- if (hoursChar[0] != displayedChar[0] || hoursChar[1] != displayedChar[1] || minutesChar[0] != displayedChar[2] ||
+ 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];
- char hourStr[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 */
- sprintf(hourStr, "%c%c", hoursChar[0], hoursChar[1]);
- lv_label_set_text(timeDD1, hourStr);
-
- sprintf(minStr, "%c%c", minutesChar[0], minutesChar[1]);
- lv_label_set_text(timeDD2, minStr);
+ 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)) {
- char dayOfWeekStr[4];
- char dayStr[3];
- char monthStr[4];
-
- sprintf(dayOfWeekStr, "%s", dateTimeController.DayOfWeekShortToString());
- sprintf(dayStr, "%d", day);
- sprintf(monthStr, "%s", dateTimeController.MonthShortToString());
-
- lv_label_set_text(dateDayOfWeek, dayOfWeekStr);
- lv_label_set_text(dateDay, dayStr);
+ lv_label_set_text_fmt(dateDayOfWeek, "%s", dateTimeController.DayOfWeekShortToString());
+ lv_label_set_text_fmt(dateDay, "%d", day);
lv_obj_realign(dateDay);
- lv_label_set_text(dateMonth, monthStr);
+ lv_label_set_text_fmt(dateMonth, "%s", dateTimeController.MonthShortToString());
currentYear = year;
currentMonth = month;
@@ -335,6 +309,4 @@ bool PineTimeStyle::Refresh() {
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
}
-
- return running;
-} \ No newline at end of file
+}