C++ conversion (#80)

Converted project to C++
This commit is contained in:
Ken Van Hoeylandt 2024-11-22 20:26:08 +01:00 committed by GitHub
parent 6d80144e12
commit 85e26636a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
489 changed files with 6022 additions and 39471 deletions

View File

@ -13,7 +13,7 @@ jobs:
- name: build - name: build
uses: espressif/esp-idf-ci-action@main uses: espressif/esp-idf-ci-action@main
with: with:
esp_idf_version: v5.2.3 esp_idf_version: v5.3.1
target: esp32 target: esp32
path: './' path: './'
build-lilygo-t-deck: build-lilygo-t-deck:
@ -28,7 +28,7 @@ jobs:
- name: build - name: build
uses: espressif/esp-idf-ci-action@main uses: espressif/esp-idf-ci-action@main
with: with:
esp_idf_version: v5.2.3 esp_idf_version: v5.3.1
target: esp32s3 target: esp32s3
path: './' path: './'
build-waveshare-s3-touch: build-waveshare-s3-touch:
@ -43,7 +43,7 @@ jobs:
- name: build - name: build
uses: espressif/esp-idf-ci-action@main uses: espressif/esp-idf-ci-action@main
with: with:
esp_idf_version: v5.2.3 esp_idf_version: v5.3.1
target: esp32s3 target: esp32s3
path: './' path: './'
build-m5stack-core2: build-m5stack-core2:
@ -58,7 +58,7 @@ jobs:
- name: build - name: build
uses: espressif/esp-idf-ci-action@main uses: espressif/esp-idf-ci-action@main
with: with:
esp_idf_version: v5.2.3 esp_idf_version: v5.3.1
target: esp32 target: esp32
path: './' path: './'
build-m5stack-cores3: build-m5stack-cores3:
@ -73,6 +73,6 @@ jobs:
- name: build - name: build
uses: espressif/esp-idf-ci-action@main uses: espressif/esp-idf-ci-action@main
with: with:
esp_idf_version: v5.2.3 esp_idf_version: v5.3.1
target: esp32s3 target: esp32s3
path: './' path: './'

View File

@ -17,4 +17,4 @@ jobs:
- name: Build Tests - name: Build Tests
run: cmake --build build --target build-tests run: cmake --build build --target build-tests
- name: Run Tests - name: Run Tests
run: build/tests/tactility-core/tactility-core-tests --exit run: build/Tests/TactilityCore/TactilityCoreTests --exit

20
.gitmodules vendored
View File

@ -1,15 +1,15 @@
[submodule "libs/M5GFX"] [submodule "Libraries/M5GFX"]
path = libs/M5GFX path = Libraries/M5GFX
url = https://github.com/m5stack/M5GFX.git url = https://github.com/m5stack/M5GFX.git
[submodule "libs/M5Unified"] [submodule "Libraries/M5Unified"]
path = libs/M5Unified path = Libraries/M5Unified
url = https://github.com/m5stack/M5Unified.git url = https://github.com/m5stack/M5Unified.git
[submodule "libs/FreeRTOS-Kernel"] [submodule "Libraries/FreeRTOS-Kernel"]
path = libs/FreeRTOS-Kernel path = Libraries/FreeRTOS-Kernel
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
[submodule "libs/mbedtls"] [submodule "Libraries/mbedtls"]
path = libs/mbedtls path = Libraries/mbedtls
url = https://github.com/Mbed-TLS/mbedtls.git url = https://github.com/Mbed-TLS/mbedtls.git
[submodule "libs/lvgl"] [submodule "Libraries/lvgl"]
path = libs/lvgl path = Libraries/lvgl
url = https://github.com/lvgl/lvgl.git url = https://github.com/lvgl/lvgl.git

View File

@ -1,25 +1,25 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
set(BOARD_COMPONENTS tactility) set(BOARD_COMPONENTS Tactility)
if("${IDF_TARGET}" STREQUAL "esp32") if("${IDF_TARGET}" STREQUAL "esp32")
list(APPEND BOARD_COMPONENTS list(APPEND BOARD_COMPONENTS
yellow_board YellowBoard
m5stack_core2 M5stackCore2
) )
endif() endif()
# T-Deck is an S3 platform # T-Deck is an S3 platform
if("${IDF_TARGET}" STREQUAL "esp32s3") if("${IDF_TARGET}" STREQUAL "esp32s3")
list(APPEND BOARD_COMPONENTS list(APPEND BOARD_COMPONENTS
lilygo_tdeck LilygoTdeck
m5stack_cores3 M5stackCoreS3
waveshare_s3_touch WaveshareS3Touch
) )
endif() endif()
idf_component_register( idf_component_register(
SRC_DIRS "src" SRC_DIRS "Source"
"src/hello_world" "Source/HelloWorld"
REQUIRES ${BOARD_COMPONENTS} REQUIRES ${BOARD_COMPONENTS}
) )

View File

@ -10,7 +10,7 @@
#include "yellow_board.h" #include "yellow_board.h"
#define TT_BOARD_HARDWARE &yellow_board_24inch_cap #define TT_BOARD_HARDWARE &yellow_board_24inch_cap
#elif defined(CONFIG_TT_BOARD_M5STACK_CORE2) #elif defined(CONFIG_TT_BOARD_M5STACK_CORE2)
#include "m5stack_core2.h" #include "M5stackCore2.h"
#define TT_BOARD_HARDWARE &m5stack_core2 #define TT_BOARD_HARDWARE &m5stack_core2
#elif defined(CONFIG_TT_BOARD_M5STACK_CORES3) #elif defined(CONFIG_TT_BOARD_M5STACK_CORES3)
#include "m5stack_cores3.h" #include "m5stack_cores3.h"

View File

@ -0,0 +1,18 @@
#include "lvgl.h"
#include "Ui/Toolbar.h"
static void app_show(tt::App app, lv_obj_t* parent) {
lv_obj_t* toolbar = tt::lvgl::toolbar_create_for_app(parent, app);
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
lv_obj_t* label = lv_label_create(parent);
lv_label_set_text(label, "Hello, world!");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
}
extern const tt::AppManifest hello_world_app = {
.id = "HelloWorld",
.name = "Hello World",
.type = tt::AppTypeUser,
.on_show = &app_show,
};

33
AppEsp32/Source/Main.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "Boards.h"
// Apps
#include "Tactility.h"
namespace tt::service::wifi {
extern void wifi_main(void*);
}
extern const tt::AppManifest hello_world_app;
extern "C" {
void app_main() {
static const tt::Configuration config = {
/**
* Auto-select a board based on the ./sdkconfig.board.* file
* that you copied to ./sdkconfig before you opened this project.
*/
.hardware = TT_BOARD_HARDWARE,
.apps = {
&hello_world_app,
},
.services = {},
.auto_start_app_id = nullptr
};
tt::init(&config);
tt::service::wifi::wifi_main(nullptr);
}
} // extern

View File

@ -3,4 +3,4 @@ dependencies:
espressif/esp_lcd_touch_cst816s: "1.0.3" espressif/esp_lcd_touch_cst816s: "1.0.3"
espressif/esp_lcd_touch_gt911: "1.1.1" espressif/esp_lcd_touch_gt911: "1.1.1"
espressif/esp_lcd_touch: "1.1.2" espressif/esp_lcd_touch: "1.1.2"
idf: '~5.2' idf: '5.3.1'

17
AppSim/CMakeLists.txt Normal file
View File

@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.16)
file(GLOB_RECURSE SOURCES "Source/*.c*")
add_executable(AppSim ${SOURCES})
target_link_libraries(AppSim
PRIVATE Tactility
PRIVATE TactilityCore
PRIVATE TactilityHeadless
PRIVATE lvgl
)
find_package(SDL2 REQUIRED CONFIG)
target_link_libraries(AppSim PRIVATE ${SDL2_LIBRARIES})
include_directories(${SDL2_INCLUDE_DIRS})
add_definitions(-D_Nullable=)
add_definitions(-D_Nonnull=)

View File

@ -0,0 +1,17 @@
#include "Ui/Toolbar.h"
static void app_show(tt::App app, lv_obj_t* parent) {
lv_obj_t* toolbar = tt::lvgl::toolbar_create_for_app(parent, app);
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
lv_obj_t* label = lv_label_create(parent);
lv_label_set_text(label, "Hello, world!");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
}
extern const tt::AppManifest hello_world_app = {
.id = "HelloWorld",
.name = "Hello World",
.type = tt::AppTypeUser,
.on_show = &app_show
};

View File

