Skip to content
Open
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
126 changes: 126 additions & 0 deletions include/graphics/LGFX/LGFX_T_WATCH_ULTRA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#pragma once

Check failure on line 1 in include/graphics/LGFX/LGFX_T_WATCH_ULTRA.h

View workflow job for this annotation

GitHub Actions / Trunk Check

clang-format

Incorrect formatting, autoformat by running 'trunk fmt'

#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <TouchDrvCSTXXX.hpp>

#ifndef SPI_FREQUENCY
#define SPI_FREQUENCY 75000000
#endif

#define TOUCH_INT 12

class LGFX_Touch : public lgfx::LGFX_Device
{
public:
bool init_impl(bool use_reset, bool use_clear) override
{
bool result = LGFX_Device::init_impl(use_reset, use_clear);
lgfx::pinMode(TOUCH_INT, lgfx::pin_mode_t::input_pullup);
touchDrv.setPins(-1, TOUCH_INT);
result |= touchDrv.begin(Wire, 0x1A, 3, 2);
if (!result) {
ILOG_ERROR("Failed to initialise touch panel!");
}
return result;
}

LGFX_Touch *touch(void) { return this; }

int8_t getTouchInt(void) { return TOUCH_INT; }

// unfortunately not declared as virtual in base class, need to choose a different name
bool getTouchXY(uint16_t *touchX, uint16_t *touchY)
{
return touchDrv.isPressed() && touchDrv.getPoint((int16_t *)touchX, (int16_t *)touchY, 1);
}

void wakeup(void) {} // TODO: use EXPANDS_TOUCH_RST
void sleep(void)
{
/* touchDrv.sleep(); */
}

private:
TouchDrvCST92xx touchDrv;
};

