update: added support for IMU and Lottie JSON

This commit is contained in:
2026-01-24 13:50:49 +05:30
parent ecf234efa5
commit 2c731c72e3
868 changed files with 318873 additions and 894 deletions

113
main/lottie_player.h Normal file
View File

@@ -0,0 +1,113 @@
/**
* @file lottie_player.h
* @brief Lightweight Lottie animation player for LVGL on ESP32
*
* This module provides a minimal Lottie JSON animation player optimized for
* embedded systems. It supports basic shape types (rounded rectangles) with
* keyframe animation and bezier curve interpolation.
*
* Designed for simple animations like blinking eyes on resource-constrained
* devices. Does not support the full Lottie specification.
*/
#ifndef LOTTIE_PLAYER_H
#define LOTTIE_PLAYER_H
#include "lvgl.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// Forward declaration of internal structure
typedef struct lottie_player_t *lottie_player_handle_t;
/**
* @brief Create a Lottie animation player from embedded JSON data
*
* Parses the Lottie JSON and creates an LVGL object hierarchy for rendering.
* The animation starts in paused state - call lottie_play() to begin playback.
*
* @param parent Parent LVGL object to attach the animation to
* @param json_data Pointer to null-terminated JSON string in flash
* @return Handle to the player instance, or NULL on failure
*/
lottie_player_handle_t lottie_create_from_data(lv_obj_t *parent,
const char *json_data);
/**
* @brief Start or resume animation playback
*
* @param handle Handle to the Lottie player instance
*/
void lottie_play(lottie_player_handle_t handle);
/**
* @brief Pause animation playback
*
* @param handle Handle to the Lottie player instance
*/
void lottie_pause(lottie_player_handle_t handle);
/**
* @brief Stop animation and reset to first frame
*
* @param handle Handle to the Lottie player instance
*/
void lottie_stop(lottie_player_handle_t handle);
/**
* @brief Set whether the animation should loop
*
* @param handle Handle to the Lottie player instance
* @param loop True to enable looping, false for single playthrough
*/
void lottie_set_loop(lottie_player_handle_t handle, bool loop);
/**
* @brief Check if animation is currently playing
*
* @param handle Handle to the Lottie player instance
* @return True if playing, false if paused or stopped
*/
bool lottie_is_playing(lottie_player_handle_t handle);
/**
* @brief Get the current frame number
*
* @param handle Handle to the Lottie player instance
* @return Current frame number (0-indexed)
*/
uint32_t lottie_get_current_frame(lottie_player_handle_t handle);
/**
* @brief Get total number of frames in the animation
*
* @param handle Handle to the Lottie player instance
* @return Total frame count
*/
uint32_t lottie_get_total_frames(lottie_player_handle_t handle);
/**
* @brief Set the current frame manually
*
* @param handle Handle to the Lottie player instance
* @param frame Frame number to seek to (clamped to valid range)
*/
void lottie_set_frame(lottie_player_handle_t handle, uint32_t frame);
/**
* @brief Destroy the Lottie player and free all resources
*
* @param handle Handle to the Lottie player instance
*/
void lottie_destroy(lottie_player_handle_t handle);
#ifdef __cplusplus
}
#endif
#endif /* LOTTIE_PLAYER_H */