Skip to content

Commit 6cd92d3

Browse files
committed
settings: Add global widget selection
Instead of each watch face implementing their own settings for which widgets to display, we can have a global selection of widgets. All watch faces can then determine whether it is enabled and so display it in whichever way makes sense for that face. Current widgets supported are heart rate, step counter, and weather.
1 parent 728da0f commit 6cd92d3

14 files changed

+371
-259
lines changed

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ list(APPEND SOURCE_FILES
410410
displayapp/screens/settings/SettingTimeFormat.cpp
411411
displayapp/screens/settings/SettingWeatherFormat.cpp
412412
displayapp/screens/settings/SettingWakeUp.cpp
413+
displayapp/screens/settings/SettingWidgets.cpp
413414
displayapp/screens/settings/SettingDisplay.cpp
414415
displayapp/screens/settings/SettingSteps.cpp
415416
displayapp/screens/settings/SettingSetDateTime.cpp

src/components/settings/Settings.h

+17-12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace Pinetime {
1414
enum class Notification : uint8_t { On, Off, Sleep };
1515
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
1616
enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 };
17+
enum class Widget : uint8_t { HeartRate = 0, Steps = 1, Weather = 2 };
1718
enum class Colors : uint8_t {
1819
White,
1920
Silver,
@@ -35,14 +36,12 @@ namespace Pinetime {
3536
Pink
3637
};
3738
enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric };
38-
enum class PTSWeather : uint8_t { On, Off };
3939

4040
struct PineTimeStyle {
4141
Colors ColorTime = Colors::Teal;
4242
Colors ColorBar = Colors::Teal;
4343
Colors ColorBG = Colors::Black;
4444
PTSGaugeStyle gaugeStyle = PTSGaugeStyle::Full;
45-
PTSWeather weatherEnable = PTSWeather::Off;
4645
};
4746

4847
struct WatchFaceInfineat {
@@ -144,16 +143,6 @@ namespace Pinetime {
144143
return settings.PTS.gaugeStyle;
145144
};
146145

147-
void SetPTSWeather(PTSWeather weatherEnable) {
148-
if (weatherEnable != settings.PTS.weatherEnable)
149-
settingsChanged = true;
150-
settings.PTS.weatherEnable = weatherEnable;
151-
};
152-
153-
PTSWeather GetPTSWeather() const {
154-
return settings.PTS.weatherEnable;
155-
};
156-
157146
void SetAppMenu(uint8_t menu) {
158147
appMenu = menu;
159148
};
@@ -192,6 +181,21 @@ namespace Pinetime {
192181
return settings.weatherFormat;
193182
};
194183

184+
void SetWidget(Widget widget, bool enabled) {
185+
if (enabled != IsWidgetOn(widget)) {
186+
settingsChanged = true;
187+
}
188+
settings.widgets.set(static_cast<size_t>(widget), enabled);
189+
}
190+
191+
std::bitset<3> GetWidgets() const {
192+
return settings.widgets;
193+
}
194+
195+
bool IsWidgetOn(const Widget widget) const {
196+
return GetWidgets()[static_cast<size_t>(widget)];
197+
}
198+
195199
void SetNotificationStatus(Notification status) {
196200
if (status != settings.notificationStatus) {
197201
settingsChanged = true;
@@ -321,6 +325,7 @@ namespace Pinetime {
321325

322326
WatchFaceInfineat watchFaceInfineat;
323327

328+
std::bitset<3> widgets {0b111}; // Set all 3 widgets to enabled by default
324329
std::bitset<5> wakeUpMode {0};
325330
uint16_t shakeWakeThreshold = 150;
326331

src/displayapp/DisplayApp.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "displayapp/screens/settings/SettingTimeFormat.h"
4444
#include "displayapp/screens/settings/SettingWeatherFormat.h"
4545
#include "displayapp/screens/settings/SettingWakeUp.h"
46+
#include "displayapp/screens/settings/SettingWidgets.h"
4647
#include "displayapp/screens/settings/SettingDisplay.h"
4748
#include "displayapp/screens/settings/SettingSteps.h"
4849
#include "displayapp/screens/settings/SettingSetDateTime.h"
@@ -605,6 +606,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
605606
case Apps::SettingWakeUp:
606607
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
607608
break;
609+
case Apps::SettingWidgets:
610+
currentScreen = std::make_unique<Screens::SettingWidgets>(settingsController);
611+
break;
608612
case Apps::SettingDisplay:
609613
currentScreen = std::make_unique<Screens::SettingDisplay>(settingsController);
610614
break;

src/displayapp/apps/Apps.h.in

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace Pinetime {
3737
SettingWeatherFormat,
3838
SettingDisplay,
3939
SettingWakeUp,
40+
SettingWidgets,
4041
SettingSteps,
4142
SettingSetDateTime,
4243
SettingChimes,

src/displayapp/fonts/fonts.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
{
99
"file": "FontAwesome5-Solid+Brands+Regular.woff",
10-
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743"
10+
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743, 0xf0ad"
1111
}
1212
],
1313
"bpp": 1,

src/displayapp/screens/Symbols.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace Pinetime {
3939
static constexpr const char* eye = "\xEF\x81\xAE";
4040
static constexpr const char* home = "\xEF\x80\x95";
4141
static constexpr const char* sleep = "\xEE\xBD\x84";
42+
static constexpr const char* wrench = "\xEF\x82\xAD";
4243

4344
// fontawesome_weathericons.c
4445
// static constexpr const char* sun = "\xEF\x86\x85";

src/displayapp/screens/WatchFaceCasioStyleG7710.cpp

+44-36
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,29 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
148148
lv_obj_set_pos(backgroundLabel, 0, 0);
149149
lv_label_set_text_static(backgroundLabel, "");
150150

151-
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
152-
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
153-
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
154-
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2);
155-
156-
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
157-
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
158-
lv_label_set_text_static(heartbeatValue, "");
159-
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
160-
161-
stepValue = lv_label_create(lv_scr_act(), nullptr);
162-
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
163-
lv_label_set_text_static(stepValue, "0");
164-
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
165-
166-
stepIcon = lv_label_create(lv_scr_act(), nullptr);
167-
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
168-
lv_label_set_text_static(stepIcon, Symbols::shoe);
169-
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
151+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
152+
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
153+
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
154+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
155+
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2);
156+
157+
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
158+
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
159+
lv_label_set_text_static(heartbeatValue, "");
160+
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
161+
}
162+
163+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
164+
stepValue = lv_label_create(lv_scr_act(), nullptr);
165+
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
166+
lv_label_set_text_static(stepValue, "0");
167+
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
168+
169+
stepIcon = lv_label_create(lv_scr_act(), nullptr);
170+
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
171+
lv_label_set_text_static(stepIcon, Symbols::shoe);
172+
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
173+
}
170174

171175
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
172176
Refresh();
@@ -289,26 +293,30 @@ void WatchFaceCasioStyleG7710::Refresh() {
289293
}
290294
}
291295

292-
heartbeat = heartRateController.HeartRate();
293-
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
294-
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
295-
if (heartbeatRunning.Get()) {
296-
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
297-
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
298-
} else {
299-
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
300-
lv_label_set_text_static(heartbeatValue, "");
301-
}
296+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
297+
heartbeat = heartRateController.HeartRate();
298+
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
299+
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
300+
if (heartbeatRunning.Get()) {
301+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
302+
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
303+
} else {
304+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
305+
lv_label_set_text_static(heartbeatValue, "");
306+
}
302307

303-
lv_obj_realign(heartbeatIcon);
304-
lv_obj_realign(heartbeatValue);
308+
lv_obj_realign(heartbeatIcon);
309+
lv_obj_realign(heartbeatValue);
310+
}
305311
}
306312

