aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/WatchFacePineTimeStyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens/WatchFacePineTimeStyle.cpp')
-rw-r--r--src/displayapp/screens/WatchFacePineTimeStyle.cpp147
1 files changed, 113 insertions, 34 deletions
diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp
index 85505a63..22ccefc7 100644
--- a/src/displayapp/screens/WatchFacePineTimeStyle.cpp
+++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp
@@ -22,17 +22,19 @@
#include "displayapp/screens/WatchFacePineTimeStyle.h"
#include <lvgl/lvgl.h>
#include <cstdio>
-#include <displayapp/Colors.h>
+#include "displayapp/Colors.h"
#include "displayapp/screens/BatteryIcon.h"
#include "displayapp/screens/BleIcon.h"
#include "displayapp/screens/NotificationIcon.h"
#include "displayapp/screens/Symbols.h"
+#include "displayapp/screens/WeatherSymbols.h"
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h"
#include "components/motion/MotionController.h"
#include "components/settings/Settings.h"
#include "displayapp/DisplayApp.h"
+#include "components/ble/SimpleWeatherService.h"
using namespace Pinetime::Applications::Screens;
@@ -48,7 +50,8 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
const Controllers::Ble& bleController,
Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController,
- Controllers::MotionController& motionController)
+ Controllers::MotionController& motionController,
+ Controllers::SimpleWeatherService& weatherService)
: currentDateTime {{}},
batteryIcon(false),
dateTimeController {dateTimeController},
@@ -56,7 +59,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 +98,53 @@ 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::ban);
+ 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_label_set_text(temperature, "--");
+ 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 +180,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 +353,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 +377,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 +389,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 +428,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 +444,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 +467,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();
@@ -499,8 +528,7 @@ void WatchFacePineTimeStyle::Refresh() {
}
stepCount = motionController.NbSteps();
- motionSensorOk = motionController.IsSensorOk();
- if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
+ if (stepCount.IsUpdated()) {
lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / (settingsController.GetStepsGoal() / 100)) % 100);
lv_obj_realign(stepGauge);
lv_label_set_text_fmt(stepValue, "%luK", (stepCount.Get() / 1000));
@@ -510,6 +538,25 @@ void WatchFacePineTimeStyle::Refresh() {
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
}
+
+ currentWeather = weatherService.Current();
+ if (currentWeather.IsUpdated()) {
+ auto optCurrentWeather = currentWeather.Get();
+ if (optCurrentWeather) {
+ int16_t temp = optCurrentWeather->temperature.Celsius();
+ if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
+ temp = optCurrentWeather->temperature.Fahrenheit();
+ }
+ lv_label_set_text_fmt(temperature, "%d°", temp);
+ lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
+ } else {
+ lv_label_set_text(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);
@@ -655,6 +702,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);
@@ -672,6 +750,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);
}
}