@@ -15,11 +15,6 @@ namespace {
1515 }
1616 }
1717
18- void lv_update_task (struct _lv_task_t * task) {
19- auto * user_data = static_cast <QuickSettings*>(task->user_data );
20- user_data->UpdateScreen ();
21- }
22-
2318 enum class ButtonState : lv_state_t {
2419 NotificationsOn = LV_STATE_CHECKED ,
2520 NotificationsOff = LV_STATE_DEFAULT ,
@@ -119,21 +114,23 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
119114 lv_obj_set_style_local_text_font (lbl_btn, LV_LABEL_PART_MAIN , LV_STATE_DEFAULT , &lv_font_sys_48);
120115 lv_label_set_text_static (lbl_btn, Symbols::settings);
121116
122- taskUpdate = lv_task_create (lv_update_task, 5000 , LV_TASK_PRIO_MID , this );
123-
124- UpdateScreen ();
117+ Refresh ();
118+ taskRefresh = lv_task_create (RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD , LV_TASK_PRIO_MID , this );
125119}
126120
127121QuickSettings::~QuickSettings () {
128122 lv_style_reset (&btn_style);
129- lv_task_del (taskUpdate );
123+ lv_task_del (taskRefresh );
130124 lv_obj_clean (lv_scr_act ());
131125 settingsController.SaveSettings ();
132126}
133127
134- void QuickSettings::UpdateScreen () {
135- lv_label_set_text (label_time, dateTimeController.FormattedTime ().c_str ());
128+ void QuickSettings::Refresh () {
136129 statusIcons.Update ();
130+ currentDateTime = std::chrono::time_point_cast<std::chrono::minutes>(dateTimeController.CurrentDateTime ());
131+ if (currentDateTime.IsUpdated ()) {
132+ lv_label_set_text (label_time, dateTimeController.FormattedTime ().c_str ());
133+ }
137134}
138135
139136void QuickSettings::OnButtonEvent (lv_obj_t * object) {
0 commit comments