From 8e5d7337c8e9490c901cd17f59b72ed300f775b1 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:18:51 +1000 Subject: [PATCH] [st7701s] Fix initialisation race (#7462) --- esphome/components/st7701s/st7701s.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/esphome/components/st7701s/st7701s.cpp b/esphome/components/st7701s/st7701s.cpp index 7248bc044e..403bff789d 100644 --- a/esphome/components/st7701s/st7701s.cpp +++ b/esphome/components/st7701s/st7701s.cpp @@ -9,14 +9,6 @@ void ST7701S::setup() { esph_log_config(TAG, "Setting up ST7701S"); this->spi_setup(); this->write_init_sequence_(); -} - -// called after a delay after writing the init sequence -void ST7701S::complete_setup_() { - this->write_command_(SLEEP_OUT); - this->write_command_(DISPLAY_ON); - this->spi_teardown(); // SPI not needed after this - delay(10); esp_lcd_rgb_panel_config_t config{}; config.flags.fb_in_psram = 1; @@ -179,7 +171,12 @@ void ST7701S::write_init_sequence_() { this->write_data_(val); ESP_LOGD(TAG, "write MADCTL %X", val); this->write_command_(this->invert_colors_ ? INVERT_ON : INVERT_OFF); - this->set_timeout(120, [this] { this->complete_setup_(); }); + // can't avoid this inline delay due to the need to complete setup before anything else tries to draw. + delay(120); // NOLINT + this->write_command_(SLEEP_OUT); + this->write_command_(DISPLAY_ON); + this->spi_teardown(); // SPI not needed after this + delay(10); } void ST7701S::dump_config() {