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