From b62c099d54eb24c3dff0e53aa3561b524a9c512b Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Tue, 12 Dec 2023 10:22:41 +1100 Subject: [PATCH] Fix 18 bit displays. (#5908) --- esphome/components/ili9xxx/ili9xxx_display.h | 25 ++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/esphome/components/ili9xxx/ili9xxx_display.h b/esphome/components/ili9xxx/ili9xxx_display.h index db1274450a..bf4889afe1 100644 --- a/esphome/components/ili9xxx/ili9xxx_display.h +++ b/esphome/components/ili9xxx/ili9xxx_display.h @@ -30,13 +30,24 @@ class ILI9XXXDisplay : public display::DisplayBuffer, const uint8_t *addr = init_sequence; while ((cmd = *addr++) != 0) { num_args = *addr++ & 0x7F; - if (cmd == ILI9XXX_MADCTL) { - bits = *addr; - this->swap_xy_ = (bits & MADCTL_MV) != 0; - this->mirror_x_ = (bits & MADCTL_MX) != 0; - this->mirror_y_ = (bits & MADCTL_MY) != 0; - this->color_order_ = (bits & MADCTL_BGR) ? display::COLOR_ORDER_BGR : display::COLOR_ORDER_RGB; - break; + bits = *addr; + switch (cmd) { + case ILI9XXX_MADCTL: { + this->swap_xy_ = (bits & MADCTL_MV) != 0; + this->mirror_x_ = (bits & MADCTL_MX) != 0; + this->mirror_y_ = (bits & MADCTL_MY) != 0; + this->color_order_ = (bits & MADCTL_BGR) ? display::COLOR_ORDER_BGR : display::COLOR_ORDER_RGB; + break; + } + + case ILI9XXX_PIXFMT: { + if ((bits & 0xF) == 6) + this->is_18bitdisplay_ = true; + break; + } + + default: + break; } addr += num_args; }