From c424fea5240edfd996fbd2f5d40f7f444c7325c3 Mon Sep 17 00:00:00 2001 From: rforro <38496829+rforro@users.noreply.github.com> Date: Tue, 25 Feb 2025 00:45:45 +0100 Subject: [PATCH] ili9xxx: Add support for GC9D01N circle display (#8302) --- esphome/components/ili9xxx/display.py | 1 + esphome/components/ili9xxx/ili9xxx_display.h | 5 ++ esphome/components/ili9xxx/ili9xxx_init.h | 59 ++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/esphome/components/ili9xxx/display.py b/esphome/components/ili9xxx/display.py index e3abb7e98c..14b7f15218 100644 --- a/esphome/components/ili9xxx/display.py +++ b/esphome/components/ili9xxx/display.py @@ -57,6 +57,7 @@ ColorOrder = display.display_ns.enum("ColorMode") MODELS = { "GC9A01A": ili9xxx_ns.class_("ILI9XXXGC9A01A", ILI9XXXDisplay), + "GC9D01N": ili9xxx_ns.class_("ILI9XXXGC9D01N", ILI9XXXDisplay), "M5STACK": ili9xxx_ns.class_("ILI9XXXM5Stack", ILI9XXXDisplay), "M5CORE": ili9xxx_ns.class_("ILI9XXXM5CORE", ILI9XXXDisplay), "TFT_2.4": ili9xxx_ns.class_("ILI9XXXILI9341", ILI9XXXDisplay), diff --git a/esphome/components/ili9xxx/ili9xxx_display.h b/esphome/components/ili9xxx/ili9xxx_display.h index 87d7c86e5c..0babcedc48 100644 --- a/esphome/components/ili9xxx/ili9xxx_display.h +++ b/esphome/components/ili9xxx/ili9xxx_display.h @@ -272,6 +272,11 @@ class ILI9XXXGC9A01A : public ILI9XXXDisplay { ILI9XXXGC9A01A() : ILI9XXXDisplay(INITCMD_GC9A01A, 240, 240) {} }; +class ILI9XXXGC9D01N : public ILI9XXXDisplay { + public: + ILI9XXXGC9D01N() : ILI9XXXDisplay(INITCMD_GC9D01N, 160, 160) {} +}; + //----------- ILI9XXX_24_TFT display -------------- class ILI9XXXST7735 : public ILI9XXXDisplay { public: diff --git a/esphome/components/ili9xxx/ili9xxx_init.h b/esphome/components/ili9xxx/ili9xxx_init.h index b176680f43..f05b884be6 100644 --- a/esphome/components/ili9xxx/ili9xxx_init.h +++ b/esphome/components/ili9xxx/ili9xxx_init.h @@ -367,6 +367,65 @@ static const uint8_t PROGMEM INITCMD_GC9A01A[] = { 0x00 // End of list }; +static const uint8_t PROGMEM INITCMD_GC9D01N[] = { + // Enable Inter_command + 0xFE, 0, // Inter Register Enable 1 (FEh) + 0xEF, 0, // Inter Register Enable 2 (EFh) + // Inter_command is now enabled + 0x80, 1, 0xFF, + 0x81, 1, 0xFF, + 0x82, 1, 0xFF, + 0x83, 1, 0xFF, + 0x84, 1, 0xFF, + 0x85, 1, 0xFF, + 0x86, 1, 0xFF, + 0x87, 1, 0xFF, + 0x88, 1, 0xFF, + 0x89, 1, 0xFF, + 0x8A, 1, 0xFF, + 0x8B, 1, 0xFF, + 0x8C, 1, 0xFF, + 0x8D, 1, 0xFF, + 0x8E, 1, 0xFF, + 0x8F, 1, 0xFF, + 0X3A, 1, 0x05, // COLMOD: Pixel Format Set (3Ah) MCU interface, 16 bits / pixel + 0xEC, 1, 0x01, // Inversion (ECh) DINV=1+2H1V column for Dual Gate (BFh=0) + // According to datasheet Inversion (ECh) value 0x01 isn't valid, but Lilygo uses it everywhere + 0x74, 7, 0x02, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x98, 1, 0x3e, + 0x99, 1, 0x3e, + 0xB5, 2, 0x0D, 0x0D, // Blanking Porch Control (B5h) VFP=14 VBP=14 HBP=Off + 0x60, 4, 0x38, 0x0F, 0x79, 0x67, + 0x61, 4, 0x38, 0x11, 0x79, 0x67, + 0x64, 6, 0x38, 0x17, 0x71, 0x5F, 0x79, 0x67, + 0x65, 6, 0x38, 0x13, 0x71, 0x5B, 0x79, 0x67, + 0x6A, 2, 0x00, 0x00, + 0x6C, 7, 0x22, 0x02, 0x22, 0x02, 0x22, 0x22, 0x50, + 0x6E, 32, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x0F, 0x0F, + 0x0D, 0x0D, 0x0B, 0x0B, 0x09, 0x09, 0x00, 0x00, + 0x00, 0x00, 0x0A, 0x0A, 0x0C, 0x0C, 0x0E, 0x0E, + 0x10, 0x10, 0x00, 0x00, 0x02, 0x02, 0x04, 0x04, + 0xBF, 1, 0x01, // Dual-Single gate select (BFh) 01h = dual gate mode + 0xF9, 1, 0x40, + 0x9B, 5, 0x3B, 0x93, 0x33, 0x7F, 0x00, + 0x7E, 1, 0x30, + 0x70, 6, 0x0D, 0x02, 0x08, 0x0D, 0x02, 0x08, + 0x71, 3, 0x0D, 0x02, 0x08, + 0x91, 2, 0x0E, 0x09, + // Set VREG1A, VREG1B, VREG2A, VREG2B voltage + // According to datasheet set either 0xC3/0xC4 or 0xC9 only, but Lilygo sets both of them + 0xC3, 5, 0x19, 0xC4, 0x19, 0xC9, 0x3C, + 0xF0, 6, 0x53, 0x15, 0x0A, 0x04, 0x00, 0x3E, // SET_GAMMA1 (F0h) + 0xF1, 6, 0x56, 0xA8, 0x7F, 0x33, 0x34, 0x5F, // SET_GAMMA2 (F1h) + 0xF2, 6, 0x53, 0x15, 0x0A, 0x04, 0x00, 0x3A, // SET_GAMMA3 (F2h) + 0xF3, 6, 0x52, 0xA4, 0x7F, 0x33, 0x34, 0xDF, // SET_GAMMA4 (F3h) + ILI9XXX_SLPOUT, 0, // Sleep Out Mode (11h) + ILI9XXX_DELAY(10), + ILI9XXX_DISPON, 0, // Display ON (29h) + ILI9XXX_DELAY(20), + 0x00 // End of list +}; + static const uint8_t PROGMEM INITCMD_ST7735[] = { ILI9XXX_SWRESET, 0, // Soft reset, then delay 10ms ILI9XXX_DELAY(10),