Skip to content

Commit 1d2d933

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 8d7a04e commit 1d2d933

14 files changed

Lines changed: 372 additions & 258 deletions

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ list(APPEND SOURCE_FILES
411411
displayapp/screens/settings/SettingTimeFormat.cpp
412412
displayapp/screens/settings/SettingWeatherFormat.cpp
413413
displayapp/screens/settings/SettingWakeUp.cpp
414+
displayapp/screens/settings/SettingWidgets.cpp
414415
displayapp/screens/settings/SettingDisplay.cpp
415416
displayapp/screens/settings/SettingHeartRate.cpp
416417
displayapp/screens/settings/SettingSteps.cpp

src/components/settings/Settings.h

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Pinetime {
1717
enum class Notification : uint8_t { On, Off, Sleep };
1818
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
1919
enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 };
20+
enum class Widget : uint8_t { HeartRate = 0, Steps = 1, Weather = 2 };
2021
enum class Colors : uint8_t {
2122
White,
2223
Silver,
@@ -38,7 +39,6 @@ namespace Pinetime {
3839
Pink
3940
};
4041
enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric };
41-
enum class PTSWeather : uint8_t { On, Off };
4242
enum class PrideFlag : uint8_t { Gay, Trans, Bi, Lesbian };
4343
enum class DfuAndFsMode : uint8_t { Disabled, Enabled, EnabledTillReboot };
4444

@@ -47,7 +47,6 @@ namespace Pinetime {
4747
Colors ColorBar = Colors::Teal;
4848
Colors ColorBG = Colors::Black;
4949
PTSGaugeStyle gaugeStyle = PTSGaugeStyle::Full;
50-
PTSWeather weatherEnable = PTSWeather::Off;
5150
};
5251

5352
struct WatchFaceInfineat {
@@ -149,16 +148,6 @@ namespace Pinetime {
149148
return settings.PTS.gaugeStyle;
150149
};
151150

152-
void SetPTSWeather(PTSWeather weatherEnable) {
153-
if (weatherEnable != settings.PTS.weatherEnable)
154-
settingsChanged = true;
155-
settings.PTS.weatherEnable = weatherEnable;
156-
};
157-
158-
PTSWeather GetPTSWeather() const {
159-
return settings.PTS.weatherEnable;
160-
};
161-
162151
void SetPrideFlag(PrideFlag prideFlag) {
163152
if (prideFlag != settings.prideFlag)
164153
settingsChanged = true;
@@ -207,6 +196,21 @@ namespace Pinetime {
207196
return settings.weatherFormat;
208197
};
209198

199+
void SetWidget(Widget widget, bool enabled) {
200+
if (enabled != IsWidgetOn(widget)) {
201+
settingsChanged = true;
202+
}
203+
settings.widgets.set(static_cast<size_t>(widget), enabled);
204+
}
205+
206+
std::bitset<3> GetWidgets() const {
207+
return settings.widgets;
208+
}
209+
210+
bool IsWidgetOn(const Widget widget) const {
211+
return GetWidgets()[static_cast<size_t>(widget)];
212+
}
213+
210214
void SetNotificationStatus(Notification status) {
211215
if (status != settings.notificationStatus) {
212216
settingsChanged = true;
@@ -376,6 +380,7 @@ namespace Pinetime {
376380

377381
WatchFaceInfineat watchFaceInfineat;
378382

383+
std::bitset<3> widgets {0b111}; // Set all 3 widgets to enabled by default
379384
std::bitset<5> wakeUpMode {0};
380385
uint16_t shakeWakeThreshold = 150;
381386

src/displayapp/DisplayApp.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "displayapp/screens/settings/SettingTimeFormat.h"
4545
#include "displayapp/screens/settings/SettingWeatherFormat.h"
4646
#include "displayapp/screens/settings/SettingWakeUp.h"
47+
#include "displayapp/screens/settings/SettingWidgets.h"
4748
#include "displayapp/screens/settings/SettingDisplay.h"
4849
#include "displayapp/screens/settings/SettingSteps.h"
4950
#include "displayapp/screens/settings/SettingSetDateTime.h"
@@ -610,6 +611,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
610611
case Apps::SettingWakeUp:
611612
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
612613
break;
614+
case Apps::SettingWidgets:
615+
currentScreen = std::make_unique<Screens::SettingWidgets>(settingsController);
616+
break;
613617
case Apps::SettingHeartRate:
614618
currentScreen = std::make_unique<Screens::SettingHeartRate>(settingsController);
615619
break;

src/displayapp/apps/Apps.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace Pinetime {
3939
SettingHeartRate,
4040
SettingDisplay,
4141
SettingWakeUp,
42+
SettingWidgets,
4243
SettingSteps,
4344
SettingSetDateTime,
4445
SettingChimes,

src/displayapp/fonts/fonts.json

Lines changed: 1 addition & 1 deletion
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, 0xf1ec, 0xf55a, 0xf3ed"
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, 0xf1ec, 0xf55a, 0xf3ed"
1111
}
1212
],
1313
"bpp": 1,

src/displayapp/screens/Symbols.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace Pinetime {
4242
static constexpr const char* sleep = "\xEE\xBD\x84";
4343
static constexpr const char* calculator = "\xEF\x87\xAC";
4444
static constexpr const char* backspace = "\xEF\x95\x9A";
45+
static constexpr const char* wrench = "\xEF\x82\xAD";
4546

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

src/displayapp/screens/WatchFaceCasioStyleG7710.cpp

Lines changed: 44 additions & 36 deletions
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

Lines changed: 71 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ 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+
lv_obj_set_auto_realign(temperature, true);
57+
}
5558

5659
label_date = lv_label_create(lv_scr_act(), nullptr);
5760
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
@@ -66,25 +69,29 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
6669
lv_label_set_text_static(label_time_ampm, "");
6770
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
6871

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);
72+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
73+
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
74+
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
75+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
76+
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
7377

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);
78+
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
79+
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
80+
lv_label_set_text_static(heartbeatValue, "");
81+
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
82+
}
7883

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);
84+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
85+
stepValue = lv_label_create(lv_scr_act(), nullptr);
86+
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
87+
lv_label_set_text_static(stepValue, "0");
88+
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
8389

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);
90+
stepIcon = lv_label_create(lv_scr_act(), nullptr);
91+
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
92+
lv_label_set_text_static(stepIcon, Symbols::shoe);
93+
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
94+
}
8895

