Skip to content

Commit b75bc54

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 6ab512a commit b75bc54

File tree

14 files changed

+377
-261
lines changed

14 files changed

+377
-261
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;
@@ -304,6 +308,7 @@ namespace Pinetime {
304308

305309
WatchFaceInfineat watchFaceInfineat;
306310

311+
std::bitset<3> widgets {0b111}; // Set all 3 widgets to enabled by default
307312
std::bitset<5> wakeUpMode {0};
308313
uint16_t shakeWakeThreshold = 150;
309314

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"
@@ -508,6 +509,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
508509
case Apps::SettingWakeUp:
509510
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
510511
break;
512+
case Apps::SettingWidgets:
513+
currentScreen = std::make_unique<Screens::SettingWidgets>(settingsController);
514+
break;
511515
case Apps::SettingDisplay:
512516
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
513517
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: 73 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,19 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
3939
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
4040
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
4141

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

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

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

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

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

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

8793
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
8894
Refresh();
@@ -148,46 +154,52 @@ void WatchFaceDigital::Refresh() {
148154
}
149155
}
150156

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

162-
lv_obj_realign(heartbeatIcon);
163-
lv_obj_realign(heartbeatValue);
169+
lv_obj_realign(heartbeatIcon);
170+
lv_obj_realign(heartbeatValue);
171+
}
164172
}
165173

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

173-
currentWeather = weatherService.Current();
174-
if (currentWeather.IsUpdated()) {
175-
auto optCurrentWeather = currentWeather.Get();
176-
if (optCurrentWeather) {
177-
int16_t temp = optCurrentWeather->temperature;
178-
char tempUnit = 'C';
179-
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
180-
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
181-
tempUnit = 'F';
183+
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
184+
currentWeather = weatherService.Current();
185+
if (currentWeather.IsUpdated()) {
186+
auto optCurrentWeather = currentWeather.Get();
187+
if (optCurrentWeather) {
188+
int16_t temp = optCurrentWeather->temperature;
189+
char tempUnit = 'C';
190+
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
191+
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
192+
tempUnit = 'F';
193+
}
194+
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
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, "");
182200
}
183-
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
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, "");
201+
lv_obj_realign(temperature);
202+
lv_obj_realign(weatherIcon);
189203
}
190-
lv_obj_realign(temperature);
191-
lv_obj_realign(weatherIcon);
192204
}
193205
}

0 commit comments

Comments
 (0)