@@ -51,7 +51,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
5151 notificatioManager {notificatioManager},
5252 settingsController {settingsController},
5353 motionController {motionController} {
54-
5554 /* This sets the watchface number to return to after leaving the menu */
5655 settingsController.SetClockFace (2 );
5756
@@ -62,15 +61,13 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
6261 displayedChar[4 ] = 0 ;
6362
6463 /* Create a 200px wide background rectangle */
65-
6664 timebar = lv_obj_create (lv_scr_act (), nullptr );
6765 lv_obj_set_style_local_bg_color (timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x000000 ));
6866 lv_obj_set_style_local_radius (timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0 );
6967 lv_obj_set_size (timebar, 200 , 240 );
7068 lv_obj_align (timebar, lv_scr_act (), LV_ALIGN_IN_TOP_LEFT, 5 , 0 );
7169
7270 /* Display the time */
73-
7471 timeDD1 = lv_label_create (lv_scr_act (), nullptr );
7572 lv_obj_set_style_local_text_font (timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
7673 lv_obj_set_style_local_text_color (timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x008080 ));
@@ -90,15 +87,13 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
9087 lv_obj_align (timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2 , -20 );
9188
9289 /* Create a 40px wide bar down the right side of the screen */
93-
9490 sidebar = lv_obj_create (lv_scr_act (), nullptr );
9591 lv_obj_set_style_local_bg_color (sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x008080 ));
9692 lv_obj_set_style_local_radius (sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0 );
9793 lv_obj_set_size (sidebar, 40 , 240 );
9894 lv_obj_align (sidebar, lv_scr_act (), LV_ALIGN_IN_TOP_RIGHT, 0 , 0 );
9995
10096 /* Display icons */
101-
10297 batteryIcon = lv_label_create (lv_scr_act (), nullptr );
10398 lv_obj_set_style_local_text_color (batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x000000 ));
10499 lv_label_set_text (batteryIcon, Symbols::batteryFull);
@@ -117,7 +112,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
117112 lv_obj_align (notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0 , 40 );
118113
119114 /* Calendar icon */
120-
121115 calendarOuter = lv_obj_create (lv_scr_act (), nullptr );
122116 lv_obj_set_style_local_bg_color (calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x000000 ));
123117 lv_obj_set_style_local_radius (calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0 );
@@ -155,7 +149,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
155149 lv_obj_align (calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0 , 0 );
156150
157151 /* Display date */
158-
159152 dateDayOfWeek = lv_label_create (lv_scr_act (), nullptr );
160153 lv_obj_set_style_local_text_color (dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x000000 ));
161154 lv_label_set_text (dateDayOfWeek, " THU" );
@@ -223,36 +216,27 @@ bool PineTimeStyle::Refresh() {
223216
224217 bleState = bleController.IsConnected ();
225218 if (bleState.IsUpdated ()) {
226- if (bleState.Get () == true ) {
227- lv_label_set_text (bleIcon, BleIcon::GetIcon (true ));
228- lv_obj_realign (bleIcon);
229- } else {
230- lv_label_set_text (bleIcon, BleIcon::GetIcon (false ));
231- }
219+ lv_label_set_text (bleIcon, BleIcon::GetIcon (bleState.Get ()));
220+ lv_obj_realign (bleIcon);
232221 }
233222
234223 notificationState = notificatioManager.AreNewNotificationsAvailable ();
235224 if (notificationState.IsUpdated ()) {
236- if (notificationState.Get () == true ) {
237- lv_label_set_text (notificationIcon, NotificationIcon::GetIcon (true ));
238- lv_obj_realign (notificationIcon);
239- } else {
240- lv_label_set_text (notificationIcon, NotificationIcon::GetIcon (false ));
241- }
225+ lv_label_set_text (notificationIcon, NotificationIcon::GetIcon (notificationState.Get ()));
226+ lv_obj_realign (notificationIcon);
242227 }
243228
244229 currentDateTime = dateTimeController.CurrentDateTime ();
245-
246230 if (currentDateTime.IsUpdated ()) {
247231 auto newDateTime = currentDateTime.Get ();
248232
249233 auto dp = date::floor<date::days>(newDateTime);
250234 auto time = date::make_time (newDateTime - dp);
251235 auto yearMonthDay = date::year_month_day (dp);
252236
253- auto year = ( int ) yearMonthDay.year ();
254- auto month = static_cast <Pinetime::Controllers::DateTime::Months>(( unsigned ) yearMonthDay.month ());
255- auto day = ( unsigned ) yearMonthDay.day ();
237+ auto year = static_cast < int >( yearMonthDay.year () );
238+ auto month = static_cast <Pinetime::Controllers::DateTime::Months>(static_cast < unsigned >( yearMonthDay.month () ));
239+ auto day = static_cast < unsigned >( yearMonthDay.day () );
256240 auto dayOfWeek = static_cast <Pinetime::Controllers::DateTime::Days>(date::weekday (yearMonthDay).iso_encoding ());
257241
258242 int hour = time.hours ().count ();
@@ -263,9 +247,8 @@ bool PineTimeStyle::Refresh() {
263247
264248 char hoursChar[3 ];
265249 char ampmChar[5 ];
266-
267250 if (settingsController.GetClockType () == Controllers::Settings::ClockType::H24) {
268- sprintf (hoursChar, " %02d" , hour);
251+ sprintf (hoursChar, " %02d" , hour);
269252 } else {
270253 if (hour == 0 && hour != 12 ) {
271254 hour = 12 ;
@@ -282,41 +265,26 @@ bool PineTimeStyle::Refresh() {
282265 sprintf (hoursChar, " %02d" , hour);
283266 }
284267
285- if (hoursChar[0 ] != displayedChar[0 ] || hoursChar[1 ] != displayedChar[1 ] || minutesChar[0 ] != displayedChar[2 ] ||
268+ if (hoursChar[0 ] != displayedChar[0 ] or hoursChar[1 ] != displayedChar[1 ] or minutesChar[0 ] != displayedChar[2 ] or
286269 minutesChar[1 ] != displayedChar[3 ]) {
287270 displayedChar[0 ] = hoursChar[0 ];
288271 displayedChar[1 ] = hoursChar[1 ];
289272 displayedChar[2 ] = minutesChar[0 ];
290273 displayedChar[3 ] = minutesChar[1 ];
291274
292- char hourStr[3 ];
293- char minStr[3 ];
294-
295275 if (settingsController.GetClockType () == Controllers::Settings::ClockType::H12) {
296276 lv_label_set_text (timeAMPM, ampmChar);
297277 }
298278
299- /* Display the time as 2 pairs of digits */
300- sprintf (hourStr, " %c%c" , hoursChar[0 ], hoursChar[1 ]);
301- lv_label_set_text (timeDD1, hourStr);
302-
303- sprintf (minStr, " %c%c" , minutesChar[0 ], minutesChar[1 ]);
304- lv_label_set_text (timeDD2, minStr);
279+ lv_label_set_text_fmt (timeDD1, " %s" , hoursChar);
280+ lv_label_set_text_fmt (timeDD2, " %s" , minutesChar);
305281 }
306282
307283 if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
308- char dayOfWeekStr[4 ];
309- char dayStr[3 ];
310- char monthStr[4 ];
311-
312- sprintf (dayOfWeekStr, " %s" , dateTimeController.DayOfWeekShortToString ());
313- sprintf (dayStr, " %d" , day);
314- sprintf (monthStr, " %s" , dateTimeController.MonthShortToString ());
315-
316- lv_label_set_text (dateDayOfWeek, dayOfWeekStr);
317- lv_label_set_text (dateDay, dayStr);
284+ lv_label_set_text_fmt (dateDayOfWeek, " %s" , dateTimeController.DayOfWeekShortToString ());
285+ lv_label_set_text_fmt (dateDay, " %d" , day);
318286 lv_obj_realign (dateDay);
319- lv_label_set_text (dateMonth, monthStr );
287+ lv_label_set_text_fmt (dateMonth, " %s " , dateTimeController. MonthShortToString () );
320288
321289 currentYear = year;
322290 currentMonth = month;
0 commit comments