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:
committed by
GitHub
parent
ed2d0cc78a
commit
14eb43211d
@@ -1,7 +1,6 @@
|
||||
#include "wifi_connect.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "services/wifi/wifi.h"
|
||||
#include "tactility_core.h"
|
||||
#include "ui/lvgl_sync.h"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "app.h"
|
||||
#include "apps/system/wifi_connect/wifi_connect_bundle.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "services/loader/loader.h"
|
||||
#include "tactility_core.h"
|
||||
#include "ui/lvgl_sync.h"
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "check.h"
|
||||
#include "display.h"
|
||||
|
||||
DisplayDevice* tt_display_device_alloc(DisplayDriver* driver) {
|
||||
DisplayDevice* display = malloc(sizeof(DisplayDevice));
|
||||
memset(display, 0, sizeof(DisplayDevice));
|
||||
tt_check(driver->create_display_device(display), "failed to create display");
|
||||
tt_check(display->io_handle != NULL);
|
||||
tt_check(display->display_handle != NULL);
|
||||
tt_check(display->horizontal_resolution != 0);
|
||||
tt_check(display->vertical_resolution != 0);
|
||||
tt_check(display->draw_buffer_height > 0);
|
||||
tt_check(display->bits_per_pixel > 0);
|
||||
return display;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_lcd_panel_io.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_panel_io_handle_t io_handle;
|
||||
esp_lcd_panel_handle_t display_handle;
|
||||
uint16_t horizontal_resolution;
|
||||
uint16_t vertical_resolution;
|
||||
uint16_t draw_buffer_height;
|
||||
uint16_t bits_per_pixel;
|
||||
bool double_buffering;
|
||||
bool mirror_x;
|
||||
bool mirror_y;
|
||||
bool swap_xy;
|
||||
bool monochrome;
|
||||
} DisplayDevice;
|
||||
|
||||
typedef bool (*CreateDisplay)(DisplayDevice* display);
|
||||
|
||||
typedef struct {
|
||||
char name[32];
|
||||
CreateDisplay create_display_device;
|
||||
} DisplayDriver;
|
||||
|
||||
/**
|
||||
* @param[in] driver
|
||||
* @return allocated display object
|
||||
*/
|
||||
DisplayDevice* tt_display_device_alloc(DisplayDriver* driver);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,59 +0,0 @@
|
||||
#include "check.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "graphics_i.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
#define TAG "lvgl"
|
||||
|
||||
Lvgl tt_graphics_init(Hardware* hardware) {
|
||||
const lvgl_port_cfg_t lvgl_cfg = {
|
||||
.task_priority = 4,
|
||||
.task_stack = 8096,
|
||||
.task_affinity = -1, // core pinning
|
||||
.task_max_sleep_ms = 500,
|
||||
.timer_period_ms = 5
|
||||
};
|
||||
|
||||
tt_check(lvgl_port_init(&lvgl_cfg) == ESP_OK, "lvgl port init failed");
|
||||
DisplayDevice* display = hardware->display;
|
||||
|
||||
// Add display
|
||||
TT_LOG_I(TAG, "lvgl add display");
|
||||
const lvgl_port_display_cfg_t disp_cfg = {
|
||||
.io_handle = display->io_handle,
|
||||
.panel_handle = display->display_handle,
|
||||
.buffer_size = display->horizontal_resolution * display->draw_buffer_height * (display->bits_per_pixel / 8),
|
||||
.double_buffer = display->double_buffering,
|
||||
.hres = display->horizontal_resolution,
|
||||
.vres = display->vertical_resolution,
|
||||
.monochrome = display->monochrome,
|
||||
.rotation = {
|
||||
.swap_xy = display->swap_xy,
|
||||
.mirror_x = display->mirror_x,
|
||||
.mirror_y = display->mirror_y,
|
||||
},
|
||||
.flags = {
|
||||
.buff_dma = true,
|
||||
}
|
||||
};
|
||||
|
||||
lv_disp_t* disp = lvgl_port_add_disp(&disp_cfg);
|
||||
tt_check(disp != NULL, "failed to add display");
|
||||
|
||||
lv_indev_t _Nullable* touch_indev = NULL;
|
||||
|
||||
// Add touch
|
||||
if (hardware->touch != NULL) {
|
||||
const lvgl_port_touch_cfg_t touch_cfg = {
|
||||
.disp = disp,
|
||||
.handle = hardware->touch->touch_handle,
|
||||
};
|
||||
touch_indev = lvgl_port_add_touch(&touch_cfg);
|
||||
tt_check(touch_indev != NULL, "failed to add touch to lvgl");
|
||||
}
|
||||
|
||||
return (Lvgl) {
|
||||
.disp = disp,
|
||||
.touch_indev = touch_indev
|
||||
};
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
lv_disp_t* disp;
|
||||
lv_indev_t* _Nullable touch_indev;
|
||||
} Lvgl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "graphics.h"
|
||||
#include "hardware.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Lvgl tt_graphics_init(Hardware* hardware);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
#include "check.h"
|
||||
#include "hardware_i.h"
|
||||
#include "touch.h"
|
||||
|
||||
#define TAG "hardware"
|
||||
|
||||
Hardware tt_hardware_init(const HardwareConfig* config) {
|
||||
if (config->bootstrap != NULL) {
|
||||
TT_LOG_I(TAG, "Bootstrapping");
|
||||
config->bootstrap();
|
||||
}
|
||||
|
||||
tt_check(config->display_driver != NULL, "no display driver configured");
|
||||
DisplayDriver display_driver = config->display_driver();
|
||||
TT_LOG_I(TAG, "display with driver %s", display_driver.name);
|
||||
DisplayDevice* display = tt_display_device_alloc(&display_driver);
|
||||
|
||||
TouchDevice* touch = NULL;
|
||||
if (config->touch_driver != NULL) {
|
||||
TouchDriver touch_driver = config->touch_driver();
|
||||
TT_LOG_I(TAG, "touch with driver %s", touch_driver.name);
|
||||
touch = tt_touch_alloc(&touch_driver);
|
||||
} else {
|
||||
TT_LOG_I(TAG, "no touch configured");
|
||||
touch = NULL;
|
||||
}
|
||||
|
||||
return (Hardware) {
|
||||
.display = display,
|
||||
.touch = touch
|
||||
};
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "display.h"
|
||||
#include "touch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
DisplayDevice* display;
|
||||
TouchDevice* _Nullable touch;
|
||||
} Hardware;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -6,4 +6,3 @@
|
||||
#define MOUNT_POINT_CONFIG "/config"
|
||||
|
||||
esp_err_t tt_partitions_init();
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "hardware.h"
|
||||
#include "tactility.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Forward declarations
|
||||
typedef void (*Bootstrap)();
|
||||
typedef TouchDriver (*CreateTouchDriver)();
|
||||
typedef DisplayDriver (*CreateDisplayDriver)();
|
||||
|
||||
typedef struct {
|
||||
// Optional bootstrapping method (e.g. to turn peripherals on)
|
||||
const Bootstrap _Nullable bootstrap;
|
||||
// Required driver for display
|
||||
const CreateDisplayDriver display_driver;
|
||||
// Optional driver for touch input
|
||||
const CreateTouchDriver _Nullable touch_driver;
|
||||
} HardwareConfig;
|
||||
|
||||
|
||||
void tt_esp_init(const HardwareConfig* hardware_config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,27 +1,13 @@
|
||||
#include "tactility.h"
|
||||
#include "tactility_core.h"
|
||||
|
||||
#include "esp_event.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "esp_netif.h"
|
||||
#include "graphics_i.h"
|
||||
#include "hardware_i.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "partitions.h"
|
||||
#include "services/loader/loader.h"
|
||||
#include "services/wifi/wifi_credentials.h"
|
||||
#include "ui/lvgl_sync.h"
|
||||
|
||||
#define TAG "tactility"
|
||||
|
||||
static bool lvgl_lock_impl(int timeout_ticks) {
|
||||
return lvgl_port_lock(timeout_ticks);
|
||||
}
|
||||
|
||||
static void lvgl_unlock_impl() {
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
void tt_esp_init(const HardwareConfig* hardware_config) {
|
||||
void tt_esp_init() {
|
||||
// Initialize NVS
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
@@ -39,9 +25,4 @@ void tt_esp_init(const HardwareConfig* hardware_config) {
|
||||
tt_partitions_init();
|
||||
|
||||
tt_wifi_credentials_init();
|
||||
|
||||
tt_lvgl_sync_set(&lvgl_lock_impl, &lvgl_unlock_impl);
|
||||
|
||||
Hardware hardware = tt_hardware_init(hardware_config);
|
||||
/*Lvgl lvgl =*/tt_graphics_init(&hardware);
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "tactility-esp.h"
|
||||
#include "hardware_config.h"
|
||||
#include "tactility.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Hardware tt_hardware_init(const HardwareConfig* config);
|
||||
void tt_esp_init();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#include "check.h"
|
||||
#include "touch.h"
|
||||
|
||||
TouchDevice* tt_touch_alloc(TouchDriver* driver) {
|
||||
TouchDevice* touch = malloc(sizeof(TouchDevice));
|
||||
bool success = driver->create_touch_device(
|
||||
&(touch->io_handle),
|
||||
&(touch->touch_handle)
|
||||
);
|
||||
tt_check(success, "touch driver failed");
|
||||
return touch;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_touch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef bool (*CreateTouch)(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle);
|
||||
|
||||
typedef struct {
|
||||
char name[32];
|
||||
CreateTouch create_touch_device;
|
||||
} TouchDriver;
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_panel_io_handle_t io_handle;
|
||||
esp_lcd_touch_handle_t touch_handle;
|
||||
} TouchDevice;
|
||||
|
||||
/**
|
||||
* @param[in] driver
|
||||
* @return a newly allocated instance
|
||||
*/
|
||||
TouchDevice* tt_touch_alloc(TouchDriver* driver);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user