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

View File

@@ -21,10 +21,11 @@ extern "C" {
// ----------------------------------------------------------------------------
// Acceleration deviation threshold to detect shake (in G)
#define SHAKE_ACCEL_THRESHOLD 0.5f
// Set above 1G to account for gravity and require actual vigorous shaking
#define SHAKE_ACCEL_THRESHOLD 1.3f
// Debounce time between shake detections (milliseconds)
#define SHAKE_DEBOUNCE_MS 2000
// Number of consecutive readings above threshold to confirm shake
#define SHAKE_CONTINUOUS_THRESHOLD 10
// Number of samples to average for baseline calibration
#define SHAKE_BASELINE_SAMPLES 10
@@ -34,13 +35,12 @@ extern "C" {
// ----------------------------------------------------------------------------
/**
* @brief Shake event types with associated emotions
* @brief Shake event types
*/
typedef enum {
SHAKE_NONE = 0, // No shake detected
SHAKE_SURPRISED, // Quick shake - surprised emotion
SHAKE_SAD, // Shake detected - sad emotion
SHAKE_ANGRY // Shake detected - angry emotion
SHAKE_NONE = 0, // No shake detected
SHAKE_ACTIVE, // Device is currently being shaken
SHAKE_STOPPED // Shaking just stopped
} ShakeEvent;
// ----------------------------------------------------------------------------
@@ -79,6 +79,36 @@ ShakeEvent shakeDetectorUpdate(void);
*/
bool shakeDetectorGetRawAccel(float *x, float *y, float *z);
/**
* @brief Perform immediate baseline calibration
*
* Collects multiple samples and computes the baseline average.
* Should be called when device is on a stable, flat surface.
*
* @return true on successful calibration, false on failure
*/
bool shakeDetectorCalibrateBaseline(void);
/**
* @brief Set baseline values directly
*
* Used to restore calibration from NVS storage.
*
* @param x X-axis baseline value
* @param y Y-axis baseline value
* @param z Z-axis baseline value
*/
void shakeDetectorSetBaseline(float x, float y, float z);
/**
* @brief Get current baseline values
*
* @param x Pointer to store X-axis baseline
* @param y Pointer to store Y-axis baseline
* @param z Pointer to store Z-axis baseline
*/
void shakeDetectorGetBaseline(float *x, float *y, float *z);
#ifdef __cplusplus
}
#endif