Files
iroBotAMOLED_Test/main/ui/splash_screen.c
Neil Arora 4d68a788ad Add shake emotion with persistent state and calibration
Introduces a new shake emotion animation with a shake-stop transition, including embedded Lottie animation data and a state machine for emotion transitions. Adds a non-volatile storage (NVS) driver for persistent state management, including first-boot detection, boot count, and IMU calibration storage. Updates emotion manager and related headers to support new shake emotion states, and integrates new UI components for calibration and loading animations.
2026-01-24 20:02:04 +05:30

84 lines
2.5 KiB
C

/**
* @file splash_screen.c
* @brief Splash screen implementation for LVGL
*
* Displays the company logo on startup for a configured duration.
* The implementation creates a temporary screen, renders the logo,
* and then cleans up to prepare for the main application UI.
*/
#include "ui/splash_screen.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "lvgl.h"
#include "ui/assets/splash_screen/logo_iro.h"
static const char *TAG = "splash_screen";
// ----------------------------------------------------------------------------
// Public API Implementation
// ----------------------------------------------------------------------------
void splashScreenShow(void) {
ESP_LOGI(TAG, "Showing splash screen");
// Create a temporary screen for the splash
lv_obj_t *splashScreen = lv_obj_create(NULL);
if (splashScreen == NULL) {
ESP_LOGE(TAG, "Failed to create splash screen object");
return;
}
lv_obj_set_style_bg_color(splashScreen, lv_color_black(),
LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(splashScreen, LV_OPA_COVER,
LV_PART_MAIN | LV_STATE_DEFAULT);
// Create and center the logo image
lv_obj_t *logoImage = lv_img_create(splashScreen);
if (logoImage == NULL) {
ESP_LOGE(TAG, "Failed to create logo image object");
lv_obj_del(splashScreen);
return;
}
lv_img_set_src(logoImage, &logoIro);
lv_obj_center(logoImage);
// Activate the splash screen
lv_scr_load(splashScreen);
lv_refr_now(NULL);
ESP_LOGI(TAG, "Splash screen displayed, waiting %d ms",
SPLASH_SCREEN_DURATION_MS);
// Block for the display duration
vTaskDelay(pdMS_TO_TICKS(SPLASH_SCREEN_DURATION_MS));
// Create a new main screen for the application to use
lv_obj_t *mainScreen = lv_obj_create(NULL);
if (mainScreen == NULL) {
ESP_LOGE(TAG, "Failed to create main screen");
return;
}
// Set black background for main screen
lv_obj_set_style_bg_color(mainScreen, lv_color_black(),
LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(mainScreen, LV_OPA_COVER,
LV_PART_MAIN | LV_STATE_DEFAULT);
// Switch to the main screen (this deactivates splash screen)
lv_scr_load(mainScreen);
// Force an immediate refresh to ensure the transition is complete
lv_refr_now(NULL);
// Now safe to delete the splash screen and its children
lv_obj_del(splashScreen);
ESP_LOGI(TAG, "Splash screen complete, main screen active");
}