@@ -41,17 +41,19 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
41
41
lv_label_set_text_static (notificationIcon, NotificationIcon::GetIcon (false ));
42
42
lv_obj_align (notificationIcon, nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 0 );
43
43
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
+ }
55
57
56
58
label_date = lv_label_create (lv_scr_act (), nullptr );
57
59
lv_obj_align (label_date, lv_scr_act (), LV_ALIGN_CENTER, 0 , 60 );
@@ -66,25 +68,29 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
66
68
lv_label_set_text_static (label_time_ampm, " " );
67
69
lv_obj_align (label_time_ampm, lv_scr_act (), LV_ALIGN_IN_RIGHT_MID, -30 , -55 );
68
70
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 );
73
76
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
+ }
78
82
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 );
83
88
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
+ }
88
94
89
95
taskRefresh = lv_task_create (RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this );
90
96
Refresh ();
@@ -150,45 +156,49 @@ void WatchFaceDigital::Refresh() {
150
156
}
151
157
}
152
158
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
+ }
163
170
164
- lv_obj_realign (heartbeatIcon);
165
- lv_obj_realign (heartbeatValue);
171
+ lv_obj_realign (heartbeatIcon);
172
+ lv_obj_realign (heartbeatValue);
173
+ }
166
174
}
167
175
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
+ }
173
183
}
174
184
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, " " );
184
201
}
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, " " );
190
202
}
191
- lv_obj_realign (temperature);
192
- lv_obj_realign (weatherIcon);
193
203
}
194
204
}
0 commit comments