From 43b32b8b686f69c3ba889b13e7706ed25d22e836 Mon Sep 17 00:00:00 2001 From: Marc Pasteur Date: Sat, 7 Feb 2026 08:24:32 +0100 Subject: [PATCH] on deplace l'ihm dans domotic_display --- components/domotic_display/CMakeLists.txt | 8 +++++ components/domotic_display/ihm.c | 19 ++++++++++- main/CMakeLists.txt | 7 ---- main/communication.c | 2 +- main/main.c | 40 ++++++++++++++++------- 5 files changed, 55 insertions(+), 21 deletions(-) diff --git a/components/domotic_display/CMakeLists.txt b/components/domotic_display/CMakeLists.txt index a76d902..2c3aabd 100644 --- a/components/domotic_display/CMakeLists.txt +++ b/components/domotic_display/CMakeLists.txt @@ -37,6 +37,14 @@ elseif(${IDF_TARGET} STREQUAL "linux") idf_component_register(SRC_DIRS . fonts images INCLUDE_DIRS "include" REQUIRES ${comps}) + message("Including SDL2 support") + find_package(SDL2 REQUIRED) + target_link_libraries(${COMPONENT_LIB} PUBLIC + -Wl,--no-as-needed + SDL2 + -Wl,--as-needed + ) + target_compile_options(${COMPONENT_LIB} PUBLIC -DLV_LVGL_H_INCLUDE_SIMPLE) endif() diff --git a/components/domotic_display/ihm.c b/components/domotic_display/ihm.c index 8741705..c6d60dc 100644 --- a/components/domotic_display/ihm.c +++ b/components/domotic_display/ihm.c @@ -206,9 +206,23 @@ static void event_handler(lv_event_t *e) } } +#if CONFIG_IDF_TARGET_LINUX + static lv_display_t *display; + static lv_indev_t *mouse; + static lv_indev_t *mouse_wheel; + static lv_indev_t *keyboard; +#endif void init_display_ihm(){ - /* + + lv_init(); + #if CONFIG_IDF_TARGET_LINUX + printf("Hello from sim\n"); + display = lv_sdl_window_create(1024, 600); + mouse = lv_sdl_mouse_create(); + mouse_wheel = lv_sdl_mousewheel_create(); + keyboard = lv_sdl_keyboard_create(); + #else lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG(); lvgl_cfg.task_priority=15; bsp_display_cfg_t cfg = { @@ -227,6 +241,9 @@ void init_display_ihm(){ bsp_display_backlight_on(); bsp_display_brightness_set(50); + #endif + + /* */ mainState.display_init=true; diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index fc4d3af..c2c7679 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -20,13 +20,6 @@ elseif(${IDF_TARGET} STREQUAL "linux") EMBED_TXTFILES ${PROJECT_DIR}/main/ca_cert.pem EMBED_FILES "index.html") - message("Including SDL2 support") - find_package(SDL2 REQUIRED) - target_link_libraries(${COMPONENT_LIB} PUBLIC - -Wl,--no-as-needed - SDL2 - -Wl,--as-needed - ) target_compile_options(${COMPONENT_LIB} PUBLIC --coverage -DLV_LVGL_H_INCLUDE_SIMPLE ) diff --git a/main/communication.c b/main/communication.c index fd1a84d..0938136 100644 --- a/main/communication.c +++ b/main/communication.c @@ -253,7 +253,7 @@ void wifi_init_sta(wifi_callback callback) ESP_ERROR_CHECK(esp_netif_init()); - ESP_ERROR_CHECK(esp_event_loop_create_default()); + //ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_create_default_wifi_sta(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); diff --git a/main/main.c b/main/main.c index a602e88..c1d14b0 100644 --- a/main/main.c +++ b/main/main.c @@ -895,34 +895,50 @@ void lightSensorTask(void *pvParameter){ } */ } - static lv_display_t *display; - static lv_indev_t *mouse; - static lv_indev_t *mouse_wheel; - static lv_indev_t *keyboard; void app_main(void) { - printf("Hello from sim\n"); - lv_init(); - display = lv_sdl_window_create(1024, 600); - mouse = lv_sdl_mouse_create(); - mouse_wheel = lv_sdl_mousewheel_create(); - keyboard = lv_sdl_keyboard_create(); + ESP_ERROR_CHECK(esp_event_loop_create_default()); ihm_gateway_init(); startEvtManager(); + + boucleMeteo(); + #if CONFIG_IDF_TARGET_LINUX + // en mode linux on simule l'obtention de la connexion wifi + xEventGroupSetBits(domotic_event_group, WIFI_CONNECTED_BIT); + drawIhm(NULL); + #else + xTaskCreatePinnedToCore(&drawIhm,"ihm_task",10000,getIHMQueueHandle(),10,NULL,0); + #endif + + TaskHandle_t xHandle = NULL; + BaseType_t ret1; + ret1 = xTaskCreate(&imgdwn, "imageDownload_task", 3 * 1024, domotic_event_group, 5, &xHandle); + if (ret1 != pdPASS) + { + ESP_LOGE(TAG, "Impossiblke de creer la tache imageDownload_task %i", ret1); + } + /* Create widgets on the screen */ //lv_demo_widgets(); +} +void boucleMeteo() +{ + on_weather_data_retrieval(weather_data_retreived); + on_weather_data_retrieval_start(weather_data_retreived_start); + ESP_LOGW(TAG, "Weather data retrieval initialized"); + initialise_weather_data_retrieval(600000, domotic_event_group); } void app_main1(void) { //esp_task_wdt_deinit(); // désactive le task watchdog - vTaskDelay(pdMS_TO_TICKS(10000)); // laisse le temps d'attacher GDB + //vTaskDelay(pdMS_TO_TICKS(10000)); // laisse le temps d'attacher GDB //bh1750_measure_mode_t cmd_measure; @@ -1011,7 +1027,7 @@ void app_main1(void) //esp_wifi_set_ps(WIFI_PS_NONE); //xTaskCreatePinnedToCore(&simple_ota_example_task, "ota__task", 8192, NULL, 6, NULL,0); - on_weather_data_retrieval(weather_data_retreived); + on_weather_data_retrieval(weather_data_retreived); on_weather_data_retrieval_start(weather_data_retreived_start); ESP_LOGW(TAG, "Weather data retrieval initialized"); initialise_weather_data_retrieval(600000, domotic_event_group);