class LGFX_TWATCH_ULTRA : public LGFX_Touch
{
lgfx::Panel_CO5300 _panel_instance;
lgfx::Bus_SPI _bus_instance;

public:
const uint32_t screenWidth = 410;
const uint32_t screenHeight = 502;

bool hasButton(void) { return true; }
lgfx::ILight* light(void) { // only used by 'bool hasLight()' to check if ptr is valid
static lgfx::Light_PWM _light_instance;
return &_light_instance;
}

LGFX_TWATCH_ULTRA(void)
{
{
auto cfg = _bus_instance.config();

// configure SPI
cfg.spi_host = SPI2_HOST; // ESP32-S2,S3,C3 : SPI2_HOST or SPI3_HOST / ESP32 : VSPI_HOST or HSPI_HOST
cfg.spi_mode = SPI_MODE0;
cfg.freq_write = SPI_FREQUENCY; // SPI clock for transmission (up to 80MHz, rounded to the value obtained by dividing
// 80MHz by an integer)
cfg.freq_read = 16000000; // SPI clock when receiving
cfg.spi_3wire = false; // Set to true if reception is done on the MOSI pin
cfg.use_lock = false; // Set to true to use transaction locking
cfg.dma_channel = SPI_DMA_CH_AUTO; // SPI_DMA_CH_AUTO; // Set DMA channel to use (0=not use DMA / 1=1ch / 2=ch /
// SPI_DMA_CH_AUTO=auto setting)
cfg.pin_sclk = 40; // Set SPI SCLK pin number
cfg.pin_io0 = 38;
cfg.pin_io1 = 39;
cfg.pin_io2 = 42;
cfg.pin_io3 = 45;

_bus_instance.config(cfg); // applies the set value to the bus.
_panel_instance.setBus(&_bus_instance); // set the bus on the panel.
}

{ // Set the display panel control.
auto cfg = _panel_instance.config(); // Gets a structure for display panel settings.

cfg.pin_cs = 41; // Pin number where CS is connected (-1 = disable)
cfg.pin_rst = 37; // Pin number where RST is connected (-1 = disable)
cfg.panel_width = screenWidth; // actual displayable width
cfg.panel_height = screenHeight; // actual displayable height
cfg.offset_x = 22;
cfg.offset_y = 0;
cfg.offset_rotation = 0; // Rotation direction value offset 0~7 (4~7 is upside down)
cfg.dummy_read_pixel = 8; // Number of bits for dummy read before pixel readout
cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read
cfg.readable = true; // Set to true if data can be read
cfg.invert = false; // Set to true if the light/darkness of the panel is reversed
cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped
cfg.dlen_16bit = false; // Set to true for panels that transmit data length in 16-bit units
cfg.bus_shared = false; // If the bus is shared with the SD card, set to true (bus control with drawJpgFile etc.)

// Set the following only when the display is shifted with a driver with a variable number of pixels
cfg.memory_width = screenWidth; // Maximum width supported by the driver IC
cfg.memory_height = screenHeight; // Maximum height supported by the driver IC
_panel_instance.config(cfg);
}

setPanel(&_panel_instance);
}

bool init()
{
ILOG_DEBUG("LGFX_Panel_CO5300::init()");
lgfx::pinMode(37, lgfx::pin_mode_t::output);
lgfx::gpio_hi(37);
delay(200);
lgfx::gpio_lo(37);
delay(300);
lgfx::gpio_hi(37);
return lgfx::LGFX_Device::init();
}
};
2 changes: 2 additions & 0 deletions include/graphics/driver/DisplayDriverConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ class DisplayDriverConfig
INDICATOR,
BPICOMPUTER_S3,
TWATCH_S3,
TWATCH_ULTRA,
UNPHONE_V9,
ELECROW_ADV,
HELTEC_TRACKER,
VISION_MASTER_T190,
WT32_SC01_PLUS,
ESP2432S028RV1,
ESP2432S028RV2,
Expand Down
14 changes: 14 additions & 0 deletions source/graphics/driver/DisplayDriverFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
#ifdef T_WATCH_S3
#include "graphics/LGFX/LGFX_T_WATCH_S3.h"
#endif
#ifdef T_WATCH_ULTRA
#include "graphics/LGFX/LGFX_T_WATCH_ULTRA.h"
#endif
#ifdef UNPHONE
#include "graphics/LGFX/LGFX_UNPHONE.h"
#endif
Expand All @@ -66,6 +69,9 @@
#ifdef HELTEC_TRACKER
#include "graphics/LGFX/LGFX_HELTEC_TRACKER.h"
#endif
#ifdef HELTEC_VISION_MASTER_T190
#include "graphics/LGFX/LGFX_VISION_MASTER_T190.h"
#endif
#ifdef NODEMCU_32S
#include "graphics/LGFX/LGFX_ESPILI9341XPT2046.h"
#endif
Expand Down Expand Up @@ -153,6 +159,10 @@ DisplayDriver *DisplayDriverFactory::create(const DisplayDriverConfig &cfg)
case DisplayDriverConfig::device_t::TWATCH_S3:
return new LGFXDriver<LGFX_TWATCH_S3>(cfg.width(), cfg.height());
break;
#elif defined(TWATCH_ULTRA)
case DisplayDriverConfig::device_t::TWATCH_ULTRA:
return new LGFXDriver<LGFX_TWATCH_ULTRA>(cfg.width(), cfg.height());
break;
#elif defined(UNPHONE)
case DisplayDriverConfig::device_t::UNPHONE_V9:
return new LGFXDriver<LGFX_UNPHONE_V9>(cfg.width(), cfg.height());
Expand All @@ -165,6 +175,10 @@ DisplayDriver *DisplayDriverFactory::create(const DisplayDriverConfig &cfg)
case DisplayDriverConfig::device_t::HELTEC_TRACKER:
// return new LGFXDriver<LGFX_HELTEC_TRACKER>(cfg.width(), cfg.height());
break;
#elif defined(HELTEC_VISION_MASTER_T190)
case DisplayDriverConfig::device_t::VISION_MASTER_T190:
return new LGFXDriver<LGFX_VISION_MASTER_T190>(cfg.width(), cfg.height());
break;
#elif defined(WT_SC01_PLUS)
case DisplayDriverConfig::device_t::WT32_SC01_PLUS:
return new LGFXDriver<LGFX_WT_SC01_PLUS>(cfg.width(), cfg.height());
Expand Down
4 changes: 2 additions & 2 deletions source/input/I2CKeyboardScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ I2CKeyboardInputDriver *I2CKeyboardScanner::scan(void)
#elif defined(T_DECK_PRO)
driver = new TDeckProKeyboardInputDriver(address);
#else
driver = new TCA8418KeyboardInputDriver(address);
// TODO: driver = new TCA8418KeyboardInputDriver(address);
#endif
break;
case SCAN_CARDKB_ADDR:
Expand All @@ -45,7 +45,7 @@ I2CKeyboardInputDriver *I2CKeyboardScanner::scan(void)
driver = new BBQ10KeyboardInputDriver(address);
break;
case SCAN_MPR121_KB_ADDR:
driver = new MPR121KeyboardInputDriver(address);
// TODO: driver = new MPR121KeyboardInputDriver(address);
break;
default:
break;
Expand Down
Loading