diff options
Diffstat (limited to 'src/displayapp/screens/WatchFaceDigital.cpp')
| -rw-r--r-- | src/displayapp/screens/WatchFaceDigital.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 68c6acb..a184c77 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -15,6 +15,41 @@ #include "displayapp/fonts/neofont.h" using namespace Pinetime::Applications::Screens; +LV_IMG_DECLARE(bg_analog24); + +namespace { +constexpr int16_t HourLength = 30; +// 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) { + return _lv_trigo_sin(angle + 90); +} + +int16_t Sine(int16_t angle) { + return _lv_trigo_sin(angle); +} + +int16_t CoordinateXRelocate(int16_t x) { + return (x + LV_HOR_RES / 2); +} + +int16_t CoordinateYRelocate(int16_t y) { + return std::abs(y - LV_HOR_RES / 2); +} + +lv_point_t CoordinateRelocate(int16_t radius, int16_t angle) { + return lv_point_t{ + .x = CoordinateXRelocate(radius * static_cast<int32_t>(Sine(angle)) / LV_TRIG_SCALE), + .y = CoordinateYRelocate(radius * static_cast<int32_t>(Cosine(angle)) / LV_TRIG_SCALE) + }; +} + +} + WatchFaceDigital::WatchFaceDigital(DisplayApp* app, Controllers::DateTime& dateTimeController, Controllers::Battery& batteryController, @@ -33,6 +68,10 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, settingsController {settingsController}, motionController {motionController} { + bg_clock_img = lv_img_create(lv_scr_act(), NULL); + lv_img_set_src(bg_clock_img, &bg_analog24); + lv_obj_align(bg_clock_img, NULL, LV_ALIGN_CENTER, 0, 0); + batteryIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_fmt(batteryIcon, "B##%%"); lv_obj_set_style_local_text_font(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont1); @@ -121,6 +160,13 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text_static(backgroundLabel, ""); + hour_body_trace = lv_line_create(lv_scr_act(), NULL); + lv_style_init(&hour_line_style_trace); + lv_style_set_line_width(&hour_line_style_trace, LV_STATE_DEFAULT, 3); + lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_LIME); + lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); + lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); Refresh(); } @@ -194,6 +240,15 @@ void WatchFaceDigital::Refresh() { uint8_t second = time.seconds().count(); if (displayedHour != hour || displayedMinute != minute) { + { + auto const angle = (hour * 15 + minute / 4); + + hour_point_trace[0] = CoordinateRelocate(-20, angle); + hour_point_trace[1] = CoordinateRelocate(121, angle); + + // lv_line_set_points(hour_body, hour_point, 2); + lv_line_set_points(hour_body_trace, hour_point_trace, 2); + } displayedHour = hour; displayedMinute = minute; bool hide_pm = true; |
