mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
Updated boards & drivers
This commit is contained in:
parent
0279568c68
commit
08b6e709d5
@ -9,7 +9,7 @@ dependencies:
|
||||
espressif/esp_io_expander: "1.0.1"
|
||||
espressif/esp_io_expander_tca95xx_16bit: "1.0.1"
|
||||
espressif/esp_lcd_st7701:
|
||||
version: "1.1.1"
|
||||
version: "1.1.3"
|
||||
rules:
|
||||
- if: "target in [esp32s3, esp32p4]"
|
||||
espressif/esp_lcd_st7796:
|
||||
|
||||
@ -32,5 +32,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
configuration->mirrorX = true;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ bool initBoot() {
|
||||
|
||||
// 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:
|
||||
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);
|
||||
assert(display != nullptr);
|
||||
tt::lvgl::lock(portMAX_DELAY);
|
||||
|
||||
@ -35,5 +35,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
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
|
||||
)
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
#include "CydDisplay.h"
|
||||
#include "PwmBacklight.h"
|
||||
|
||||
#include <Gt911Touch.h>
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_lcd_panel_rgb.h>
|
||||
#include <esp_lcd_panel_ops.h>
|
||||
#include <esp_lcd_panel_io.h>
|
||||
#include <esp_lcd_panel_io_additions.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[] = {
|
||||
// {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
|
||||
};
|
||||
|
||||
bool CydDisplay::start() {
|
||||
TT_LOG_I(TAG, "Starting");
|
||||
|
||||
bool CydDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||
spi_line_config_t line_config = {
|
||||
.cs_io_type = IO_TYPE_GPIO,
|
||||
.cs_gpio_num = GPIO_NUM_39,
|
||||
@ -68,11 +64,13 @@ bool CydDisplay::start() {
|
||||
.scl_gpio_num = GPIO_NUM_48,
|
||||
.sda_io_type = IO_TYPE_GPIO,
|
||||
.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_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 = {
|
||||
.clk_src = LCD_CLK_SRC_DEFAULT,
|
||||
.timings = {
|
||||
@ -179,7 +177,11 @@ bool CydDisplay::start() {
|
||||
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,
|
||||
.panel_handle = panelHandle,
|
||||
.control_handle = nullptr,
|
||||
@ -204,44 +206,29 @@ bool CydDisplay::start() {
|
||||
.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 = {
|
||||
.bb_mode = true,
|
||||
.avoid_tearing = false
|
||||
}
|
||||
};
|
||||
|
||||
displayHandle = lvgl_port_add_disp_rgb(&disp_cfg, &rgb_cfg);
|
||||
TT_LOG_I(TAG, "Finished");
|
||||
return displayHandle != nullptr;
|
||||
}
|
||||
|
||||
bool CydDisplay::stop() {
|
||||
assert(displayHandle != nullptr);
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable CydDisplay::getTouchDevice() {
|
||||
if (touchDevice == nullptr) {
|
||||
auto configuration = std::make_unique<Gt911Touch::Configuration>(
|
||||
I2C_NUM_0,
|
||||
480,
|
||||
480
|
||||
);
|
||||
|
||||
lvgl_port_remove_disp(displayHandle);
|
||||
|
||||
if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
|
||||
return false;
|
||||
touchDevice = std::make_shared<Gt911Touch>(std::move(configuration));
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
|
||||
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));
|
||||
return touchDevice;
|
||||
}
|
||||
|
||||
void CydDisplay::setBacklightDuty(uint8_t backlightDuty) {
|
||||
@ -249,5 +236,6 @@ void CydDisplay::setBacklightDuty(uint8_t backlightDuty) {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1,32 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <esp_lcd_types.h>
|
||||
#include <EspLcdDisplay.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;
|
||||
esp_lcd_panel_handle_t panelHandle = nullptr;
|
||||
lv_display_t* displayHandle = nullptr;
|
||||
bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle) override;
|
||||
|
||||
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:
|
||||
|
||||
std::string getName() const final { return "ST7701S"; }
|
||||
std::string getDescription() const final { return "RGB Display"; }
|
||||
std::string getName() const override { return "ST7701S"; }
|
||||
|
||||
bool start() override;
|
||||
std::string getDescription() const override { return "ST7701S RGB display"; }
|
||||
|
||||
bool stop() override;
|
||||
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() override;
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable getTouchDevice() 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();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
idf_component_register(
|
||||
SRC_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
|
||||
)
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/touch/TouchDevice.h>
|
||||
#include <esp_lcd_touch.h>
|
||||
#include <EspLcdTouch.h>
|
||||
|
||||
class Cst816sTouch final : public tt::hal::touch::TouchDevice {
|
||||
class Cst816sTouch final : public EspLcdTouch {
|
||||
|
||||
public:
|
||||
|
||||
@ -54,16 +53,18 @@ private:
|
||||
|
||||
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:
|
||||
|
||||
explicit Cst816sTouch(std::unique_ptr<Configuration> inConfiguration) : configuration(std::move(inConfiguration)) {
|
||||
assert(configuration != nullptr);
|
||||
}
|
||||
|
||||
std::string getName() const final { return "CST816S"; }
|
||||
std::string getDescription() const final { return "I2C touch driver"; }
|
||||
|
||||
bool start(lv_display_t* display) override;
|
||||
bool stop() override;
|
||||
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
|
||||
std::string getName() const override { return "CST816S"; }
|
||||
std::string getDescription() const override { return "CST816S I2C touch driver"; }
|
||||
};
|
||||
|
||||
@ -1,25 +1,18 @@
|
||||
#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_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) {
|
||||
TT_LOG_I(TAG, "Starting");
|
||||
const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
|
||||
bool Cst816sTouch::createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& touchConfiguration, esp_lcd_touch_handle_t& touchHandle) {
|
||||
return esp_lcd_touch_new_i2c_cst816s(ioHandle, &touchConfiguration, &touchHandle) == ESP_OK;
|
||||
}
|
||||
|
||||
if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)configuration->port, &touch_io_config, &ioHandle) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Touch I2C IO init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_lcd_touch_config_t config = {
|
||||
esp_lcd_touch_config_t Cst816sTouch::createEspLcdTouchConfig() {
|
||||
return {
|
||||
.x_max = configuration->xMax,
|
||||
.y_max = configuration->yMax,
|
||||
.rst_gpio_num = configuration->pinReset,
|
||||
@ -38,47 +31,4 @@ bool Cst816sTouch::start(lv_display_t* display) {
|
||||
.user_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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include <Tactility/LogEsp.h>
|
||||
#include <Tactility/hal/touch/TouchDevice.h>
|
||||
|
||||
constexpr char* TAG = "EspLcdDisplay";
|
||||
constexpr const char* TAG = "EspLcdDisplay";
|
||||
|
||||
EspLcdDisplay::~EspLcdDisplay() {
|
||||
if (nativeDisplay != nullptr && nativeDisplay.use_count() > 1) {
|
||||
@ -59,7 +59,13 @@ bool EspLcdDisplay::startLvgl() {
|
||||
}
|
||||
|
||||
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();
|
||||
if (touch_device != nullptr) {
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
#include <esp_lcd_types.h>
|
||||
#include <esp_lvgl_port_disp.h>
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/hal/display/NativeDisplay.h>
|
||||
|
||||
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 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:
|
||||
|
||||
~EspLcdDisplay() override;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#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) {
|
||||
if (esp_lcd_touch_read_data(handle) != ESP_OK) {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <esp_lvgl_port_touch.h>
|
||||
#include <Tactility/LogEsp.h>
|
||||
|
||||
constexpr char* TAG = "EspLcdTouch";
|
||||
constexpr const char* TAG = "EspLcdTouch";
|
||||
|
||||
bool EspLcdTouch::start() {
|
||||
if (!createIoHandle(ioHandle) != ESP_OK) {
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
|
||||
#include <esp_lcd_touch_gt911.h>
|
||||
#include <esp_err.h>
|
||||
#include <esp_lvgl_port.h>
|
||||
|
||||
#define TAG "GT911"
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS "Source"
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility esp_lvgl_port esp_lcd esp_lcd_ili9341 driver
|
||||
REQUIRES Tactility EspLcdCompat esp_lcd_ili9341 driver
|
||||
)
|
||||
|
||||
@ -6,11 +6,9 @@
|
||||
#include <esp_lcd_panel_commands.h>
|
||||
#include <esp_lvgl_port.h>
|
||||
|
||||
#define TAG "ili934x"
|
||||
|
||||
bool Ili934xDisplay::start() {
|
||||
TT_LOG_I(TAG, "Starting");
|
||||
constexpr const char* TAG = "ILI934x";
|
||||
|
||||
bool Ili934xDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||
const esp_lcd_panel_io_spi_config_t panel_io_config = {
|
||||
.cs_gpio_num = configuration->csPin,
|
||||
.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) {
|
||||
TT_LOG_E(TAG, "Failed to create panel");
|
||||
return false;
|
||||
}
|
||||
return esp_lcd_new_panel_io_spi(configuration->spiBusHandle, &panel_io_config, &outHandle) == ESP_OK;
|
||||
}
|
||||
|
||||
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 = {
|
||||
.reset_gpio_num = configuration->resetPin,
|
||||
.rgb_ele_order = configuration->rgbElementOrder,
|
||||
@ -86,18 +83,15 @@ bool Ili934xDisplay::start() {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t buffer_size;
|
||||
if (configuration->bufferSize == 0) {
|
||||
buffer_size = configuration->horizontalResolution * configuration->verticalResolution / 10;
|
||||
} else {
|
||||
buffer_size = configuration->bufferSize;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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,
|
||||
.panel_handle = panelHandle,
|
||||
.control_handle = nullptr,
|
||||
.buffer_size = buffer_size,
|
||||
.buffer_size = configuration->bufferSize,
|
||||
.double_buffer = false,
|
||||
.trans_size = 0,
|
||||
.hres = configuration->horizontalResolution,
|
||||
@ -118,28 +112,6 @@ bool Ili934xDisplay::start() {
|
||||
.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
|
||||
};
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,9 @@
|
||||
#include <functional>
|
||||
#include <lvgl.h>
|
||||
|
||||
class Ili934xDisplay final : public tt::hal::display::DisplayDevice {
|
||||
#include <EspLcdDisplay.h>
|
||||
|
||||
class Ili934xDisplay final : public EspLcdDisplay {
|
||||
|
||||
public:
|
||||
|
||||
@ -41,8 +43,12 @@ public:
|
||||
invertColor(invertColor),
|
||||
bufferSize(bufferSize),
|
||||
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;
|
||||
gpio_num_t csPin;
|
||||
@ -65,9 +71,12 @@ public:
|
||||
private:
|
||||
|
||||
std::unique_ptr<Configuration> configuration;
|
||||
esp_lcd_panel_io_handle_t ioHandle = nullptr;
|
||||
esp_lcd_panel_handle_t panelHandle = nullptr;
|
||||
lv_display_t* displayHandle = nullptr;
|
||||
|
||||
bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle);
|
||||
|
||||
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:
|
||||
|
||||
@ -75,25 +84,21 @@ public:
|
||||
assert(configuration != nullptr);
|
||||
}
|
||||
|
||||
std::string getName() const final { return "ILI934x"; }
|
||||
std::string getDescription() const final { return "ILI934x display"; }
|
||||
std::string getName() const override { return "ILI934x"; }
|
||||
|
||||
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) final {
|
||||
void setBacklightDuty(uint8_t backlightDuty) override {
|
||||
if (configuration->backlightDutyFunction != nullptr) {
|
||||
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;
|
||||
uint8_t getGammaCurveCount() const final { return 4; };
|
||||
void setGammaCurve(uint8_t index) override;
|
||||
|
||||
lv_display_t* _Nullable getLvglDisplay() const final { return displayHandle; }
|
||||
uint8_t getGammaCurveCount() const override { return 4; };
|
||||
};
|
||||
|
||||
@ -92,7 +92,6 @@ bool St7789Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
|
||||
return false;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Finished");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user