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.

Revisions

  1. CelliesProjects revised this gist Sep 17, 2023. 1 changed file with 0 additions and 14 deletions.
    14 changes: 0 additions & 14 deletions TTGO-TM-Lovyan.ino
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,6 @@ class LGFX : public lgfx::LGFX_Device
    {
    lgfx::Panel_ST7789 _panel_instance;
    lgfx::Bus_SPI _bus_instance;
    lgfx::Light_PWM _light_instance;

    public:
    LGFX(void)
    @@ -34,19 +33,7 @@ public:
    _bus_instance.config(cfg);
    _panel_instance.setBus(&_bus_instance);
    }
    /*
    {
    auto cfg = _light_instance.config();
    cfg.pin_bl = 4;
    cfg.invert = false;
    cfg.freq = 44100;
    cfg.pwm_channel = 7;

    _light_instance.config(cfg);
    _panel_instance.setLight(&_light_instance);
    }
    */
    {
    auto cfg = _panel_instance.config();

    @@ -77,7 +64,6 @@ public:
    LGFX lcd;
    void setup(void)
    {
    Serial.begin(115200);
    lcd.init();
    lcd.print("hello T-Display !");
    }
  2. CelliesProjects revised this gist Sep 17, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions TTGO-TM-Lovyan.ino
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ public:
    _bus_instance.config(cfg);
    _panel_instance.setBus(&_bus_instance);
    }

    /*
    {
    auto cfg = _light_instance.config();
    @@ -46,7 +46,7 @@ public:
    _light_instance.config(cfg);
    _panel_instance.setLight(&_light_instance);
    }

    */
    {
    auto cfg = _panel_instance.config();

  3. CelliesProjects created this gist Sep 17, 2023.
    88 changes: 88 additions & 0 deletions TTGO-TM-Lovyan.ino
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,88 @@
    #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;
    lgfx::Light_PWM _light_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 = _light_instance.config();

    cfg.pin_bl = 4;
    cfg.invert = false;
    cfg.freq = 44100;
    cfg.pwm_channel = 7;

    _light_instance.config(cfg);
    _panel_instance.setLight(&_light_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)
    {
    Serial.begin(115200);
    lcd.init();
    lcd.print("hello T-Display !");
    }

    void loop(void)
    {
    delay(100);
    }