Skip to content

Commit

Permalink
app: fix display lock during gui initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
georgik committed Jul 19, 2024
1 parent 706e947 commit 8c6a4b9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
16 changes: 16 additions & 0 deletions apps/tic_tac_toe/diagram.json
Original file line number Diff line number Diff line change
@@ -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": {}
}
14 changes: 5 additions & 9 deletions apps/tic_tac_toe/main/tic_tac_toe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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};
Expand All @@ -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
}
}
5 changes: 5 additions & 0 deletions apps/tic_tac_toe/wokwi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[wokwi]
version = 1
elf = "build/uf2.bin"
firmware = "build/uf2.bin"

0 comments on commit 8c6a4b9

Please sign in to comment.