From 49c801b82768346fe34906dbc43639feebcfdaf9 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Tue, 11 Jun 2024 21:27:26 -0700 Subject: [PATCH] Fix location counter width, font, and lat/lng bugs --- src/components/settings/Settings.h | 2 +- src/displayapp/screens/WatchFaceSundial.cpp | 19 +++++++++++-------- .../screens/settings/SettingLocation.cpp | 13 +++++++------ .../screens/settings/SettingLocation.h | 6 +++--- src/displayapp/widgets/Counter.h | 9 --------- 5 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index f76be9ff..96b8f0d0 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -330,7 +330,7 @@ namespace Pinetime { Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium; - Location location = {(int16_t)-123,(int16_t)44,(int8_t)-8}; + Location location = {(int16_t)44,(int16_t)-123,(int8_t)-8}; }; SettingsData settings; diff --git a/src/displayapp/screens/WatchFaceSundial.cpp b/src/displayapp/screens/WatchFaceSundial.cpp index 1999cc78..7bac1ff9 100644 --- a/src/displayapp/screens/WatchFaceSundial.cpp +++ b/src/displayapp/screens/WatchFaceSundial.cpp @@ -91,11 +91,11 @@ WatchFaceSundial::WatchFaceSundial(Controllers::DateTime& dateTimeController, // lv_obj_set_style_local_scale_end_line_width(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 4); // lv_obj_set_style_local_scale_end_color(large_scales, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - // twelve = lv_label_create(lv_scr_act(), nullptr); - // lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER); - // lv_label_set_text_static(twelve, "12"); - // lv_obj_set_pos(twelve, 110, 10); - // lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + twelve = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_align(twelve, LV_LABEL_ALIGN_RIGHT); + lv_label_set_text_static(twelve, "XII"); + lv_obj_align(twelve, NULL, LV_ALIGN_IN_TOP_RIGHT, -20, SunDialVerticalOffset-20); + lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); one = lv_label_create(lv_scr_act(), NULL); lv_label_set_align(one, LV_LABEL_ALIGN_LEFT); @@ -190,6 +190,7 @@ void WatchFaceSundial::Refresh() { void WatchFaceSundial::UpdateClock() { uint8_t hour = dateTimeController.Hours(); uint8_t minute = dateTimeController.Minutes(); + location = settingsController.GetLocation(); if (sHour != hour || sMinute != minute) { // sun.setPosition(settings.lat.toFloat(), settings.lon.toFloat(), settings.gmtOffset / 3600); @@ -215,11 +216,13 @@ void WatchFaceSundial::UpdateClock() { lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); lv_obj_set_style_local_text_color(one, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); } else { // night (before sunrise or after sunset) lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, DARK_GRAY); lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, DARK_GRAY); lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_ORANGE); lv_obj_set_style_local_text_color(one, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY); + lv_obj_set_style_local_text_color(twelve, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, DARK_GRAY); if(minutesBeforeSunset > minutesDaytime) { // before sunrise hourAngle = 180.0 * (minutesBeforeSunset - minutesDaytime) / minutesNighttime + 90; @@ -238,11 +241,11 @@ void WatchFaceSundial::UpdateClock() { sHour = hour; sMinute = minute; - printf("<: %d %d @%d/%d+/-%d\n", hour, minute, location.latitude, location.longitude, location.tzOffset); - printf("@: %d %d:%d %d:%d\n", + printf("H%d:%d lat%f lng%f z%d\n", hour, minute, (float)location.latitude, (float)location.longitude, location.tzOffset); + printf("%d before sunset, sunrise at %d:%d sunset at %d:%d angle %d\n", minutesBeforeSunset, minutesSunrise/60, minutesSunrise % 60, - minutesSunset/60, minutesSunset % 60); + minutesSunset/60, minutesSunset % 60, hourAngle); hour_point_trace[0] = CoordinateRelocateSundial(HourLength*.75, hourAngle); hour_point_trace[1] = CoordinateRelocateSundial(HourLength, hourAngle); diff --git a/src/displayapp/screens/settings/SettingLocation.cpp b/src/displayapp/screens/settings/SettingLocation.cpp index 4de374b5..45909fac 100644 --- a/src/displayapp/screens/settings/SettingLocation.cpp +++ b/src/displayapp/screens/settings/SettingLocation.cpp @@ -9,6 +9,9 @@ using namespace Pinetime::Applications::Screens; namespace { + constexpr int16_t POS_X_LAT = -80; + constexpr int16_t POS_X_LONG = 0; + constexpr int16_t POS_X_TZ = 80; constexpr int16_t POS_Y_TEXT = 25; void ValueChangedHandler(void* userData) { @@ -27,6 +30,7 @@ SettingLocation::SettingLocation(Pinetime::Controllers::Settings& settingsContro lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_label_set_text_static(icon, Symbols::map); lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); @@ -34,21 +38,18 @@ SettingLocation::SettingLocation(Pinetime::Controllers::Settings& settingsContro Controllers::Settings::Location loc = settingsController.GetLocation(); latCounter.Create(); - latCounter.SetWidth(80); latCounter.SetValue(loc.latitude); - lv_obj_align(latCounter.GetObject(), nullptr, LV_ALIGN_CENTER, -90, POS_Y_TEXT); + lv_obj_align(latCounter.GetObject(), nullptr, LV_ALIGN_CENTER, POS_X_LAT, POS_Y_TEXT); latCounter.SetValueChangedEventCallback(this, ValueChangedHandler); longCounter.Create(); - longCounter.SetWidth(110); longCounter.SetValue(loc.longitude); - lv_obj_align(longCounter.GetObject(), nullptr, LV_ALIGN_CENTER, -5, POS_Y_TEXT); + lv_obj_align(longCounter.GetObject(), nullptr, LV_ALIGN_CENTER, POS_X_LONG, POS_Y_TEXT); longCounter.SetValueChangedEventCallback(this, ValueChangedHandler); tzCounter.Create(); - tzCounter.SetWidth(60); tzCounter.SetValue(loc.tzOffset); - lv_obj_align(tzCounter.GetObject(), nullptr, LV_ALIGN_CENTER, 75, POS_Y_TEXT); + lv_obj_align(tzCounter.GetObject(), nullptr, LV_ALIGN_CENTER, POS_X_TZ, POS_Y_TEXT); tzCounter.SetValueChangedEventCallback(this, ValueChangedHandler); UpdateScreen(); diff --git a/src/displayapp/screens/settings/SettingLocation.h b/src/displayapp/screens/settings/SettingLocation.h index 9596d12f..9d977ac5 100644 --- a/src/displayapp/screens/settings/SettingLocation.h +++ b/src/displayapp/screens/settings/SettingLocation.h @@ -22,9 +22,9 @@ namespace Pinetime { private: Controllers::Settings& settingsController; - Widgets::Counter latCounter = Widgets::Counter(-90, 90, jetbrains_mono_42); - Widgets::Counter longCounter = Widgets::Counter(-180, 180, jetbrains_mono_42); - Widgets::Counter tzCounter = Widgets::Counter(-12, 12, jetbrains_mono_42); + Widgets::Counter latCounter = Widgets::Counter(-90, 90, jetbrains_mono_bold_20); + Widgets::Counter longCounter = Widgets::Counter(-180, 180, jetbrains_mono_bold_20); + Widgets::Counter tzCounter = Widgets::Counter(-12, 12, jetbrains_mono_bold_20); }; } } diff --git a/src/displayapp/widgets/Counter.h b/src/displayapp/widgets/Counter.h index 2deb3a99..f075869b 100644 --- a/src/displayapp/widgets/Counter.h +++ b/src/displayapp/widgets/Counter.h @@ -18,15 +18,6 @@ namespace Pinetime { void EnableMonthMode(); void SetMax(int newMax); void SetValueChangedEventCallback(void* userData, void (*handler)(void* userData)); - void SetWidth(uint8_t width) { - lv_obj_set_size(counterContainer, width, containerHeight); - lv_obj_set_size(upBtn, width, btnHeight); - lv_obj_set_size(downBtn, width, btnHeight); - linePoints[0] = {0, 0}; - linePoints[1] = {width, 0}; - lv_line_set_points(upperLine, linePoints, 2); - lv_line_set_points(lowerLine, linePoints, 2); - } int GetValue() const { return value;