Support for Waveshare S3 Touch LCD 4.3 (#18)

* initial changes for waveshare s3 touch support

* fix lvgl locking

* fix for lvgl locking

* cleaned up dependencies

* boards now depend on tactility instead of tactility-esp

* revert deletion

* remove component

* working touch&display driver

* added waveshare to github actions

* cleanup

* fix for driver

* fix for sim build

* build fixes

* updated docs

* updated docs

* attempt new sdl2 github action

* revert

* fixes for clion/cmdline build

environment wasn't parsed properly

* temporarily disable pc sim build
This commit is contained in:
Ken Van Hoeylandt
2024-01-26 21:36:21 +01:00
committed by GitHub
parent ed2d0cc78a
commit 14eb43211d
65 changed files with 944 additions and 437 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
idf_component_register(
SRC_DIRS "."
INCLUDE_DIRS "."
REQUIRES tactility-esp esp_lcd esp_lcd_touch_gt911
REQUIRES esp_lvgl_port esp_lcd esp_lcd_touch_gt911 driver
)
target_link_libraries(${COMPONENT_LIB} ${IDF_TARGET_NAME} tactility)
+3
View File
@@ -1,10 +1,13 @@
#include "esp_log.h"
#include "driver/gpio.h"
#include "kernel.h"
#include "esp_lvgl_port.h"
#define TAG "lilygo_tdeck_bootstrap"
#define TDECK_PERI_POWERON GPIO_NUM_10
lv_disp_t* lilygo_tdeck_init_display();
static void tdeck_power_on() {
ESP_LOGI(TAG, "power on");
gpio_config_t device_power_signal_config = {
+30 -24
View File
@@ -4,7 +4,7 @@
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_log.h"
#include "tactility-esp.h"
#include "esp_lvgl_port.h"
#define TAG "lilygo_tdeck_display"
@@ -57,7 +57,7 @@ static void tdeck_backlight() {
ESP_ERROR_CHECK(ledc_set_duty(LCD_BACKLIGHT_LEDC_MODE, LCD_BACKLIGHT_LEDC_CHANNEL, LCD_BACKLIGHT_LEDC_DUTY));
}
static bool create_display_device(DisplayDevice* display) {
lv_disp_t* lilygo_tdeck_init_display() {
ESP_LOGI(TAG, "creating display");
int draw_buffer_size = LCD_HORIZONTAL_RESOLUTION * LCD_DRAW_BUFFER_HEIGHT * (LCD_BITS_PER_PIXEL / 8);
@@ -96,7 +96,8 @@ static bool create_display_device(DisplayDevice* display) {
}
};
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_SPI_HOST, &panel_io_config, &display->io_handle) != ESP_OK) {
esp_lcd_panel_io_handle_t io_handle;
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_SPI_HOST, &panel_io_config, &io_handle) != ESP_OK) {
ESP_LOGD(TAG, "failed to create panel IO");
return false;
}
@@ -113,56 +114,61 @@ static bool create_display_device(DisplayDevice* display) {
.vendor_config = NULL
};
if (esp_lcd_new_panel_st7789(display->io_handle, &panel_config, &display->display_handle) != ESP_OK) {
esp_lcd_panel_handle_t panel_handle;
if (esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle) != ESP_OK) {
ESP_LOGD(TAG, "failed to create panel");
return false;
}
if (esp_lcd_panel_reset(display->display_handle) != ESP_OK) {
if (esp_lcd_panel_reset(panel_handle) != ESP_OK) {
ESP_LOGD(TAG, "failed to reset panel");
return false;
}
if (esp_lcd_panel_init(display->display_handle) != ESP_OK) {
if (esp_lcd_panel_init(panel_handle) != ESP_OK) {
ESP_LOGD(TAG, "failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(display->display_handle, true) != ESP_OK) {
if (esp_lcd_panel_invert_color(panel_handle, true) != ESP_OK) {
ESP_LOGD(TAG, "failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(display->display_handle, true) != ESP_OK) {
if (esp_lcd_panel_swap_xy(panel_handle, true) != ESP_OK) {
ESP_LOGD(TAG, "failed to init panel");
return false;
}
if (esp_lcd_panel_mirror(display->display_handle, true, false) != ESP_OK) {
if (esp_lcd_panel_mirror(panel_handle, true, false) != ESP_OK) {
ESP_LOGD(TAG, "failed to init panel");
return false;
}
if (esp_lcd_panel_disp_on_off(display->display_handle, true) != ESP_OK) {
if (esp_lcd_panel_disp_on_off(panel_handle, true) != ESP_OK) {
ESP_LOGD(TAG, "failed to turn display on");
return false;
}
display->horizontal_resolution = LCD_HORIZONTAL_RESOLUTION;
display->vertical_resolution = LCD_VERTICAL_RESOLUTION;
display->draw_buffer_height = LCD_DRAW_BUFFER_HEIGHT;
display->bits_per_pixel = LCD_BITS_PER_PIXEL;
display->monochrome = false;
display->double_buffering = false;
const lvgl_port_display_cfg_t disp_cfg = {
.io_handle = io_handle,
.panel_handle = panel_handle,
.buffer_size = LCD_HORIZONTAL_RESOLUTION * LCD_DRAW_BUFFER_HEIGHT * (LCD_BITS_PER_PIXEL / 8),
.double_buffer = false,
.hres = LCD_HORIZONTAL_RESOLUTION,
.vres = LCD_VERTICAL_RESOLUTION,
.monochrome = false,
.rotation = {
.swap_xy = true, // TODO: check if code above is still needed
.mirror_x = true,
.mirror_y = false,
},
.flags = {
.buff_dma = true,
}
};
tdeck_backlight();
return true;
}
DisplayDriver lilygo_tdeck_display_driver() {
return (DisplayDriver) {
.name = "lilygo_tdeck_display",
.create_display_device = &create_display_device
};
return lvgl_port_add_disp(&disp_cfg);
}
+5 -2
View File
@@ -1,7 +1,10 @@
#include "lilygo_tdeck.h"
#include <stdbool.h>
bool lilygo_tdeck_bootstrap();
bool lilygo_init_lvgl();
const HardwareConfig lilygo_tdeck = {
.bootstrap = &lilygo_tdeck_bootstrap,
.display_driver = &lilygo_tdeck_display_driver,
.touch_driver = &lilygo_tdeck_touch_driver
.init_lvgl = &lilygo_init_lvgl
};
+1 -6
View File
@@ -1,16 +1,11 @@
#pragma once
#include "tactility-esp.h"
#include "hardware_config.h"
#ifdef __cplusplus
extern "C" {
#endif
// Available for HardwareConfig customizations
void lilygo_tdeck_bootstrap();
DisplayDriver lilygo_tdeck_display_driver();
TouchDriver lilygo_tdeck_touch_driver();
extern const HardwareConfig lilygo_tdeck;
#ifdef __cplusplus
+57
View File
@@ -0,0 +1,57 @@
#include "esp_lvgl_port.h"
#include "log.h"
#include "ui/lvgl_sync.h"
#include <thread.h>
#define TAG "lilygo_tdeck_lvgl"
lv_disp_t* lilygo_tdeck_init_display();
bool lilygo_tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle);
bool lilygo_init_lvgl() {
static lv_disp_t* display = NULL;
static esp_lcd_panel_io_handle_t touch_io_handle;
static esp_lcd_touch_handle_t touch_handle;
const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = ThreadPriorityHigh,
.task_stack = 8096,
.task_affinity = -1, // core pinning
.task_max_sleep_ms = 500,
.timer_period_ms = 5
};
if (lvgl_port_init(&lvgl_cfg) != ESP_OK) {
TT_LOG_E(TAG, "lvgl port init failed");
return false;
}
// Add display
display = lilygo_tdeck_init_display();
if (display == NULL) {
TT_LOG_E(TAG, "failed to add display");
return false;
}
// Add touch
if (!lilygo_tdeck_init_touch(&touch_io_handle, &touch_handle)) {
return false;
}
const lvgl_port_touch_cfg_t touch_cfg = {
.disp = display,
.handle = touch_handle,
};
lv_indev_t _Nullable* touch_indev = lvgl_port_add_touch(&touch_cfg);
if (touch_indev == NULL) {
TT_LOG_E(TAG, "failed to add touch to lvgl");
return false;
}
// Set syncing functions
tt_lvgl_sync_set(&lvgl_port_lock, &lvgl_port_unlock);
return true;
}
+2 -11
View File
@@ -1,5 +1,3 @@
#include "tactility-esp.h"
#include "esp_lcd_touch_gt911.h"
#include "esp_log.h"
#include "esp_err.h"
@@ -9,7 +7,7 @@
#define TAG "lilygo_tdeck_touch"
static bool create_touch_device(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) {
bool lilygo_tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) {
ESP_LOGI(TAG, "creating touch");
const i2c_config_t i2c_conf = {
@@ -64,11 +62,4 @@ static bool create_touch_device(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_to
}
return true;
}
TouchDriver lilygo_tdeck_touch_driver() {
return (TouchDriver) {
.name = "lilygo_tdeck_touch",
.create_touch_device = &create_touch_device
};
}
}