fix: 快速旋转 EC11 时,有概率界面卡死或崩溃。

This commit is contained in:
Ivan Li 2023-05-10 21:31:18 +08:00
parent 3bdd8d70c3
commit 7c9c016aef

View File

@ -84,6 +84,7 @@ static lv_obj_t *desktop_label;
static lv_anim_t desktop_animate; static lv_anim_t desktop_animate;
value_setting_panel_t *value_setting_panel = NULL; value_setting_panel_t *value_setting_panel = NULL;
static bool panel_locked = false;
static lv_obj_t *scr; static lv_obj_t *scr;
@ -237,10 +238,11 @@ static void gui_close_value_setting_panel() {
} }
static void gui_check_value_setting_panel_task(void *pvParameters) { static void gui_check_value_setting_panel_task(void *pvParameters) {
vTaskDelay(5000 / portTICK_PERIOD_MS); vTaskDelay(GUI_PANEL_TIMEOUT_US / 1000 / portTICK_PERIOD_MS);
for (;;) { for (;;) {
if (esp_timer_get_time() - value_setting_panel->last_updated_at > if (!panel_locked &&
GUI_PANEL_TIMEOUT_US) { esp_timer_get_time() - value_setting_panel->last_updated_at >
GUI_PANEL_TIMEOUT_US) {
gui_close_value_setting_panel(); gui_close_value_setting_panel();
vTaskDelete(NULL); vTaskDelete(NULL);
} }
@ -296,26 +298,32 @@ static void gui_create_value_setting_panel() {
} }
static void gui_change_strip_level(int32_t target_value) { static void gui_change_strip_level(int32_t target_value) {
panel_locked = true;
gui_create_value_setting_panel(); gui_create_value_setting_panel();
lv_label_set_text(value_setting_panel->label, "Strip Level"); lv_label_set_text(value_setting_panel->label, "Strip Level");
lv_bar_set_range(value_setting_panel->bar, 0, 255); lv_bar_set_range(value_setting_panel->bar, 0, 255);
lv_bar_set_value(value_setting_panel->bar, target_value, LV_ANIM_ON); lv_bar_set_value(value_setting_panel->bar, target_value, LV_ANIM_ON);
panel_locked = false;
} }
static void gui_change_display_brightness(int8_t display_index, static void gui_change_display_brightness(int8_t display_index,
int32_t target_value) { int32_t target_value) {
panel_locked = true;
gui_create_value_setting_panel(); gui_create_value_setting_panel();
lv_label_set_text_fmt(value_setting_panel->label, "Display#%d Brightness", lv_label_set_text_fmt(value_setting_panel->label, "Display#%d Brightness",
display_index); display_index);
lv_bar_set_range(value_setting_panel->bar, 0, 100); lv_bar_set_range(value_setting_panel->bar, 0, 100);
lv_bar_set_value(value_setting_panel->bar, target_value, LV_ANIM_ON); lv_bar_set_value(value_setting_panel->bar, target_value, LV_ANIM_ON);
panel_locked = false;
} }
static void gui_change_volume_level(int32_t target_value) { static void gui_change_volume_level(int32_t target_value) {
panel_locked = true;
gui_create_value_setting_panel(); gui_create_value_setting_panel();
lv_label_set_text(value_setting_panel->label, "Volume Level"); lv_label_set_text(value_setting_panel->label, "Volume Level");
lv_bar_set_range(value_setting_panel->bar, 0, 100); lv_bar_set_range(value_setting_panel->bar, 0, 100);
lv_bar_set_value(value_setting_panel->bar, target_value, LV_ANIM_ON); lv_bar_set_value(value_setting_panel->bar, target_value, LV_ANIM_ON);
panel_locked = false;
} }
void gui_status_bar_create(lv_obj_t *scr) { void gui_status_bar_create(lv_obj_t *scr) {