@ -1,5 +1,5 @@
#include "tactility.h" #include "Tactility.h"
#include "thread.h" #include "Thread.h"
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "task.h" #include "task.h"
@ -12,7 +12,7 @@ static void main_task(TT_UNUSED void* parameter) {
TT_LOG_I(TAG, "starting app_main()"); TT_LOG_I(TAG, "starting app_main()");
app_main(); app_main();
TT_LOG_I(TAG, "returned from app_main()"); TT_LOG_I(TAG, "returned from app_main()");
vTaskDelete(NULL); vTaskDelete(nullptr);
} }
int main() { int main() {
@ -20,9 +20,9 @@ int main() {
main_task, main_task,
"main", "main",
8192, 8192,
NULL, nullptr,
ThreadPriorityNormal, tt::ThreadPriorityNormal,
NULL nullptr
); );
tt_assert(task_result == pdTRUE); tt_assert(task_result == pdTRUE);

View File

@ -1,11 +1,10 @@
#include "hardware_config.h" #include "Hal/Configuration.h"
#include "lvgl_task.h" #include "lvgl_task.h"
#include "src/lv_init.h" #include "src/lv_init.h"
#include <stdbool.h>
#define TAG "hardware" #define TAG "hardware"
extern const Power power; extern const tt::hal::Power power;
static bool lvgl_init() { static bool lvgl_init() {
lv_init(); lv_init();
@ -16,7 +15,7 @@ static bool lvgl_init() {
TT_UNUSED static void lvgl_deinit() { TT_UNUSED static void lvgl_deinit() {
lvgl_task_interrupt(); lvgl_task_interrupt();
while (lvgl_task_is_running()) { while (lvgl_task_is_running()) {
tt_delay_ms(10); tt::delay_ms(10);
} }
#if LV_ENABLE_GC || !LV_MEM_CUSTOM #if LV_ENABLE_GC || !LV_MEM_CUSTOM
@ -24,12 +23,12 @@ TT_UNUSED static void lvgl_deinit() {
#endif #endif
} }
const HardwareConfig sim_hardware = { extern const tt::hal::Configuration sim_hardware = {
.bootstrap = NULL, .bootstrap = nullptr,
.init_graphics = &lvgl_init, .init_graphics = &lvgl_init,
.display = { .display = {
.set_backlight_duty = NULL, .set_backlight_duty = nullptr,
}, },
.power = &power, .sdcard = nullptr,
.sdcard = NULL .power = &power
}; };

View File

@ -1,5 +1,5 @@
#include "lvgl.h" #include "lvgl.h"
#include "ui/lvgl_keypad.h" #include "Ui/LvglKeypad.h"
lv_display_t* lvgl_hal_init() { lv_display_t* lvgl_hal_init() {
static lv_display_t* display = NULL; static lv_display_t* display = NULL;
@ -9,7 +9,7 @@ lv_display_t* lvgl_hal_init() {
display = lv_sdl_window_create(320, 240); display = lv_sdl_window_create(320, 240);
mouse = lv_sdl_mouse_create(); mouse = lv_sdl_mouse_create();
keyboard = lv_sdl_keyboard_create(); keyboard = lv_sdl_keyboard_create();
tt_lvgl_keypad_set_indev(keyboard); tt::lvgl::keypad_set_indev(keyboard);
return display; return display;
} }

5
AppSim/Source/lvgl_hal.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <cstdint>
lv_display_t* lvgl_hal_init();

View File

@ -1,11 +1,11 @@
#include "lvgl_task.h" #include "lvgl_task.h"
#include "lvgl.h" #include "lvgl.h"
#include "Log.h"
#include "lvgl_hal.h" #include "lvgl_hal.h"
#include "tactility_core.h" #include "TactilityCore.h"
#include "thread.h" #include "Thread.h"
#include "ui/lvgl_sync.h" #include "Ui/LvglSync.h"
#include <stdbool.h>
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "semphr.h" #include "semphr.h"
@ -55,7 +55,7 @@ static void lvgl_unlock() {
} }
void lvgl_task_interrupt() { void lvgl_task_interrupt() {
tt_check(lvgl_lock(TtWaitForever)); tt_check(lvgl_lock(tt::TtWaitForever));
task_set_running(false); // interrupt task with boolean as flag task_set_running(false); // interrupt task with boolean as flag
lvgl_unlock(); lvgl_unlock();
} }
@ -73,7 +73,7 @@ void lvgl_task_start() {
task_mutex = xSemaphoreCreateRecursiveMutex(); task_mutex = xSemaphoreCreateRecursiveMutex();
} }
tt_lvgl_sync_set(&lvgl_lock, &lvgl_unlock); tt::lvgl::sync_set(&lvgl_lock, &lvgl_unlock);
// Create the main app loop, like ESP-IDF // Create the main app loop, like ESP-IDF
BaseType_t task_result = xTaskCreate( BaseType_t task_result = xTaskCreate(
@ -81,7 +81,7 @@ void lvgl_task_start() {
"lvgl", "lvgl",
8192, 8192,
NULL, NULL,
ThreadPriorityHigh, // Should be higher than main app task tt::ThreadPriorityHigh, // Should be higher than main app task
NULL NULL
); );

View File

@ -1,15 +1,5 @@
#pragma once #pragma once
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
void lvgl_task_start(); void lvgl_task_start();
bool lvgl_task_is_running(); bool lvgl_task_is_running();
void lvgl_task_interrupt(); void lvgl_task_interrupt();
#ifdef __cplusplus
}
#endif

17
AppSim/Source/main.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "Tactility.h"
extern const tt::hal::Configuration sim_hardware;
extern const tt::AppManifest hello_world_app;
void app_main() {
static const tt::Configuration config = {
.hardware = &sim_hardware,
.apps = {
&hello_world_app
},
.services = {},
.auto_start_app_id = nullptr
};
tt::init(&config);
}

View File

@ -1,8 +1,4 @@
#include "power.h" #include "Hal/Power.h"
#ifdef __cplusplus
extern "C" {
#endif
static bool is_charging_enabled = false; static bool is_charging_enabled = false;
@ -26,14 +22,10 @@ static int32_t power_get_current() {
return is_charging_enabled ? 100 : -50; return is_charging_enabled ? 100 : -50;
} }
const Power power = { extern const tt::hal::Power power = {
.is_charging = &power_is_charging, .is_charging = &power_is_charging,
.is_charging_enabled = &power_is_charging_enabled, .is_charging_enabled = &power_is_charging_enabled,
.set_charging_enabled = &power_set_charging_enabled, .set_charging_enabled = &power_set_charging_enabled,
.get_charge_level = &power_get_charge_level, .get_charge_level = &power_get_charge_level,
.get_current = &power_get_current .get_current = &power_get_current
}; };
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
idf_component_register( idf_component_register(
SRC_DIRS "." SRC_DIRS "."
INCLUDE_DIRS "." INCLUDE_DIRS "."
REQUIRES tactility esp_lvgl_port esp_lcd esp_lcd_touch_gt911 driver vfs fatfs REQUIRES Tactility esp_lvgl_port esp_lcd esp_lcd_touch_gt911 driver vfs fatfs
) )

View File

@ -2,7 +2,7 @@
#include "display_i.h" #include "display_i.h"
#include "driver/spi_common.h" #include "driver/spi_common.h"
#include "keyboard.h" #include "keyboard.h"
#include "tactility_core.h" #include "TactilityCore.h"
#define TAG "tdeck_bootstrap" #define TAG "tdeck_bootstrap"
@ -30,10 +30,12 @@ static bool init_i2c() {
const i2c_config_t i2c_conf = { const i2c_config_t i2c_conf = {
.mode = I2C_MODE_MASTER, .mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_18, .sda_io_num = GPIO_NUM_18,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_io_num = GPIO_NUM_8, .scl_io_num = GPIO_NUM_8,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_pullup_en = GPIO_PULLUP_DISABLE, .scl_pullup_en = GPIO_PULLUP_DISABLE,
.master.clk_speed = 400000 .master = {
.clk_speed = 400000
}
}; };
return i2c_param_config(TDECK_I2C_BUS_HANDLE, &i2c_conf) == ESP_OK && i2c_driver_install(TDECK_I2C_BUS_HANDLE, i2c_conf.mode, 0, 0, 0) == ESP_OK; return i2c_param_config(TDECK_I2C_BUS_HANDLE, &i2c_conf) == ESP_OK && i2c_driver_install(TDECK_I2C_BUS_HANDLE, i2c_conf.mode, 0, 0, 0) == ESP_OK;
@ -41,9 +43,9 @@ static bool init_i2c() {
static bool init_spi() { static bool init_spi() {
spi_bus_config_t bus_config = { spi_bus_config_t bus_config = {
.sclk_io_num = TDECK_SPI_PIN_SCLK,
.mosi_io_num = TDECK_SPI_PIN_MOSI, .mosi_io_num = TDECK_SPI_PIN_MOSI,
.miso_io_num = TDECK_SPI_PIN_MISO, .miso_io_num = TDECK_SPI_PIN_MISO,
.sclk_io_num = TDECK_SPI_PIN_SCLK,
.quadwp_io_num = -1, // Quad SPI LCD driver is not yet supported .quadwp_io_num = -1, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = -1, // Quad SPI LCD driver is not yet supported .quadhd_io_num = -1, // Quad SPI LCD driver is not yet supported
.max_transfer_sz = TDECK_SPI_TRANSFER_SIZE_LIMIT, .max_transfer_sz = TDECK_SPI_TRANSFER_SIZE_LIMIT,
@ -72,7 +74,7 @@ bool tdeck_bootstrap() {
* It doesn't work, because it never recovers from the error. * It doesn't work, because it never recovers from the error.
*/ */
TT_LOG_I(TAG, "Waiting after power-on"); TT_LOG_I(TAG, "Waiting after power-on");
tt_delay_ms(TDECK_POWERON_DELAY); tt::delay_ms(TDECK_POWERON_DELAY);
TT_LOG_I(TAG, "Init I2C"); TT_LOG_I(TAG, "Init I2C");
if (!init_i2c()) { if (!init_i2c()) {

View File

@ -4,7 +4,7 @@
#include "driver/gpio.h" #include "driver/gpio.h"
// Main bus, used by GT911 touch hardware and keyboard // Main bus, used by GT911 touch hardware and keyboard
#define TDECK_I2C_BUS_HANDLE (0) #define TDECK_I2C_BUS_HANDLE I2C_NUM_0
// SPI // SPI
#define TDECK_SPI_HOST SPI2_HOST #define TDECK_SPI_HOST SPI2_HOST

View File

@ -5,15 +5,15 @@
#include "esp_lcd_panel_ops.h" #include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_vendor.h" #include "esp_lcd_panel_vendor.h"
#include "esp_lvgl_port.h" #include "esp_lvgl_port.h"
#include "log.h" #include "Log.h"
#define TAG "tdeck_display" #define TAG "tdeck_display"
bool tdeck_backlight_init() { bool tdeck_backlight_init() {
ledc_timer_config_t ledc_timer = { ledc_timer_config_t ledc_timer = {
.speed_mode = TDECK_LCD_BACKLIGHT_LEDC_MODE, .speed_mode = TDECK_LCD_BACKLIGHT_LEDC_MODE,
.timer_num = TDECK_LCD_BACKLIGHT_LEDC_TIMER,
.duty_resolution = TDECK_LCD_BACKLIGHT_LEDC_DUTY_RES, .duty_resolution = TDECK_LCD_BACKLIGHT_LEDC_DUTY_RES,
.timer_num = TDECK_LCD_BACKLIGHT_LEDC_TIMER,
.freq_hz = TDECK_LCD_BACKLIGHT_LEDC_FREQUENCY, .freq_hz = TDECK_LCD_BACKLIGHT_LEDC_FREQUENCY,
.clk_cfg = LEDC_AUTO_CLK .clk_cfg = LEDC_AUTO_CLK
}; };
@ -28,11 +28,11 @@ bool tdeck_backlight_init() {
void tdeck_backlight_set(uint8_t duty) { void tdeck_backlight_set(uint8_t duty) {
ledc_channel_config_t ledc_channel = { ledc_channel_config_t ledc_channel = {
.gpio_num = TDECK_LCD_PIN_BACKLIGHT,
.speed_mode = TDECK_LCD_BACKLIGHT_LEDC_MODE, .speed_mode = TDECK_LCD_BACKLIGHT_LEDC_MODE,
.channel = TDECK_LCD_BACKLIGHT_LEDC_CHANNEL, .channel = TDECK_LCD_BACKLIGHT_LEDC_CHANNEL,
.timer_sel = TDECK_LCD_BACKLIGHT_LEDC_TIMER,
.intr_type = LEDC_INTR_DISABLE, .intr_type = LEDC_INTR_DISABLE,
.gpio_num = TDECK_LCD_PIN_BACKLIGHT, .timer_sel = TDECK_LCD_BACKLIGHT_LEDC_TIMER,
.duty = duty, .duty = duty,
.hpoint = 0 .hpoint = 0
}; };
@ -51,8 +51,8 @@ lv_display_t* tdeck_display_init() {
.spi_mode = 0, .spi_mode = 0,
.pclk_hz = TDECK_LCD_SPI_FREQUENCY, .pclk_hz = TDECK_LCD_SPI_FREQUENCY,
.trans_queue_depth = 10, .trans_queue_depth = 10,
.on_color_trans_done = NULL, .on_color_trans_done = nullptr,
.user_ctx = NULL, .user_ctx = nullptr,
.lcd_cmd_bits = 8, .lcd_cmd_bits = 8,
.lcd_param_bits = 8, .lcd_param_bits = 8,
.flags = { .flags = {
@ -68,7 +68,7 @@ lv_display_t* tdeck_display_init() {
esp_lcd_panel_io_handle_t io_handle; esp_lcd_panel_io_handle_t io_handle;
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TDECK_LCD_SPI_HOST, &panel_io_config, &io_handle) != ESP_OK) { if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TDECK_LCD_SPI_HOST, &panel_io_config, &io_handle) != ESP_OK) {
TT_LOG_E(TAG, "failed to create panel IO"); TT_LOG_E(TAG, "failed to create panel IO");
return false; return nullptr;
} }
const esp_lcd_panel_dev_config_t panel_config = { const esp_lcd_panel_dev_config_t panel_config = {
@ -79,43 +79,43 @@ lv_display_t* tdeck_display_init() {
.flags = { .flags = {
.reset_active_high = 0 .reset_active_high = 0
}, },
.vendor_config = NULL .vendor_config = nullptr
}; };
esp_lcd_panel_handle_t panel_handle; esp_lcd_panel_handle_t panel_handle;
if (esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle) != ESP_OK) { if (esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "failed to create panel"); TT_LOG_E(TAG, "failed to create panel");
return false; return nullptr;
} }
if (esp_lcd_panel_reset(panel_handle) != ESP_OK) { if (esp_lcd_panel_reset(panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "failed to reset panel"); TT_LOG_E(TAG, "failed to reset panel");
return false; return nullptr;
} }
if (esp_lcd_panel_init(panel_handle) != ESP_OK) { if (esp_lcd_panel_init(panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "failed to init panel"); TT_LOG_E(TAG, "failed to init panel");
return false; return nullptr;
} }
if (esp_lcd_panel_invert_color(panel_handle, true) != ESP_OK) { if (esp_lcd_panel_invert_color(panel_handle, true) != ESP_OK) {
TT_LOG_E(TAG, "failed to init panel"); TT_LOG_E(TAG, "failed to init panel");
return false; return nullptr;
} }
if (esp_lcd_panel_swap_xy(panel_handle, true) != ESP_OK) { if (esp_lcd_panel_swap_xy(panel_handle, true) != ESP_OK) {
TT_LOG_E(TAG, "failed to init panel"); TT_LOG_E(TAG, "failed to init panel");
return false; return nullptr;
} }
if (esp_lcd_panel_mirror(panel_handle, true, false) != ESP_OK) { if (esp_lcd_panel_mirror(panel_handle, true, false) != ESP_OK) {
TT_LOG_E(TAG, "failed to init panel"); TT_LOG_E(TAG, "failed to init panel");
return false; return nullptr;
} }
if (esp_lcd_panel_disp_on_off(panel_handle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panel_handle, true) != ESP_OK) {
TT_LOG_E(TAG, "failed to turn display on"); TT_LOG_E(TAG, "failed to turn display on");
return false; return nullptr;
} }
const lvgl_port_display_cfg_t disp_cfg = { const lvgl_port_display_cfg_t disp_cfg = {
@ -139,7 +139,5 @@ lv_display_t* tdeck_display_init() {
} }
}; };
lv_display_t* display = lvgl_port_add_disp(&disp_cfg); return lvgl_port_add_disp(&disp_cfg);
return display;
} }

View File

@ -0,0 +1,9 @@
#pragma once
#include "lvgl.h"
lv_display_t* tdeck_display_init();
bool tdeck_backlight_init();
void tdeck_backlight_set(uint8_t duty);

View File

@ -1,8 +1,8 @@
#include "keyboard.h" #include "keyboard.h"
#include "config.h" #include "config.h"
#include "lvgl.h" #include "lvgl.h"
#include "tactility_core.h" #include "TactilityCore.h"
#include "ui/lvgl_keypad.h" #include "Ui/LvglKeypad.h"
#include <driver/i2c.h> #include <driver/i2c.h>
#define TAG "tdeck_keyboard" #define TAG "tdeck_keyboard"
@ -28,7 +28,7 @@ void keyboard_wait_for_response() {
do { do {
awake = keyboard_i2c_read(&read_buffer) == ESP_OK; awake = keyboard_i2c_read(&read_buffer) == ESP_OK;
if (!awake) { if (!awake) {
tt_delay_ms(100); tt::delay_ms(100);
} }
} while (!awake); } while (!awake);
TT_LOG_I(TAG, "Keyboard responded"); TT_LOG_I(TAG, "Keyboard responded");
@ -67,20 +67,20 @@ static void keyboard_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t*
} }
Keyboard keyboard_alloc(_Nullable lv_disp_t* display) { Keyboard keyboard_alloc(_Nullable lv_disp_t* display) {
KeyboardData* data = malloc(sizeof(KeyboardData)); auto* data = static_cast<KeyboardData*>(malloc(sizeof(KeyboardData)));
data->device = lv_indev_create(); data->device = lv_indev_create();
lv_indev_set_type(data->device, LV_INDEV_TYPE_KEYPAD); lv_indev_set_type(data->device, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(data->device, &keyboard_read_callback); lv_indev_set_read_cb(data->device, &keyboard_read_callback);
lv_indev_set_display(data->device, display); lv_indev_set_display(data->device, display);
tt_lvgl_keypad_set_indev(data->device); tt::lvgl::keypad_set_indev(data->device);
return data; return data;
} }
void keyboard_free(Keyboard keyboard) { void keyboard_free(Keyboard keyboard) {
KeyboardData* data = (KeyboardData*)keyboard; auto* data = static_cast<KeyboardData*>(keyboard);
lv_indev_delete(data->device); lv_indev_delete(data->device);
free(data); free(data);
} }

View File

@ -2,17 +2,9 @@
#include "lvgl.h" #include "lvgl.h"
#ifdef __cplusplus
extern "C" {
#endif
void keyboard_wait_for_response(); void keyboard_wait_for_response();
typedef void* Keyboard; typedef void* Keyboard;
Keyboard keyboard_alloc(_Nullable lv_disp_t* display); Keyboard keyboard_alloc(_Nullable lv_disp_t* display);
void keyboard_free(Keyboard keyboard); void keyboard_free(Keyboard keyboard);
#ifdef __cplusplus
}
#endif

View File

@ -1,18 +1,17 @@
#include "lilygo_tdeck.h" #include "lilygo_tdeck.h"
#include "display_i.h" #include "display_i.h"
#include <stdbool.h>
bool tdeck_bootstrap(); bool tdeck_bootstrap();
bool tdeck_init_lvgl(); bool tdeck_init_lvgl();
extern const SdCard tdeck_sdcard; extern const tt::hal::sdcard::SdCard tdeck_sdcard;
const HardwareConfig lilygo_tdeck = { extern const tt::hal::Configuration lilygo_tdeck = {
.bootstrap = &tdeck_bootstrap, .bootstrap = &tdeck_bootstrap,
.init_graphics = &tdeck_init_lvgl,
.display = { .display = {
.set_backlight_duty = &tdeck_backlight_set .set_backlight_duty = &tdeck_backlight_set
}, },
.init_graphics = &tdeck_init_lvgl,
.sdcard = &tdeck_sdcard, .sdcard = &tdeck_sdcard,
.power = NULL .power = nullptr
}; };

View File

@ -0,0 +1,5 @@
#pragma once
#include "Hal/Configuration.h"
extern const tt::hal::Configuration lilygo_tdeck;

View File

@ -2,21 +2,21 @@
#include "display_i.h" #include "display_i.h"
#include "esp_lvgl_port.h" #include "esp_lvgl_port.h"
#include "keyboard.h" #include "keyboard.h"
#include "log.h" #include "Log.h"
#include "ui/lvgl_sync.h" #include "Ui/LvglSync.h"
#include "thread.h" #include "Thread.h"
#define TAG "tdeck_lvgl" #define TAG "tdeck_lvgl"
bool tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle); bool tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle);
bool tdeck_init_lvgl() { bool tdeck_init_lvgl() {
static lv_disp_t* display = NULL; static lv_disp_t* display = nullptr;
static esp_lcd_panel_io_handle_t touch_io_handle; static esp_lcd_panel_io_handle_t touch_io_handle;
static esp_lcd_touch_handle_t touch_handle; static esp_lcd_touch_handle_t touch_handle;
const lvgl_port_cfg_t lvgl_cfg = { const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = THREAD_PRIORITY_RENDER, .task_priority = tt::THREAD_PRIORITY_RENDER,
.task_stack = TDECK_LVGL_TASK_STACK_DEPTH, .task_stack = TDECK_LVGL_TASK_STACK_DEPTH,
.task_affinity = -1, // core pinning .task_affinity = -1, // core pinning
.task_max_sleep_ms = 500, .task_max_sleep_ms = 500,
@ -33,7 +33,7 @@ bool tdeck_init_lvgl() {
TT_LOG_D(TAG, "Creating display"); TT_LOG_D(TAG, "Creating display");
display = tdeck_display_init(); display = tdeck_display_init();
if (display == NULL) { if (display == nullptr) {
TT_LOG_E(TAG, "Creating display failed"); TT_LOG_E(TAG, "Creating display failed");
return false; return false;
} }
@ -53,13 +53,13 @@ bool tdeck_init_lvgl() {
TT_LOG_D(TAG, "Adding touch"); TT_LOG_D(TAG, "Adding touch");
lv_indev_t _Nullable* touch_indev = lvgl_port_add_touch(&touch_cfg); lv_indev_t _Nullable* touch_indev = lvgl_port_add_touch(&touch_cfg);
if (touch_indev == NULL) { if (touch_indev == nullptr) {
TT_LOG_E(TAG, "Adding touch failed"); TT_LOG_E(TAG, "Adding touch failed");
return false; return false;
} }
// Set syncing functions // Set syncing functions
tt_lvgl_sync_set(&lvgl_port_lock, &lvgl_port_unlock); tt::lvgl::sync_set(&lvgl_port_lock, &lvgl_port_unlock);
keyboard_alloc(display); keyboard_alloc(display);

View File

@ -1,11 +1,11 @@
#include "sdcard.h" #include "Hal/Sdcard.h"
#include "check.h" #include "Check.h"
#include "log.h" #include "Log.h"
#include "config.h" #include "config.h"
#include "esp_vfs_fat.h" #include "esp_vfs_fat.h"
#include "sdmmc_cmd.h" #include "sdmmc_cmd.h"
#include "ui/lvgl_sync.h" #include "Ui/LvglSync.h"
#define TAG "tdeck_sdcard" #define TAG "tdeck_sdcard"
@ -88,10 +88,10 @@ static void* _Nullable sdcard_mount(const char* mount_point) {
return NULL; return NULL;
} }
MountData* data = malloc(sizeof(MountData)); auto* data = static_cast<MountData*>(malloc(sizeof(MountData)));
*data = (MountData) { *data = (MountData) {
.mount_point = mount_point,
.card = card, .card = card,
.mount_point = mount_point
}; };
return data; return data;
@ -102,10 +102,10 @@ static void* sdcard_init_and_mount(const char* mount_point) {
TT_LOG_E(TAG, "Failed to set SPI CS pins high. This is a pre-requisite for mounting."); TT_LOG_E(TAG, "Failed to set SPI CS pins high. This is a pre-requisite for mounting.");
return NULL; return NULL;
} }
MountData* data = sdcard_mount(mount_point); auto* data = static_cast<MountData*>(sdcard_mount(mount_point));
if (data == NULL) { if (data == nullptr) {
TT_LOG_E(TAG, "Mount failed for %s", mount_point); TT_LOG_E(TAG, "Mount failed for %s", mount_point);
return NULL; return nullptr;
} }
sdmmc_card_print_info(stdout, data->card); sdmmc_card_print_info(stdout, data->card);
@ -114,10 +114,10 @@ static void* sdcard_init_and_mount(const char* mount_point) {
} }
static void sdcard_unmount(void* context) { static void sdcard_unmount(void* context) {
MountData* data = (MountData*)context; auto* data = static_cast<MountData*>(context);
TT_LOG_I(TAG, "Unmounting %s", data->mount_point); TT_LOG_I(TAG, "Unmounting %s", data->mount_point);
tt_assert(data != NULL); tt_assert(data != nullptr);
if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) { if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) {
TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point); TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point);
} }
@ -126,24 +126,24 @@ static void sdcard_unmount(void* context) {
} }
static bool sdcard_is_mounted(void* context) { static bool sdcard_is_mounted(void* context) {
MountData* data = (MountData*)context; auto* data = static_cast<MountData*>(context);
/** /**
* The SD card and the screen are on the same SPI bus. * The SD card and the screen are on the same SPI bus.
* Writing and reading to the bus from 2 devices at the same time causes crashes. * Writing and reading to the bus from 2 devices at the same time causes crashes.
* This work-around ensures that this check is only happening when LVGL isn't rendering. * This work-around ensures that this check is only happening when LVGL isn't rendering.
*/ */
if (tt_lvgl_lock(100)) { if (tt::lvgl::lock(100)) {
bool result = (data != NULL) && (sdmmc_get_status(data->card) == ESP_OK); bool result = (data != nullptr) && (sdmmc_get_status(data->card) == ESP_OK);
tt_lvgl_unlock(); tt::lvgl::unlock();
return result; return result;
} else { } else {
return false; return false;
} }
} }
const SdCard tdeck_sdcard = { extern const tt::hal::sdcard::SdCard tdeck_sdcard = {
.mount = &sdcard_init_and_mount, .mount = &sdcard_init_and_mount,
.unmount = &sdcard_unmount, .unmount = &sdcard_unmount,
.is_mounted = &sdcard_is_mounted, .is_mounted = &sdcard_is_mounted,
.mount_behaviour = SdcardMountBehaviourAtBoot .mount_behaviour = tt::hal::sdcard::MountBehaviourAtBoot
}; };

View File

@ -2,13 +2,22 @@
#include "esp_err.h" #include "esp_err.h"
#include "esp_lcd_panel_io_interface.h" #include "esp_lcd_panel_io_interface.h"
#include "esp_lcd_touch_gt911.h" #include "esp_lcd_touch_gt911.h"
#include "log.h" #include "Log.h"
#include <kernel.h> #include "Kernel.h"
#define TAG "tdeck_touch" #define TAG "tdeck_touch"
bool tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) { bool tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) {
const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
// TODO: Revert on new ESP-IDF version
static_assert(ESP_IDF_VERSION == ESP_IDF_VERSION_VAL(5, 3, 1));
esp_lcd_new_panel_io_i2c(
(esp_lcd_i2c_bus_handle_t)TDECK_TOUCH_I2C_BUS_HANDLE,
&touch_io_config,
io_handle
);
/*
if ( if (
esp_lcd_new_panel_io_i2c( esp_lcd_new_panel_io_i2c(
(esp_lcd_i2c_bus_handle_t)TDECK_TOUCH_I2C_BUS_HANDLE, (esp_lcd_i2c_bus_handle_t)TDECK_TOUCH_I2C_BUS_HANDLE,
@ -19,6 +28,7 @@ bool tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle
TT_LOG_E(TAG, "touch io i2c creation failed"); TT_LOG_E(TAG, "touch io i2c creation failed");
return false; return false;
} }
*/
esp_lcd_touch_config_t config = { esp_lcd_touch_config_t config = {
.x_max = TDECK_TOUCH_X_MAX, .x_max = TDECK_TOUCH_X_MAX,
@ -34,9 +44,9 @@ bool tdeck_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle
.mirror_x = 1, .mirror_x = 1,
.mirror_y = 0, .mirror_y = 0,
}, },
.process_coordinates = NULL, .process_coordinates = nullptr,
.interrupt_callback = NULL, .interrupt_callback = nullptr,
.user_data = NULL .user_data = nullptr
}; };
if (esp_lcd_touch_new_i2c_gt911(*io_handle, &config, touch_handle) != ESP_OK) { if (esp_lcd_touch_new_i2c_gt911(*io_handle, &config, touch_handle) != ESP_OK) {

View File

@ -0,0 +1,5 @@
idf_component_register(
SRC_DIRS "Source"
INCLUDE_DIRS "Source"
REQUIRES Tactility M5stackShared vfs fatfs M5Unified
)

View File

@ -1,14 +1,14 @@
#include "m5stack_core2.h" #include "M5stackCore2.h"
#include "m5stack_shared.h" #include "m5stack_shared.h"
extern const SdCard m5stack_core2_sdcard; extern const tt::hal::sdcard::SdCard m5stack_core2_sdcard;
const HardwareConfig m5stack_core2 = { extern const tt::hal::Configuration m5stack_core2 = {
.bootstrap = &m5stack_bootstrap, .bootstrap = &m5stack_bootstrap,
.display = {
.set_backlight_duty = NULL
},
.init_graphics = &m5stack_lvgl_init, .init_graphics = &m5stack_lvgl_init,
.display = {
.set_backlight_duty = nullptr
},
.sdcard = &m5stack_core2_sdcard, .sdcard = &m5stack_core2_sdcard,
.power = &m5stack_power .power = &m5stack_power
}; };

View File

@ -0,0 +1,5 @@
#pragma once
#include "Hal/Configuration.h"
extern const tt::hal::Configuration m5stack_core2;

View File

@ -1,13 +1,20 @@
#include "sdcard.h" #include "Check.h"
#include "check.h" #include "Log.h"
#include "log.h" #include "Hal/Sdcard.h"
#include "config.h"
#include "esp_vfs_fat.h" #include "esp_vfs_fat.h"
#include "sdmmc_cmd.h" #include "sdmmc_cmd.h"
#define TAG "m5stack_core2_sdcard" #define TAG "m5stack_core2_sdcard"
#define CORE2_SDCARD_SPI_HOST SPI2_HOST
#define CORE2_SDCARD_PIN_CS GPIO_NUM_4
#define CORE2_SDCARD_SPI_FREQUENCY 800000U
#define CORE2_SDCARD_FORMAT_ON_MOUNT_FAILED false
#define CORE2_SDCARD_MAX_OPEN_FILES 4
#define CORE2_SDCARD_ALLOC_UNIT_SIZE (16 * 1024)
#define CORE2_SDCARD_STATUS_CHECK_ENABLED false
typedef struct { typedef struct {
const char* mount_point; const char* mount_point;
sdmmc_card_t* card; sdmmc_card_t* card;
@ -40,13 +47,13 @@ static void* sdcard_mount(const char* mount_point) {
} else { } else {
TT_LOG_E(TAG, "Mounting failed (%s)", esp_err_to_name(ret)); TT_LOG_E(TAG, "Mounting failed (%s)", esp_err_to_name(ret));
} }
return NULL; return nullptr;
} }
MountData* data = malloc(sizeof(MountData)); auto* data = static_cast<MountData*>(malloc(sizeof(MountData)));
*data = (MountData) { *data = (MountData) {
.mount_point = mount_point,
.card = card, .card = card,
.mount_point = mount_point
}; };
sdmmc_card_print_info(stdout, data->card); sdmmc_card_print_info(stdout, data->card);
@ -55,10 +62,10 @@ static void* sdcard_mount(const char* mount_point) {
} }
static void sdcard_unmount(void* context) { static void sdcard_unmount(void* context) {
MountData* data = (MountData*)context; auto* data = static_cast<MountData*>(context);
TT_LOG_I(TAG, "Unmounting %s", data->mount_point); TT_LOG_I(TAG, "Unmounting %s", data->mount_point);
tt_assert(data != NULL); tt_assert(data != nullptr);
if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) { if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) {
TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point); TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point);
} }
@ -67,13 +74,13 @@ static void sdcard_unmount(void* context) {
} }
static bool sdcard_is_mounted(void* context) { static bool sdcard_is_mounted(void* context) {
MountData* data = (MountData*)context; auto* data = static_cast<MountData*>(context);
return (data != NULL) && (sdmmc_get_status(data->card) == ESP_OK); return (data != nullptr) && (sdmmc_get_status(data->card) == ESP_OK);
} }
const SdCard m5stack_core2_sdcard = { extern const tt::hal::sdcard::SdCard m5stack_core2_sdcard = {
.mount = &sdcard_mount, .mount = &sdcard_mount,
.unmount = &sdcard_unmount, .unmount = &sdcard_unmount,
.is_mounted = &sdcard_is_mounted, .is_mounted = &sdcard_is_mounted,
.mount_behaviour = SdcardMountBehaviourAnytime .mount_behaviour = tt::hal::sdcard::MountBehaviourAnytime
}; };

View File

@ -0,0 +1,6 @@
idf_component_register(
SRC_DIRS "Source"
INCLUDE_DIRS "Source"
PRIV_INCLUDE_DIRS "Private"
REQUIRES Tactility M5stackShared vfs fatfs M5Unified
)

View File

@ -1,14 +1,14 @@
#include "m5stack_cores3.h" #include "m5stack_cores3.h"
#include "m5stack_shared.h" #include "m5stack_shared.h"
extern const SdCard m5stack_cores3_sdcard; extern const tt::hal::sdcard::SdCard m5stack_cores3_sdcard;
const HardwareConfig m5stack_cores3 = { const tt::hal::Configuration m5stack_cores3 = {
.bootstrap = &m5stack_bootstrap, .bootstrap = &m5stack_bootstrap,
.display = {
.set_backlight_duty = NULL
},
.init_graphics = &m5stack_lvgl_init, .init_graphics = &m5stack_lvgl_init,
.display = {
.set_backlight_duty = nullptr
},
.sdcard = &m5stack_cores3_sdcard, .sdcard = &m5stack_cores3_sdcard,
.power = &m5stack_power .power = &m5stack_power
}; };

View File

@ -0,0 +1,5 @@
#pragma once
#include "Hal/Configuration.h"
extern const tt::hal::Configuration m5stack_cores3;

View File

@ -1,6 +1,6 @@
#include "sdcard.h" #include "Hal/Sdcard.h"
#include "check.h" #include "Check.h"
#include "log.h" #include "Log.h"
#include "config.h" #include "config.h"
#include "esp_vfs_fat.h" #include "esp_vfs_fat.h"
@ -40,13 +40,13 @@ static void* sdcard_mount(const char* mount_point) {
} else { } else {
TT_LOG_E(TAG, "Mounting failed (%s)", esp_err_to_name(ret)); TT_LOG_E(TAG, "Mounting failed (%s)", esp_err_to_name(ret));
} }
return NULL; return nullptr;
} }
MountData* data = malloc(sizeof(MountData)); auto* data = static_cast<MountData*>(malloc(sizeof(MountData)));
*data = (MountData) { *data = (MountData) {
.card = card, .mount_point = mount_point,
.mount_point = mount_point .card = card
}; };
sdmmc_card_print_info(stdout, data->card); sdmmc_card_print_info(stdout, data->card);
@ -55,10 +55,10 @@ static void* sdcard_mount(const char* mount_point) {
} }
static void sdcard_unmount(void* context) { static void sdcard_unmount(void* context) {
MountData* data = (MountData*)context; auto* data = static_cast<MountData*>(context);
TT_LOG_I(TAG, "Unmounting %s", data->mount_point); TT_LOG_I(TAG, "Unmounting %s", data->mount_point);
tt_assert(data != NULL); tt_assert(data != nullptr);
if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) { if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) {
TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point); TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point);
} }
@ -67,13 +67,13 @@ static void sdcard_unmount(void* context) {
} }
static bool sdcard_is_mounted(void* context) { static bool sdcard_is_mounted(void* context) {
MountData* data = (MountData*)context; auto* data = static_cast<MountData*>(context);
return (data != NULL) && (sdmmc_get_status(data->card) == ESP_OK); return (data != nullptr) && (sdmmc_get_status(data->card) == ESP_OK);
} }
const SdCard m5stack_cores3_sdcard = { extern const tt::hal::sdcard::SdCard m5stack_cores3_sdcard = {
.mount = &sdcard_mount, .mount = &sdcard_mount,
.unmount = &sdcard_unmount, .unmount = &sdcard_unmount,
.is_mounted = &sdcard_is_mounted, .is_mounted = &sdcard_is_mounted,
.mount_behaviour = SdcardMountBehaviourAnytime .mount_behaviour = tt::hal::sdcard::MountBehaviourAnytime
}; };

