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_touch_cst816s esp_lcd_ili9341
REQUIRES esp_lvgl_port esp_lcd_touch_cst816s esp_lcd_ili9341
)
target_link_libraries(${COMPONENT_LIB} ${IDF_TARGET_NAME} tactility)
+30 -35
View File
@@ -4,14 +4,12 @@
#include "esp_lcd_ili9341.h"
#include "esp_lcd_panel_ops.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "tactility-esp.h"
#include "esp_lvgl_port.h"
#include "hal/lv_hal_disp.h"
#include <esp_lcd_panel_io.h>
#define TAG "2432s024_ili9341"
static SemaphoreHandle_t refresh_finish = NULL;
#define LCD_SPI_HOST SPI2_HOST
#define LCD_PIN_SCLK GPIO_NUM_14
#define LCD_PIN_MOSI GPIO_NUM_13
@@ -24,7 +22,7 @@ static SemaphoreHandle_t refresh_finish = NULL;
#define LCD_BITS_PER_PIXEL 16
#define LCD_DRAW_BUFFER_HEIGHT (LCD_VERTICAL_RESOLUTION / 10)
static bool create_display_device(DisplayDevice* display) {
lv_disp_t* yellow_board_init_display() {
ESP_LOGI(TAG, "creating display");
gpio_config_t io_conf = {
@@ -55,7 +53,8 @@ static bool create_display_device(DisplayDevice* display) {
NULL
);
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");
return false;
}
@@ -67,36 +66,28 @@ static bool create_display_device(DisplayDevice* display) {
.bits_per_pixel = LCD_BITS_PER_PIXEL,
};
if (esp_lcd_new_panel_ili9341(display->io_handle, &panel_config, &display->display_handle) != ESP_OK) {
esp_lcd_panel_handle_t panel_handle;
if (esp_lcd_new_panel_ili9341(io_handle, &panel_config, &panel_handle) != ESP_OK) {
ESP_LOGD(TAG, "failed to create ili9341");
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_mirror(display->display_handle, true, false) != ESP_OK) {
if (esp_lcd_panel_mirror(panel_handle, true, false) != ESP_OK) {
ESP_LOGD(TAG, "failed to set panel to mirror");
display->mirror_x = true;
display->mirror_y = false;
return false;
}
if (esp_lcd_panel_swap_xy(display->display_handle, false) != ESP_OK) {
ESP_LOGD(TAG, "failed to set panel xy swap");
display->swap_xy = false;
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;
}
@@ -106,19 +97,23 @@ static bool create_display_device(DisplayDevice* display) {
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 = true;
return true;
}
DisplayDriver board_2432s024_create_display_driver() {
return (DisplayDriver) {
.name = "ili9341_2432s024",
.create_display_device = &create_display_device
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 = false,
.mirror_x = true,
.mirror_y = false,
},
.flags = {
.buff_dma = true,
}
};
return lvgl_port_add_disp(&disp_cfg);
}
+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 "yellow_board_lvgl"
lv_disp_t* yellow_board_init_display();
bool yellow_board_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle);
bool yellow_board_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 = yellow_board_init_display();
if (display == NULL) {
TT_LOG_E(TAG, "failed to add display");
return false;
}
// Add touch
if (!yellow_board_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;
}
+1 -9
View File
@@ -2,13 +2,12 @@
#include "esp_err.h"
#include "esp_lcd_touch_cst816s.h"
#include "esp_log.h"
#include "tactility-esp.h"
#define TOUCH_I2C_PORT 0
#define TAG "2432s024_cst816"
static bool create_touch_device(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) {
bool yellow_board_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,10 +63,3 @@ static bool create_touch_device(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_to
return true;
}
TouchDriver board_2432s024_create_touch_driver() {
return (TouchDriver) {
.name = "cst816s_2432s024",
.create_touch_device = &create_touch_device
};
}
+3 -2
View File
@@ -1,7 +1,8 @@
#include "yellow_board.h"
bool yellow_board_init_lvgl();
const HardwareConfig yellow_board_24inch_cap = {
.bootstrap = NULL,
.display_driver = &board_2432s024_create_display_driver,
.touch_driver = &board_2432s024_create_touch_driver
.init_lvgl = &yellow_board_init_lvgl
};
+1 -5
View File
@@ -1,15 +1,11 @@
#pragma once
#include "tactility-esp.h"
#include "hardware_config.h"
#ifdef __cplusplus
extern "C" {
#endif
// Available for HardwareConfig customizations
DisplayDriver board_2432s024_create_display_driver();
TouchDriver board_2432s024_create_touch_driver();
// Capacitive touch version of the 2.4" yellow board
extern const HardwareConfig yellow_board_24inch_cap;