Updated boards & drivers

This commit is contained in:
Ken Van Hoeylandt 2025-08-15 21:35:27 +02:00
parent 0279568c68
commit 08b6e709d5
19 changed files with 118 additions and 190 deletions

View File

@ -9,7 +9,7 @@ dependencies:
espressif/esp_io_expander: "1.0.1" espressif/esp_io_expander: "1.0.1"
espressif/esp_io_expander_tca95xx_16bit: "1.0.1" espressif/esp_io_expander_tca95xx_16bit: "1.0.1"
espressif/esp_lcd_st7701: espressif/esp_lcd_st7701:
version: "1.1.1" version: "1.1.3"
rules: rules:
- if: "target in [esp32s3, esp32p4]" - if: "target in [esp32s3, esp32p4]"
espressif/esp_lcd_st7796: espressif/esp_lcd_st7796:

View File

@ -32,5 +32,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
configuration->mirrorX = true; configuration->mirrorX = true;
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili934xDisplay>(std::move(configuration)); auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }

View File

@ -14,7 +14,7 @@ bool initBoot() {
// This display has a weird glitch with gamma during boot, which results in uneven dark gray colours. // This display has a weird glitch with gamma during boot, which results in uneven dark gray colours.
// Setting gamma curve index to 0 doesn't work at boot for an unknown reason, so we set the curve index to 1: // Setting gamma curve index to 0 doesn't work at boot for an unknown reason, so we set the curve index to 1:
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootInitLvglEnd, [](auto event) { tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](auto) {
auto display = tt::hal::findFirstDevice<tt::hal::display::DisplayDevice>(tt::hal::Device::Type::Display); auto display = tt::hal::findFirstDevice<tt::hal::display::DisplayDevice>(tt::hal::Device::Type::Display);
assert(display != nullptr); assert(display != nullptr);
tt::lvgl::lock(portMAX_DELAY); tt::lvgl::lock(portMAX_DELAY);

View File

@ -35,5 +35,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili934xDisplay>(std::move(configuration)); auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }

View File

@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register( idf_component_register(
SRCS ${SOURCE_FILES} SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source" INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port esp_lcd esp_lcd_st7701 esp_lcd_panel_io_additions GT911 PwmBacklight driver vfs fatfs REQUIRES Tactility EspLcdCompat esp_lcd_st7701 esp_lcd_panel_io_additions GT911 PwmBacklight driver vfs fatfs
) )

View File

@ -1,19 +1,17 @@
#include "CydDisplay.h" #include "CydDisplay.h"
#include "PwmBacklight.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <Tactility/Log.h> #include <Tactility/Log.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <esp_err.h> #include <esp_err.h>
#include <esp_lcd_panel_rgb.h> #include <esp_lcd_panel_rgb.h>
#include <esp_lcd_panel_ops.h> #include <esp_lcd_panel_ops.h>
#include <esp_lcd_panel_io.h>
#include <esp_lcd_panel_io_additions.h> #include <esp_lcd_panel_io_additions.h>
#include <esp_lcd_st7701.h> #include <esp_lcd_st7701.h>
#include <esp_lvgl_port.h>
#define TAG "cyd_display" constexpr auto TAG = "ST7701";
static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = { static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = {
// {cmd, { data }, data_size, delay_ms} // {cmd, { data }, data_size, delay_ms}
@ -58,9 +56,7 @@ static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = {
{0x29, (uint8_t[]) {0x00}, 0, 0}, //Display On {0x29, (uint8_t[]) {0x00}, 0, 0}, //Display On
}; };
bool CydDisplay::start() { bool CydDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
TT_LOG_I(TAG, "Starting");
spi_line_config_t line_config = { spi_line_config_t line_config = {
.cs_io_type = IO_TYPE_GPIO, .cs_io_type = IO_TYPE_GPIO,
.cs_gpio_num = GPIO_NUM_39, .cs_gpio_num = GPIO_NUM_39,
@ -68,11 +64,13 @@ bool CydDisplay::start() {
.scl_gpio_num = GPIO_NUM_48, .scl_gpio_num = GPIO_NUM_48,
.sda_io_type = IO_TYPE_GPIO, .sda_io_type = IO_TYPE_GPIO,
.sda_gpio_num = GPIO_NUM_47, .sda_gpio_num = GPIO_NUM_47,
.io_expander = NULL, .io_expander = nullptr,
}; };
esp_lcd_panel_io_3wire_spi_config_t panel_io_config = ST7701_PANEL_IO_3WIRE_SPI_CONFIG(line_config, 0); esp_lcd_panel_io_3wire_spi_config_t panel_io_config = ST7701_PANEL_IO_3WIRE_SPI_CONFIG(line_config, 0);
ESP_ERROR_CHECK(esp_lcd_new_panel_io_3wire_spi(&panel_io_config, &ioHandle)); return esp_lcd_new_panel_io_3wire_spi(&panel_io_config, &outHandle) == ESP_OK;
}
bool CydDisplay::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) {
const esp_lcd_rgb_panel_config_t rgb_config = { const esp_lcd_rgb_panel_config_t rgb_config = {
.clk_src = LCD_CLK_SRC_DEFAULT, .clk_src = LCD_CLK_SRC_DEFAULT,
.timings = { .timings = {
@ -179,7 +177,11 @@ bool CydDisplay::start() {
TT_LOG_E(TAG, "Failed to turn display on"); TT_LOG_E(TAG, "Failed to turn display on");
} }
const lvgl_port_display_cfg_t disp_cfg = { return true;
}
lvgl_port_display_cfg_t CydDisplay::getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return {
.io_handle = ioHandle, .io_handle = ioHandle,
.panel_handle = panelHandle, .panel_handle = panelHandle,
.control_handle = nullptr, .control_handle = nullptr,
@ -204,44 +206,29 @@ bool CydDisplay::start() {
.direct_mode = false .direct_mode = false
} }
}; };
}
const lvgl_port_display_rgb_cfg_t rgb_cfg = { lvgl_port_display_rgb_cfg_t CydDisplay::getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return {
.flags = { .flags = {
.bb_mode = true, .bb_mode = true,
.avoid_tearing = false .avoid_tearing = false
} }
}; };
displayHandle = lvgl_port_add_disp_rgb(&disp_cfg, &rgb_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
} }
bool CydDisplay::stop() { std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable CydDisplay::getTouchDevice() {
assert(displayHandle != nullptr); if (touchDevice == nullptr) {
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
480,
480
);
lvgl_port_remove_disp(displayHandle); touchDevice = std::make_shared<Gt911Touch>(std::move(configuration));
if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
return false;
} }
if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) { return touchDevice;
return false;
}
displayHandle = nullptr;
return true;
}
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable CydDisplay::createTouch() {
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
480,
480
);
return std::make_shared<Gt911Touch>(std::move(configuration));
} }
void CydDisplay::setBacklightDuty(uint8_t backlightDuty) { void CydDisplay::setBacklightDuty(uint8_t backlightDuty) {
@ -249,5 +236,6 @@ void CydDisplay::setBacklightDuty(uint8_t backlightDuty) {
} }
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
return std::make_shared<CydDisplay>(); auto display = std::make_shared<CydDisplay>();
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }

