diff --git a/src/M5GFX.cpp b/src/M5GFX.cpp index 359da14..a37aa7e 100644 --- a/src/M5GFX.cpp +++ b/src/M5GFX.cpp @@ -23,6 +23,7 @@ #include "lgfx/v1/panel/Panel_ST7735.hpp" #include "lgfx/v1/panel/Panel_ST7789.hpp" #include "lgfx/v1/panel/Panel_GC9A01.hpp" +#include "lgfx/v1/panel/Panel_JD9853.hpp" #include "lgfx/v1/panel/Panel_GDEW0154M09.hpp" #include "lgfx/v1/panel/Panel_GDEW0154D67.hpp" #include "lgfx/v1/panel/Panel_IT8951.hpp" @@ -2228,13 +2229,14 @@ namespace m5gfx bus_spi->config(bus_cfg); bus_spi->init(); - auto p = new Panel_ST7789(); + auto p = new Panel_JD9853(); p->bus(bus_spi); { auto cfg = p->config(); cfg.pin_cs = GPIO_NUM_45; cfg.pin_rst = GPIO_NUM_NC; cfg.memory_width = 240; + // Chain Captain uses a 240-line window at y=80 in a 320-line GRAM. cfg.memory_height = 320; cfg.panel_width = 240; cfg.panel_height = 240; @@ -2242,7 +2244,7 @@ namespace m5gfx cfg.offset_y = 0; cfg.offset_rotation = 2; cfg.readable = false; - cfg.invert = true; + cfg.rgb_order = true; cfg.bus_shared = false; p->config(cfg); p->setRotation(0); diff --git a/src/lgfx/v1/panel/Panel_JD9853.hpp b/src/lgfx/v1/panel/Panel_JD9853.hpp new file mode 100644 index 0000000..02ccd09 --- /dev/null +++ b/src/lgfx/v1/panel/Panel_JD9853.hpp @@ -0,0 +1,84 @@ +/*----------------------------------------------------------------------------/ + Lovyan GFX - Graphics library for embedded devices. + +Original Source: + https://github.com/lovyan03/LovyanGFX/ + +Licence: + [FreeBSD](https://github.com/lovyan03/LovyanGFX/blob/master/license.txt) + +Author: + [lovyan03](https://twitter.com/lovyan03) +/----------------------------------------------------------------------------*/ +#pragma once + +#include "Panel_GC9A01.hpp" + +namespace lgfx +{ + inline namespace v1 + { + + // HSD015BPN2-A0 240x240 JD9853 panel used by M5ChainCaptain. + struct Panel_JD9853 : public Panel_GC9xxx + { + Panel_JD9853(void) + { + _cfg.memory_width = 240; + _cfg.panel_width = 240; + _cfg.panel_height = 240; + _cfg.memory_height = _cfg.panel_height; + _cfg.dummy_read_pixel = 16; + } + + protected: + uint8_t getColMod(uint8_t bpp) const override + { + return bpp > 16 ? 0x66 : 0x05; + } + + const uint8_t* getInitCommands(uint8_t listno) const override + { + static constexpr uint8_t list0[] = { + 0x01, 0 + CMD_INIT_DELAY, 20, + 0xDF, 2, 0x98, 0x53, + 0xDE, 1, 0x00, + 0xB2, 1, 0x38, + 0xB7, 4, 0x00, 0x29, 0x00, 0x51, + 0xBB, 6, 0x28, 0x2F, 0x55, 0x73, 0x63, 0xF0, + 0xC0, 2, 0x22, 0xA2, + 0xC1, 1, 0x12, + 0xC3, 8, 0x7D, 0x08, 0x08, 0x0C, 0xC2, 0x72, 0x22, 0x88, + 0xC4, 12, 0x00, 0x00, 0xA0, 0x79, 0x0A, 0x0B, 0x16, 0x79, 0x0A, 0x0B, 0x16, 0x82, + 0xC8, 32, + 0x3F, 0x29, 0x23, 0x20, 0x27, 0x2D, 0x2A, 0x2B, + 0x2A, 0x28, 0x25, 0x17, 0x12, 0x0D, 0x07, 0x02, + 0x3F, 0x29, 0x23, 0x20, 0x27, 0x2D, 0x2A, 0x2B, + 0x2A, 0x28, 0x25, 0x17, 0x12, 0x0D, 0x07, 0x02, + 0xD0, 5, 0x04, 0x04, 0x6A, 0x1C, 0x03, + 0xD7, 2, 0x00, 0x20, + 0xE6, 1, 0x10, + 0xDE, 1, 0x01, + 0xBB, 1, 0x04, + 0xD7, 1, 0x12, + 0xB7, 5, 0x03, 0x13, 0xE5, 0x38, 0x38, + 0xC1, 3, 0x14, 0x15, 0xC0, + 0xC2, 2, 0x06, 0x3A, + 0xC4, 2, 0x72, 0x12, + 0xBE, 1, 0x00, + 0xDE, 1, 0x00, + 0x35, 1, 0x00, + 0x36, 1, 0x00, + 0x3A, 1, 0x05, + 0x2A, 4, 0x00, 0x00, 0x00, 0xEF, + 0x2B, 4, 0x00, 0x00, 0x00, 0xEF, + 0x11, 0 + CMD_INIT_DELAY, 120, + 0x29, 0 + CMD_INIT_DELAY, 10, + 0xFF, 0xFF, + }; + return listno == 0 ? list0 : nullptr; + } + }; + + } +}