Driver improvements (#226)

- Created driver subprojects: `FT5x06`, `FT6x36`, `CST816S`.
- Refactored existing projects to use new drivers.
- Improve `PwmBacklight` driver: expose frequency, channel id and timer id
- Update `build-and-release-all.sh` for recent board addition
This commit is contained in:
Ken Van Hoeylandt
2025-02-20 22:41:56 +01:00
committed by GitHub
parent 6e8fbae62b
commit 933bc5fb97
49 changed files with 429 additions and 413 deletions
@@ -6,7 +6,7 @@
#include <Tactility/hal/Configuration.h>
#define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (CROWPANEL_LCD_BITS_PER_PIXEL / 8))
#define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8))
using namespace tt::hal;
@@ -1,16 +1,28 @@
#include "CrowPanelDisplay.h"
#include "CrowPanelDisplayConstants.h"
#include "CrowPanelTouch.h"
#include <St7789Display.h>
#include <Ft5x06Touch.h>
#include <PwmBacklight.h>
#include <Tactility/Log.h>
#include <St7789Display.h>
#define TAG "crowpanel_display"
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 48 and interrupt pin is 47
auto configuration = std::make_unique<Ft5x06Touch::Configuration>(
I2C_NUM_0,
240,
320,
true,
true,
false
);
return std::make_shared<Ft5x06Touch>(std::move(configuration));
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = std::make_shared<CrowPanelTouch>();
auto touch = createTouch();
auto configuration = std::make_unique<St7789Display::Configuration>(
CROWPANEL_LCD_SPI_HOST,
@@ -5,13 +5,4 @@
#define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 240
#define CROWPANEL_LCD_BITS_PER_PIXEL 16
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
// Backlight (PWM)
#define CROWPANEL_LCD_BACKLIGHT_LEDC_TIMER LEDC_TIMER_0
#define CROWPANEL_LCD_BACKLIGHT_LEDC_MODE LEDC_LOW_SPEED_MODE
#define CROWPANEL_LCD_BACKLIGHT_LEDC_CHANNEL LEDC_CHANNEL_0
#define CROWPANEL_LCD_BACKLIGHT_LEDC_DUTY_RES LEDC_TIMER_8_BIT
#define CROWPANEL_LCD_BACKLIGHT_LEDC_FREQUENCY (4000)
@@ -1,84 +0,0 @@
#include "CrowPanelTouch.h"
#include "esp_lcd_touch_ft5x06.h"
#include <Tactility/Log.h>
#include <esp_err.h>
#include <esp_lvgl_port.h>
#define TAG "crowpanel_touch"
#define CROWPANEL_TOUCH_I2C_BUS_HANDLE I2C_NUM_0
#define CROWPANEL_TOUCH_X_MAX 240
#define CROWPANEL_TOUCH_Y_MAX 320
bool CrowPanelTouch::start(lv_display_t* display) {
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG();
if (esp_lcd_new_panel_io_i2c(CROWPANEL_TOUCH_I2C_BUS_HANDLE, &io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "touch io i2c creation failed");
return false;
}
esp_lcd_touch_config_t config = {
.x_max = CROWPANEL_TOUCH_X_MAX,
.y_max = CROWPANEL_TOUCH_Y_MAX,
.rst_gpio_num = GPIO_NUM_NC, // GPIO_NUM_48,
.int_gpio_num = GPIO_NUM_NC, // GPIO_NUM_47,
.levels = {
.reset = 0,
.interrupt = 0,
},
.flags = {
.swap_xy = 1,
.mirror_x = 1,
.mirror_y = 0,
},
.process_coordinates = nullptr,
.interrupt_callback = nullptr,
.user_data = nullptr,
.driver_data = nullptr
};
if (esp_lcd_touch_new_i2c_ft5x06(ioHandle, &config, &touchHandle) != ESP_OK) {
TT_LOG_E(TAG, "GT911 driver init failed");
cleanup();
return false;
}
const lvgl_port_touch_cfg_t touch_cfg = {
.disp = display,
.handle = touchHandle,
};
TT_LOG_I(TAG, "Adding touch to LVGL");
deviceHandle = lvgl_port_add_touch(&touch_cfg);
if (deviceHandle == nullptr) {
TT_LOG_E(TAG, "Adding touch failed");
cleanup();
return false;
}
return true;
}
bool CrowPanelTouch::stop() {
cleanup();
return true;
}
void CrowPanelTouch::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;
}
}
@@ -1,25 +0,0 @@
#pragma once
#include "Tactility/hal/touch/TouchDevice.h"
#include <Tactility/TactilityCore.h>
#include <esp_lcd_panel_io_interface.h>
#include <esp_lcd_touch.h>
class CrowPanelTouch : public tt::hal::touch::TouchDevice {
private:
std::string getName() const final { return "GT911"; }
std::string getDescription() const final { return "I2C Touch Driver"; }
esp_lcd_panel_io_handle_t _Nullable ioHandle = nullptr;
esp_lcd_touch_handle_t _Nullable touchHandle = nullptr;
lv_indev_t* _Nullable deviceHandle = nullptr;
void cleanup();
public:
bool start(lv_display_t* display) override;
bool stop() override;
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
};