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; 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 #pragma once
#include "Tactility/hal/display/DisplayDevice.h" #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; }
};
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); 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; 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: public:

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_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; 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: public:

View File

@ -72,11 +72,11 @@ private:
std::unique_ptr<Configuration> configuration; 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: public:

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_ili9488 driver REQUIRES Tactility EspLcdCompat esp_lcd_ili9488 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 "ili9488" #define TAG "ILI9488"
bool Ili9488Display::start() {
TT_LOG_I(TAG, "Starting");
bool Ili9488Display::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,11 @@ bool Ili9488Display::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 Ili9488Display::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 = LCD_RGB_ELEMENT_ORDER_BGR, .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
@ -51,14 +49,7 @@ bool Ili9488Display::start() {
.vendor_config = nullptr .vendor_config = nullptr
}; };
uint32_t buffer_size; if (esp_lcd_new_panel_ili9488(ioHandle, &panel_config, configuration->bufferSize, &panelHandle) != ESP_OK) {
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) {
TT_LOG_E(TAG, "Failed to create panel"); TT_LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
@ -93,11 +84,16 @@ bool Ili9488Display::start() {
return false; 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, .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,26 +114,4 @@ bool Ili9488Display::start() {
.direct_mode = false .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 "Tactility/hal/display/DisplayDevice.h"
#include <driver/spi_common.h> #include <EspLcdDisplay.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <esp_lcd_panel_io.h>
#include <esp_lcd_types.h>
#include <functional> #include <functional>
#include <lvgl.h> #include <lvgl.h>
class Ili9488Display final : public tt::hal::display::DisplayDevice { class Ili9488Display final : public EspLcdDisplay {
public: public:
@ -39,8 +38,11 @@ public:
mirrorY(mirrorY), mirrorY(mirrorY),
invertColor(invertColor), invertColor(invertColor),
bufferSize(bufferSize), 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; esp_lcd_spi_bus_handle_t spiBusHandle;
gpio_num_t csPin; gpio_num_t csPin;
@ -62,9 +64,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) override;
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;
public: public:
@ -72,24 +77,19 @@ public:
assert(configuration != nullptr); assert(configuration != nullptr);
} }
std::string getName() const final { return "ILI9488"; } std::string getName() const override { return "ILI9488"; }
std::string getDescription() const final { return "ILI9488 display"; }
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) 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; }
lv_display_t* _Nullable getLvglDisplay() const final { return displayHandle; }
}; };
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();