From fa22cce8ddaba0fe03f6d90b579b51d0390c4f67 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Mon, 11 Sep 2023 23:35:37 +0300 Subject: [PATCH] audio: hide lbl_ln3 and lbl_ln4 before calling endpoint Hiding labels after calling the endpoint could result in them being hidden after the endpoint unhid them. This currently seems to happen for both the openHAB and the REST endpoint. Adding some logging confirms the label is hid in the audio code just a few milliseconds after unhiding in the endpoint code. We don't see this with Home Assistant as we're using a recent Home Assistant version where the endpoint code sets up a WebSocket. The additional JSON constructing and parsing in the Home Assistant WebSocket code causes enough delay to not see the issue there. (cherry picked from commit c18aa98a2b0ead138dd093aeb817765db7cc519f) --- main/audio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main/audio.c b/main/audio.c index 0070e69b..5c555f98 100644 --- a/main/audio.c +++ b/main/audio.c @@ -448,6 +448,11 @@ static esp_err_t hdl_ev_hs(http_stream_event_msg_t *msg) } buf[read_len] = 0; ESP_LOGI(TAG, "WIS HTTP Response = %s", (char *)buf); + if (lvgl_port_lock(lvgl_lock_timeout)) { + lv_obj_add_flag(lbl_ln3, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(lbl_ln4, LV_OBJ_FLAG_HIDDEN); + lvgl_port_unlock(); + } char *command_endpoint = config_get_char("command_endpoint", DEFAULT_COMMAND_ENDPOINT); if (strcmp(command_endpoint, "Home Assistant") == 0) { hass_send(buf); @@ -465,8 +470,6 @@ static esp_err_t hdl_ev_hs(http_stream_event_msg_t *msg) if (lvgl_port_lock(lvgl_lock_timeout)) { lv_obj_clear_flag(lbl_ln1, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(lbl_ln2, LV_OBJ_FLAG_HIDDEN); - lv_obj_add_flag(lbl_ln3, LV_OBJ_FLAG_HIDDEN); - lv_obj_add_flag(lbl_ln4, LV_OBJ_FLAG_HIDDEN); if (cJSON_IsString(speaker_status) && speaker_status->valuestring != NULL) { lv_label_set_text(lbl_ln1, speaker_status->valuestring); } else {