Skip to content

Commit 0a5e92e

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 a77a3dc commit 0a5e92e

File tree

14 files changed

+371
-259
lines changed

14 files changed

+371
-259
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
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

Lines changed: 17 additions & 12 deletions
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

Lines changed: 4 additions & 0 deletions
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"
@@ -603,6 +604,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
603604
case Apps::SettingWakeUp:
604605
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
605606
break;
607+
case Apps::SettingWidgets:
608+
currentScreen = std::make_unique<Screens::SettingWidgets>(settingsController);
609+
break;
606610
case Apps::SettingDisplay:
607611
currentScreen = std::make_unique<Screens::SettingDisplay>(settingsController);
608612
break;

src/displayapp/apps/Apps.h.in

Lines changed: 1 addition & 0 deletions
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

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"
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

Lines changed: 1 addition & 0 deletions
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

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: 70 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
4040
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
4141
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
4242

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

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

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

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

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

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

8894
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
8995
Refresh();
@@ -149,45 +155,49 @@ void WatchFaceDigital::Refresh() {
149155
}
150156
}
151157

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

163-
lv_obj_realign(heartbeatIcon);
164-
lv_obj_realign(heartbeatValue);
170+
lv_obj_realign(heartbeatIcon);
171+
lv_obj_realign(heartbeatValue);
172+
}
165173
}
166174

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

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

0 commit comments

Comments
 (0)