From ddf46b07e936dd9b6f62e0cf8c393f5f536053ff Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 28 Jan 2024 21:52:05 +0100 Subject: [PATCH] SD card support for 2432S024C and some fixes (#24) - Implemented SD card support for Yellow Board 2432S024C - Fix for locking bug when showing gui keyboard - T-Deck driver naming fixes - Loader tag name consistency improvement --- README.md | 2 +- boards/lilygo_tdeck/config.h | 2 +- boards/lilygo_tdeck/lilygo_tdeck.c | 2 +- boards/lilygo_tdeck/sdcard.c | 4 +- boards/yellow_board/CMakeLists.txt | 2 +- boards/yellow_board/bootstrap.c | 87 +++++++++++++++++++++++ boards/yellow_board/config.h | 39 ++++++++++ boards/yellow_board/display.c | 79 ++++++++------------ boards/yellow_board/lvgl.c | 13 ++-- boards/yellow_board/sdcard.c | 73 +++++++++++++++++++ boards/yellow_board/touch.c | 37 +++------- boards/yellow_board/yellow_board.c | 10 ++- tactility/src/services/gui/gui.c | 4 +- tactility/src/services/gui/gui_keyboard.c | 3 - tactility/src/services/loader/loader.c | 2 +- 15 files changed, 259 insertions(+), 100 deletions(-) create mode 100644 boards/yellow_board/bootstrap.c create mode 100644 boards/yellow_board/config.h create mode 100644 boards/yellow_board/sdcard.c diff --git a/README.md b/README.md index ee78f4a2..3efdf925 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Predefined configurations are available for: |------------------------------------------|--------------|---------|----------| | [LilyGo T-Deck][tdeck] | ✅ | ✅ | Keyboard | | [Waveshare S3 Touch][waveshare_s3_touch] | ✅ | ⏳ | | -| Yellow Board 2432S024C (\*) | ✅ | ⏳ | | +| Yellow Board 2432S024C (\*) | ✅ | ✅ | | - ✅: Capable and implemented - ⏳: Capable but not yet implemented diff --git a/boards/lilygo_tdeck/config.h b/boards/lilygo_tdeck/config.h index d52239dd..57f2e5af 100644 --- a/boards/lilygo_tdeck/config.h +++ b/boards/lilygo_tdeck/config.h @@ -55,7 +55,7 @@ #define TDECK_SDCARD_FORMAT_ON_MOUNT_FAILED false #define TDECK_SDCARD_MAX_OPEN_FILES 4 #define TDECK_SDCARD_ALLOC_UNIT_SIZE (16 * 1024) -#define TDECK_SDCARD_STATUS_CHECK_ENALBED false +#define TDECK_SDCARD_STATUS_CHECK_ENABLED false // Keyboard #define TDECK_KEYBOARD_I2C_BUS_HANDLE TDECK_I2C_BUS_HANDLE diff --git a/boards/lilygo_tdeck/lilygo_tdeck.c b/boards/lilygo_tdeck/lilygo_tdeck.c index 5d61be3b..69ddb953 100644 --- a/boards/lilygo_tdeck/lilygo_tdeck.c +++ b/boards/lilygo_tdeck/lilygo_tdeck.c @@ -4,7 +4,7 @@ bool tdeck_bootstrap(); bool tdeck_init_lvgl(); -extern SdCard tdeck_sdcard; +extern const SdCard tdeck_sdcard; const HardwareConfig lilygo_tdeck = { .bootstrap = &tdeck_bootstrap, diff --git a/boards/lilygo_tdeck/sdcard.c b/boards/lilygo_tdeck/sdcard.c index 47ba1a6f..c662c4e6 100644 --- a/boards/lilygo_tdeck/sdcard.c +++ b/boards/lilygo_tdeck/sdcard.c @@ -61,7 +61,7 @@ static void* sdcard_mount(const char* mount_point) { .format_if_mount_failed = TDECK_SDCARD_FORMAT_ON_MOUNT_FAILED, .max_files = TDECK_SDCARD_MAX_OPEN_FILES, .allocation_unit_size = TDECK_SDCARD_ALLOC_UNIT_SIZE, - .disk_status_check_enable = TDECK_SDCARD_STATUS_CHECK_ENALBED + .disk_status_check_enable = TDECK_SDCARD_STATUS_CHECK_ENABLED }; sdmmc_card_t* card; @@ -125,7 +125,7 @@ static void sdcard_unmount(void* context) { free(data); } -SdCard tdeck_sdcard = { +const SdCard tdeck_sdcard = { .mount = &sdcard_init_and_mount, .unmount = &sdcard_unmount, .mount_behaviour = SDCARD_MOUNT_BEHAVIOUR_AT_BOOT diff --git a/boards/yellow_board/CMakeLists.txt b/boards/yellow_board/CMakeLists.txt index 2f04cad1..cc39151c 100644 --- a/boards/yellow_board/CMakeLists.txt +++ b/boards/yellow_board/CMakeLists.txt @@ -1,7 +1,7 @@ idf_component_register( SRC_DIRS "." INCLUDE_DIRS "." - REQUIRES esp_lvgl_port esp_lcd_touch_cst816s esp_lcd_ili9341 + REQUIRES esp_lvgl_port esp_lcd_touch_cst816s esp_lcd_ili9341 driver vfs fatfs ) target_link_libraries(${COMPONENT_LIB} ${IDF_TARGET_NAME} tactility) \ No newline at end of file diff --git a/boards/yellow_board/bootstrap.c b/boards/yellow_board/bootstrap.c new file mode 100644 index 00000000..4a61e9ce --- /dev/null +++ b/boards/yellow_board/bootstrap.c @@ -0,0 +1,87 @@ +#include "config.h" +#include "kernel.h" +#include "log.h" +#include + +#define TAG "twodotfour_bootstrap" + +static bool init_i2c() { + const i2c_config_t i2c_conf = { + .mode = I2C_MODE_MASTER, + .sda_io_num = GPIO_NUM_33, + .sda_pullup_en = GPIO_PULLUP_DISABLE, + .scl_io_num = GPIO_NUM_32, + .scl_pullup_en = GPIO_PULLUP_DISABLE, + .master.clk_speed = 400000 + }; + + if (i2c_param_config(TWODOTFOUR_TOUCH_I2C_PORT, &i2c_conf) != ESP_OK) { + ESP_LOGE(TAG, "i2c config failed"); + return false; + } + + if (i2c_driver_install(TWODOTFOUR_TOUCH_I2C_PORT, i2c_conf.mode, 0, 0, 0) != ESP_OK) { + ESP_LOGE(TAG, "i2c driver install failed"); + return false; + } + + return true; +} + +static bool init_spi2() { + const spi_bus_config_t bus_config = { + .sclk_io_num = TWODOTFOUR_SPI2_PIN_SCLK, + .mosi_io_num = TWODOTFOUR_SPI2_PIN_MOSI, + .miso_io_num = GPIO_NUM_NC, + .quadhd_io_num = GPIO_NUM_NC, + .quadwp_io_num = GPIO_NUM_NC, + .max_transfer_sz = TWODOTFOUR_SPI2_TRANSACTION_LIMIT + }; + + if (spi_bus_initialize(SPI2_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) { + TT_LOG_E(TAG, "SPI bus init failed"); + return false; + } + + return true; +} + +static bool init_spi3() { + const spi_bus_config_t bus_config = { + .sclk_io_num = TWODOTFOUR_SPI3_PIN_SCLK, + .mosi_io_num = TWODOTFOUR_SPI3_PIN_MOSI, + .miso_io_num = TWODOTFOUR_SPI3_PIN_MISO, + .quadhd_io_num = GPIO_NUM_NC, + .quadwp_io_num = GPIO_NUM_NC, + .max_transfer_sz = TWODOTFOUR_SPI3_TRANSACTION_LIMIT + }; + + if (spi_bus_initialize(SPI3_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) { + TT_LOG_E(TAG, "SPI bus init failed"); + return false; + } + + return true; +} + +bool twodotfour_bootstrap() { + TT_LOG_I(TAG, "Init I2C"); + if (!init_i2c()) { + TT_LOG_E(TAG, "Init I2C failed"); + return false; + } + + TT_LOG_I(TAG, "Init SPI2"); + if (!init_spi2()) { + TT_LOG_E(TAG, "Init SPI2 failed"); + return false; + } + + TT_LOG_I(TAG, "Init SPI3"); + if (!init_spi3()) { + TT_LOG_E(TAG, "Init SPI3 failed"); + return false; + } + + return true; +} diff --git a/boards/yellow_board/config.h b/boards/yellow_board/config.h new file mode 100644 index 00000000..2b9a3297 --- /dev/null +++ b/boards/yellow_board/config.h @@ -0,0 +1,39 @@ +#pragma once + +#include "driver/spi_common.h" +#include "driver/i2c.h" +#include "driver/gpio.h" + +// SPI 2 - display +#define TWODOTFOUR_SPI2_PIN_SCLK GPIO_NUM_14 +#define TWODOTFOUR_SPI2_PIN_MOSI GPIO_NUM_13 +#define TWODOTFOUR_SPI2_TRANSACTION_LIMIT TWODOTFOUR_LCD_DRAW_BUFFER_SIZE + +// SPI 3 - sdcard +#define TWODOTFOUR_SPI3_PIN_SCLK GPIO_NUM_18 +#define TWODOTFOUR_SPI3_PIN_MOSI GPIO_NUM_23 +#define TWODOTFOUR_SPI3_PIN_MISO GPIO_NUM_19 +#define TWODOTFOUR_SPI3_TRANSACTION_LIMIT 8192 // TODO: Determine proper limit + +// Display +#define TWODOTFOUR_LCD_SPI_HOST SPI2_HOST +#define TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION 240 +#define TWODOTFOUR_LCD_VERTICAL_RESOLUTION 320 +#define TWODOTFOUR_LCD_BITS_PER_PIXEL 16 +#define TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT (TWODOTFOUR_LCD_VERTICAL_RESOLUTION / 10) +#define TWODOTFOUR_LCD_DRAW_BUFFER_SIZE (TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION * TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT * (TWODOTFOUR_LCD_BITS_PER_PIXEL / 8)) +#define TWODOTFOUR_LCD_PIN_CS GPIO_NUM_15 +#define TWODOTFOUR_LCD_PIN_DC GPIO_NUM_2 +#define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27 + +// Touch +#define TWODOTFOUR_TOUCH_I2C_PORT 0 + +// SD Card +#define TWODOTFOUR_SDCARD_SPI_HOST SPI3_HOST +#define TWODOTFOUR_SDCARD_PIN_CS GPIO_NUM_5 +#define TWODOTFOUR_SDCARD_SPI_FREQUENCY 800000U +#define TWODOTFOUR_SDCARD_FORMAT_ON_MOUNT_FAILED false +#define TWODOTFOUR_SDCARD_MAX_OPEN_FILES 4 +#define TWODOTFOUR_SDCARD_ALLOC_UNIT_SIZE (16 * 1024) +#define TWODOTFOUR_SDCARD_STATUS_CHECK_ENABLED false diff --git a/boards/yellow_board/display.c b/boards/yellow_board/display.c index 09f269f8..d095d6d4 100644 --- a/boards/yellow_board/display.c +++ b/boards/yellow_board/display.c @@ -1,109 +1,86 @@ +#include "config.h" +#include "log.h" #include "driver/gpio.h" -#include "driver/spi_master.h" #include "esp_err.h" #include "esp_lcd_ili9341.h" #include "esp_lcd_panel_ops.h" -#include "esp_log.h" #include "esp_lvgl_port.h" #include "hal/lv_hal_disp.h" #include -#define TAG "2432s024_ili9341" - -#define LCD_SPI_HOST SPI2_HOST -#define LCD_PIN_SCLK GPIO_NUM_14 -#define LCD_PIN_MOSI GPIO_NUM_13 -#define LCD_PIN_CS GPIO_NUM_15 -#define LCD_PIN_DC GPIO_NUM_2 -#define LCD_PIN_BACKLIGHT GPIO_NUM_27 - -#define LCD_HORIZONTAL_RESOLUTION 240 -#define LCD_VERTICAL_RESOLUTION 320 -#define LCD_BITS_PER_PIXEL 16 -#define LCD_DRAW_BUFFER_HEIGHT (LCD_VERTICAL_RESOLUTION / 10) - -lv_disp_t* yellow_board_init_display() { - ESP_LOGI(TAG, "creating display"); +#define TAG "twodotfour_ili9341" +static void twodotfour_backlight_on() { gpio_config_t io_conf = { - .pin_bit_mask = BIT64(LCD_PIN_BACKLIGHT), + .pin_bit_mask = BIT64(TWODOTFOUR_LCD_PIN_BACKLIGHT), .mode = GPIO_MODE_OUTPUT, .pull_up_en = GPIO_PULLUP_DISABLE, .pull_down_en = GPIO_PULLDOWN_DISABLE, .intr_type = GPIO_INTR_DISABLE, }; + gpio_config(&io_conf); - size_t draw_buffer_size = LCD_HORIZONTAL_RESOLUTION * LCD_DRAW_BUFFER_HEIGHT * (LCD_BITS_PER_PIXEL / 8); - const spi_bus_config_t bus_config = ILI9341_PANEL_BUS_SPI_CONFIG( - LCD_PIN_SCLK, - LCD_PIN_MOSI, - draw_buffer_size - ); - - if (spi_bus_initialize(LCD_SPI_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) { - ESP_LOGD(TAG, "spi bus init failed"); - return false; + if (gpio_set_level(TWODOTFOUR_LCD_PIN_BACKLIGHT, 1) != ESP_OK) { + TT_LOG_E(TAG, "Failed to turn backlight on"); } +} + +lv_disp_t* twodotfour_display_init() { + TT_LOG_I(TAG, "Display init"); const esp_lcd_panel_io_spi_config_t panel_io_config = ILI9341_PANEL_IO_SPI_CONFIG( - LCD_PIN_CS, - LCD_PIN_DC, + TWODOTFOUR_LCD_PIN_CS, + TWODOTFOUR_LCD_PIN_DC, NULL, NULL ); 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"); + 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"); return false; } - ESP_LOGI(TAG, "install driver"); const esp_lcd_panel_dev_config_t panel_config = { .reset_gpio_num = GPIO_NUM_NC, .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR, - .bits_per_pixel = LCD_BITS_PER_PIXEL, + .bits_per_pixel = TWODOTFOUR_LCD_BITS_PER_PIXEL, }; 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"); + TT_LOG_E(TAG, "Failed to create ili9341"); return false; } if (esp_lcd_panel_reset(panel_handle) != ESP_OK) { - ESP_LOGD(TAG, "failed to reset panel"); + TT_LOG_E(TAG, "Failed to reset panel"); return false; } if (esp_lcd_panel_init(panel_handle) != ESP_OK) { - ESP_LOGD(TAG, "failed to init panel"); + TT_LOG_E(TAG, "Failed to init panel"); return false; } if (esp_lcd_panel_mirror(panel_handle, true, false) != ESP_OK) { - ESP_LOGD(TAG, "failed to set panel to mirror"); + TT_LOG_E(TAG, "Failed to set panel to mirror"); return false; } if (esp_lcd_panel_disp_on_off(panel_handle, true) != ESP_OK) { - ESP_LOGD(TAG, "failed to turn display on"); - return false; - } - - if (gpio_set_level(LCD_PIN_BACKLIGHT, 1) != ESP_OK) { - ESP_LOGD(TAG, "failed to turn backlight on"); + TT_LOG_E(TAG, "Failed to turn display on"); return false; } const lvgl_port_display_cfg_t disp_cfg = { .io_handle = io_handle, .panel_handle = panel_handle, - .buffer_size = LCD_HORIZONTAL_RESOLUTION * LCD_DRAW_BUFFER_HEIGHT * (LCD_BITS_PER_PIXEL / 8), + .buffer_size = TWODOTFOUR_LCD_DRAW_BUFFER_SIZE, .double_buffer = false, - .hres = LCD_HORIZONTAL_RESOLUTION, - .vres = LCD_VERTICAL_RESOLUTION, + .hres = TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION, + .vres = TWODOTFOUR_LCD_VERTICAL_RESOLUTION, .monochrome = false, .rotation = { .swap_xy = false, @@ -115,5 +92,9 @@ lv_disp_t* yellow_board_init_display() { } }; - return lvgl_port_add_disp(&disp_cfg); + lv_disp_t* display = lvgl_port_add_disp(&disp_cfg); + + twodotfour_backlight_on(); + + return display; } diff --git a/boards/yellow_board/lvgl.c b/boards/yellow_board/lvgl.c index 3c8ade16..2f6fc69d 100644 --- a/boards/yellow_board/lvgl.c +++ b/boards/yellow_board/lvgl.c @@ -3,12 +3,12 @@ #include "ui/lvgl_sync.h" #include -#define TAG "yellow_board_lvgl" +#define TAG "twodotfour_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); +lv_disp_t* twodotfour_display_init(); +bool twodotfour_touch_init(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle); -bool yellow_board_init_lvgl() { +bool twodotfour_lvgl_init() { static lv_disp_t* display = NULL; static esp_lcd_panel_io_handle_t touch_io_handle; static esp_lcd_touch_handle_t touch_handle; @@ -27,15 +27,14 @@ bool yellow_board_init_lvgl() { } // Add display - display = yellow_board_init_display(); + display = twodotfour_display_init(); 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)) { + if (!twodotfour_touch_init(&touch_io_handle, &touch_handle)) { return false; } diff --git a/boards/yellow_board/sdcard.c b/boards/yellow_board/sdcard.c new file mode 100644 index 00000000..c8cc18e1 --- /dev/null +++ b/boards/yellow_board/sdcard.c @@ -0,0 +1,73 @@ +#include "sdcard.h" +#include "check.h" +#include "log.h" +#include "config.h" + +#include "esp_vfs_fat.h" +#include "sdmmc_cmd.h" + +#define TAG "twodotfour_sdcard" + +typedef struct { + const char* mount_point; + sdmmc_card_t* card; +} MountData; + +static void* sdcard_mount(const char* mount_point) { + TT_LOG_I(TAG, "Mounting %s", mount_point); + + esp_vfs_fat_sdmmc_mount_config_t mount_config = { + .format_if_mount_failed = TWODOTFOUR_SDCARD_FORMAT_ON_MOUNT_FAILED, + .max_files = TWODOTFOUR_SDCARD_MAX_OPEN_FILES, + .allocation_unit_size = TWODOTFOUR_SDCARD_ALLOC_UNIT_SIZE, + .disk_status_check_enable = TWODOTFOUR_SDCARD_STATUS_CHECK_ENABLED + }; + + sdmmc_card_t* card; + + // Init without card detect (CD) and write protect (WD) + sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT(); + slot_config.gpio_cs = TWODOTFOUR_SDCARD_PIN_CS; + slot_config.host_id = TWODOTFOUR_SDCARD_SPI_HOST; + + sdmmc_host_t host = SDSPI_HOST_DEFAULT(); + host.max_freq_khz = TWODOTFOUR_SDCARD_SPI_FREQUENCY; + esp_err_t ret = esp_vfs_fat_sdspi_mount(mount_point, &host, &slot_config, &mount_config, &card); + + if (ret != ESP_OK) { + if (ret == ESP_FAIL) { + TT_LOG_E(TAG, "Mounting failed. Ensure the card is formatted with FAT."); + } else { + TT_LOG_E(TAG, "Mounting failed (%s)", esp_err_to_name(ret)); + } + return NULL; + } + + MountData* data = malloc(sizeof(MountData)); + *data = (MountData) { + .card = card, + .mount_point = mount_point + }; + + sdmmc_card_print_info(stdout, data->card); + + return data; +} + +static void sdcard_unmount(void* context) { + MountData* data = (MountData*)context; + TT_LOG_I(TAG, "Unmounting %s", data->mount_point); + + tt_assert(data != NULL); + if (esp_vfs_fat_sdcard_unmount(data->mount_point, data->card) != ESP_OK) { + TT_LOG_E(TAG, "Unmount failed for %s", data->mount_point); + } + + free(data); +} + +const SdCard twodotfour_sdcard = { + .mount = &sdcard_mount, + .unmount = &sdcard_unmount, + .mount_behaviour = SDCARD_MOUNT_BEHAVIOUR_ANYTIME +}; diff --git a/boards/yellow_board/touch.c b/boards/yellow_board/touch.c index 6866bad7..ec3d737f 100644 --- a/boards/yellow_board/touch.c +++ b/boards/yellow_board/touch.c @@ -1,42 +1,21 @@ +#include "config.h" #include "driver/i2c.h" +#include "log.h" #include "esp_err.h" #include "esp_lcd_touch_cst816s.h" -#include "esp_log.h" -#define TOUCH_I2C_PORT 0 +#define TAG "twodotfour_cst816" -#define TAG "2432s024_cst816" - -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 = { - .mode = I2C_MODE_MASTER, - .sda_io_num = GPIO_NUM_33, - .sda_pullup_en = GPIO_PULLUP_DISABLE, - .scl_io_num = GPIO_NUM_32, - .scl_pullup_en = GPIO_PULLUP_DISABLE, - .master.clk_speed = 400000 - }; - - if (i2c_param_config(TOUCH_I2C_PORT, &i2c_conf) != ESP_OK) { - ESP_LOGE(TAG, "i2c config failed"); - return false; - } - - if (i2c_driver_install(TOUCH_I2C_PORT, i2c_conf.mode, 0, 0, 0) != ESP_OK) { - ESP_LOGE(TAG, "i2c driver install failed"); - return false; - } +bool twodotfour_touch_init(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_handle_t* touch_handle) { + TT_LOG_I(TAG, "Touch init"); const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG(); - if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TOUCH_I2C_PORT, &touch_io_config, io_handle) != ESP_OK) { - ESP_LOGE(TAG, "touch I2C IO init failed"); + 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"); return false; } - ESP_LOGI(TAG, "create_touch"); esp_lcd_touch_config_t config = { .x_max = 240, .y_max = 320, @@ -57,7 +36,7 @@ bool yellow_board_init_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch }; if (esp_lcd_touch_new_i2c_cst816s(*io_handle, &config, touch_handle) != ESP_OK) { - ESP_LOGE(TAG, "esp_lcd_touch_new_i2c_cst816s failed"); + TT_LOG_E(TAG, "Driver init failed"); return false; } diff --git a/boards/yellow_board/yellow_board.c b/boards/yellow_board/yellow_board.c index 1208eec4..3ab71a41 100644 --- a/boards/yellow_board/yellow_board.c +++ b/boards/yellow_board/yellow_board.c @@ -1,8 +1,12 @@ #include "yellow_board.h" -bool yellow_board_init_lvgl(); +bool twodotfour_lvgl_init(); +bool twodotfour_bootstrap(); + +extern const SdCard twodotfour_sdcard; const HardwareConfig yellow_board_24inch_cap = { - .bootstrap = NULL, - .init_lvgl = &yellow_board_init_lvgl + .bootstrap = &twodotfour_bootstrap, + .init_lvgl = &twodotfour_lvgl_init, + .sdcard = &twodotfour_sdcard }; diff --git a/tactility/src/services/gui/gui.c b/tactility/src/services/gui/gui.c index 418cd53c..78fe28c4 100644 --- a/tactility/src/services/gui/gui.c +++ b/tactility/src/services/gui/gui.c @@ -54,7 +54,7 @@ void gui_free(Gui* instance) { void gui_lock() { tt_assert(gui); tt_assert(gui->mutex); - tt_check(tt_mutex_acquire(gui->mutex, 1000 / portTICK_PERIOD_MS) == TtStatusOk); + tt_check(tt_mutex_acquire(gui->mutex, configTICK_RATE_HZ) == TtStatusOk); } void gui_unlock() { @@ -84,7 +84,7 @@ void gui_hide_app() { // We must lock the LVGL port, because the viewport hide callbacks // might call LVGL APIs (e.g. to remove the keyboard from the screen root) - tt_check(tt_lvgl_lock(1000)); + tt_check(tt_lvgl_lock(configTICK_RATE_HZ)); view_port_hide(view_port); tt_lvgl_unlock(); diff --git a/tactility/src/services/gui/gui_keyboard.c b/tactility/src/services/gui/gui_keyboard.c index f18f47e0..77832ed0 100644 --- a/tactility/src/services/gui/gui_keyboard.c +++ b/tactility/src/services/gui/gui_keyboard.c @@ -23,15 +23,12 @@ void gui_keyboard_show(lv_obj_t* textarea) { gui_lock(); if (gui->keyboard) { - gui_lock(); - lv_obj_clear_flag(gui->keyboard, LV_OBJ_FLAG_HIDDEN); lv_keyboard_set_textarea(gui->keyboard, textarea); if (gui->toolbar) { lv_obj_add_flag(gui->toolbar, LV_OBJ_FLAG_HIDDEN); } - } gui_unlock(); diff --git a/tactility/src/services/loader/loader.c b/tactility/src/services/loader/loader.c index 5beb80d4..8d62ec5f 100644 --- a/tactility/src/services/loader/loader.c +++ b/tactility/src/services/loader/loader.c @@ -15,7 +15,7 @@ #include "semphr.h" #endif -#define TAG "Loader" +#define TAG "loader" // Forward declarations static int32_t loader_main(void* p);