8996
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
9097
Refresh();
@@ -150,45 +157,49 @@ void WatchFaceDigital::Refresh() {
150157
}
151158
}
152159

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-
}
160+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
161+
heartbeat = heartRateController.HeartRate();
162+
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
163+
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
164+
if (heartbeatRunning.Get()) {
165+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
166+
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
167+
} else {
168+
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
169+
lv_label_set_text_static(heartbeatValue, "");
170+
}
163171

164-
lv_obj_realign(heartbeatIcon);
165-
lv_obj_realign(heartbeatValue);
172+
lv_obj_realign(heartbeatIcon);
173+
lv_obj_realign(heartbeatValue);
174+
}
166175
}
167176

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);
177+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
178+
stepCount = motionController.NbSteps();
179+
if (stepCount.IsUpdated()) {
180+
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
181+
lv_obj_realign(stepValue);
182+
lv_obj_realign(stepIcon);
183+
}
173184
}
174185

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';
186+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
187+
currentWeather = weatherService.Current();
188+
if (currentWeather.IsUpdated()) {
189+
auto optCurrentWeather = currentWeather.Get();
190+
if (optCurrentWeather) {
191+
int16_t temp = optCurrentWeather->temperature.Celsius();
192+
char tempUnit = 'C';
193+
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
194+
temp = optCurrentWeather->temperature.Fahrenheit();
195+
tempUnit = 'F';
196+
}
197+
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
198+
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId, weatherService.IsNight()));
199+
} else {
200+
lv_label_set_text_static(temperature, "");
201+
lv_label_set_text(weatherIcon, "");
184202
}
185-
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
186-
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId, weatherService.IsNight()));
187-
} else {
188-
lv_label_set_text_static(temperature, "");
189-
lv_label_set_text(weatherIcon, "");
190203
}
191-
lv_obj_realign(temperature);
192-
lv_obj_realign(weatherIcon);
193204
}
194205
}

0 commit comments

Comments
 (0)