Skip to content

Instantly share code, notes, and snippets.

@CelliesProjects
Last active September 17, 2023 17:11
Show Gist options
  • Save CelliesProjects/fa5cfd22433455e38fe3ae0ff8897bba to your computer and use it in GitHub Desktop.
Save CelliesProjects/fa5cfd22433455e38fe3ae0ff8897bba to your computer and use it in GitHub Desktop.
LovyanGFX working on TTGO-TM-ESP32
#include <Arduino.h>
// #define LGFX_USE_V1
#include <LovyanGFX.hpp>
// This is the hardware:
// https://github.com/LilyGO/TTGO-TM-ESP32
// LGFX for TTGO T-Display
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ST7789 _panel_instance;
lgfx::Bus_SPI _bus_instance;
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.spi_host = VSPI_HOST;
cfg.spi_mode = 0;
cfg.freq_write = 40000000;
cfg.freq_read = 14000000;
cfg.spi_3wire = true;
cfg.use_lock = true;
cfg.dma_channel = 1;
cfg.pin_sclk = 18;
cfg.pin_mosi = 23;
cfg.pin_miso = -1;
cfg.pin_dc = 16;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.pin_cs = 5;
cfg.pin_rst = 17;
cfg.pin_busy = -1;
cfg.panel_width = 240;
cfg.panel_height = 320;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 0;
cfg.dummy_read_pixel = 16;
cfg.dummy_read_bits = 1;
cfg.readable = true;
cfg.invert = true;
cfg.rgb_order = false;
cfg.dlen_16bit = false;
cfg.bus_shared = true;
_panel_instance.config(cfg);
}
setPanel(&_panel_instance);
}
};
LGFX lcd;
void setup(void)
{
lcd.init();
lcd.print("hello T-Display !");
}
void loop(void)
{
delay(100);
}
@CelliesProjects
Copy link
Author

CelliesProjects commented Sep 17, 2023

This board: https://github.com/LilyGO/TTGO-TM-ESP32
This board has no backlight controls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment