Initial project import with ESP32 animated eyes
Add initial project files for ESP32 animated eyes, including main application sources, assets, CMake configuration, and supporting ESP-IDF components for LCD and touch functionality. Includes documentation, test apps, and configuration files.
This commit is contained in:
55
main/splash_screen.c
Normal file
55
main/splash_screen.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @file splash_screen.c
|
||||
* @brief Splash screen implementation for LVGL
|
||||
*/
|
||||
|
||||
#include "splash_screen.h"
|
||||
#include "lvgl.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
// Include the logo image data
|
||||
#include "../assets/logoIro.c"
|
||||
|
||||
static const char *TAG = "splash_screen";
|
||||
|
||||
// Splash screen display duration in milliseconds
|
||||
#define SPLASH_SCREEN_DURATION_MS 2000
|
||||
|
||||
void splash_screen_show(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Showing splash screen");
|
||||
|
||||
// Create a new screen for the splash
|
||||
lv_obj_t *splash_screen = lv_obj_create(NULL);
|
||||
// Set background color and opacity using LVGL v8 style API (selector LV_PART_MAIN|LV_STATE_DEFAULT)
|
||||
lv_obj_set_style_bg_color(splash_screen, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_opa(splash_screen, LV_OPA_COVER, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
// Removed redundant old style call (LVGL v7 API)
|
||||
|
||||
// Create the logo image
|
||||
lv_obj_t *logo_img = lv_img_create(splash_screen);
|
||||
lv_img_set_src(logo_img, &logoIro);
|
||||
lv_obj_center(logo_img);
|
||||
|
||||
// Load the splash screen
|
||||
lv_scr_load(splash_screen);
|
||||
|
||||
// Force a refresh to ensure the splash screen is displayed
|
||||
lv_refr_now(NULL);
|
||||
|
||||
ESP_LOGI(TAG, "Splash screen displayed, waiting %d ms", SPLASH_SCREEN_DURATION_MS);
|
||||
|
||||
// Wait for the splash screen duration
|
||||
vTaskDelay(pdMS_TO_TICKS(SPLASH_SCREEN_DURATION_MS));
|
||||
|
||||
ESP_LOGI(TAG, "Splash screen done");
|
||||
|
||||
// Clean up: Delete the logo image object before returning
|
||||
// This ensures LVGL's internal state is clean before lv_demo_music() runs
|
||||
lv_obj_del(logo_img);
|
||||
|
||||
// Note: We delete the image but keep the screen active.
|
||||
// The next screen (lv_demo_music) will replace it automatically.
|
||||
}
|
||||
Reference in New Issue
Block a user