diff options
Diffstat (limited to 'src/displayapp/screens')
| -rw-r--r-- | src/displayapp/screens/Clock.cpp | 5 | ||||
| -rw-r--r-- | src/displayapp/screens/Clock.h | 3 | ||||
| -rw-r--r-- | src/displayapp/screens/Symbols.h | 9 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFacePineTimeStyle.cpp | 150 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFacePineTimeStyle.h | 14 |
5 files changed, 145 insertions, 36 deletions
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index ce70f23f..4219b090 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -24,6 +24,7 @@ Clock::Clock(Controllers::DateTime& dateTimeController, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController, + Controllers::WeatherService& weatherService, Controllers::FS& filesystem) : dateTimeController {dateTimeController}, batteryController {batteryController}, @@ -32,6 +33,7 @@ Clock::Clock(Controllers::DateTime& dateTimeController, settingsController {settingsController}, heartRateController {heartRateController}, motionController {motionController}, + weatherService {weatherService}, filesystem {filesystem}, screen {[this, &settingsController]() { switch (settingsController.GetWatchFace()) { @@ -95,7 +97,8 @@ std::unique_ptr<Screen> Clock::WatchFacePineTimeStyleScreen() { bleController, notificationManager, settingsController, - motionController); + motionController, + weatherService); } std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() { diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index 8c987fbb..f3591f43 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -7,6 +7,7 @@ #include <components/heartrate/HeartRateController.h> #include "displayapp/screens/Screen.h" #include "components/datetime/DateTimeController.h" +#include "components/ble/weather/WeatherService.h" namespace Pinetime { namespace Controllers { @@ -28,6 +29,7 @@ namespace Pinetime { Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController, + Controllers::WeatherService& weatherService, Controllers::FS& filesystem); ~Clock() override; @@ -42,6 +44,7 @@ namespace Pinetime { Controllers::Settings& settingsController; Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; + Controllers::WeatherService& weatherService; Controllers::FS& filesystem; std::unique_ptr<Screen> screen; diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h index 934cdc3f..7154ff44 100644 --- a/src/displayapp/screens/Symbols.h +++ b/src/displayapp/screens/Symbols.h @@ -38,6 +38,15 @@ namespace Pinetime { static constexpr const char* home = "\xEF\x80\x95"; static constexpr const char* sleep = "\xEE\xBD\x84"; + // fontawesome_weathericons.c + // static constexpr const char* sun = "\xEF\x86\x85"; + static constexpr const char* cloudSun = "\xEF\x9B\x84"; + static constexpr const char* cloudSunRain = "\xEF\x9D\x83"; + static constexpr const char* cloudShowersHeavy = "\xEF\x9D\x80"; + static constexpr const char* smog = "\xEF\x9D\x9F"; + static constexpr const char* cloud = "\xEF\x83\x82"; + static constexpr const char* ban = "\xEF\x81\x9E"; + // lv_font_sys_48.c static constexpr const char* settings = "\xEE\xA2\xB8"; diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp index fbdabc9e..250a745c 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.cpp +++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp @@ -33,6 +33,7 @@ #include "components/motion/MotionController.h" #include "components/settings/Settings.h" #include "displayapp/DisplayApp.h" +#include "components/ble/weather/WeatherService.h" using namespace Pinetime::Applications::Screens; @@ -48,7 +49,8 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo const Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, - Controllers::MotionController& motionController) + Controllers::MotionController& motionController, + Controllers::WeatherService& weatherService) : currentDateTime {{}}, batteryIcon(false), dateTimeController {dateTimeController}, @@ -56,7 +58,8 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo bleController {bleController}, notificationManager {notificationManager}, settingsController {settingsController}, - motionController {motionController} { + motionController {motionController}, + weatherService {weatherService} { // Create a 200px wide background rectangle timebar = lv_obj_create(lv_scr_act(), nullptr); @@ -94,27 +97,52 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo // Display icons batteryIcon.Create(sidebar); batteryIcon.SetColor(LV_COLOR_BLACK); - lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_MID, 0, 2); + lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_MID, 10, 2); plugIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(plugIcon, Symbols::plug); lv_obj_set_style_local_text_color(plugIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_obj_align(plugIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2); + lv_obj_align(plugIcon, sidebar, LV_ALIGN_IN_TOP_MID, 10, 2); bleIcon = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_label_set_text_static(bleIcon, ""); + lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, -10, 2); notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_label_set_text_static(notificationIcon, ""); + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); + lv_obj_align(notificationIcon, timebar, LV_ALIGN_IN_TOP_LEFT, 5, 5); + + weatherIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + lv_obj_set_style_local_text_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons); + lv_label_set_text(weatherIcon, Symbols::cloudSunRain); + lv_obj_align(weatherIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 35); + lv_obj_set_auto_realign(weatherIcon, true); + if (settingsController.GetPTSWeather() == Pinetime::Controllers::Settings::PTSWeather::On) { + lv_obj_set_hidden(weatherIcon, false); + } else { + lv_obj_set_hidden(weatherIcon, true); + } + + temperature = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + lv_obj_align(temperature, sidebar, LV_ALIGN_IN_TOP_MID, 0, 65); + if (settingsController.GetPTSWeather() == Pinetime::Controllers::Settings::PTSWeather::On) { + lv_obj_set_hidden(temperature, false); + } else { + lv_obj_set_hidden(temperature, true); + } // 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_BLACK); lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_size(calendarOuter, 34, 34); - lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); + if (settingsController.GetPTSWeather() == Pinetime::Controllers::Settings::PTSWeather::On) { + lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 20); + } else { + lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); + } calendarInner = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); @@ -150,17 +178,17 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo 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_BLACK); lv_label_set_text_static(dateDayOfWeek, "THU"); - lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34); + lv_obj_align(dateDayOfWeek, calendarOuter, LV_ALIGN_CENTER, 0, -32); dateDay = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_label_set_text_static(dateDay, "25"); - lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3); + lv_obj_align(dateDay, calendarOuter, LV_ALIGN_CENTER, 0, 3); dateMonth = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_label_set_text_static(dateMonth, "MAR"); - lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); + lv_obj_align(dateMonth, calendarOuter, LV_ALIGN_CENTER, 0, 32); // Step count gauge if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) { @@ -323,13 +351,23 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo btnSteps = lv_btn_create(lv_scr_act(), nullptr); btnSteps->user_data = this; lv_obj_set_size(btnSteps, 160, 60); - lv_obj_align(btnSteps, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_obj_align(btnSteps, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); lv_obj_set_style_local_bg_opa(btnSteps, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_t* lblSteps = lv_label_create(btnSteps, nullptr); lv_label_set_text_static(lblSteps, "Steps style"); lv_obj_set_event_cb(btnSteps, event_handler); lv_obj_set_hidden(btnSteps, true); + btnWeather = lv_btn_create(lv_scr_act(), nullptr); + btnWeather->user_data = this; + lv_obj_set_size(btnWeather, 160, 60); + lv_obj_align(btnWeather, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); + lv_obj_set_style_local_bg_opa(btnWeather, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); + lv_obj_t* lblWeather = lv_label_create(btnWeather, nullptr); + lv_label_set_text_static(lblWeather, "Weather"); + lv_obj_set_event_cb(btnWeather, event_handler); + lv_obj_set_hidden(btnWeather, true); + btnSetColor = lv_btn_create(lv_scr_act(), nullptr); btnSetColor->user_data = this; lv_obj_set_size(btnSetColor, 150, 60); @@ -337,9 +375,9 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo lv_obj_set_style_local_radius(btnSetColor, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 20); lv_obj_set_style_local_bg_opa(btnSetColor, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_set_event_cb(btnSetColor, event_handler); - lbl_btnSetColor = lv_label_create(btnSetColor, nullptr); - lv_obj_set_style_local_text_font(lbl_btnSetColor, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); - lv_label_set_text_static(lbl_btnSetColor, Symbols::paintbrushLg); + lv_obj_t* lblSetColor = lv_label_create(btnSetColor, nullptr); + lv_obj_set_style_local_text_font(lblSetColor, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lv_label_set_text_static(lblSetColor, Symbols::paintbrushLg); lv_obj_set_hidden(btnSetColor, true); btnSetOpts = lv_btn_create(lv_scr_act(), nullptr); @@ -349,9 +387,9 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo lv_obj_set_style_local_radius(btnSetOpts, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 20); lv_obj_set_style_local_bg_opa(btnSetOpts, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_set_event_cb(btnSetOpts, event_handler); - lbl_btnSetOpts = lv_label_create(btnSetOpts, nullptr); - lv_obj_set_style_local_text_font(lbl_btnSetOpts, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); - lv_label_set_text_static(lbl_btnSetOpts, Symbols::settings); + lv_obj_t* lblSetOpts = lv_label_create(btnSetOpts, nullptr); + lv_obj_set_style_local_text_font(lblSetOpts, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lv_label_set_text_static(lblSetOpts, Symbols::settings); lv_obj_set_hidden(btnSetOpts, true); taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); @@ -388,6 +426,7 @@ void WatchFacePineTimeStyle::CloseMenu() { lv_obj_set_hidden(btnRandom, true); lv_obj_set_hidden(btnClose, true); lv_obj_set_hidden(btnSteps, true); + lv_obj_set_hidden(btnWeather, true); } bool WatchFacePineTimeStyle::OnButtonPushed() { @@ -403,17 +442,6 @@ void WatchFacePineTimeStyle::SetBatteryIcon() { batteryIcon.SetBatteryPercentage(batteryPercent); } -void WatchFacePineTimeStyle::AlignIcons() { - if (notificationState.Get() && bleState.Get()) { - lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 8, 25); - lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, -8, 25); - } else if (notificationState.Get() && !bleState.Get()) { - lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); - } else { - lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); - } -} - void WatchFacePineTimeStyle::Refresh() { isCharging = batteryController.IsCharging(); if (isCharging.IsUpdated()) { @@ -437,13 +465,12 @@ void WatchFacePineTimeStyle::Refresh() { bleRadioEnabled = bleController.IsRadioEnabled(); if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get())); - AlignIcons(); + lv_obj_realign(bleIcon); } notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); - AlignIcons(); } currentDateTime = dateTimeController.CurrentDateTime(); @@ -509,6 +536,35 @@ void WatchFacePineTimeStyle::Refresh() { lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); } } + + if (weatherService.GetCurrentTemperature()->timestamp != 0 && weatherService.GetCurrentClouds()->timestamp != 0 && + weatherService.GetCurrentPrecipitation()->timestamp != 0) { + nowTemp = (weatherService.GetCurrentTemperature()->temperature / 100); + clouds = (weatherService.GetCurrentClouds()->amount); + precip = (weatherService.GetCurrentPrecipitation()->amount); + if (nowTemp.IsUpdated()) { + lv_label_set_text_fmt(temperature, "%d°", nowTemp.Get()); + if ((clouds <= 30) && (precip == 0)) { + lv_label_set_text(weatherIcon, Symbols::sun); + } else if ((clouds >= 70) && (clouds <= 90) && (precip == 1)) { + lv_label_set_text(weatherIcon, Symbols::cloudSunRain); + } else if ((clouds > 90) && (precip == 0)) { + lv_label_set_text(weatherIcon, Symbols::cloud); + } else if ((clouds > 70) && (precip >= 2)) { + lv_label_set_text(weatherIcon, Symbols::cloudShowersHeavy); + } else { + lv_label_set_text(weatherIcon, Symbols::cloudSun); + }; + lv_obj_realign(temperature); + lv_obj_realign(weatherIcon); + } + } else { + lv_label_set_text_static(temperature, "--"); + lv_label_set_text(weatherIcon, Symbols::ban); + lv_obj_realign(temperature); + lv_obj_realign(weatherIcon); + } + if (!lv_obj_get_hidden(btnSetColor)) { if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) { lv_obj_set_hidden(btnSetColor, true); @@ -654,6 +710,37 @@ void WatchFacePineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) settingsController.SetPTSGaugeStyle(Controllers::Settings::PTSGaugeStyle::Full); } } + if (object == btnWeather) { + if (lv_obj_get_hidden(weatherIcon)) { + // show weather icon and temperature + lv_obj_set_hidden(weatherIcon, false); + lv_obj_set_hidden(temperature, false); + lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 20); + lv_obj_realign(calendarInner); + lv_obj_realign(calendarBar1); + lv_obj_realign(calendarBar2); + lv_obj_realign(calendarCrossBar1); + lv_obj_realign(calendarCrossBar2); + lv_obj_realign(dateDayOfWeek); + lv_obj_realign(dateDay); + lv_obj_realign(dateMonth); + settingsController.SetPTSWeather(Controllers::Settings::PTSWeather::On); + } else { + // hide weather + lv_obj_set_hidden(weatherIcon, true); + lv_obj_set_hidden(temperature, true); + lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); + lv_obj_realign(calendarInner); + lv_obj_realign(calendarBar1); + lv_obj_realign(calendarBar2); + lv_obj_realign(calendarCrossBar1); + lv_obj_realign(calendarCrossBar2); + lv_obj_realign(dateDayOfWeek); + lv_obj_realign(dateDay); + lv_obj_realign(dateMonth); + settingsController.SetPTSWeather(Controllers::Settings::PTSWeather::Off); + } + } if (object == btnSetColor) { lv_obj_set_hidden(btnSetColor, true); lv_obj_set_hidden(btnSetOpts, true); @@ -671,6 +758,7 @@ void WatchFacePineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) lv_obj_set_hidden(btnSetColor, true); lv_obj_set_hidden(btnSetOpts, true); lv_obj_set_hidden(btnSteps, false); + lv_obj_set_hidden(btnWeather, false); lv_obj_set_hidden(btnClose, false); } } diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.h b/src/displayapp/screens/WatchFacePineTimeStyle.h index a5c06901..e157bb2c 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.h +++ b/src/displayapp/screens/WatchFacePineTimeStyle.h @@ -8,6 +8,7 @@ #include "displayapp/screens/BatteryIcon.h" #include "displayapp/Colors.h" #include "components/datetime/DateTimeController.h" +#include "components/ble/weather/WeatherService.h" #include "components/ble/BleController.h" #include "utility/DirtyValue.h" @@ -30,7 +31,8 @@ namespace Pinetime { const Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, - Controllers::MotionController& motionController); + Controllers::MotionController& motionController, + Controllers::WeatherService& weather); ~WatchFacePineTimeStyle() override; bool OnTouchEvent(TouchEvents event) override; @@ -58,6 +60,9 @@ namespace Pinetime { Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {}; Utility::DirtyValue<uint32_t> stepCount {}; Utility::DirtyValue<bool> notificationState {}; + Utility::DirtyValue<int16_t> nowTemp {}; + int16_t clouds = 0; + int16_t precip = 0; static Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color); static Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color); @@ -72,6 +77,7 @@ namespace Pinetime { lv_obj_t* btnRandom; lv_obj_t* btnClose; lv_obj_t* btnSteps; + lv_obj_t* btnWeather; lv_obj_t* timebar; lv_obj_t* sidebar; lv_obj_t* timeDD1; @@ -81,6 +87,8 @@ namespace Pinetime { lv_obj_t* dateDayOfWeek; lv_obj_t* dateDay; lv_obj_t* dateMonth; + lv_obj_t* weatherIcon; + lv_obj_t* temperature; lv_obj_t* plugIcon; lv_obj_t* bleIcon; lv_obj_t* calendarOuter; @@ -93,8 +101,6 @@ namespace Pinetime { lv_obj_t* stepGauge; lv_obj_t* btnSetColor; lv_obj_t* btnSetOpts; - lv_obj_t* lbl_btnSetColor; - lv_obj_t* lbl_btnSetOpts; lv_obj_t* stepIcon; lv_obj_t* stepValue; lv_color_t needle_colors[1]; @@ -107,10 +113,10 @@ namespace Pinetime { Controllers::NotificationManager& notificationManager; Controllers::Settings& settingsController; Controllers::MotionController& motionController; + Controllers::WeatherService& weatherService; void SetBatteryIcon(); void CloseMenu(); - void AlignIcons(); lv_task_t* taskRefresh; }; |