View File

@ -1,32 +1,33 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h" #include <EspLcdDisplay.h>
#include <esp_lcd_types.h>
#include <lvgl.h> #include <lvgl.h>
class CydDisplay : public tt::hal::display::DisplayDevice { class CydDisplay final : public EspLcdDisplay {
private: std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable touchDevice;
esp_lcd_panel_io_handle_t ioHandle = nullptr; bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle) override;
esp_lcd_panel_handle_t panelHandle = nullptr;
lv_display_t* displayHandle = nullptr; bool createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) override;
lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) override;
bool isRgbPanel() const override { return true; }
lvgl_port_display_rgb_cfg_t getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) override;
public: public:
std::string getName() const final { return "ST7701S"; } std::string getName() const override { return "ST7701S"; }
std::string getDescription() const final { return "RGB Display"; }
bool start() override; std::string getDescription() const override { return "ST7701S RGB display"; }
bool stop() override; std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable getTouchDevice() override;
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() override;
void setBacklightDuty(uint8_t backlightDuty) override; void setBacklightDuty(uint8_t backlightDuty) override;
bool supportsBacklightDuty() const override { return true; }
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; } bool supportsBacklightDuty() const override { return true; }
}; };
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,5 +1,5 @@
idf_component_register( idf_component_register(
SRC_DIRS "Source" SRC_DIRS "Source"
INCLUDE_DIRS "Source" INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port esp_lcd_touch esp_lcd_touch_cst816s driver REQUIRES Tactility EspLcdCompat esp_lcd_touch_cst816s driver
) )

View File

