Fix location counter width, font, and lat/lng bugs

This commit is contained in:
Will Bradley 2024-06-11 21:27:26 -07:00
parent f6a5588544
commit 49c801b827
Signed by: will
GPG Key ID: 7753374769D155F8
5 changed files with 22 additions and 27 deletions

View File

@ -330,7 +330,7 @@ namespace Pinetime {
Controllers::BrightnessController::Levels brightLevel = Controllers::BrightnessController::Levels::Medium; 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; SettingsData settings;

View File

@ -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_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); // 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); twelve = lv_label_create(lv_scr_act(), nullptr);
// lv_label_set_align(twelve, LV_LABEL_ALIGN_CENTER); lv_label_set_align(twelve, LV_LABEL_ALIGN_RIGHT);
// lv_label_set_text_static(twelve, "12"); lv_label_set_text_static(twelve, "XII");
// lv_obj_set_pos(twelve, 110, 10); 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_AQUA); 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); one = lv_label_create(lv_scr_act(), NULL);
lv_label_set_align(one, LV_LABEL_ALIGN_LEFT); lv_label_set_align(one, LV_LABEL_ALIGN_LEFT);
@ -190,6 +190,7 @@ void WatchFaceSundial::Refresh() {
void WatchFaceSundial::UpdateClock() { void WatchFaceSundial::UpdateClock() {
uint8_t hour = dateTimeController.Hours(); uint8_t hour = dateTimeController.Hours();
uint8_t minute = dateTimeController.Minutes(); uint8_t minute = dateTimeController.Minutes();
location = settingsController.GetLocation();
if (sHour != hour || sMinute != minute) { if (sHour != hour || sMinute != minute) {
// sun.setPosition(settings.lat.toFloat(), settings.lon.toFloat(), settings.gmtOffset / 3600); // 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_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(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(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) } 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, LV_STATE_DEFAULT, DARK_GRAY);
lv_style_set_line_color(&hour_line_style_trace, 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(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(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 if(minutesBeforeSunset > minutesDaytime) { // before sunrise
hourAngle = 180.0 * (minutesBeforeSunset - minutesDaytime) / minutesNighttime + 90; hourAngle = 180.0 * (minutesBeforeSunset - minutesDaytime) / minutesNighttime + 90;
@ -238,11 +241,11 @@ void WatchFaceSundial::UpdateClock() {
sHour = hour; sHour = hour;
sMinute = minute; sMinute = minute;
printf("<: %d %d @%d/%d+/-%d\n", hour, minute, location.latitude, location.longitude, location.tzOffset); printf("H%d:%d lat%f lng%f z%d\n", hour, minute, (float)location.latitude, (float)location.longitude, location.tzOffset);
printf("@: %d %d:%d %d:%d\n", printf("%d before sunset, sunrise at %d:%d sunset at %d:%d angle %d\n",
minutesBeforeSunset, minutesBeforeSunset,
minutesSunrise/60, minutesSunrise % 60, minutesSunrise/60, minutesSunrise % 60,
minutesSunset/60, minutesSunset % 60); minutesSunset/60, minutesSunset % 60, hourAngle);
hour_point_trace[0] = CoordinateRelocateSundial(HourLength*.75, hourAngle); hour_point_trace[0] = CoordinateRelocateSundial(HourLength*.75, hourAngle);
hour_point_trace[1] = CoordinateRelocateSundial(HourLength, hourAngle); hour_point_trace[1] = CoordinateRelocateSundial(HourLength, hourAngle);

View File

@ -9,6 +9,9 @@
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
namespace { 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; constexpr int16_t POS_Y_TEXT = 25;
void ValueChangedHandler(void* userData) { 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_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_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_text_static(icon, Symbols::map);
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); 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(); Controllers::Settings::Location loc = settingsController.GetLocation();
latCounter.Create(); latCounter.Create();
latCounter.SetWidth(80);
latCounter.SetValue(loc.latitude); 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); latCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
longCounter.Create(); longCounter.Create();
longCounter.SetWidth(110);
longCounter.SetValue(loc.longitude); 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); longCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
tzCounter.Create(); tzCounter.Create();
tzCounter.SetWidth(60);
tzCounter.SetValue(loc.tzOffset); 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); tzCounter.SetValueChangedEventCallback(this, ValueChangedHandler);
UpdateScreen(); UpdateScreen();

View File

@ -22,9 +22,9 @@ namespace Pinetime {
private: private:
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
Widgets::Counter latCounter = Widgets::Counter(-90, 90, jetbrains_mono_42); Widgets::Counter latCounter = Widgets::Counter(-90, 90, jetbrains_mono_bold_20);
Widgets::Counter longCounter = Widgets::Counter(-180, 180, jetbrains_mono_42); Widgets::Counter longCounter = Widgets::Counter(-180, 180, jetbrains_mono_bold_20);
Widgets::Counter tzCounter = Widgets::Counter(-12, 12, jetbrains_mono_42); Widgets::Counter tzCounter = Widgets::Counter(-12, 12, jetbrains_mono_bold_20);
}; };
} }
} }

View File

@ -18,15 +18,6 @@ namespace Pinetime {
void EnableMonthMode(); void EnableMonthMode();
void SetMax(int newMax); void SetMax(int newMax);
void SetValueChangedEventCallback(void* userData, void (*handler)(void* userData)); 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 { int GetValue() const {
return value; return value;