Driver and board updates

This commit is contained in:
Ken Van Hoeylandt 2025-08-15 23:06:56 +02:00
parent db31cd2b1a
commit 41ed700214
9 changed files with 43 additions and 103 deletions

View File

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

View File

@ -1,40 +1,5 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <esp_lcd_types.h>
#include <lvgl.h>
class CrowPanelDisplay : public tt::hal::display::DisplayDevice {
private:
esp_lcd_panel_io_handle_t ioHandle = nullptr;
esp_lcd_panel_handle_t panelHandle = nullptr;
lv_display_t* displayHandle = nullptr;
bool poweredOn = false;
public:
std::string getName() const final { return "ST7789"; }
std::string getDescription() const final { return "SPI display"; }
bool start() override;
bool stop() override;
void setPowerOn(bool turnOn) override;
bool isPoweredOn() const override { return poweredOn; };
bool supportsPowerControl() const override { return true; }
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() override;
void setBacklightDuty(uint8_t backlightDuty) override;
bool supportsBacklightDuty() const override { return true; }
void setGammaCurve(uint8_t index) override;
uint8_t getGammaCurveCount() const override { return 4; };
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
};
#include <Tactility/hal/display/DisplayDevice.h>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -56,7 +56,7 @@ private:
bool createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& configuration, esp_lcd_touch_handle_t& panelHandle) override;
esp_lcd_touch_config_t createEspLcdTouchConfig();
esp_lcd_touch_config_t createEspLcdTouchConfig() override;
public:

View File

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

View File

@ -56,7 +56,7 @@ private:
bool createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& configuration, esp_lcd_touch_handle_t& panelHandle) override;
esp_lcd_touch_config_t createEspLcdTouchConfig();
esp_lcd_touch_config_t createEspLcdTouchConfig() override;
public:

View File

@ -72,11 +72,11 @@ private:
std::unique_ptr<Configuration> configuration;
bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle);
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);
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);
lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) override;
public:

View File

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

View File

@ -6,11 +6,9 @@
#include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h>
#define TAG "ili9488"
bool Ili9488Display::start() {
TT_LOG_I(TAG, "Starting");
#define TAG "ILI9488"
bool Ili9488Display::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,10 +33,10 @@ bool Ili9488Display::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 Ili9488Display::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,
@ -51,14 +49,7 @@ bool Ili9488Display::start() {
.vendor_config = nullptr
};
uint32_t buffer_size;
if (configuration->bufferSize == 0) {
buffer_size = configuration->horizontalResolution * configuration->verticalResolution / 20;
} else {
buffer_size = configuration->bufferSize;
}
if (esp_lcd_new_panel_ili9488(ioHandle, &panel_config, buffer_size, &panelHandle) != ESP_OK) {
if (esp_lcd_new_panel_ili9488(ioHandle, &panel_config, configuration->bufferSize, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
return false;
}
@ -93,11 +84,16 @@ bool Ili9488Display::start() {
return false;
}
const lvgl_port_display_cfg_t disp_cfg = {
return true;
}
lvgl_port_display_cfg_t Ili9488Display::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,26 +114,4 @@ bool Ili9488Display::start() {
.direct_mode = false
}
};
displayHandle = lvgl_port_add_disp(&disp_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
}
bool Ili9488Display::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;
}

View File

@ -2,14 +2,13 @@
#include "Tactility/hal/display/DisplayDevice.h"
#include <driver/spi_common.h>
#include <EspLcdDisplay.h>
#include <driver/gpio.h>
#include <esp_lcd_panel_io.h>
#include <esp_lcd_types.h>
#include <functional>
#include <lvgl.h>
class Ili9488Display final : public tt::hal::display::DisplayDevice {
class Ili9488Display final : public EspLcdDisplay {
public:
@ -39,8 +38,11 @@ public:
mirrorY(mirrorY),
invertColor(invertColor),
bufferSize(bufferSize),
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;
@ -62,9 +64,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) 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;
public:
@ -72,24 +77,19 @@ public:
assert(configuration != nullptr);
}
std::string getName() const final { return "ILI9488"; }
std::string getDescription() const final { return "ILI9488 display"; }
std::string getName() const override { return "ILI9488"; }
bool start() final;
std::string getDescription() const override { return "ILI9488 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; }
lv_display_t* _Nullable getLvglDisplay() const final { return displayHandle; }
bool supportsBacklightDuty() const override { return configuration->backlightDutyFunction != nullptr; }
};
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();