@ -1,9 +1,8 @@
#pragma once #pragma once
#include <Tactility/hal/touch/TouchDevice.h> #include <EspLcdTouch.h>
#include <esp_lcd_touch.h>
class Cst816sTouch final : public tt::hal::touch::TouchDevice { class Cst816sTouch final : public EspLcdTouch {
public: public:
@ -54,16 +53,18 @@ private:
void cleanup(); void cleanup();
bool createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) override;
bool createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& configuration, esp_lcd_touch_handle_t& touchHandle) override;
esp_lcd_touch_config_t createEspLcdTouchConfig() override;
public: public:
explicit Cst816sTouch(std::unique_ptr<Configuration> inConfiguration) : configuration(std::move(inConfiguration)) { explicit Cst816sTouch(std::unique_ptr<Configuration> inConfiguration) : configuration(std::move(inConfiguration)) {
assert(configuration != nullptr); assert(configuration != nullptr);
} }
std::string getName() const final { return "CST816S"; } std::string getName() const override { return "CST816S"; }
std::string getDescription() const final { return "I2C touch driver"; } std::string getDescription() const override { return "CST816S I2C touch driver"; }
bool start(lv_display_t* display) override;
bool stop() override;
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
}; };

View File

@ -1,25 +1,18 @@
#include "Cst816Touch.h" #include "Cst816Touch.h"
#include <Tactility/Log.h>
#include <driver/i2c.h>
#include <esp_err.h>
#include <esp_lcd_touch.h>
#include <esp_lcd_touch_cst816s.h> #include <esp_lcd_touch_cst816s.h>
#include <esp_lvgl_port.h>
#define TAG "cst816s" bool Cst816sTouch::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
constexpr esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
return esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)configuration->port, &touch_io_config, &ioHandle) == ESP_OK;
}
bool Cst816sTouch::start(lv_display_t* display) { bool Cst816sTouch::createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& touchConfiguration, esp_lcd_touch_handle_t& touchHandle) {
TT_LOG_I(TAG, "Starting"); return esp_lcd_touch_new_i2c_cst816s(ioHandle, &touchConfiguration, &touchHandle) == ESP_OK;
const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG(); }
if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)configuration->port, &touch_io_config, &ioHandle) != ESP_OK) { esp_lcd_touch_config_t Cst816sTouch::createEspLcdTouchConfig() {
TT_LOG_E(TAG, "Touch I2C IO init failed"); return {
return false;
}
esp_lcd_touch_config_t config = {
.x_max = configuration->xMax, .x_max = configuration->xMax,
.y_max = configuration->yMax, .y_max = configuration->yMax,
.rst_gpio_num = configuration->pinReset, .rst_gpio_num = configuration->pinReset,
@ -38,47 +31,4 @@ bool Cst816sTouch::start(lv_display_t* display) {
.user_data = nullptr, .user_data = nullptr,
.driver_data = nullptr .driver_data = nullptr
}; };
if (esp_lcd_touch_new_i2c_cst816s(ioHandle, &config, &touchHandle) != ESP_OK) {
TT_LOG_E(TAG, "Driver init failed");
cleanup();
return false;
}
const lvgl_port_touch_cfg_t touch_cfg = {
.disp = display,
.handle = touchHandle,
};
deviceHandle = lvgl_port_add_touch(&touch_cfg);
if (deviceHandle == nullptr) {
TT_LOG_E(TAG, "Adding touch failed");
cleanup();
return false;
}
TT_LOG_I(TAG, "Finished");
return true;
}
bool Cst816sTouch::stop() {
cleanup();
return true;
}
void Cst816sTouch::cleanup() {
if (deviceHandle != nullptr) {
lv_indev_delete(deviceHandle);
deviceHandle = nullptr;
}
if (touchHandle != nullptr) {
esp_lcd_touch_del(touchHandle);
touchHandle = nullptr;
}
if (ioHandle != nullptr) {
esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr;
}
} }

View File

