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.
This commit is contained in:
2026-01-24 20:02:04 +05:30
parent 8aeaed8a15
commit 4d68a788ad
22 changed files with 5255 additions and 93 deletions

84
main/drivers/nvs_driver.h Normal file
View File

@@ -0,0 +1,84 @@
/**
* @file nvs_driver.h
* @brief Non-Volatile Storage abstraction for persistent state
*
* Handles reading and writing system state to flash memory.
* Used for tracking first-boot status and other persistent flags.
*/
#ifndef NVS_DRIVER_H
#define NVS_DRIVER_H
#include "esp_err.h"
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize NVS flash
*
* Must be called before any other NVS operations.
* Handles partition initialization and potential recovery.
*
* @return true on success, false on failure
*/
bool nvsDriverInit(void);
/**
* @brief Check if this is the device's first boot
*
* Checks for the existence of a "provisioned" flag.
*
* @return true if first boot (flag not found), false otherwise
*/
bool nvsDriverIsFirstBoot(void);
/**
* @brief Mark the device as provisioned (not first boot)
*
* Writes the persistent flag to storage.
*
* @return true on success
*/
bool nvsDriverMarkProvisioned(void);
/**
* @brief Get the total boot count
*
* @return Number of times device has booted (defaults to 1 if read fails)
*/
uint32_t nvsDriverGetBootCount(void);
/**
* @brief Increment the total boot count
*/
void nvsDriverIncrementBootCount(void);
/**
* @brief Save IMU calibration data to NVS
*
* @param x X-axis baseline value
* @param y Y-axis baseline value
* @param z Z-axis baseline value
* @return true on success, false on failure
*/
bool nvsDriverSaveImuCalibration(float x, float y, float z);
/**
* @brief Load IMU calibration data from NVS
*
* @param x Pointer to store X-axis baseline
* @param y Pointer to store Y-axis baseline
* @param z Pointer to store Z-axis baseline
* @return true if calibration data exists and was loaded, false otherwise
*/
bool nvsDriverLoadImuCalibration(float *x, float *y, float *z);
#ifdef __cplusplus
}
#endif
#endif // NVS_DRIVER_H