Extra init for 240x240 ST7789 displays
@@ -27,6 +27,7 @@ namespace pimoroni {
enum reg {
SWRESET = 0x01,
+ TEOFF = 0x34,
TEON = 0x35,
MADCTL = 0x36,
COLMOD = 0x3A,
@@ -95,9 +96,23 @@ namespace pimoroni {
sleep_ms(150);
- command(reg::TEON, 1, "\x00"); // enable frame sync signal if used
+ command(reg::TEON); // enable frame sync signal if used
command(reg::COLMOD, 1, "\x05"); // 16 bits per pixel
+ if(width == 240 && height == 240) {
+ command(reg::FRMCTR2, 5, "\x0c\x0c\x00\x33\x33");
+ command(reg::GCTRL, 1, "\x14");
+ command(reg::VCOMS, 1, "\x37");
+ command(reg::LCMCTRL, 1, "\x2c");
+ command(reg::VDVVRHEN, 1, "\x01");
+ command(reg::VRHS, 1, "\x12");
+ command(reg::VDVS, 1, "\x20");
+ command(0xd0, 2, "\xa4\xa1");
+ command(reg::FRMCTR2, 1, "\x0f");
+ command(reg::GMCTRP1, 14, "\xD0\x04\x0D\x11\x13\x2B\x3F\x54\x4C\x18\x0D\x0B\x1F\x23");
+ command(reg::GMCTRN1, 14, "\xD0\x04\x0C\x11\x13\x2C\x3F\x44\x51\x2F\x1F\x1F\x20\x23");
+ }
+
command(reg::INVON); // set inversion mode
command(reg::SLPOUT); // leave sleep mode
command(reg::DISPON); // turn display on
@@ -202,7 +217,7 @@ namespace pimoroni {
}
void ST7789::update(bool dont_block) {
- ST7789::command(reg::RAMWR, width * height * sizeof(uint16_t), (const char*)frame_buffer);
+ command(reg::RAMWR, width * height * sizeof(uint16_t), (const char*)frame_buffer);
/*if(dma_channel_is_busy(dma_channel) && dont_block) {
return;