@ -7,7 +7,7 @@
#include <Tactility/LogEsp.h> #include <Tactility/LogEsp.h>
#include <Tactility/hal/touch/TouchDevice.h> #include <Tactility/hal/touch/TouchDevice.h>
constexpr char* TAG = "EspLcdDisplay"; constexpr const char* TAG = "EspLcdDisplay";
EspLcdDisplay::~EspLcdDisplay() { EspLcdDisplay::~EspLcdDisplay() {
if (nativeDisplay != nullptr && nativeDisplay.use_count() > 1) { if (nativeDisplay != nullptr && nativeDisplay.use_count() > 1) {
@ -59,7 +59,13 @@ bool EspLcdDisplay::startLvgl() {
} }
lvglPortDisplayConfig = getLvglPortDisplayConfig(ioHandle, panelHandle); lvglPortDisplayConfig = getLvglPortDisplayConfig(ioHandle, panelHandle);
lvglDisplay = lvgl_port_add_disp(&lvglPortDisplayConfig);
if (isRgbPanel()) {
auto rgb_config = getLvglPortDisplayRgbConfig(ioHandle, panelHandle);
lvglDisplay = lvgl_port_add_disp_rgb(&lvglPortDisplayConfig, &rgb_config);
} else {
lvglDisplay = lvgl_port_add_disp(&lvglPortDisplayConfig);
}
auto touch_device = getTouchDevice(); auto touch_device = getTouchDevice();
if (touch_device != nullptr) { if (touch_device != nullptr) {

View File

@ -4,6 +4,7 @@
#include <esp_lcd_types.h> #include <esp_lcd_types.h>
#include <esp_lvgl_port_disp.h> #include <esp_lvgl_port_disp.h>
#include <Tactility/Check.h>
#include <Tactility/hal/display/NativeDisplay.h> #include <Tactility/hal/display/NativeDisplay.h>
class EspLcdDisplay : tt::hal::display::DisplayDevice { class EspLcdDisplay : tt::hal::display::DisplayDevice {
@ -25,6 +26,10 @@ protected:
virtual lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) = 0; virtual lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) = 0;
virtual bool isRgbPanel() const { return false; }
virtual lvgl_port_display_rgb_cfg_t getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) { tt_crash("Not supported"); }
public: public:
~EspLcdDisplay() override; ~EspLcdDisplay() override;

View File

@ -2,7 +2,7 @@
#include <Tactility/LogEsp.h> #include <Tactility/LogEsp.h>
constexpr char* TAG = "EspLcdNativeTouch"; constexpr const char* TAG = "EspLcdNativeTouch";
bool EspLcdNativeTouch::getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* _Nullable strength, uint8_t* pointCount, uint8_t maxPointCount) { bool EspLcdNativeTouch::getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* _Nullable strength, uint8_t* pointCount, uint8_t maxPointCount) {
if (esp_lcd_touch_read_data(handle) != ESP_OK) { if (esp_lcd_touch_read_data(handle) != ESP_OK) {

View File

@ -4,7 +4,7 @@
#include <esp_lvgl_port_touch.h> #include <esp_lvgl_port_touch.h>
#include <Tactility/LogEsp.h> #include <Tactility/LogEsp.h>
constexpr char* TAG = "EspLcdTouch"; constexpr const char* TAG = "EspLcdTouch";
bool EspLcdTouch::start() { bool EspLcdTouch::start() {
if (!createIoHandle(ioHandle) != ESP_OK) { if (!createIoHandle(ioHandle) != ESP_OK) {

View File

@ -5,7 +5,6 @@
#include <esp_lcd_touch_gt911.h> #include <esp_lcd_touch_gt911.h>
#include <esp_err.h> #include <esp_err.h>
#include <esp_lvgl_port.h>
#define TAG "GT911" #define TAG "GT911"

View File

@ -1,5 +1,5 @@
idf_component_register( idf_component_register(
SRC_DIRS "Source" SRC_DIRS "Source"
INCLUDE_DIRS "Source" INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port esp_lcd esp_lcd_ili9341 driver REQUIRES Tactility EspLcdCompat esp_lcd_ili9341 driver
) )

View File

@ -6,11 +6,9 @@
#include <esp_lcd_panel_commands.h> #include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h> #include <esp_lvgl_port.h>
#define TAG "ili934x" constexpr const char* TAG = "ILI934x";
bool Ili934xDisplay::start() {
TT_LOG_I(TAG, "Starting");
bool Ili934xDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
const esp_lcd_panel_io_spi_config_t panel_io_config = { const esp_lcd_panel_io_spi_config_t panel_io_config = {
.cs_gpio_num = configuration->csPin, .cs_gpio_num = configuration->csPin,
.dc_gpio_num = configuration->dcPin, .dc_gpio_num = configuration->dcPin,
@ -35,11 +33,10 @@ bool Ili934xDisplay::start() {
} }
}; };
if (esp_lcd_new_panel_io_spi(configuration->spiBusHandle, &panel_io_config, &ioHandle) != ESP_OK) { return esp_lcd_new_panel_io_spi(configuration->spiBusHandle, &panel_io_config, &outHandle) == ESP_OK;
TT_LOG_E(TAG, "Failed to create panel"); }
return false;
}
bool Ili934xDisplay::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) {
const esp_lcd_panel_dev_config_t panel_config = { const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = configuration->resetPin, .reset_gpio_num = configuration->resetPin,
.rgb_ele_order = configuration->rgbElementOrder, .rgb_ele_order = configuration->rgbElementOrder,
@ -86,18 +83,15 @@ bool Ili934xDisplay::start() {
return false; return false;
} }
uint32_t buffer_size; return true;
if (configuration->bufferSize == 0) { }
buffer_size = configuration->horizontalResolution * configuration->verticalResolution / 10;
} else {
buffer_size = configuration->bufferSize;
}
const lvgl_port_display_cfg_t disp_cfg = { lvgl_port_display_cfg_t Ili934xDisplay::getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return {
.io_handle = ioHandle, .io_handle = ioHandle,
.panel_handle = panelHandle, .panel_handle = panelHandle,
.control_handle = nullptr, .control_handle = nullptr,
.buffer_size = buffer_size, .buffer_size = configuration->bufferSize,
.double_buffer = false, .double_buffer = false,
.trans_size = 0, .trans_size = 0,
.hres = configuration->horizontalResolution, .hres = configuration->horizontalResolution,
@ -118,28 +112,6 @@ bool Ili934xDisplay::start() {
.direct_mode = false .direct_mode = false
} }
}; };
displayHandle = lvgl_port_add_disp(&disp_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
}
bool Ili934xDisplay::stop() {
assert(displayHandle != nullptr);
lvgl_port_remove_disp(displayHandle);
if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
return false;
}
if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
return false;
}
displayHandle = nullptr;
return true;
} }
/** /**
@ -174,7 +146,7 @@ void Ili934xDisplay::setGammaCurve(uint8_t index) {
gamma_curve gamma_curve
}; };
if (esp_lcd_panel_io_tx_param(ioHandle , LCD_CMD_GAMSET, param, 1) != ESP_OK) { if (esp_lcd_panel_io_tx_param(getIoHandle() , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma"); TT_LOG_E(TAG, "Failed to set gamma");
} }
} }

View File

@ -9,7 +9,9 @@
#include <functional> #include <functional>
#include <lvgl.h> #include <lvgl.h>
class Ili934xDisplay final : public tt::hal::display::DisplayDevice { #include <EspLcdDisplay.h>
class Ili934xDisplay final : public EspLcdDisplay {
public: public:
@ -41,8 +43,12 @@ public:
invertColor(invertColor), invertColor(invertColor),
bufferSize(bufferSize), bufferSize(bufferSize),
rgbElementOrder(rgbElementOrder), rgbElementOrder(rgbElementOrder),
touch(std::move(touch)) touch(std::move(touch)
{} ) {
if (this->bufferSize == 0) {
this->bufferSize = horizontalResolution * verticalResolution / 10;
}
}
esp_lcd_spi_bus_handle_t spiBusHandle; esp_lcd_spi_bus_handle_t spiBusHandle;
gpio_num_t csPin; gpio_num_t csPin;
@ -65,9 +71,12 @@ public:
private: private:
std::unique_ptr<Configuration> configuration; std::unique_ptr<Configuration> configuration;
esp_lcd_panel_io_handle_t ioHandle = nullptr;
esp_lcd_panel_handle_t panelHandle = nullptr; bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle);
lv_display_t* displayHandle = nullptr;
bool createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle);
lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle);
public: public:
@ -75,25 +84,21 @@ public:
assert(configuration != nullptr); assert(configuration != nullptr);
} }
std::string getName() const final { return "ILI934x"; } std::string getName() const override { return "ILI934x"; }
std::string getDescription() const final { return "ILI934x display"; }
bool start() final; std::string getDescription() const override { return "ILI934x display"; }
bool stop() final; std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable getTouchDevice() override { return configuration->touch; }
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() final { return configuration->touch; } void setBacklightDuty(uint8_t backlightDuty) override {
void setBacklightDuty(uint8_t backlightDuty) final {
if (configuration->backlightDutyFunction != nullptr) { if (configuration->backlightDutyFunction != nullptr) {
configuration->backlightDutyFunction(backlightDuty); configuration->backlightDutyFunction(backlightDuty);
} }
} }
bool supportsBacklightDuty() const final { return configuration->backlightDutyFunction != nullptr; } bool supportsBacklightDuty() const override { return configuration->backlightDutyFunction != nullptr; }
void setGammaCurve(uint8_t index) final; void setGammaCurve(uint8_t index) override;
uint8_t getGammaCurveCount() const final { return 4; };
lv_display_t* _Nullable getLvglDisplay() const final { return displayHandle; } uint8_t getGammaCurveCount() const override { return 4; };
}; };

View File

@ -92,7 +92,6 @@ bool St7789Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
return false; return false;
} }
TT_LOG_I(TAG, "Finished");
return true; return true;
} }