diff --git a/main/ui/apps/iotdis/ui/main_handler.cpp b/main/ui/apps/iotdis/ui/main_handler.cpp index 073d897..08a14ba 100644 --- a/main/ui/apps/iotdis/ui/main_handler.cpp +++ b/main/ui/apps/iotdis/ui/main_handler.cpp @@ -109,13 +109,21 @@ void MainUIHandler::on_status_update_(StatusUpdateEventData data) { ESP_LOGI(TAG, "on_status_update_ called with state: %d", data.state); // Update state in thread-safe manner + bool update_ui = false; if (state_mutex_ && xSemaphoreTake(state_mutex_, pdMS_TO_TICKS(100)) == pdTRUE) { + if (data.state != current_state_) { + update_ui = true; + } current_state_ = data.state; xSemaphoreGive(state_mutex_); ESP_LOGI(TAG, "State updated in mutex"); } // Update UI + if (!update_ui) { + ESP_LOGI(TAG, "State unchanged, skipping UI update"); + return; + } ESP_LOGI(TAG, "Calling update_ui_()"); update_ui_(); ESP_LOGI(TAG, "on_status_update_ complete"); @@ -127,6 +135,7 @@ void MainUIHandler::update_ui_() { if (main_ui_) { StatusUpdateEventData::VoiceState state; if (state_mutex_ && xSemaphoreTake(state_mutex_, pdMS_TO_TICKS(100)) == pdTRUE) { + state = current_state_; xSemaphoreGive(state_mutex_); } else {