From 1e66241b2696c80f222dd853db76bd10acb48ac4 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:01:07 +1200 Subject: [PATCH] [ili9xxx] Fix init for GC9A01A (#6913) --- .../components/ili9xxx/ili9xxx_display.cpp | 20 ++++++++++++++++--- esphome/components/ili9xxx/ili9xxx_display.h | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/esphome/components/ili9xxx/ili9xxx_display.cpp b/esphome/components/ili9xxx/ili9xxx_display.cpp index 21d46ea825..de03df5d41 100644 --- a/esphome/components/ili9xxx/ili9xxx_display.cpp +++ b/esphome/components/ili9xxx/ili9xxx_display.cpp @@ -34,8 +34,8 @@ void ILI9XXXDisplay::setup() { ESP_LOGD(TAG, "Setting up ILI9xxx"); this->setup_pins_(); - this->init_lcd_(this->init_sequence_); - this->init_lcd_(this->extra_init_sequence_.data()); + this->init_lcd(this->init_sequence_); + this->init_lcd(this->extra_init_sequence_.data()); switch (this->pixel_mode_) { case PIXEL_MODE_16: if (this->is_18bitdisplay_) { @@ -405,7 +405,7 @@ void ILI9XXXDisplay::reset_() { } } -void ILI9XXXDisplay::init_lcd_(const uint8_t *addr) { +void ILI9XXXDisplay::init_lcd(const uint8_t *addr) { if (addr == nullptr) return; uint8_t cmd, x, num_args; @@ -427,6 +427,20 @@ void ILI9XXXDisplay::init_lcd_(const uint8_t *addr) { } } +void ILI9XXXGC9A01A::init_lcd(const uint8_t *addr) { + if (addr == nullptr) + return; + uint8_t cmd, x, num_args; + while ((cmd = *addr++) != 0) { + x = *addr++; + num_args = x & 0x7F; + this->send_command(cmd, addr, num_args); + addr += num_args; + if (x & 0x80) + delay(150); // NOLINT + } +} + // Tell the display controller where we want to draw pixels. void ILI9XXXDisplay::set_addr_window_(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { x1 += this->offset_x_; diff --git a/esphome/components/ili9xxx/ili9xxx_display.h b/esphome/components/ili9xxx/ili9xxx_display.h index 7a320dac7b..b60047a8c3 100644 --- a/esphome/components/ili9xxx/ili9xxx_display.h +++ b/esphome/components/ili9xxx/ili9xxx_display.h @@ -109,7 +109,7 @@ class ILI9XXXDisplay : public display::DisplayBuffer, virtual void set_madctl(); void display_(); - void init_lcd_(const uint8_t *addr); + virtual void init_lcd(const uint8_t *addr); void set_addr_window_(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2); void reset_(); @@ -269,6 +269,7 @@ class ILI9XXXS3BoxLite : public ILI9XXXDisplay { class ILI9XXXGC9A01A : public ILI9XXXDisplay { public: ILI9XXXGC9A01A() : ILI9XXXDisplay(INITCMD_GC9A01A, 240, 240, true) {} + void init_lcd(const uint8_t *addr) override; }; //----------- ILI9XXX_24_TFT display --------------