307-
stepCount = motionController.NbSteps();
308-
if (stepCount.IsUpdated()) {
309-
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
310-
lv_obj_realign(stepValue);
311-
lv_obj_realign(stepIcon);
313+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
314+
stepCount = motionController.NbSteps();
315+
if (stepCount.IsUpdated()) {
316+
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
317+
lv_obj_realign(stepValue);
318+
lv_obj_realign(stepIcon);
319+
}
312320
}
313321
}
314322

src/displayapp/screens/WatchFaceDigital.cpp

+70-60
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
4141
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
4242
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
4343

44-
weatherIcon = lv_label_create(lv_scr_act(), nullptr);
45-
lv_obj_set_style_local_text_color(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
46-
lv_obj_set_style_local_text_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
47-
lv_label_set_text(weatherIcon, "");
48-
lv_obj_align(weatherIcon, nullptr, LV_ALIGN_IN_TOP_MID, -20, 50);
49-
lv_obj_set_auto_realign(weatherIcon, true);
50-
51-
temperature = lv_label_create(lv_scr_act(), nullptr);
52-
lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
53-
lv_label_set_text(temperature, "");
54-
lv_obj_align(temperature, nullptr, LV_ALIGN_IN_TOP_MID, 20, 50);
44+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
45+
weatherIcon = lv_label_create(lv_scr_act(), nullptr);
46+
lv_obj_set_style_local_text_color(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
47+
lv_obj_set_style_local_text_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
48+
lv_label_set_text(weatherIcon, "");
49+
lv_obj_align(weatherIcon, nullptr, LV_ALIGN_IN_TOP_MID, -20, 50);
50+
lv_obj_set_auto_realign(weatherIcon, true);
51+
52+
temperature = lv_label_create(lv_scr_act(), nullptr);
53+
lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
54+
lv_label_set_text(temperature, "");
55+
lv_obj_align(temperature, nullptr, LV_ALIGN_IN_TOP_MID, 20, 50);
56+
}
5557

5658
label_date = lv_label_create(lv_scr_act(), nullptr);
5759
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
@@ -66,25 +68,29 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
6668
lv_label_set_text_static(label_time_ampm, "");
6769
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
6870

69-
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
70-
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
71-
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
72-
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
71+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
72+
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
73+
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
74+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
75+
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
7376

74-
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
75-
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
76-
lv_label_set_text_static(heartbeatValue, "");
77-
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
77+
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
78+
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
79+
lv_label_set_text_static(heartbeatValue, "");
80+
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
81+
}
7882

