From 90031cd16e72f15eda516102b6a29ca93f95bbdf Mon Sep 17 00:00:00 2001 From: Neil Arora Date: Sun, 25 Jan 2026 16:12:11 +0530 Subject: [PATCH] Add progressive deceleration to shake emotion and new shy asset Implements a progressive deceleration phase for the shake emotion using a cubic ease-out, replacing the previous abrupt stop logic. Adds the shy.json animation asset for the 'shy' emotion. Updates lottie_player to properly delete existing blink timers before scheduling a new one. Also includes minor header and enum adjustments for shake_emotion. --- .gitignore | 1 + main/emotion-engine/shake/shake_emotion.c | 84 +++++++++++++---------- main/emotion-engine/shake/shake_emotion.h | 1 + main/emotion-engine/shy/shy.json | 1 + main/ui/lottie_player.c | 6 ++ 5 files changed, 56 insertions(+), 37 deletions(-) create mode 100644 main/emotion-engine/shy/shy.json diff --git a/.gitignore b/.gitignore index fefd354..22b1ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ sdkconfig.old /managed_components /03_QMI8658 /.github +AGENTS.md diff --git a/main/emotion-engine/shake/shake_emotion.c b/main/emotion-engine/shake/shake_emotion.c index 4156d0f..a65c046 100644 --- a/main/emotion-engine/shake/shake_emotion.c +++ b/main/emotion-engine/shake/shake_emotion.c @@ -18,6 +18,7 @@ #include "drivers/display_driver.h" #include "esp_log.h" #include "ui/lottie_player.h" +#include "esp_timer.h" static const char *TAG = "shake_emotion"; @@ -257,8 +258,7 @@ static const char *shakeStopAnimationData = typedef enum { SHAKE_STATE_IDLE = 0, SHAKE_STATE_SHAKING, - SHAKE_STATE_FINISHING_LOOP, - SHAKE_STATE_PLAYING_STOP_ANIM, + SHAKE_STATE_SLOWING_DOWN, SHAKE_STATE_COMPLETE } ShakeState; @@ -271,6 +271,10 @@ static lottie_player_handle_t stopPlayer = NULL; static bool initialized = false; static ShakeState state = SHAKE_STATE_IDLE; +// Recovery phase variables for progressive deceleration +static int64_t slowdown_start_time = 0; +static const int64_t slowdown_duration_ms = 1000; // 1 second recovery phase + // ---------------------------------------------------------------------------- // Public API Implementation // ---------------------------------------------------------------------------- @@ -330,8 +334,11 @@ void shakeEmotionBeginStop(void) { lottieSetLoop(shakePlayer, false); } - state = SHAKE_STATE_FINISHING_LOOP; - ESP_LOGI(TAG, "Finishing shake loop before stop animation"); + // Record the start time for progressive deceleration + slowdown_start_time = esp_timer_get_time() / 1000; // Convert to milliseconds + + state = SHAKE_STATE_SLOWING_DOWN; + ESP_LOGI(TAG, "Starting progressive deceleration phase"); } bool shakeEmotionUpdate(void) { @@ -339,44 +346,48 @@ bool shakeEmotionUpdate(void) { return false; } - if (state == SHAKE_STATE_FINISHING_LOOP) { + if (state == SHAKE_STATE_SLOWING_DOWN) { + // Calculate elapsed time since slowdown began + int64_t current_time = esp_timer_get_time() / 1000; // Convert to milliseconds + int64_t elapsed_ms = current_time - slowdown_start_time; + // Check if shake animation has completed its loop if (shakePlayer != NULL && !lottieIsPlaying(shakePlayer)) { // Destroy shake player lottieDestroy(shakePlayer); shakePlayer = NULL; - - // Create and play the stop animation - lv_obj_t *screen = displayDriverGetActiveScreen(); - if (screen != NULL) { - stopPlayer = lottieCreateFromData(screen, shakeStopAnimationData); - if (stopPlayer != NULL) { - lottieDisableNaturalBlink(stopPlayer); - lottieSetSpeed(stopPlayer, 1.0f); - lottieSetLoop(stopPlayer, false); - lottieSetFrame(stopPlayer, 0); - lottiePlay(stopPlayer); - state = SHAKE_STATE_PLAYING_STOP_ANIM; - ESP_LOGI(TAG, "Playing shake-stop transition animation"); - } else { - ESP_LOGE(TAG, "Failed to create stop animation player"); - state = SHAKE_STATE_COMPLETE; - } - } else { - state = SHAKE_STATE_COMPLETE; - } - } - return false; - } - - if (state == SHAKE_STATE_PLAYING_STOP_ANIM) { - // Check if stop animation has completed - if (stopPlayer != NULL && !lottieIsPlaying(stopPlayer)) { - lottieDestroy(stopPlayer); - stopPlayer = NULL; state = SHAKE_STATE_COMPLETE; - ESP_LOGI(TAG, "Shake-stop transition complete"); + ESP_LOGI(TAG, "Progressive deceleration complete"); + return false; } + + // Calculate current speed using linear interpolation (1.0 -> 0.0) + if (elapsed_ms >= slowdown_duration_ms) { + // Recovery phase complete, stop the animation + if (shakePlayer != NULL) { + lottiePause(shakePlayer); + lottieDestroy(shakePlayer); + shakePlayer = NULL; + } + state = SHAKE_STATE_COMPLETE; + ESP_LOGI(TAG, "Progressive deceleration complete"); + return false; + } + + // Calculate speed: 1.0 at start, 0.0 at end + float progress = (float)elapsed_ms / (float)slowdown_duration_ms; + float current_speed = 1.0f - progress; + + // Apply easing function for smoother deceleration (ease-out cubic) + // This makes the deceleration feel more natural - starts fast, slows gradually + float eased_speed = 1.0f - (progress * progress * progress); + + // Update animation speed with thread safety + if (shakePlayer != NULL && displayDriverLock(100)) { + lottieSetSpeed(shakePlayer, eased_speed); + displayDriverUnlock(); + } + return false; } @@ -404,6 +415,5 @@ void shakeEmotionStop(void) { } bool shakeEmotionIsPlaying(void) { - return state == SHAKE_STATE_SHAKING || state == SHAKE_STATE_FINISHING_LOOP || - state == SHAKE_STATE_PLAYING_STOP_ANIM; + return state == SHAKE_STATE_SHAKING || state == SHAKE_STATE_SLOWING_DOWN; } diff --git a/main/emotion-engine/shake/shake_emotion.h b/main/emotion-engine/shake/shake_emotion.h index dd274c5..efe0dc3 100644 --- a/main/emotion-engine/shake/shake_emotion.h +++ b/main/emotion-engine/shake/shake_emotion.h @@ -10,6 +10,7 @@ #define SHAKE_EMOTION_H #include +#include #ifdef __cplusplus extern "C" { diff --git a/main/emotion-engine/shy/shy.json b/main/emotion-engine/shy/shy.json new file mode 100644 index 0000000..3491c53 --- /dev/null +++ b/main/emotion-engine/shy/shy.json @@ -0,0 +1 @@ +{"assets":[{"id":"7","layers":[{"ind":6,"ty":4,"parent":5,"ks":{},"ef":[{"ty":29,"ef":[{"ty":0,"nm":"","v":{"a":1,"k":[{"t":0,"s":[166.67],"h":1},{"t":48,"s":[166.67],"i":{"x":0.264,"y":0.814},"o":{"x":0.025,"y":0.49}},{"t":60,"s":[98.58],"i":{"x":0.627,"y":0.782},"o":{"x":0.286,"y":0.474}},{"t":72,"s":[88.19],"i":{"x":0.504,"y":0.999},"o":{"x":0.192,"y":0.479}},{"t":96,"s":[83.33],"h":1},{"t":204,"s":[83.33],"i":{"x":0.806,"y":0.515},"o":{"x":0.494,"y":0.001}},{"t":228,"s":[88.19],"i":{"x":0.715,"y":0.528},"o":{"x":0.375,"y":0.22}},{"t":240,"s":[98.58],"i":{"x":0.675,"y":0.522},"o":{"x":0.307,"y":0.21}},{"t":246,"s":[111.19],"i":{"x":0.965,"y":0.589},"o":{"x":0.735,"y":0.246}},{"t":252,"s":[166.67],"h":1},{"t":300,"s":[166.67],"h":1}]}},{"ty":7,"nm":"","v":{"a":0,"k":1}},{"ty":7,"nm":"","v":{"a":0,"k":0}}]}],"ip":0,"op":301,"st":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","p":{"a":0,"k":[33,31.5]},"r":{"a":0,"k":0},"s":{"a":0,"k":[266,263]}},{"ty":"fl","c":{"a":0,"k":[0,0,0,0]},"o":{"a":0,"k":0}},{"ty":"tr","o":{"a":0,"k":100}}]},{"ty":"gr","it":[{"ty":"el","p":{"a":0,"k":[33,31.5]},"s":{"a":0,"k":[66,63]}},{"ty":"fl","c":{"a":0,"k":[1,0.51,0.51]},"o":{"a":0,"k":100}},{"ty":"tr","o":{"a":0,"k":100}}]}]},{"ind":5,"ty":3,"ks":{"p":{"a":0,"k":[101,101]}},"ip":0,"op":301,"st":0}]},{"id":"11","layers":[{"ind":9,"ty":0,"ks":{"a":{"a":0,"k":[101,101]},"o":{"a":0,"k":50},"p":{"a":0,"k":[141,141]}},"w":267,"h":264,"ip":0,"op":301,"st":0,"refId":"7"},{"ind":10,"ty":4,"ks":{},"ip":0,"op":301,"st":0,"shapes":[{"ty":"rc","p":{"a":0,"k":[224,222.5]},"r":{"a":0,"k":0},"s":{"a":0,"k":[448,445]}},{"ty":"fl","c":{"a":0,"k":[0,0,0,0]},"o":{"a":0,"k":0}}]}]},{"id":"14","layers":[{"ind":13,"ty":0,"parent":4,"ks":{"p":{"a":0,"k":[-141,-141]}},"ef":[{"ty":29,"ef":[{"ty":0,"nm":"","v":{"a":1,"k":[{"t":0,"s":[66.67],"h":1},{"t":48,"s":[66.67],"i":{"x":0.28,"y":0.759},"o":{"x":0.029,"y":0.406}},{"t":54,"s":[22.21],"i":{"x":0.637,"y":0.751},"o":{"x":0.296,"y":0.44}},{"t":60,"s":[12.21],"i":{"x":0.618,"y":0.777},"o":{"x":0.28,"y":0.46}},{"t":72,"s":[3.88],"i":{"x":0.504,"y":0.999},"o":{"x":0.192,"y":0.48}},{"t":96,"s":[0],"h":1},{"t":300,"s":[0],"h":1}]}},{"ty":7,"nm":"","v":{"a":0,"k":1}},{"ty":7,"nm":"","v":{"a":0,"k":0}}]}],"w":448,"h":445,"ip":0,"op":301,"st":0,"refId":"11"},{"ind":4,"ty":3,"ks":{"p":{"a":0,"k":[141,141]}},"ip":0,"op":301,"st":0}]},{"id":"18","layers":[{"ind":16,"ty":0,"ks":{"a":{"a":0,"k":[174,172.5]},"o":{"a":1,"k":[{"t":0,"s":[0],"h":1},{"t":48,"s":[0],"i":{"x":0,"y":1},"o":{"x":0,"y":0}},{"t":96,"s":[100],"h":1},{"t":300,"s":[100],"h":1}]},"p":{"a":0,"k":[214,212.5]},"s":{"a":1,"k":[{"t":0,"s":[50,50],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":48,"s":[50,50],"i":{"x":[0,0],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":96,"s":[100,100],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":300,"s":[100,100],"h":1}]}},"w":448,"h":445,"ip":0,"op":301,"st":0,"refId":"14"},{"ind":17,"ty":4,"ks":{},"ip":0,"op":301,"st":0,"shapes":[{"ty":"rc","p":{"a":0,"k":[334.5,333]},"r":{"a":0,"k":0},"s":{"a":0,"k":[669,666]}},{"ty":"fl","c":{"a":0,"k":[0,0,0,0]},"o":{"a":0,"k":0}}]}]},{"id":"21","layers":[{"ind":20,"ty":0,"parent":3,"ks":{"p":{"a":0,"k":[-181,-181]}},"ef":[{"ty":29,"ef":[{"ty":0,"nm":"","v":{"a":1,"k":[{"t":0,"s":[0],"h":1},{"t":204,"s":[0],"i":{"x":0.806,"y":0.515},"o":{"x":0.494,"y":0.001}},{"t":228,"s":[3.88],"i":{"x":0.715,"y":0.528},"o":{"x":0.375,"y":0.22}},{"t":240,"s":[12.19],"i":{"x":0.675,"y":0.522},"o":{"x":0.307,"y":0.21}},{"t":246,"s":[22.29],"i":{"x":0.965,"y":0.589},"o":{"x":0.735,"y":0.246}},{"t":252,"s":[66.67],"h":1},{"t":300,"s":[66.67],"h":1}]}},{"ty":7,"nm":"","v":{"a":0,"k":1}},{"ty":7,"nm":"","v":{"a":0,"k":0}}]}],"w":669,"h":666,"ip":0,"op":301,"st":0,"refId":"18"},{"ind":3,"ty":3,"ks":{"p":{"a":0,"k":[181,181]}},"ip":0,"op":301,"st":0}]},{"id":"24","layers":[{"ind":23,"ty":0,"parent":2,"ks":{"a":{"a":0,"k":[214,212.5]},"o":{"a":1,"k":[{"t":0,"s":[100],"h":1},{"t":204,"s":[100],"i":{"x":1,"y":1},"o":{"x":1,"y":0}},{"t":252,"s":[0],"h":1},{"t":300,"s":[0],"h":1}]},"p":{"a":0,"k":[33,31.5]},"s":{"a":1,"k":[{"t":0,"s":[100,100],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":204,"s":[100,100],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[1,1],"y":[0,0]}},{"t":252,"s":[50,50],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":300,"s":[50,50],"h":1}]}},"w":669,"h":666,"ip":0,"op":301,"st":0,"refId":"21"},{"ind":2,"ty":3,"ks":{"p":{"a":0,"k":[181,181]}},"ip":0,"op":301,"st":0}]},{"id":"32","layers":[{"ind":31,"ty":4,"parent":30,"ks":{},"ef":[{"ty":29,"ef":[{"ty":0,"nm":"","v":{"a":1,"k":[{"t":0,"s":[166.67],"h":1},{"t":48,"s":[166.67],"i":{"x":0.264,"y":0.814},"o":{"x":0.025,"y":0.49}},{"t":60,"s":[98.58],"i":{"x":0.627,"y":0.782},"o":{"x":0.286,"y":0.474}},{"t":72,"s":[88.19],"i":{"x":0.504,"y":0.999},"o":{"x":0.192,"y":0.479}},{"t":96,"s":[83.33],"h":1},{"t":204,"s":[83.33],"i":{"x":0.806,"y":0.515},"o":{"x":0.494,"y":0.001}},{"t":228,"s":[88.19],"i":{"x":0.715,"y":0.528},"o":{"x":0.375,"y":0.22}},{"t":240,"s":[98.58],"i":{"x":0.675,"y":0.522},"o":{"x":0.307,"y":0.21}},{"t":246,"s":[111.19],"i":{"x":0.965,"y":0.589},"o":{"x":0.735,"y":0.246}},{"t":252,"s":[166.67],"h":1},{"t":300,"s":[166.67],"h":1}]}},{"ty":7,"nm":"","v":{"a":0,"k":1}},{"ty":7,"nm":"","v":{"a":0,"k":0}}]}],"ip":0,"op":301,"st":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","p":{"a":0,"k":[33,31.5]},"r":{"a":0,"k":0},"s":{"a":0,"k":[266,263]}},{"ty":"fl","c":{"a":0,"k":[0,0,0,0]},"o":{"a":0,"k":0}},{"ty":"tr","o":{"a":0,"k":100}}]},{"ty":"gr","it":[{"ty":"el","p":{"a":0,"k":[33,31.5]},"s":{"a":0,"k":[66,63]}},{"ty":"fl","c":{"a":0,"k":[1,0.51,0.51]},"o":{"a":0,"k":100}},{"ty":"tr","o":{"a":0,"k":100}}]}]},{"ind":30,"ty":3,"ks":{"p":{"a":0,"k":[101,101]}},"ip":0,"op":301,"st":0}]},{"id":"36","layers":[{"ind":34,"ty":0,"ks":{"a":{"a":0,"k":[101,101]},"o":{"a":0,"k":50},"p":{"a":0,"k":[141,141]}},"w":267,"h":264,"ip":0,"op":301,"st":0,"refId":"32"},{"ind":35,"ty":4,"ks":{},"ip":0,"op":301,"st":0,"shapes":[{"ty":"rc","p":{"a":0,"k":[224,222.5]},"r":{"a":0,"k":0},"s":{"a":0,"k":[448,445]}},{"ty":"fl","c":{"a":0,"k":[0,0,0,0]},"o":{"a":0,"k":0}}]}]},{"id":"39","layers":[{"ind":38,"ty":0,"parent":29,"ks":{"p":{"a":0,"k":[-141,-141]}},"ef":[{"ty":29,"ef":[{"ty":0,"nm":"","v":{"a":1,"k":[{"t":0,"s":[66.67],"h":1},{"t":48,"s":[66.67],"i":{"x":0.28,"y":0.759},"o":{"x":0.029,"y":0.406}},{"t":54,"s":[22.21],"i":{"x":0.637,"y":0.751},"o":{"x":0.296,"y":0.44}},{"t":60,"s":[12.21],"i":{"x":0.618,"y":0.777},"o":{"x":0.28,"y":0.46}},{"t":72,"s":[3.88],"i":{"x":0.504,"y":0.999},"o":{"x":0.192,"y":0.48}},{"t":96,"s":[0],"h":1},{"t":300,"s":[0],"h":1}]}},{"ty":7,"nm":"","v":{"a":0,"k":1}},{"ty":7,"nm":"","v":{"a":0,"k":0}}]}],"w":448,"h":445,"ip":0,"op":301,"st":0,"refId":"36"},{"ind":29,"ty":3,"ks":{"p":{"a":0,"k":[141,141]}},"ip":0,"op":301,"st":0}]},{"id":"43","layers":[{"ind":41,"ty":0,"ks":{"a":{"a":0,"k":[174,172.5]},"o":{"a":1,"k":[{"t":0,"s":[0],"h":1},{"t":48,"s":[0],"i":{"x":0,"y":1},"o":{"x":0,"y":0}},{"t":96,"s":[100],"h":1},{"t":300,"s":[100],"h":1}]},"p":{"a":0,"k":[214,212.5]},"s":{"a":1,"k":[{"t":0,"s":[50,50],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":48,"s":[50,50],"i":{"x":[0,0],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":96,"s":[100,100],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":300,"s":[100,100],"h":1}]}},"w":448,"h":445,"ip":0,"op":301,"st":0,"refId":"39"},{"ind":42,"ty":4,"ks":{},"ip":0,"op":301,"st":0,"shapes":[{"ty":"rc","p":{"a":0,"k":[334.5,333]},"r":{"a":0,"k":0},"s":{"a":0,"k":[669,666]}},{"ty":"fl","c":{"a":0,"k":[0,0,0,0]},"o":{"a":0,"k":0}}]}]},{"id":"46","layers":[{"ind":45,"ty":0,"parent":28,"ks":{"p":{"a":0,"k":[-181,-181]}},"ef":[{"ty":29,"ef":[{"ty":0,"nm":"","v":{"a":1,"k":[{"t":0,"s":[0],"h":1},{"t":204,"s":[0],"i":{"x":0.806,"y":0.515},"o":{"x":0.494,"y":0.001}},{"t":228,"s":[3.88],"i":{"x":0.715,"y":0.528},"o":{"x":0.375,"y":0.22}},{"t":240,"s":[12.19],"i":{"x":0.675,"y":0.522},"o":{"x":0.307,"y":0.21}},{"t":246,"s":[22.29],"i":{"x":0.965,"y":0.589},"o":{"x":0.735,"y":0.246}},{"t":252,"s":[66.67],"h":1},{"t":300,"s":[66.67],"h":1}]}},{"ty":7,"nm":"","v":{"a":0,"k":1}},{"ty":7,"nm":"","v":{"a":0,"k":0}}]}],"w":669,"h":666,"ip":0,"op":301,"st":0,"refId":"43"},{"ind":28,"ty":3,"ks":{"p":{"a":0,"k":[181,181]}},"ip":0,"op":301,"st":0}]},{"id":"49","layers":[{"ind":48,"ty":0,"parent":27,"ks":{"a":{"a":0,"k":[214,212.5]},"o":{"a":1,"k":[{"t":0,"s":[100],"h":1},{"t":204,"s":[100],"i":{"x":1,"y":1},"o":{"x":1,"y":0}},{"t":252,"s":[0],"h":1},{"t":300,"s":[0],"h":1}]},"p":{"a":0,"k":[33,31.5]},"s":{"a":1,"k":[{"t":0,"s":[100,100],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":204,"s":[100,100],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[1,1],"y":[0,0]}},{"t":252,"s":[50,50],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":300,"s":[50,50],"h":1}]}},"w":669,"h":666,"ip":0,"op":301,"st":0,"refId":"46"},{"ind":27,"ty":3,"ks":{"p":{"a":0,"k":[181,181]}},"ip":0,"op":301,"st":0}]}],"fr":60,"h":448,"ip":0,"layers":[{"ind":26,"ty":0,"parent":1,"ks":{"a":{"a":0,"k":[181,181]},"o":{"a":1,"k":[{"t":0,"s":[0],"h":1},{"t":48,"s":[0],"h":1},{"t":48,"s":[100],"h":1},{"t":252,"s":[100],"h":1},{"t":252,"s":[0],"h":1},{"t":300,"s":[0],"h":1}]},"p":{"a":0,"k":[260,192]}},"w":850,"h":847,"ip":0,"op":301,"st":0,"refId":"24"},{"ind":51,"ty":0,"parent":1,"ks":{"a":{"a":0,"k":[181,181]},"o":{"a":1,"k":[{"t":0,"s":[0],"h":1},{"t":48,"s":[0],"h":1},{"t":48,"s":[100],"h":1},{"t":252,"s":[100],"h":1},{"t":252,"s":[0],"h":1},{"t":300,"s":[0],"h":1}]},"p":{"a":0,"k":[42,192]}},"w":850,"h":847,"ip":0,"op":301,"st":0,"refId":"49"},{"ind":53,"ty":4,"parent":52,"ks":{},"ip":0,"op":301,"st":0,"shapes":[{"ty":"rc","p":{"a":1,"k":[{"t":0,"s":[48.5,68],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":48,"s":[48.5,22.5],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":252,"s":[48.5,22.5],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":300,"s":[48.5,68],"h":1}]},"r":{"a":0,"k":20},"s":{"a":1,"k":[{"t":0,"s":[97,136],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":48,"s":[97,45],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":252,"s":[97,45],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":300,"s":[97,136],"h":1}]}},{"ty":"fl","c":{"a":0,"k":[1,1,1]},"o":{"a":0,"k":100}}]},{"ind":52,"ty":3,"parent":1,"ks":{"p":{"a":1,"k":[{"t":0,"s":[211,88],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":48,"s":[211,133.5],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":252,"s":[211,133.5],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":300,"s":[211,88],"h":1}]}},"ip":0,"op":301,"st":0},{"ind":55,"ty":4,"parent":54,"ks":{},"ip":0,"op":301,"st":0,"shapes":[{"ty":"rc","p":{"a":1,"k":[{"t":0,"s":[48.5,68],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":48,"s":[48.5,22.5],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":252,"s":[48.5,22.5],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":300,"s":[48.5,68],"h":1}]},"r":{"a":0,"k":20},"s":{"a":1,"k":[{"t":0,"s":[97,136],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":48,"s":[97,45],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":252,"s":[97,45],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":300,"s":[97,136],"h":1}]}},{"ty":"fl","c":{"a":0,"k":[1,1,1]},"o":{"a":0,"k":100}}]},{"ind":54,"ty":3,"parent":1,"ks":{"a":{"a":1,"k":[{"t":0,"s":[48.5,68],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":48,"s":[48.5,22.5],"i":{"x":[1,1],"y":[1,1]},"o":{"x":[0,0],"y":[0,0]}},{"t":252,"s":[48.5,22.5],"i":{"x":[1,0],"y":[1,1]},"o":{"x":[0,0.5],"y":[0,0]}},{"t":300,"s":[48.5,68],"h":1}]},"p":{"a":0,"k":[108.5,156]}},"ip":0,"op":301,"st":0},{"ind":1,"ty":3,"parent":0,"ks":{},"ip":0,"op":301,"st":0},{"ind":56,"ty":4,"parent":0,"ks":{},"ip":0,"op":301,"st":0,"shapes":[{"ty":"rc","p":{"a":0,"k":[184,224]},"r":{"a":0,"k":0},"s":{"a":0,"k":[368,448]}},{"ty":"fl","c":{"a":0,"k":[0,0,0]},"o":{"a":0,"k":100}}]},{"ind":0,"ty":3,"ks":{},"ip":0,"op":301,"st":0}],"meta":{"g":"https://jitter.video"},"op":300,"v":"5.7.4","w":368} \ No newline at end of file diff --git a/main/ui/lottie_player.c b/main/ui/lottie_player.c index 98c8574..18e2920 100644 --- a/main/ui/lottie_player.c +++ b/main/ui/lottie_player.c @@ -1388,6 +1388,12 @@ static void scheduleNextBlink(lottie_player_handle_t handle) { return; } + // Delete existing timer if it exists + if (handle->blinkTimer) { + lv_timer_del(handle->blinkTimer); + handle->blinkTimer = NULL; + } + uint32_t delayMs = LOTTIE_BLINK_MIN_MS + (esp_random() % (LOTTIE_BLINK_MAX_MS - LOTTIE_BLINK_MIN_MS));