@@ -74,6 +74,13 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
7474 lv_label_set_text_static (colonLabel, " :" );
7575 lv_obj_align (colonLabel, lv_scr_act (), LV_ALIGN_CENTER, 0 , -29 );
7676
77+ progressStop = lv_bar_create (lv_scr_act (), nullptr );
78+ lv_bar_set_range (progressStop, 0 , 240 );
79+ lv_bar_set_value (progressStop, 0 , LV_ANIM_OFF);
80+ lv_obj_set_size (progressStop, 240 , 10 );
81+ lv_obj_align (progressStop, nullptr , LV_ALIGN_IN_TOP_MID, 0 , 0 );
82+ lv_obj_set_style_local_bg_color (progressStop, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
83+
7784 btnStop = lv_btn_create (lv_scr_act (), nullptr );
7885 btnStop->user_data = this ;
7986 lv_obj_set_event_cb (btnStop, btnEventHandler);
@@ -122,12 +129,27 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
122129 } else {
123130 SetSwitchState (LV_ANIM_OFF);
124131 }
132+
133+ taskRefresh = lv_task_create (RefreshTaskCallback, 50 , LV_TASK_PRIO_MID, this );
134+ }
135+
136+ void Alarm::Refresh () {
137+ if (stopBtnPressing && xTaskGetTickCount () > stopBtnPressTime + pdMS_TO_TICKS (150 )) {
138+ stopPosition += 15 ;
139+ if (stopPosition > 240 ) {
140+ ResetStopProgress ();
141+ StopAlerting ();
142+ } else {
143+ UpdateStopProgress ();
144+ }
145+ }
125146}
126147
127148Alarm::~Alarm () {
128149 if (alarmController.IsAlerting ()) {
129150 StopAlerting ();
130151 }
152+ lv_task_del (taskRefresh);
131153 lv_obj_clean (lv_scr_act ());
132154 alarmController.SaveAlarm ();
133155}
@@ -139,12 +161,31 @@ void Alarm::DisableAlarm() {
139161 }
140162}
141163
164+ void Alarm::StopButtonPressed () {
165+ stopBtnPressTime = xTaskGetTickCount ();
166+ stopBtnPressing = true ;
167+ }
168+
169+ void Alarm::ResetStopProgress () {
170+ stopBtnPressing = false ;
171+ stopPosition = 0 ;
172+ UpdateStopProgress ();
173+ }
174+
175+ void Alarm::UpdateStopProgress () {
176+ lv_bar_set_value (progressStop, stopPosition, LV_ANIM_OFF);
177+ }
178+
142179void Alarm::OnButtonEvent (lv_obj_t * obj, lv_event_t event) {
143- if (event == LV_EVENT_CLICKED) {
144- if (obj == btnStop) {
145- StopAlerting ();
146- return ;
180+ if (obj == btnStop) {
181+ if (event == LV_EVENT_PRESSED) {
182+ StopButtonPressed ();
183+ } else if (event == LV_EVENT_RELEASED || event == LV_EVENT_PRESS_LOST) {
184+ ResetStopProgress ();
147185 }
186+ return ;
187+ }
188+ if (event == LV_EVENT_CLICKED) {
148189 if (obj == btnInfo) {
149190 ShowInfo ();
150191 return ;
0 commit comments