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