The shake animation figures have been fixed. However, the petting emotion working with touch remains an issue. The Lottie JSON for the emotion is unable not parsable for some reason and my next step is to fix that for tomorrow's meeting.
141 lines
19 KiB
C
141 lines
19 KiB
C
/**
|
|
* @file shy_emotion.c
|
|
* @brief Shy emotion animation implementation
|
|
*
|
|
* This module manages the shy Lottie animation that plays when the
|
|
* device responds to touch with a shy expression.
|
|
*
|
|
* State machine:
|
|
* 1. IDLE -> shyEmotionPlay() -> PLAYING (single play)
|
|
* 2. PLAYING -> (animation ends) -> COMPLETE
|
|
* 3. shyEmotionUpdate() returns true when COMPLETE
|
|
* 4. COMPLETE -> IDLE (ready for next animation)
|
|
*/
|
|
|
|
#include "emotion-engine/shy/shy_emotion.h"
|
|
#include "drivers/display_driver.h"
|
|
#include "esp_log.h"
|
|
#include "ui/lottie_player.h"
|
|
|
|
static const char *TAG = "shy_emotion";
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Embedded Animation Data
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Shy animation JSON data (from shy.json)
|
|
// 300 frames at 60fps = 5 seconds
|
|
static const char *shyAnimationData =
|
|
"{\"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}";
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// State Machine
|
|
// ----------------------------------------------------------------------------
|
|
|
|
typedef enum {
|
|
SHY_STATE_IDLE = 0,
|
|
SHY_STATE_PLAYING,
|
|
SHY_STATE_COMPLETE
|
|
} ShyState;
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Private State
|
|
// ----------------------------------------------------------------------------
|
|
|
|
static lottie_player_handle_t shyPlayer = NULL;
|
|
static bool initialized = false;
|
|
static ShyState state = SHY_STATE_IDLE;
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Public API Implementation
|
|
// ----------------------------------------------------------------------------
|
|
|
|
bool shyEmotionInit(void) {
|
|
ESP_LOGI(TAG, "Initializing shy emotion");
|
|
initialized = true;
|
|
state = SHY_STATE_IDLE;
|
|
ESP_LOGI(TAG, "Shy emotion initialized (deferred player creation)");
|
|
return true;
|
|
}
|
|
|
|
void shyEmotionPlay(void) {
|
|
if (!initialized) {
|
|
ESP_LOGE(TAG, "Shy emotion not initialized");
|
|
return;
|
|
}
|
|
|
|
// Create shy player on first play
|
|
if (shyPlayer == NULL) {
|
|
ESP_LOGI(TAG, "Creating shy player");
|
|
|
|
// Diagnostic: Log JSON data length and first/last characters
|
|
size_t jsonLen = strlen(shyAnimationData);
|
|
ESP_LOGI(TAG, "JSON data length: %zu bytes", jsonLen);
|
|
ESP_LOGI(TAG, "JSON starts: %.50s", shyAnimationData);
|
|
ESP_LOGI(TAG, "JSON ends: %.50s", shyAnimationData + (jsonLen > 50 ? jsonLen - 50 : 0));
|
|
|
|
lv_obj_t *screen = displayDriverGetActiveScreen();
|
|
if (screen == NULL) {
|
|
ESP_LOGE(TAG, "No active screen available");
|
|
return;
|
|
}
|
|
|
|
shyPlayer = lottieCreateFromData(screen, shyAnimationData);
|
|
if (shyPlayer == NULL) {
|
|
ESP_LOGE(TAG, "Failed to create shy player");
|
|
return;
|
|
}
|
|
|
|
// Disable natural blink mode for shy emotion
|
|
lottieDisableNaturalBlink(shyPlayer);
|
|
lottieSetSpeed(shyPlayer, 1.0f);
|
|
}
|
|
|
|
// Set to non-looping mode and play once
|
|
lottieSetLoop(shyPlayer, false);
|
|
lottieSetFrame(shyPlayer, 0);
|
|
lottiePlay(shyPlayer);
|
|
state = SHY_STATE_PLAYING;
|
|
|
|
ESP_LOGI(TAG, "Shy animation started (single play)");
|
|
}
|
|
|
|
bool shyEmotionUpdate(void) {
|
|
if (state == SHY_STATE_IDLE) {
|
|
return false;
|
|
}
|
|
|
|
if (state == SHY_STATE_PLAYING) {
|
|
// Check if shy animation has completed
|
|
if (shyPlayer != NULL && !lottieIsPlaying(shyPlayer)) {
|
|
// Destroy shy player
|
|
lottieDestroy(shyPlayer);
|
|
shyPlayer = NULL;
|
|
state = SHY_STATE_COMPLETE;
|
|
ESP_LOGI(TAG, "Shy animation complete");
|
|
return true; // Signal ready to return to idle
|
|
}
|
|
}
|
|
|
|
if (state == SHY_STATE_COMPLETE) {
|
|
state = SHY_STATE_IDLE;
|
|
return true; // Signal ready to return to idle
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void shyEmotionStop(void) {
|
|
if (shyPlayer != NULL) {
|
|
lottiePause(shyPlayer);
|
|
lottieDestroy(shyPlayer);
|
|
shyPlayer = NULL;
|
|
}
|
|
state = SHY_STATE_IDLE;
|
|
ESP_LOGI(TAG, "Shy animation stopped (immediate)");
|
|
}
|
|
|
|
bool shyEmotionIsPlaying(void) {
|
|
return state == SHY_STATE_PLAYING;
|
|
}
|