mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-20 15:35:05 +00:00
Driver and board updates
This commit is contained in:
parent
1dea7fc87d
commit
db31cd2b1a
@ -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 FT5x06 ST7789 PwmBacklight driver
|
REQUIRES Tactility FT5x06 ST7789 PwmBacklight driver
|
||||||
)
|
)
|
||||||
|
|||||||
@ -5,8 +5,6 @@
|
|||||||
#include <PwmBacklight.h>
|
#include <PwmBacklight.h>
|
||||||
#include <St7789Display.h>
|
#include <St7789Display.h>
|
||||||
|
|
||||||
#define TAG "crowpanel_display"
|
|
||||||
|
|
||||||
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
|
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
|
||||||
// Note for future changes: Reset pin is 48 and interrupt pin is 47
|
// Note for future changes: Reset pin is 48 and interrupt pin is 47
|
||||||
auto configuration = std::make_unique<Ft5x06Touch::Configuration>(
|
auto configuration = std::make_unique<Ft5x06Touch::Configuration>(
|
||||||
@ -39,5 +37,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
|||||||
|
|
||||||
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
|
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
|
||||||
|
|
||||||
return std::make_shared<St7789Display>(std::move(configuration));
|
auto display = std::make_shared<St7789Display>(std::move(configuration));
|
||||||
|
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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_ft5x06 driver
|
REQUIRES Tactility EspLcdCompat esp_lcd_touch_ft5x06 driver
|
||||||
)
|
)
|
||||||
|
|||||||
@ -8,15 +8,17 @@
|
|||||||
|
|
||||||
#define TAG "ft5x06"
|
#define TAG "ft5x06"
|
||||||
|
|
||||||
bool Ft5x06Touch::start(lv_display_t* display) {
|
bool Ft5x06Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||||
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG();
|
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG();
|
||||||
|
return esp_lcd_new_panel_io_i2c(configuration->port, &io_config, &outHandle) == ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (esp_lcd_new_panel_io_i2c(configuration->port, &io_config, &ioHandle) != ESP_OK) {
|
bool Ft5x06Touch::createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& configuration, esp_lcd_touch_handle_t& panelHandle) {
|
||||||
TT_LOG_E(TAG, "Touch IO I2C creation failed");
|
return esp_lcd_touch_new_i2c_ft5x06(ioHandle, &configuration, &panelHandle) == ESP_OK;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
esp_lcd_touch_config_t config = {
|
esp_lcd_touch_config_t Ft5x06Touch::createEspLcdTouchConfig() {
|
||||||
|
return {
|
||||||
.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,
|
||||||
@ -35,47 +37,4 @@ bool Ft5x06Touch::start(lv_display_t* display) {
|
|||||||
.user_data = nullptr,
|
.user_data = nullptr,
|
||||||
.driver_data = nullptr
|
.driver_data = nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
if (esp_lcd_touch_new_i2c_ft5x06(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,
|
|
||||||
};
|
|
||||||
|
|
||||||
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 Ft5x06Touch::stop() {
|
|
||||||
cleanup();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Ft5x06Touch::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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,9 @@
|
|||||||
#include <Tactility/TactilityCore.h>
|
#include <Tactility/TactilityCore.h>
|
||||||
#include <driver/i2c.h>
|
#include <driver/i2c.h>
|
||||||
|
|
||||||
#include <esp_lcd_panel_io_interface.h>
|
#include <EspLcdTouch.h>
|
||||||
#include <esp_lcd_touch.h>
|
|
||||||
|
|
||||||
class Ft5x06Touch final : public tt::hal::touch::TouchDevice {
|
class Ft5x06Touch final : public EspLcdTouch {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -52,11 +51,12 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
std::unique_ptr<Configuration> configuration;
|
std::unique_ptr<Configuration> configuration;
|
||||||
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();
|
bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle) 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();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -64,10 +64,7 @@ public:
|
|||||||
assert(configuration != nullptr);
|
assert(configuration != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool start(lv_display_t* display) override;
|
std::string getName() const override { return "FT5x06"; }
|
||||||
bool stop() override;
|
|
||||||
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
|
|
||||||
|
|
||||||
std::string getName() const final { return "FT5x06"; }
|
std::string getDescription() const override { return "FT5x06 I2C touch driver"; }
|
||||||
std::string getDescription() const final { return "I2C Touch Driver"; }
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,9 +4,7 @@
|
|||||||
#include <Tactility/TactilityCore.h>
|
#include <Tactility/TactilityCore.h>
|
||||||
#include <driver/i2c.h>
|
#include <driver/i2c.h>
|
||||||
|
|
||||||
#include <esp_lcd_touch.h>
|
#include <EspLcdTouch.h>
|
||||||
|
|
||||||
#include "../../EspLcdCompat/Source/EspLcdTouch.h"
|
|
||||||
|
|
||||||
class Gt911Touch final : public EspLcdTouch {
|
class Gt911Touch final : public EspLcdTouch {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user