@@ -74,6 +74,13 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
74
74
lv_label_set_text_static (colonLabel, " :" );
75
75
lv_obj_align (colonLabel, lv_scr_act (), LV_ALIGN_CENTER, 0 , -29 );
76
76
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 , 50 );
81
+ lv_obj_align (progressStop, nullptr , LV_ALIGN_CENTER, 0 , 0 );
82
+ lv_obj_set_style_local_bg_color (progressStop, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
83
+
77
84
btnStop = lv_btn_create (lv_scr_act (), nullptr );
78
85
btnStop->user_data = this ;
79
86
lv_obj_set_event_cb (btnStop, btnEventHandler);
@@ -122,12 +129,27 @@ Alarm::Alarm(Controllers::AlarmController& alarmController,
122
129
} else {
123
130
SetSwitchState (LV_ANIM_OFF);
124
131
}
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
+ }
125
146
}
126
147
127
148
Alarm::~Alarm () {
128
149
if (alarmController.IsAlerting ()) {
129
150
StopAlerting ();
130
151
}
152
+ lv_task_del (taskRefresh);
131
153
lv_obj_clean (lv_scr_act ());
132
154
alarmController.SaveAlarm ();
133
155
}
@@ -139,12 +161,31 @@ void Alarm::DisableAlarm() {
139
161
}
140
162
}
141
163
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
+
142
179
void 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 ();
147
185
}
186
+ return ;
187
+ }
188
+ if (event == LV_EVENT_CLICKED) {
148
189
if (obj == btnInfo) {
149
190
ShowInfo ();
150
191
return ;
0 commit comments