View File

@ -0,0 +1,5 @@
idf_component_register(
SRC_DIRS "Source"
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port M5Unified
)

View File

@ -1,9 +1,5 @@
#include "M5Unified.hpp" #include "M5Unified.hpp"
#include "log.h" #include "Log.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TAG "m5stack_bootstrap" #define TAG "m5stack_bootstrap"
@ -12,7 +8,3 @@ bool m5stack_bootstrap() {
M5.begin(); M5.begin();
return true; return true;
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,18 +1,18 @@
#include "esp_lvgl_port.h" #include "esp_lvgl_port.h"
#include "log.h" #include "Log.h"
#include "thread.h" #include "Thread.h"
#include "ui/lvgl_sync.h" #include "Ui/LvglSync.h"
#define TAG "cores3_lvgl" #define TAG "cores3_lvgl"
extern _Nullable lv_disp_t* m5stack_lvgl_display(bool usePsram); _Nullable lv_disp_t* m5stack_lvgl_display(bool usePsram);
extern _Nullable lv_indev_t* m5stack_lvgl_touch(); _Nullable lv_indev_t* m5stack_lvgl_touch();
bool m5stack_lvgl_init() { bool m5stack_lvgl_init() {
static lv_display_t* display = NULL; static lv_display_t* display = nullptr;
const lvgl_port_cfg_t lvgl_cfg = { const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = ThreadPriorityHigh, .task_priority = tt::ThreadPriorityHigh,
.task_stack = 8096, .task_stack = 8096,
.task_affinity = -1, // core pinning .task_affinity = -1, // core pinning
.task_max_sleep_ms = 500, .task_max_sleep_ms = 500,
@ -26,21 +26,21 @@ bool m5stack_lvgl_init() {
// Add display // Add display
display = m5stack_lvgl_display(true); display = m5stack_lvgl_display(true);
if (display == NULL) { if (display == nullptr) {
TT_LOG_E(TAG, "failed to add display"); TT_LOG_E(TAG, "failed to add display");
return false; return false;
} }
// Add touch // Add touch
lv_indev_t* touch_indev = m5stack_lvgl_touch(); lv_indev_t* touch_indev = m5stack_lvgl_touch();
if (touch_indev == NULL) { if (touch_indev == nullptr) {
TT_LOG_E(TAG, "failed to add touch"); TT_LOG_E(TAG, "failed to add touch");
return false; return false;
} }
lv_indev_set_display(touch_indev, display); lv_indev_set_display(touch_indev, display);
// Set syncing functions // Set syncing functions
tt_lvgl_sync_set(&lvgl_port_lock, &lvgl_port_unlock); tt::lvgl::sync_set(&lvgl_port_lock, &lvgl_port_unlock);
return true; return true;
} }

View File

@ -1,13 +1,9 @@
#include "tactility_core.h" #include "TactilityCore.h"
#include "M5Unified.hpp" #include "M5Unified.hpp"
#include "esp_err.h" #include "esp_err.h"
#include "esp_lvgl_port.h" #include "esp_lvgl_port.h"
#ifdef __cplusplus
extern "C" {
#endif
static void flush_callback(lv_display_t* display, const lv_area_t* area, uint8_t* px_map) { static void flush_callback(lv_display_t* display, const lv_area_t* area, uint8_t* px_map) {
M5GFX& gfx = *(M5GFX*)lv_display_get_driver_data(display); M5GFX& gfx = *(M5GFX*)lv_display_get_driver_data(display);
@ -63,7 +59,3 @@ _Nullable lv_disp_t* m5stack_lvgl_display(bool usePsram) {
return display; return display;
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,13 +1,9 @@
#include "M5Unified.hpp" #include "M5Unified.hpp"
#include "lvgl.h" #include "lvgl.h"
#include "tactility_core.h" #include "TactilityCore.h"
#define TAG "cores3_touch" #define TAG "cores3_touch"
#ifdef __cplusplus
extern "C" {
#endif
static void touch_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t* data) { static void touch_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t* data) {
lgfx::touch_point_t point; // Making it static makes it unreliable lgfx::touch_point_t point; // Making it static makes it unreliable
bool touched = M5.Lcd.getTouch(&point) > 0; bool touched = M5.Lcd.getTouch(&point) > 0;
@ -31,7 +27,3 @@ _Nullable lv_indev_t* m5stack_lvgl_touch() {
lv_indev_set_read_cb(indev, touch_read_callback); lv_indev_set_read_cb(indev, touch_read_callback);
return indev; return indev;
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,10 +1,6 @@
#include "power.h" #include "Hal/Power.h"
#include "M5Unified.hpp" #include "M5Unified.hpp"
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* M5.Power by default doesn't have a check to see if charging is enabled. * M5.Power by default doesn't have a check to see if charging is enabled.
* However, it's always enabled by default after boot, so we cover that here: * However, it's always enabled by default after boot, so we cover that here:
@ -33,14 +29,10 @@ static int32_t power_get_current() {
return M5.Power.getBatteryCurrent(); return M5.Power.getBatteryCurrent();
} }
Power m5stack_power = { extern const tt::hal::Power m5stack_power = {
.is_charging = &power_is_charging, .is_charging = &power_is_charging,
.is_charging_enabled = &power_is_charging_enabled, .is_charging_enabled = &power_is_charging_enabled,
.set_charging_enabled = &power_set_charging_enabled, .set_charging_enabled = &power_set_charging_enabled,
.get_charge_level = &power_get_charge_level, .get_charge_level = &power_get_charge_level,
.get_current = &power_get_current .get_current = &power_get_current
}; };
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,9 @@
#pragma once
#include "Hal/Power.h"
#include "Hal/Sdcard.h"
extern bool m5stack_lvgl_init();
extern bool m5stack_bootstrap();
extern const tt::hal::Power m5stack_power;

View File

@ -1,5 +1,5 @@
idf_component_register( idf_component_register(
SRC_DIRS "." SRC_DIRS "."
INCLUDE_DIRS "." INCLUDE_DIRS "."
REQUIRES tactility lvgl esp_lcd esp_lcd_touch_gt911 REQUIRES Tactility lvgl esp_lcd esp_lcd_touch_gt911
) )

View File

@ -1,5 +1,5 @@
#include "config.h" #include "config.h"
#include "tactility_core.h" #include "TactilityCore.h"
#include <driver/i2c.h> #include <driver/i2c.h>
#define TAG "waveshare_bootstrap" #define TAG "waveshare_bootstrap"
@ -7,14 +7,16 @@
#define WAVESHARE_I2C_MASTER_TX_BUF_DISABLE 0 #define WAVESHARE_I2C_MASTER_TX_BUF_DISABLE 0
#define WAVESHARE_I2C_MASTER_RX_BUF_DISABLE 0 #define WAVESHARE_I2C_MASTER_RX_BUF_DISABLE 0
static esp_err_t i2c_init(void) { static esp_err_t i2c_init() {
const i2c_config_t i2c_conf = { const i2c_config_t i2c_conf = {
.mode = I2C_MODE_MASTER, .mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_8, .sda_io_num = GPIO_NUM_8,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_io_num = GPIO_NUM_9, .scl_io_num = GPIO_NUM_9,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_pullup_en = GPIO_PULLUP_DISABLE, .scl_pullup_en = GPIO_PULLUP_DISABLE,
.master.clk_speed = 400000 .master = {
.clk_speed = 400000
}
}; };
i2c_param_config(WAVESHARE_TOUCH_I2C_PORT, &i2c_conf); i2c_param_config(WAVESHARE_TOUCH_I2C_PORT, &i2c_conf);

View File

@ -0,0 +1,3 @@
#pragma once
bool ws3t_bootstrap();

View File

@ -35,4 +35,4 @@
#define WAVESHARE_LVGL_TICK_PERIOD_MS 2 // TODO: Setting it to 5 causes a crash - why? #define WAVESHARE_LVGL_TICK_PERIOD_MS 2 // TODO: Setting it to 5 causes a crash - why?
#define LVGL_MAX_SLEEP 500 #define LVGL_MAX_SLEEP 500
#define WAVESHARE_TOUCH_I2C_PORT 0 #define WAVESHARE_TOUCH_I2C_PORT I2C_NUM_0

View File

@ -1,9 +1,8 @@
#include "config.h" #include "config.h"
#include "lvgl.h" #include "lvgl.h"
#include "lvgl_i.h" #include "TactilityCore.h"
#include "tactility_core.h" #include "Thread.h"
#include "thread.h"
#include "esp_err.h" #include "esp_err.h"
#include "esp_lcd_panel_ops.h" #include "esp_lcd_panel_ops.h"
@ -16,9 +15,9 @@
#define TAG "waveshare_s3_touch_display" #define TAG "waveshare_s3_touch_display"
SemaphoreHandle_t sem_vsync_end = NULL; SemaphoreHandle_t sem_vsync_end = nullptr;
SemaphoreHandle_t sem_gui_ready = NULL; SemaphoreHandle_t sem_gui_ready = nullptr;
SemaphoreHandle_t lvgl_mux = NULL; SemaphoreHandle_t lvgl_mux = nullptr;
#if WAVESHARE_LCD_USE_DOUBLE_FB #if WAVESHARE_LCD_USE_DOUBLE_FB
#define WAVESHARE_LCD_NUM_FB 2 #define WAVESHARE_LCD_NUM_FB 2
@ -30,7 +29,7 @@ static bool lvgl_is_running = false;
bool ws3t_display_lock(uint32_t timeout_ms) { bool ws3t_display_lock(uint32_t timeout_ms) {
assert(lvgl_mux && "lvgl_port_init must be called first"); assert(lvgl_mux && "lvgl_port_init must be called first");
const TickType_t timeout_ticks = (timeout_ms == 0) ? TtWaitForever : pdMS_TO_TICKS(timeout_ms); const TickType_t timeout_ticks = (timeout_ms == 0) ? tt::TtWaitForever : pdMS_TO_TICKS(timeout_ms);
return xSemaphoreTakeRecursive(lvgl_mux, timeout_ticks) == pdTRUE; return xSemaphoreTakeRecursive(lvgl_mux, timeout_ticks) == pdTRUE;
} }
@ -58,7 +57,7 @@ static int32_t display_task(TT_UNUSED void* parameter) {
vTaskDelay(pdMS_TO_TICKS(task_delay_ms)); vTaskDelay(pdMS_TO_TICKS(task_delay_ms));
} }
vTaskDelete(NULL); vTaskDelete(nullptr);
return 0; return 0;
} }
@ -82,7 +81,7 @@ static void lvgl_tick_task(TT_UNUSED void* arg) {
} }
static void display_flush_callback(lv_display_t* disp, const lv_area_t* area, uint8_t* px_map) { static void display_flush_callback(lv_display_t* disp, const lv_area_t* area, uint8_t* px_map) {
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t)lv_display_get_user_data(disp); auto panel_handle = static_cast<esp_lcd_panel_handle_t>(lv_display_get_user_data(disp));
int offsetx1 = area->x1; int offsetx1 = area->x1;
int offsetx2 = area->x2; int offsetx2 = area->x2;
int offsety1 = area->y1; int offsety1 = area->y1;
@ -105,9 +104,9 @@ lv_disp_t* ws3t_display_create() {
lvgl_mux = xSemaphoreCreateRecursiveMutex(); lvgl_mux = xSemaphoreCreateRecursiveMutex();
tt_assert(lvgl_mux); tt_assert(lvgl_mux);
Thread* thread = tt_thread_alloc_ex("display_task", 8192, &display_task, NULL); tt::Thread* thread = tt::thread_alloc_ex("display_task", 8192, &display_task, nullptr);
tt_thread_set_priority(thread, ThreadPriorityHigh); // TODO: try out THREAD_PRIORITY_RENDER tt::thread_set_priority(thread, tt::ThreadPriorityHigh); // TODO: try out THREAD_PRIORITY_RENDER
tt_thread_start(thread); tt::thread_start(thread);
esp_lcd_panel_handle_t panel_handle = NULL; esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_rgb_panel_config_t panel_config = { esp_lcd_rgb_panel_config_t panel_config = {
@ -116,13 +115,13 @@ lv_disp_t* ws3t_display_create() {
.pclk_hz = WAVESHARE_LCD_PIXEL_CLOCK_HZ, .pclk_hz = WAVESHARE_LCD_PIXEL_CLOCK_HZ,
.h_res = WAVESHARE_LCD_HOR_RES, .h_res = WAVESHARE_LCD_HOR_RES,
.v_res = WAVESHARE_LCD_VER_RES, .v_res = WAVESHARE_LCD_VER_RES,
.hsync_pulse_width = 10,
// The following parameters should refer to LCD spec // The following parameters should refer to LCD spec
.hsync_back_porch = 10, .hsync_back_porch = 10,
.hsync_front_porch = 20, .hsync_front_porch = 20,
.hsync_pulse_width = 10, .vsync_pulse_width = 10,
.vsync_back_porch = 10, .vsync_back_porch = 10,
.vsync_front_porch = 10, .vsync_front_porch = 10,
.vsync_pulse_width = 10,
}, },
.data_width = 16, // RGB565 in parallel mode, thus 16bit in width .data_width = 16, // RGB565 in parallel mode, thus 16bit in width
.bits_per_pixel = 16, .bits_per_pixel = 16,
@ -141,32 +140,31 @@ lv_disp_t* ws3t_display_create() {
if (esp_lcd_new_rgb_panel(&panel_config, &panel_handle) != ESP_OK) { if (esp_lcd_new_rgb_panel(&panel_config, &panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create RGB panel"); TT_LOG_E(TAG, "Failed to create RGB panel");
return NULL; return nullptr;
} }
esp_lcd_rgb_panel_event_callbacks_t cbs = { esp_lcd_rgb_panel_event_callbacks_t cbs = {
.on_vsync = on_vsync_event, .on_vsync = on_vsync_event,
.on_bounce_empty = NULL, .on_bounce_empty = nullptr,
.on_bounce_frame_finish = NULL .on_bounce_frame_finish = nullptr
}; };
if (esp_lcd_rgb_panel_register_event_callbacks(panel_handle, &cbs, NULL) != ESP_OK) { if (esp_lcd_rgb_panel_register_event_callbacks(panel_handle, &cbs, nullptr) != ESP_OK) {
TT_LOG_E(TAG, "Failed to register callbacks"); TT_LOG_E(TAG, "Failed to register callbacks");
return NULL; return nullptr;
} }
if (esp_lcd_panel_reset(panel_handle) != ESP_OK) { if (esp_lcd_panel_reset(panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel"); TT_LOG_E(TAG, "Failed to reset panel");
return NULL; return nullptr;
} }
if (esp_lcd_panel_init(panel_handle) != ESP_OK) { if (esp_lcd_panel_init(panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel"); TT_LOG_E(TAG, "Failed to init panel");
return NULL; return nullptr;
} }
lv_init(); lv_init();
NULL;
#if WAVESHARE_LCD_USE_DOUBLE_FB #if WAVESHARE_LCD_USE_DOUBLE_FB
// initialize LVGL draw buffers // initialize LVGL draw buffers
lv_draw_buf_t* buffer1 = lv_draw_buf_create(WAVESHARE_LCD_HOR_RES, WAVESHARE_LCD_BUFFER_HEIGHT, LV_COLOR_FORMAT_RGB565, 0); lv_draw_buf_t* buffer1 = lv_draw_buf_create(WAVESHARE_LCD_HOR_RES, WAVESHARE_LCD_BUFFER_HEIGHT, LV_COLOR_FORMAT_RGB565, 0);
@ -190,7 +188,7 @@ lv_disp_t* ws3t_display_create() {
.callback = &lvgl_tick_task, .callback = &lvgl_tick_task,
.name = "lvgl_tick" .name = "lvgl_tick"
}; };
esp_timer_handle_t lvgl_tick_timer = NULL; esp_timer_handle_t lvgl_tick_timer = nullptr;
ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer)); ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer));
ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, WAVESHARE_LVGL_TICK_PERIOD_MS * 1000)); ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, WAVESHARE_LVGL_TICK_PERIOD_MS * 1000));
@ -202,7 +200,7 @@ void ws3t_display_destroy() {
// TODO: see esp_lvlg_port.c for more info // TODO: see esp_lvlg_port.c for more info
if (lvgl_mux) { if (lvgl_mux) {
vSemaphoreDelete(lvgl_mux); vSemaphoreDelete(lvgl_mux);
lvgl_mux = NULL; lvgl_mux = nullptr;
} }
#if LV_ENABLE_GC || !LV_MEM_CUSTOM #if LV_ENABLE_GC || !LV_MEM_CUSTOM
lv_deinit(); lv_deinit();

View File

@ -1,19 +1,10 @@
#pragma once #pragma once
#include "lvgl.h" #include "lvgl.h"
#include <stdbool.h> #include <cstdint>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
bool ws3t_display_lock(uint32_t timeout_ms); bool ws3t_display_lock(uint32_t timeout_ms);
void ws3t_display_unlock(void); void ws3t_display_unlock(void);
lv_display_t* ws3t_display_create(); lv_display_t* ws3t_display_create();
void ws3t_display_destroy(); void ws3t_display_destroy();
#ifdef __cplusplus
}
#endif

View File

@ -2,13 +2,13 @@
#include "display_i.h" #include "display_i.h"
#include "touch_i.h" #include "touch_i.h"
#include "ui/lvgl_sync.h" #include "Ui/LvglSync.h"
bool ws3t_init_lvgl() { bool ws3t_init_lvgl() {
tt_lvgl_sync_set(&ws3t_display_lock, &ws3t_display_unlock); tt::lvgl::sync_set(&ws3t_display_lock, &ws3t_display_unlock);
lv_display_t* display = ws3t_display_create(); lv_display_t* display = ws3t_display_create();
if (display == NULL) { if (display == nullptr) {
return false; return false;
} }

View File

@ -0,0 +1,3 @@
#pragma once
bool ws3t_init_lvgl();

View File

@ -9,16 +9,20 @@
#define TAG "waveshare_s3_touch_i2c" #define TAG "waveshare_s3_touch_i2c"
static esp_lcd_touch_handle_t touch_init_internal() { static esp_lcd_touch_handle_t touch_init_internal() {
static esp_lcd_panel_io_handle_t tp_io_handle = NULL; static esp_lcd_panel_io_handle_t tp_io_handle = nullptr;
static esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); static esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
ESP_LOGI(TAG, "Initialize touch IO"); ESP_LOGI(TAG, "Initialize touch IO");
/* Touch IO handle */
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)WAVESHARE_TOUCH_I2C_PORT, &tp_io_config, &tp_io_handle)); // TODO: Revert on new ESP-IDF version
static_assert(ESP_IDF_VERSION == ESP_IDF_VERSION_VAL(5, 3, 1));
// ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)WAVESHARE_TOUCH_I2C_PORT, &tp_io_config, &tp_io_handle));
esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)WAVESHARE_TOUCH_I2C_PORT, &tp_io_config, &tp_io_handle);
esp_lcd_touch_config_t tp_cfg = { esp_lcd_touch_config_t tp_cfg = {
.x_max = WAVESHARE_LCD_VER_RES, .x_max = WAVESHARE_LCD_VER_RES,
.y_max = WAVESHARE_LCD_HOR_RES, .y_max = WAVESHARE_LCD_HOR_RES,
.rst_gpio_num = -1, .rst_gpio_num = GPIO_NUM_NC,
.int_gpio_num = -1, .int_gpio_num = GPIO_NUM_NC,
.flags = { .flags = {
.swap_xy = 0, .swap_xy = 0,
.mirror_x = 0, .mirror_x = 0,
@ -27,7 +31,7 @@ static esp_lcd_touch_handle_t touch_init_internal() {
}; };
/* Initialize touch */ /* Initialize touch */
ESP_LOGI(TAG, "Initialize touch controller GT911"); ESP_LOGI(TAG, "Initialize touch controller GT911");
esp_lcd_touch_handle_t tp = NULL; esp_lcd_touch_handle_t tp = nullptr;
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp)); ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp));
return tp; return tp;
@ -39,11 +43,11 @@ static void touch_callback(lv_indev_t* indev, lv_indev_data_t* data) {
uint8_t touchpad_cnt = 0; uint8_t touchpad_cnt = 0;
/* Read touch controller data */ /* Read touch controller data */
esp_lcd_touch_handle_t touch_handle = lv_indev_get_user_data(indev); auto touch_handle = static_cast<esp_lcd_touch_handle_t>(lv_indev_get_user_data(indev));
esp_lcd_touch_read_data(touch_handle); esp_lcd_touch_read_data(touch_handle);
/* Get coordinates */ /* Get coordinates */
bool touchpad_pressed = esp_lcd_touch_get_coordinates(touch_handle, touchpad_x, touchpad_y, NULL, &touchpad_cnt, 1); bool touchpad_pressed = esp_lcd_touch_get_coordinates(touch_handle, touchpad_x, touchpad_y, nullptr, &touchpad_cnt, 1);
if (touchpad_pressed && touchpad_cnt > 0) { if (touchpad_pressed && touchpad_cnt > 0) {
data->point.x = touchpad_x[0]; data->point.x = touchpad_x[0];
@ -59,7 +63,7 @@ void ws3t_touch_init(lv_display_t* display) {
ESP_LOGI(TAG, "Register display indev to LVGL"); ESP_LOGI(TAG, "Register display indev to LVGL");
static lv_indev_t* device = NULL; static lv_indev_t* device = nullptr;
device = lv_indev_create(); device = lv_indev_create();
lv_indev_set_type(device, LV_INDEV_TYPE_POINTER); lv_indev_set_type(device, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(device, &touch_callback); lv_indev_set_read_cb(device, &touch_callback);

View File

@ -0,0 +1,5 @@
#pragma once
#include "lvgl.h"
void ws3t_touch_init(lv_display_t* display);

View File

@ -0,0 +1,15 @@
#include "waveshare_s3_touch.h"
#include "lvgl_i.h"
bool ws3t_bootstrap();
extern const tt::hal::Configuration waveshare_s3_touch = {
.bootstrap = &ws3t_bootstrap,
.init_graphics = &ws3t_init_lvgl,
.display = {
.set_backlight_duty = nullptr // TODO: This requires implementing the CH422G IO expander
},
.sdcard = nullptr,
.power = nullptr
};

View File

@ -0,0 +1,6 @@
#pragma once
#include "Hal/Configuration.h"
// Waveshare S3 Touch LCD 4.3
extern const tt::hal::Configuration waveshare_s3_touch;

View File

@ -1,5 +1,5 @@
idf_component_register( idf_component_register(
SRC_DIRS "." SRC_DIRS "."
INCLUDE_DIRS "." INCLUDE_DIRS "."
REQUIRES tactility esp_lvgl_port esp_lcd_touch_cst816s esp_lcd_ili9341 driver vfs fatfs REQUIRES Tactility esp_lvgl_port esp_lcd_touch_cst816s esp_lcd_ili9341 driver vfs fatfs
) )

View File

@ -1,5 +1,5 @@
#include "config.h" #include "config.h"
#include "tactility_core.h" #include "TactilityCore.h"
#include "display_i.h" #include "display_i.h"
#include <driver/spi_common.h> #include <driver/spi_common.h>
@ -9,19 +9,21 @@ static bool init_i2c() {
const i2c_config_t i2c_conf = { const i2c_config_t i2c_conf = {
.mode = I2C_MODE_MASTER, .mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_33, .sda_io_num = GPIO_NUM_33,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_io_num = GPIO_NUM_32, .scl_io_num = GPIO_NUM_32,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_pullup_en = GPIO_PULLUP_DISABLE, .scl_pullup_en = GPIO_PULLUP_DISABLE,
.master.clk_speed = 400000 .master = {
.clk_speed = 400000
}
}; };
if (i2c_param_config(TWODOTFOUR_TOUCH_I2C_PORT, &i2c_conf) != ESP_OK) { if (i2c_param_config(TWODOTFOUR_TOUCH_I2C_PORT, &i2c_conf) != ESP_OK) {
ESP_LOGE(TAG, "i2c config failed"); TT_LOG_E(TAG, "i2c config failed");
return false; return false;
} }
if (i2c_driver_install(TWODOTFOUR_TOUCH_I2C_PORT, i2c_conf.mode, 0, 0, 0) != ESP_OK) { if (i2c_driver_install(TWODOTFOUR_TOUCH_I2C_PORT, i2c_conf.mode, 0, 0, 0) != ESP_OK) {
ESP_LOGE(TAG, "i2c driver install failed"); TT_LOG_E(TAG, "i2c driver install failed");
return false; return false;
} }
@ -30,11 +32,11 @@ static bool init_i2c() {
static bool init_spi2() { static bool init_spi2() {
const spi_bus_config_t bus_config = { const spi_bus_config_t bus_config = {
.sclk_io_num = TWODOTFOUR_SPI2_PIN_SCLK,
.mosi_io_num = TWODOTFOUR_SPI2_PIN_MOSI, .mosi_io_num = TWODOTFOUR_SPI2_PIN_MOSI,
.miso_io_num = GPIO_NUM_NC, .miso_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC, .sclk_io_num = TWODOTFOUR_SPI2_PIN_SCLK,
.quadwp_io_num = GPIO_NUM_NC, .quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = TWODOTFOUR_SPI2_TRANSACTION_LIMIT .max_transfer_sz = TWODOTFOUR_SPI2_TRANSACTION_LIMIT
}; };
@ -48,11 +50,11 @@ static bool init_spi2() {
static bool init_spi3() { static bool init_spi3() {
const spi_bus_config_t bus_config = { const spi_bus_config_t bus_config = {
.sclk_io_num = TWODOTFOUR_SPI3_PIN_SCLK,
.mosi_io_num = TWODOTFOUR_SPI3_PIN_MOSI, .mosi_io_num = TWODOTFOUR_SPI3_PIN_MOSI,
.miso_io_num = TWODOTFOUR_SPI3_PIN_MISO, .miso_io_num = TWODOTFOUR_SPI3_PIN_MISO,
.quadhd_io_num = GPIO_NUM_NC, .sclk_io_num = TWODOTFOUR_SPI3_PIN_SCLK,
.quadwp_io_num = GPIO_NUM_NC, .quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = TWODOTFOUR_SPI3_TRANSACTION_LIMIT .max_transfer_sz = TWODOTFOUR_SPI3_TRANSACTION_LIMIT
}; };

View File

@ -27,7 +27,7 @@
#define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27 #define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27
// Touch // Touch
#define TWODOTFOUR_TOUCH_I2C_PORT 0 #define TWODOTFOUR_TOUCH_I2C_PORT I2C_NUM_0
// SD Card // SD Card
#define TWODOTFOUR_SDCARD_SPI_HOST SPI3_HOST #define TWODOTFOUR_SDCARD_SPI_HOST SPI3_HOST

View File

@ -1,5 +1,5 @@
#include "config.h" #include "config.h"
#include "tactility_core.h" #include "TactilityCore.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/ledc.h" #include "driver/ledc.h"
@ -21,8 +21,8 @@
bool twodotfour_backlight_init() { bool twodotfour_backlight_init() {
ledc_timer_config_t ledc_timer = { ledc_timer_config_t ledc_timer = {
.speed_mode = TWODOTFOUR_LCD_BACKLIGHT_LEDC_MODE, .speed_mode = TWODOTFOUR_LCD_BACKLIGHT_LEDC_MODE,
.timer_num = TWODOTFOUR_LCD_BACKLIGHT_LEDC_TIMER,
.duty_resolution = TWODOTFOUR_LCD_BACKLIGHT_LEDC_DUTY_RES, .duty_resolution = TWODOTFOUR_LCD_BACKLIGHT_LEDC_DUTY_RES,
.timer_num = TWODOTFOUR_LCD_BACKLIGHT_LEDC_TIMER,
.freq_hz = TWODOTFOUR_LCD_BACKLIGHT_LEDC_FREQUENCY, .freq_hz = TWODOTFOUR_LCD_BACKLIGHT_LEDC_FREQUENCY,
.clk_cfg = LEDC_AUTO_CLK .clk_cfg = LEDC_AUTO_CLK
}; };
@ -37,11 +37,11 @@ bool twodotfour_backlight_init() {
void twodotfour_backlight_set(uint8_t duty) { void twodotfour_backlight_set(uint8_t duty) {
ledc_channel_config_t ledc_channel = { ledc_channel_config_t ledc_channel = {
.gpio_num = TWODOTFOUR_LCD_PIN_BACKLIGHT,
.speed_mode = TWODOTFOUR_LCD_BACKLIGHT_LEDC_MODE, .speed_mode = TWODOTFOUR_LCD_BACKLIGHT_LEDC_MODE,
.channel = TWODOTFOUR_LCD_BACKLIGHT_LEDC_CHANNEL, .channel = TWODOTFOUR_LCD_BACKLIGHT_LEDC_CHANNEL,
.timer_sel = TWODOTFOUR_LCD_BACKLIGHT_LEDC_TIMER,
.intr_type = LEDC_INTR_DISABLE, .intr_type = LEDC_INTR_DISABLE,
.gpio_num = TWODOTFOUR_LCD_PIN_BACKLIGHT, .timer_sel = TWODOTFOUR_LCD_BACKLIGHT_LEDC_TIMER,
.duty = duty, .duty = duty,
.hpoint = 0 .hpoint = 0
}; };
@ -59,14 +59,14 @@ lv_disp_t* twodotfour_display_init() {
const esp_lcd_panel_io_spi_config_t panel_io_config = ILI9341_PANEL_IO_SPI_CONFIG( const esp_lcd_panel_io_spi_config_t panel_io_config = ILI9341_PANEL_IO_SPI_CONFIG(
TWODOTFOUR_LCD_PIN_CS, TWODOTFOUR_LCD_PIN_CS,
TWODOTFOUR_LCD_PIN_DC, TWODOTFOUR_LCD_PIN_DC,
NULL, nullptr,
NULL nullptr
); );
esp_lcd_panel_io_handle_t io_handle; esp_lcd_panel_io_handle_t io_handle;
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TWODOTFOUR_LCD_SPI_HOST, &panel_io_config, &io_handle) != ESP_OK) { if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TWODOTFOUR_LCD_SPI_HOST, &panel_io_config, &io_handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel"); TT_LOG_E(TAG, "Failed to create panel");
return false; return nullptr;
} }
const esp_lcd_panel_dev_config_t panel_config = { const esp_lcd_panel_dev_config_t panel_config = {
@ -78,27 +78,27 @@ lv_disp_t* twodotfour_display_init() {
esp_lcd_panel_handle_t panel_handle; esp_lcd_panel_handle_t panel_handle;
if (esp_lcd_new_panel_ili9341(io_handle, &panel_config, &panel_handle) != ESP_OK) { if (esp_lcd_new_panel_ili9341(io_handle, &panel_config, &panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create ili9341"); TT_LOG_E(TAG, "Failed to create ili9341");
return false; return nullptr;
} }
if (esp_lcd_panel_reset(panel_handle) != ESP_OK) { if (esp_lcd_panel_reset(panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel"); TT_LOG_E(TAG, "Failed to reset panel");
return false; return nullptr;
} }
if (esp_lcd_panel_init(panel_handle) != ESP_OK) { if (esp_lcd_panel_init(panel_handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel"); TT_LOG_E(TAG, "Failed to init panel");
return false; return nullptr;
} }
if (esp_lcd_panel_mirror(panel_handle, true, false) != ESP_OK) { if (esp_lcd_panel_mirror(panel_handle, true, false) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror"); TT_LOG_E(TAG, "Failed to set panel to mirror");
return false; return nullptr;
} }
if (esp_lcd_panel_disp_on_off(panel_handle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panel_handle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on"); TT_LOG_E(TAG, "Failed to turn display on");
return false; return nullptr;
} }
const lvgl_port_display_cfg_t disp_cfg = { const lvgl_port_display_cfg_t disp_cfg = {
@ -122,7 +122,5 @@ lv_disp_t* twodotfour_display_init() {
} }
}; };
lv_display_t* display = lvgl_port_add_disp(&disp_cfg); return lvgl_port_add_disp(&disp_cfg);
return display;
} }

View File

@ -0,0 +1,6 @@
#pragma once
#include <cstdint>
bool twodotfour_backlight_init();
void twodotfour_backlight_set(uint8_t duty);

View File

@ -1,7 +1,7 @@
#include "esp_lvgl_port.h" #include "esp_lvgl_port.h"
#include "log.h" #include "Log.h"
#include "ui/lvgl_sync.h" #include "Ui/LvglSync.h"
#include <thread.h> #include "Thread.h"
#define TAG "twodotfour_lvgl" #define TAG "twodotfour_lvgl"
@ -9,12 +9,12 @@ lv_display_t* twodotfour_display_init();
bool twodotfour_touch_init(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle); bool twodotfour_touch_init(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle);
bool twodotfour_lvgl_init() { bool twodotfour_lvgl_init() {
static lv_display_t* display = NULL; static lv_display_t* display = nullptr;
static esp_lcd_panel_io_handle_t touch_io_handle; static esp_lcd_panel_io_handle_t touch_io_handle;
static esp_lcd_touch_handle_t touch_handle; static esp_lcd_touch_handle_t touch_handle;
const lvgl_port_cfg_t lvgl_cfg = { const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = ThreadPriorityHigh, .task_priority = tt::ThreadPriorityHigh,
.task_stack = 8096, .task_stack = 8096,
.task_affinity = -1, // core pinning .task_affinity = -1, // core pinning
.task_max_sleep_ms = 500, .task_max_sleep_ms = 500,
@ -28,7 +28,7 @@ bool twodotfour_lvgl_init() {
// Add display // Add display
display = twodotfour_display_init(); display = twodotfour_display_init();
if (display == NULL) { if (display == nullptr) {
TT_LOG_E(TAG, "failed to add display"); TT_LOG_E(TAG, "failed to add display");
return false; return false;
} }
@ -43,14 +43,14 @@ bool twodotfour_lvgl_init() {
.handle = touch_handle, .handle = touch_handle,
}; };
lv_indev_t _Nullable* touch_indev = lvgl_port_add_touch(&touch_cfg); auto* touch_indev= lvgl_port_add_touch(&touch_cfg);
if (touch_indev == NULL) { if (touch_indev == nullptr) {
TT_LOG_E(TAG, "failed to add touch to lvgl"); TT_LOG_E(TAG, "failed to add touch to lvgl");
return false; return false;
} }
// Set syncing functions // Set syncing functions
tt_lvgl_sync_set(&lvgl_port_lock, &lvgl_port_unlock); tt::lvgl::sync_set(&lvgl_port_lock, &lvgl_port_unlock);
return true; return true;
} }

View File

@ -1,6 +1,6 @@
#include "sdcard.h" #include "Hal/Sdcard.h"
#include "check.h" #include "Check.h"
#include "log.h" #include "Log.h"
#include "config.h" #include "config.h"
#include "esp_vfs_fat.h" #include "esp_vfs_fat.h"
@ -40,13 +40,13 @@ static void* sdcard_mount(const char* mount_point) {
} else { } else {
TT_LOG_E(TAG, "Mounting failed (%s)", esp_err_to_name(ret)); TT_LOG_E(TAG, "Mounting failed (%s)", esp_err_to_name(ret));
} }
return NULL; return nullptr;
} }
MountData* data = malloc(sizeof(MountData)); auto* data = static_cast<MountData*>(malloc(sizeof(MountData)));
*data = (MountData) { *data = (MountData) {
.card = card, .mount_point = mount_point,
.mount_point = mount_point .card = card
}; };
sdmmc_card_print_info(stdout, data->card); sdmmc_card_print_info(stdout, data->card);
@ -55,10 +55,10 @@ static void* sdcard_mount(const char* mount_point) {
} }
static void sdcard_unmount(void* context) { static void sdcard_unmount(void* context) {
MountData* data = (MountData*)context; auto* data = static_cast<MountData*>(context);
TT_LOG_I(TAG, "Unmounting %s", data->mount_point); TT_LOG_I(TAG, "Unmounting %s", data->mount_point);
tt_assert(data != NULL); tt_assert(data != nullptr);
if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) { if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) {
TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point); TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point);
} }
@ -67,13 +67,13 @@ static void sdcard_unmount(void* context) {
} }
static bool sdcard_is_mounted(void* context) { static bool sdcard_is_mounted(void* context) {
MountData* data = (MountData*)context; auto* data = static_cast<MountData*>(context);
return (data != NULL) && (sdmmc_get_status(data->card) == ESP_OK); return (data != nullptr) && (sdmmc_get_status(data->card) == ESP_OK);
} }
const SdCard twodotfour_sdcard = { extern const tt::hal::sdcard::SdCard twodotfour_sdcard = {
.mount = &sdcard_mount, .mount = &sdcard_mount,
.unmount = &sdcard_unmount, .unmount = &sdcard_unmount,
.is_mounted = &sdcard_is_mounted, .is_mounted = &sdcard_is_mounted,
.mount_behaviour = SdcardMountBehaviourAnytime .mount_behaviour = tt::hal::sdcard::MountBehaviourAnytime
}; };

View File

@ -1,8 +1,9 @@
#include "config.h" #include "config.h"
#include "driver/i2c.h" #include "driver/i2c.h"
#include "log.h"
#include "esp_err.h" #include "esp_err.h"
#include "esp_lcd_touch_cst816s.h" #include "esp_lcd_touch_cst816s.h"
#include "esp_lcd_touch.h"
#include "Log.h"
#define TAG "twodotfour_cst816" #define TAG "twodotfour_cst816"
@ -11,10 +12,15 @@ bool twodotfour_touch_init(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_h
const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG(); const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
// TODO: Check when ESP-IDF publishes fix (5.3.2 or 5.4.x)
static_assert(ESP_IDF_VERSION == ESP_IDF_VERSION_VAL(5, 3, 1));
esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TWODOTFOUR_TOUCH_I2C_PORT, &touch_io_config, io_handle);
/*
if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TWODOTFOUR_TOUCH_I2C_PORT, &touch_io_config, io_handle) != ESP_OK) { if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TWODOTFOUR_TOUCH_I2C_PORT, &touch_io_config, io_handle) != ESP_OK) {
TT_LOG_E(TAG, "Touch I2C IO init failed"); TT_LOG_E(TAG, "Touch I2C IO init failed");
return false; return false;
} }
*/
esp_lcd_touch_config_t config = { esp_lcd_touch_config_t config = {
.x_max = 240, .x_max = 240,
@ -30,9 +36,9 @@ bool twodotfour_touch_init(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_h
.mirror_x = 0, .mirror_x = 0,
.mirror_y = 0, .mirror_y = 0,
}, },
.process_coordinates = NULL, .process_coordinates = nullptr,
.interrupt_callback = NULL, .interrupt_callback = nullptr,
.user_data = NULL .user_data = nullptr
}; };
if (esp_lcd_touch_new_i2c_cst816s(*io_handle, &config, touch_handle) != ESP_OK) { if (esp_lcd_touch_new_i2c_cst816s(*io_handle, &config, touch_handle) != ESP_OK) {

View File

@ -4,14 +4,14 @@
bool twodotfour_lvgl_init(); bool twodotfour_lvgl_init();
bool twodotfour_bootstrap(); bool twodotfour_bootstrap();
extern const SdCard twodotfour_sdcard; extern const tt::hal::sdcard::SdCard twodotfour_sdcard;
const HardwareConfig yellow_board_24inch_cap = { const tt::hal::Configuration yellow_board_24inch_cap = {
.bootstrap = &twodotfour_bootstrap, .bootstrap = &twodotfour_bootstrap,
.init_graphics = &twodotfour_lvgl_init,
.display = { .display = {
.set_backlight_duty = &twodotfour_backlight_set .set_backlight_duty = &twodotfour_backlight_set
}, },
.init_graphics = &twodotfour_lvgl_init,
.sdcard = &twodotfour_sdcard, .sdcard = &twodotfour_sdcard,
.power = NULL .power = nullptr
}; };

View File

@ -0,0 +1,6 @@
#pragma once
#include "Hal/Configuration.h"
// Capacitive touch version of the 2.4" yellow board
extern const tt::hal::Configuration yellow_board_24inch_cap;

View File

@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.16)
add_definitions(-DTT_DEBUG) add_definitions(-DTT_DEBUG)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_CXX_COMPILER_TARGET}")
if (DEFINED ENV{ESP_IDF_VERSION}) if (DEFINED ENV{ESP_IDF_VERSION})
message("Building with ESP-IDF v$ENV{ESP_IDF_VERSION}") message("Building with ESP-IDF v$ENV{ESP_IDF_VERSION}")
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
@ -12,78 +16,72 @@ if (DEFINED ENV{ESP_IDF_VERSION})
add_definitions(-DARDUINO_M5STACK_CORE2) add_definitions(-DARDUINO_M5STACK_CORE2)
add_compile_definitions(ARDUINO_M5STACK_CORE2) add_compile_definitions(ARDUINO_M5STACK_CORE2)
set(COMPONENTS app-esp) set(COMPONENTS AppEsp32)
set(EXTRA_COMPONENT_DIRS set(EXTRA_COMPONENT_DIRS
"boards" "Boards"
"app-esp" "AppEsp32"
"tactility" "Tactility"
"tactility-headless" "TactilityHeadless"
"libs/esp_lvgl_port" "Libraries/esp_lvgl_port"
"libs/lvgl" "Libraries/lvgl"
"libs/M5Unified" "Libraries/M5Unified"
"libs/M5GFX" "Libraries/M5GFX"
) )
# ESP32 boards # ESP32 boards
if(NOT "${IDF_TARGET}" STREQUAL "esp32") if(NOT "${IDF_TARGET}" STREQUAL "esp32")
set(EXCLUDE_COMPONENTS "yellow_board_2432s024") set(EXCLUDE_COMPONENTS "YellowBoard")
set(EXCLUDE_COMPONENTS "m5stack_core2") set(EXCLUDE_COMPONENTS "M5stackCore2")
set(EXCLUDE_COMPONENTS "m5stack_cores3") set(EXCLUDE_COMPONENTS "M5stackCoreS3")
endif() endif()
# ESP32-S3 boards # ESP32-S3 boards
if(NOT "${IDF_TARGET}" STREQUAL "esp32s3") if(NOT "${IDF_TARGET}" STREQUAL "esp32s3")
set(EXCLUDE_COMPONENTS "lilygo_tdeck") set(EXCLUDE_COMPONENTS "LilygoTdeck")
set(EXCLUDE_COMPONENTS "waveshare_s3_touch") set(EXCLUDE_COMPONENTS "WaveshareS3Touch")
endif() endif()
else() else()
message("Building for sim target") message("Building for sim target")
endif() endif()
project(tactility-root) project(TactilityRoot)
# Defined as regular project for PC and component for ESP # Defined as regular project for PC and component for ESP
if (NOT DEFINED ENV{ESP_IDF_VERSION}) if (NOT DEFINED ENV{ESP_IDF_VERSION})
add_subdirectory(tactility) add_subdirectory(Tactility)
add_subdirectory(tactility-headless) add_subdirectory(TactilityHeadless)
endif() endif()
add_subdirectory(tactility-core) add_subdirectory(TactilityCore)
add_subdirectory(libs/mlib) add_subdirectory(Libraries/lv_screenshot)
add_subdirectory(libs/lv_screenshot)
if (NOT DEFINED ENV{ESP_IDF_VERSION}) if (NOT DEFINED ENV{ESP_IDF_VERSION})
set(CMAKE_C_STANDARD 99) # C99 # lvgl officially support C99 and above
set(CMAKE_CXX_STANDARD 17) # C17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER_TARGET}")
# FreeRTOS # FreeRTOS
set(FREERTOS_CONFIG_FILE_DIRECTORY ${PROJECT_SOURCE_DIR}/app-sim/src CACHE STRING "") set(FREERTOS_CONFIG_FILE_DIRECTORY ${PROJECT_SOURCE_DIR}/AppSim/Source CACHE STRING "")
set(FREERTOS_PORT GCC_POSIX CACHE STRING "") set(FREERTOS_PORT GCC_POSIX CACHE STRING "")
add_subdirectory(libs/FreeRTOS-Kernel) add_subdirectory(Libraries/FreeRTOS-Kernel)
target_compile_definitions(freertos_kernel PUBLIC "projCOVERAGE_TEST=0") target_compile_definitions(freertos_kernel PUBLIC "projCOVERAGE_TEST=0")
target_include_directories(freertos_kernel target_include_directories(freertos_kernel
PUBLIC app-sim/src # for FreeRTOSConfig.h PUBLIC AppSim/Source # for FreeRTOSConfig.h
) )
# EmbedTLS # EmbedTLS
add_subdirectory(libs/mbedtls) add_subdirectory(Libraries/mbedtls)
# Sim app # Sim app
if (NOT DEFINED ENV{SKIP_SDL}) if (NOT DEFINED ENV{SKIP_SDL})
add_subdirectory(app-sim) add_subdirectory(AppSim)
endif() endif()
# Tests # Tests
add_subdirectory(tests) add_subdirectory(Tests)
# SDL & LVGL # SDL & LVGL
set(LV_CONF_PATH ${PROJECT_SOURCE_DIR}/app-sim/src/lv_conf.h) set(LV_CONF_PATH ${PROJECT_SOURCE_DIR}/AppSim/Source/lv_conf.h)
add_subdirectory(libs/lvgl) # Added as idf component for ESP and as library for other targets add_subdirectory(Libraries/lvgl) # Added as idf component for ESP and as library for other targets
target_include_directories(lvgl target_include_directories(lvgl
PUBLIC app-sim/src # for lv_conf.h and lv_drv_conf.h PUBLIC AppSim/Source # for lv_conf.h and lv_drv_conf.h
) )
# TODO: This is a temporary skipping option for running unit tests # TODO: This is a temporary skipping option for running unit tests
@ -109,13 +107,13 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
# `brew install sdl2_image` # `brew install sdl2_image`
find_package(SDL2_image REQUIRED) find_package(SDL2_image REQUIRED)
target_include_directories(lvgl PUBLIC ${SDL2_IMAGE_INCLUDE_DIRS}) target_include_directories(lvgl PUBLIC ${SDL2_IMAGE_INCLUDE_DIRS})
target_link_libraries(app-sim ${SDL2_IMAGE_LIBRARIES}) target_link_libraries(AppSim ${SDL2_IMAGE_LIBRARIES})
endif(LV_USE_DRAW_SDL) endif(LV_USE_DRAW_SDL)
if (LV_USE_LIBPNG) if (LV_USE_LIBPNG)
find_package(PNG REQUIRED) find_package(PNG REQUIRED)
target_include_directories(lvgl PUBLIC ${PNG_INCLUDE_DIR}) target_include_directories(lvgl PUBLIC ${PNG_INCLUDE_DIR})
target_link_libraries(app-sim ${PNG_LIBRARY}) target_link_libraries(AppSim ${PNG_LIBRARY})
endif(LV_USE_LIBPNG) endif(LV_USE_LIBPNG)
if (LV_USE_LIBJPEG_TURBO) if (LV_USE_LIBJPEG_TURBO)
@ -124,7 +122,7 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
# `brew install libjpeg-turbo` # `brew install libjpeg-turbo`
find_package(JPEG REQUIRED) find_package(JPEG REQUIRED)
target_include_directories(lvgl PUBLIC ${JPEG_INCLUDE_DIRS}) target_include_directories(lvgl PUBLIC ${JPEG_INCLUDE_DIRS})
target_link_libraries(app-sim ${JPEG_LIBRARIES}) target_link_libraries(AppSim ${JPEG_LIBRARIES})
endif(LV_USE_LIBJPEG_TURBO) endif(LV_USE_LIBJPEG_TURBO)
if (LV_USE_FFMPEG) if (LV_USE_FFMPEG)
@ -133,7 +131,7 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION})
if (LV_USE_FREETYPE) if (LV_USE_FREETYPE)
find_package(Freetype REQUIRED) find_package(Freetype REQUIRED)
target_link_libraries(app-sim ${FREETYPE_LIBRARIES}) target_link_libraries(AppSim ${FREETYPE_LIBRARIES})
target_include_directories(lvgl PUBLIC ${FREETYPE_INCLUDE_DIRS}) target_include_directories(lvgl PUBLIC ${FREETYPE_INCLUDE_DIRS})
endif(LV_USE_FREETYPE) endif(LV_USE_FREETYPE)
endif() endif()

View File

Before

Width:  |  Height:  |  Size: 333 B

After

Width:  |  Height:  |  Size: 333 B

View File

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 240 B

View File

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

View File

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 299 B

View File

Before

Width:  |  Height:  |  Size: 535 B

After

Width:  |  Height:  |  Size: 535 B

View File

Before

Width:  |  Height:  |  Size: 436 B

After

Width:  |  Height:  |  Size: 436 B

View File

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 256 B

View File

Before

Width:  |  Height:  |  Size: 261 B

After

Width:  |  Height:  |  Size: 261 B

View File

Before

Width:  |  Height:  |  Size: 268 B

After

Width:  |  Height:  |  Size: 268 B

View File

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 262 B

View File

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 259 B

View File

Before

Width:  |  Height:  |  Size: 287 B

After

Width:  |  Height:  |  Size: 287 B

View File

Before

Width:  |  Height:  |  Size: 309 B

After

Width:  |  Height:  |  Size: 309 B

View File

Before

Width:  |  Height:  |  Size: 376 B

After

Width:  |  Height:  |  Size: 376 B

View File

Before

Width:  |  Height:  |  Size: 464 B

After

Width:  |  Height:  |  Size: 464 B

View File

Before

Width:  |  Height:  |  Size: 411 B

After

Width:  |  Height:  |  Size: 411 B

View File

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 435 B

View File

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 404 B

View File

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 451 B

View File

Before

Width:  |  Height:  |  Size: 415 B

After

Width:  |  Height:  |  Size: 415 B

View File

Before

Width:  |  Height:  |  Size: 473 B

After

Width:  |  Height:  |  Size: 473 B

View File

Before

Width:  |  Height:  |  Size: 419 B

After

Width:  |  Height:  |  Size: 419 B

View File

Before

Width:  |  Height:  |  Size: 473 B

After

Width:  |  Height:  |  Size: 473 B

View File

Before

Width:  |  Height:  |  Size: 415 B

After

Width:  |  Height:  |  Size: 415 B

View File

Before

Width:  |  Height:  |  Size: 478 B

After

Width:  |  Height:  |  Size: 478 B

View File

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 406 B

View File

Before

Width:  |  Height:  |  Size: 466 B

After

Width:  |  Height:  |  Size: 466 B

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Some files were not shown because too many files have changed in this diff Show More