79-
stepValue = lv_label_create(lv_scr_act(), nullptr);
80-
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
81-
lv_label_set_text_static(stepValue, "0");
82-
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
83+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
84+
stepValue = lv_label_create(lv_scr_act(), nullptr);
85+
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
86+
lv_label_set_text_static(stepValue, "0");
87+
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
8388

84-
stepIcon = lv_label_create(lv_scr_act(), nullptr);
85-
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
86-
lv_label_set_text_static(stepIcon, Symbols::shoe);
87-
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
89+
stepIcon = lv_label_create(lv_scr_act(), nullptr);
90+
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
91+
lv_label_set_text_static(stepIcon, Symbols::shoe);
92+
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
93+
}
8894

8995
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
9096
Refresh();
@@ -150,45 +156,49 @@ void WatchFaceDigital::Refresh() {
150156
}
151157
}
152158

153-
heartbeat = heartRateController.HeartRate();
154-
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
155-
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
156-
if (heartbeatRunning.Get()) {
157-
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
158-
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
159-
} else {
160-
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
161-
lv_label_set_text_static(heartbeatValue, "");
162-
}
159+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
160+
heartbeat = heartRateController.HeartRate();
161+
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
162+
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
163+
if (heartbeatRunning.Get()) {
164+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
165+
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
166+
} else {
167+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
168+
lv_label_set_text_static(heartbeatValue, "");
169+
}
163170

164-
lv_obj_realign(heartbeatIcon);
165-
lv_obj_realign(heartbeatValue);
171+
lv_obj_realign(heartbeatIcon);
172+
lv_obj_realign(heartbeatValue);
173+
}
166174
}
167175

168-
stepCount = motionController.NbSteps();
169-
if (stepCount.IsUpdated()) {
170-
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
171-
lv_obj_realign(stepValue);
172-
lv_obj_realign(stepIcon);
176+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
177+
stepCount = motionController.NbSteps();
178+
if (stepCount.IsUpdated()) {
179+
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
180+
lv_obj_realign(stepValue);
181+
lv_obj_realign(stepIcon);
182+
}
173183
}
174184

175-
currentWeather = weatherService.Current();
176-
if (currentWeather.IsUpdated()) {
177-
auto optCurrentWeather = currentWeather.Get();
178-
if (optCurrentWeather) {
179-
int16_t temp = optCurrentWeather->temperature.Celsius();
180-
char tempUnit = 'C';
181-
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
182-
temp = optCurrentWeather->temperature.Fahrenheit();
183-
tempUnit = 'F';
185+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
186+
currentWeather = weatherService.Current();
187+
if (currentWeather.IsUpdated()) {
188+
auto optCurrentWeather = currentWeather.Get();
189+
if (optCurrentWeather) {
190+
int16_t temp = optCurrentWeather->temperature.Celsius();
191+
char tempUnit = 'C';
192+
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
193+
temp = optCurrentWeather->temperature.Fahrenheit();
194+
tempUnit = 'F';
195+
}
196+
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
197+
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
198+
} else {
199+
lv_label_set_text_static(temperature, "");
200+
lv_label_set_text(weatherIcon, "");
184201
}
185-
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
186-
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
187-
} else {
188-
lv_label_set_text_static(temperature, "");
189-
lv_label_set_text(weatherIcon, "");
190202
}
191-
lv_obj_realign(temperature);
192-
lv_obj_realign(weatherIcon);
193203
}
194204
}

0 commit comments

Comments
 (0)