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