Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Add panel instruction to version ESP32-4848S040 by GUITION manufactu… #556

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions src/lgfx/v1/platforms/esp32s3/Panel_RGB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,148 @@ namespace lgfx
return true;
}

//----------------------------------------------------------------------------

const uint8_t* Panel_ST7701_guition_esp32_4848S040::getInitCommands(uint8_t listno) const
{
static constexpr const uint8_t list0[] =
{
// Command2 BK0 SEL
0xFF, 5, 0x77, 0x01, 0x00, 0x00, 0x10,

0xC0, 2, 0x3B, 0x00, // added by manufacture
0xC1, 2, 0x0D, 0x02,
0xC2, 2, 0x31, 0x05,
0xCD, 1, 0x00, // changed by manufacture

// Positive Voltage Gamma Control
0xB0, 16, 0x00, 0x11, 0x18, 0x0E, 0x11, 0x06, 0x07, 0x08,
0x07, 0x22, 0x04, 0x12, 0x0F, 0xAA, 0x31, 0x18,

// Negative Voltage Gamma Control
0xB1, 16, 0x00, 0x11, 0x19, 0x0E, 0x12, 0x07, 0x08, 0x08,
0x08, 0x22, 0x04, 0x11, 0x11, 0xA9, 0x32, 0x18,

// Command2 BK1 SEL
0xFF, 5, 0x77, 0x01, 0x00, 0x00, 0x11,

0xB0, 1, 0x60, // Vop=4.7375v
0xB1, 1, 0x32, // VCOM=32
0xB2, 1, 0x07, // VGH=15v
0xB3, 1, 0x80,
0xB5, 1, 0x49, // VGL=-10.17v
0xB7, 1, 0x85,
0xB8, 1, 0x21, // AVDD=6.6 & AVCL=-4.6
0xC1, 1, 0x78,
0xC2, 1, 0x78,

0xE0, 3, 0x00, 0x1B, 0x02,

0xE1, 11, 0x08, 0xA0, 0x00, 0x00, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x44, 0x44,
0xE2, 12, 0x11, 0x11, 0x44, 0x44, 0xED, 0xA0, 0x00, 0x00, 0xEC, 0xA0, 0x00, 0x00,

0xE3, 4, 0x00, 0x00, 0x11, 0x11,
0xE4, 2, 0x44, 0x44,

0xE5, 16, 0x0A, 0xE9, 0xD8, 0xA0, 0x0C, 0xEB, 0xD8, 0xA0,
0x0E, 0xED, 0xD8, 0xA0, 0x10, 0xEF, 0xD8, 0xA0,

0xE6, 4, 0x00, 0x00, 0x11, 0x11,

0xE7, 2, 0x44, 0x44,

0xE8, 16, 0x09, 0xE8, 0xD8, 0xA0, 0x0B, 0xEA, 0xD8, 0xA0,
0x0D, 0xEC, 0xD8, 0xA0, 0x0F, 0xEE, 0xD8, 0xA0,

0xEB, 7, 0x02, 0x00, 0xE4, 0xE4, 0x88, 0x00, 0x40,
0xEC, 2, 0x3C, 0x00,
0xED, 16, 0xAB, 0x89, 0x76, 0x54, 0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x20, 0x45, 0x67, 0x98, 0xBA,

//-----------VAP & VAN---------------
// Command2 BK3 SEL
0xFF, 5, 0x77, 0x01, 0x00, 0x00, 0x13,

0xE5, 1, 0xE4,

// Command2 BK0 SEL
0xFF, 5, 0x77, 0x01, 0x00, 0x00, 0x00,

//0x21, 0, // 0x20 normal, 0x21 IPS // commented by manufacture
0x3A, 1, 0x60, // 0x70 RGB888, 0x60 RGB666, 0x50 RGB565

0x11, CMD_INIT_DELAY, 120, // Sleep Out

0x29, 0, // Display On

0xFF, 0xFF,
};
switch (listno)
{
case 0: return list0;
default: return nullptr;
}
}

bool Panel_ST7701_guition_esp32_4848S040::init(bool use_reset)
{
if (!Panel_RGB::init(use_reset))
{
return false;
}

int32_t pin_mosi = _config_detail.pin_mosi;
int32_t pin_sclk = _config_detail.pin_sclk;
if (pin_mosi >= 0 && pin_sclk >= 0)
{
lgfx::gpio::pin_backup_t backup_pins[] = { (gpio_num_t)pin_mosi, (gpio_num_t)pin_sclk };

lgfx::gpio_lo(pin_mosi);
lgfx::pinMode(pin_mosi, pin_mode_t::output);
lgfx::gpio_lo(pin_sclk);
lgfx::pinMode(pin_sclk, pin_mode_t::output);


int32_t pin_cs = _config_detail.pin_cs;
lgfx::gpio_lo(pin_cs);

writeCommand(0xFF, 1);
writeData(0x77, 1);
writeData(0x01, 1);
writeData(0x00, 2);
writeData(0x10, 1);

// 0xC0 : LNSET : Display Line Setting
writeCommand(0xC0, 1);
uint32_t line1 = (_cfg.panel_height >> 3) + 1;
uint32_t line2 = (_cfg.panel_height >> 1) & 3;
writeData(line1 + (line2 ? 0x80 : 0x00), 1);
writeData(line2, 1);

// 0xC3 : RGBCTRL
auto cfg = ((Bus_RGB*)_bus)->config();
writeCommand(0xC3, 1);
uint32_t rgbctrl = 0;
if ( cfg.de_idle_high ) rgbctrl += 0x01;
if ( cfg.pclk_idle_high) rgbctrl += 0x02;
if (!cfg.hsync_polarity) rgbctrl += 0x04;
if (!cfg.vsync_polarity) rgbctrl += 0x08;
writeData(rgbctrl, 1);
writeData(0x10, 1);
writeData(0x08, 1);

for (uint8_t i = 0; auto cmds = getInitCommands(i); i++)
{
command_list(cmds);
}

lgfx::gpio_hi(pin_cs);
for (auto &bup : backup_pins) { bup.restore(); }
}

return true;
}

//----------------------------------------------------------------------------

const uint8_t* Panel_GC9503::getInitCommands(uint8_t listno) const
Expand Down
6 changes: 6 additions & 0 deletions src/lgfx/v1/platforms/esp32s3/Panel_RGB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ namespace lgfx
const uint8_t* getInitCommands(uint8_t listno) const override;
};

struct Panel_ST7701_guition_esp32_4848S040: public Panel_RGB
{
bool init(bool) override;
protected:
const uint8_t* getInitCommands(uint8_t listno) const override;
};

struct Panel_GC9503 : public Panel_RGB
{
Expand Down