summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/WatchFaceAnalog.cpp
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2021-08-10 14:13:58 +0300
committerRiku Isokoski <riksu9000@gmail.com>2021-08-10 14:13:58 +0300
commitd307c6bd9ebd5e0af166ba9b4a491eb284b10b1d (patch)
tree7dad6f7b07a8ed0cd80c96367cb0c463b654d3dc /src/displayapp/screens/WatchFaceAnalog.cpp
parent10b5d30ec31fcd98343eee46c135659004fae19f (diff)
parent9fb37550886f09f6510e99a5b452262c53c3987c (diff)
Merge branch 'develop' into refresh_rework
Diffstat (limited to 'src/displayapp/screens/WatchFaceAnalog.cpp')
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp51
1 files changed, 22 insertions, 29 deletions
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index 95c3fe46..29b9fcda 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -10,38 +10,37 @@ LV_IMG_DECLARE(bg_clock);
using namespace Pinetime::Applications::Screens;
namespace {
-
-constexpr auto HOUR_LENGTH = 70;
-constexpr auto MINUTE_LENGTH = 90;
-constexpr auto SECOND_LENGTH = 110;
+constexpr int16_t HourLength = 70;
+constexpr int16_t MinuteLength = 90;
+constexpr int16_t SecondLength = 110;
// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor
const auto LV_TRIG_SCALE = _lv_trigo_sin(90);
-int16_t cosine(int16_t angle) {
+int16_t Cosine(int16_t angle) {
return _lv_trigo_sin(angle + 90);
}
-int16_t sine(int16_t angle) {
+int16_t Sine(int16_t angle) {
return _lv_trigo_sin(angle);
}
-int16_t coordinate_x_relocate(int16_t x) {
+int16_t CoordinateXRelocate(int16_t x) {
return (x + LV_HOR_RES / 2);
}
-int16_t coordinate_y_relocate(int16_t y) {
+int16_t CoordinateYRelocate(int16_t y) {
return std::abs(y - LV_HOR_RES / 2);
}
-lv_point_t coordinate_relocate(int16_t radius, int16_t angle) {
+lv_point_t CoordinateRelocate(int16_t radius, int16_t angle) {
return lv_point_t{
- .x = coordinate_x_relocate(radius * static_cast<int32_t>(sine(angle)) / LV_TRIG_SCALE),
- .y = coordinate_y_relocate(radius * static_cast<int32_t>(cosine(angle)) / LV_TRIG_SCALE)
+ .x = CoordinateXRelocate(radius * static_cast<int32_t>(Sine(angle)) / LV_TRIG_SCALE),
+ .y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE)
};
}
-} // namespace
+}
WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
Controllers::DateTime& dateTimeController,
@@ -136,18 +135,17 @@ WatchFaceAnalog::~WatchFaceAnalog() {
}
void WatchFaceAnalog::UpdateClock() {
-
hour = dateTimeController.Hours();
minute = dateTimeController.Minutes();
second = dateTimeController.Seconds();
if (sMinute != minute) {
auto const angle = minute * 6;
- minute_point[0] = coordinate_relocate(30, angle);
- minute_point[1] = coordinate_relocate(MINUTE_LENGTH, angle);
+ minute_point[0] = CoordinateRelocate(30, angle);
+ minute_point[1] = CoordinateRelocate(MinuteLength, angle);
- minute_point_trace[0] = coordinate_relocate(5, angle);
- minute_point_trace[1] = coordinate_relocate(31, angle);
+ minute_point_trace[0] = CoordinateRelocate(5, angle);
+ minute_point_trace[1] = CoordinateRelocate(31, angle);
lv_line_set_points(minute_body, minute_point, 2);
lv_line_set_points(minute_body_trace, minute_point_trace, 2);
@@ -158,11 +156,11 @@ void WatchFaceAnalog::UpdateClock() {
sMinute = minute;
auto const angle = (hour * 30 + minute / 2);
- hour_point[0] = coordinate_relocate(30, angle);
- hour_point[1] = coordinate_relocate(HOUR_LENGTH, angle);
+ hour_point[0] = CoordinateRelocate(30, angle);
+ hour_point[1] = CoordinateRelocate(HourLength, angle);
- hour_point_trace[0] = coordinate_relocate(5, angle);
- hour_point_trace[1] = coordinate_relocate(31, angle);
+ hour_point_trace[0] = CoordinateRelocate(5, angle);
+ hour_point_trace[1] = CoordinateRelocate(31, angle);
lv_line_set_points(hour_body, hour_point, 2);
lv_line_set_points(hour_body_trace, hour_point_trace, 2);
@@ -172,8 +170,8 @@ void WatchFaceAnalog::UpdateClock() {
sSecond = second;
auto const angle = second * 6;
- second_point[0] = coordinate_relocate(-20, angle);
- second_point[1] = coordinate_relocate(SECOND_LENGTH, angle);
+ second_point[0] = CoordinateRelocate(-20, angle);
+ second_point[1] = CoordinateRelocate(SecondLength, angle);
lv_line_set_points(second_body, second_point, 2);
}
}
@@ -188,16 +186,12 @@ void WatchFaceAnalog::Refresh() {
notificationState = notificationManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- if (notificationState.Get() == true)
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
- else
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) {
-
month = dateTimeController.Month();
day = dateTimeController.Day();
dayOfWeek = dateTimeController.DayOfWeek();
@@ -205,7 +199,6 @@ void WatchFaceAnalog::Refresh() {
UpdateClock();
if ((month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
-
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), day);
currentMonth = month;