From 8c6a4b932c41ab0d6dc1bae4b4a7a34eb54f2688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Fri, 19 Jul 2024 09:13:23 +0200 Subject: [PATCH] app: fix display lock during gui initialization --- apps/tic_tac_toe/diagram.json | 16 ++++++++++++++++ apps/tic_tac_toe/main/tic_tac_toe.c | 14 +++++--------- apps/tic_tac_toe/wokwi.toml | 5 +++++ 3 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 apps/tic_tac_toe/diagram.json create mode 100644 apps/tic_tac_toe/wokwi.toml diff --git a/apps/tic_tac_toe/diagram.json b/apps/tic_tac_toe/diagram.json new file mode 100644 index 0000000..8ff7d2e --- /dev/null +++ b/apps/tic_tac_toe/diagram.json @@ -0,0 +1,16 @@ +{ + "version": 1, + "author": "Uri Shaked", + "editor": "wokwi", + "parts": [ + { + "type": "board-esp32-s3-box-3", + "id": "esp32", + "top": -24.91, + "left": -388.54, + "attrs": { "psramSize": "16", "flashSize": "16" } + } + ], + "connections": [ [ "$serialMonitor:RX", "esp32:G43", "", [] ], [ "$serialMonitor:TX", "esp32:G44", "", [] ] ], + "dependencies": {} + } \ No newline at end of file diff --git a/apps/tic_tac_toe/main/tic_tac_toe.c b/apps/tic_tac_toe/main/tic_tac_toe.c index cf57234..c506841 100644 --- a/apps/tic_tac_toe/main/tic_tac_toe.c +++ b/apps/tic_tac_toe/main/tic_tac_toe.c @@ -89,12 +89,6 @@ static void event_handler(lv_event_t *e) { } } -void lvgl_task(void *pvParameter) { - while (1) { - vTaskDelay(pdMS_TO_TICKS(1000)); // Add a small delay to prevent watchdog issues - } -} - void reset_to_factory_app() { // Get the partition structure for the factory partition const esp_partition_t *factory_partition = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL); @@ -119,8 +113,8 @@ void app_main(void) { // Initialize the BSP bsp_i2c_init(); bsp_display_start(); - lv_init(); + bsp_display_lock(0); // Create a grid for buttons lv_obj_t *grid = lv_obj_create(lv_scr_act()); static lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; @@ -140,11 +134,13 @@ void app_main(void) { btn_grid[row][col] = btn; } } + bsp_display_unlock(); bsp_display_backlight_on(); reset_game(); - // Create a task to handle LVGL - xTaskCreate(lvgl_task, "lvgl_task", 16384, NULL, 1, NULL); + while (1) { + vTaskDelay(pdMS_TO_TICKS(1000)); // Add a small delay to prevent watchdog issues + } } diff --git a/apps/tic_tac_toe/wokwi.toml b/apps/tic_tac_toe/wokwi.toml new file mode 100644 index 0000000..689fc7e --- /dev/null +++ b/apps/tic_tac_toe/wokwi.toml @@ -0,0 +1,5 @@ +[wokwi] +version = 1 +elf = "build/uf2.bin" +firmware = "build/uf2.bin" +