diff --git a/components/SensorLib/src/SensorLib.h b/components/SensorLib/src/SensorLib.h index c3bb954..18ebc47 100644 --- a/components/SensorLib/src/SensorLib.h +++ b/components/SensorLib/src/SensorLib.h @@ -89,8 +89,8 @@ #elif defined(ESP_PLATFORM) -#define SENSORLIB_I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ -#define SENSORLIB_I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ +#define SENSORLIB_I2C_MASTER_TX_BUF_DISABLE 256 /*!< I2C master TX buffer size */ +#define SENSORLIB_I2C_MASTER_RX_BUF_DISABLE 256 /*!< I2C master RX buffer size */ #define SENSORLIB_I2C_MASTER_TIMEOUT_MS 1000 #define SENSORLIB_I2C_MASTER_SEEED 400000 diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 232c4e9..3fab0a7 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -11,9 +11,11 @@ idf_component_register( "ui/assets/splash_screen/logo_iro.c" "ui/assets/fonts/Geist.c" "sensors/shake_detector.cpp" + "sensors/glide_detector.c" "emotion-engine/emotion_manager.c" "emotion-engine/blink/blink_emotion.c" "emotion-engine/shake/shake_emotion.c" + "emotion-engine/shy/shy_emotion.c" INCLUDE_DIRS "." "config" diff --git a/main/drivers/display_driver.c b/main/drivers/display_driver.c index 61962d0..76fb442 100644 --- a/main/drivers/display_driver.c +++ b/main/drivers/display_driver.c @@ -173,6 +173,7 @@ static bool initI2cBus(void) { return false; } + ESP_LOGI(TAG, "I2C bus initialized successfully"); return true; } diff --git a/main/drivers/touch_driver.c b/main/drivers/touch_driver.c index 8c60df4..8f0e87e 100644 --- a/main/drivers/touch_driver.c +++ b/main/drivers/touch_driver.c @@ -40,6 +40,7 @@ static void touchInputCallback(lv_indev_drv_t *drv, lv_indev_data_t *data); bool touchDriverInit(void) { ESP_LOGI(TAG, "Initializing touch controller"); + ESP_LOGI(TAG, "DEBUG: touchHandle before init: %p", (void*)touchHandle); // Create I2C IO handle for touch controller esp_lcd_panel_io_handle_t tpIoHandle = NULL; @@ -50,6 +51,9 @@ bool touchDriverInit(void) { (esp_lcd_i2c_bus_handle_t)I2C_MASTER_PORT, &tpIoConfig, &tpIoHandle); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to create touch panel IO: %s", esp_err_to_name(err)); + ESP_LOGE(TAG, "DEBUG: touchHandle after I2C IO failure: %p", (void*)touchHandle); + // Ensure touchHandle is NULL on any initialization failure + touchHandle = NULL; return false; } @@ -72,10 +76,16 @@ bool touchDriverInit(void) { }, }; + ESP_LOGI(TAG, "DEBUG: About to call esp_lcd_touch_new_i2c_ft5x06, current touchHandle: %p", (void*)touchHandle); err = esp_lcd_touch_new_i2c_ft5x06(tpIoHandle, &touchConfig, &touchHandle); + ESP_LOGI(TAG, "DEBUG: esp_lcd_touch_new_i2c_ft5x06 returned err=%d, touchHandle=%p", err, (void*)touchHandle); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to initialize touch controller: %s", esp_err_to_name(err)); + ESP_LOGE(TAG, "DEBUG: touchHandle after FT5x06 init failure: %p", (void*)touchHandle); + // CRITICAL: Set touchHandle to NULL to prevent dangling pointer access + // The esp_lcd_touch_new_i2c_ft5x06 function may set touchHandle to a freed pointer on error + touchHandle = NULL; return false; } @@ -87,6 +97,7 @@ bool touchDriverInit(void) { lv_indev_drv_register(&inputDriver); ESP_LOGI(TAG, "Touch controller initialized successfully"); + ESP_LOGI(TAG, "DEBUG: Final touchHandle: %p", (void*)touchHandle); return true; } diff --git a/main/emotion-engine/emotion_manager.c b/main/emotion-engine/emotion_manager.c index 8afb7b6..c762c45 100644 --- a/main/emotion-engine/emotion_manager.c +++ b/main/emotion-engine/emotion_manager.c @@ -10,6 +10,7 @@ #include "drivers/display_driver.h" #include "emotion-engine/blink/blink_emotion.h" #include "emotion-engine/shake/shake_emotion.h" +#include "emotion-engine/shy/shy_emotion.h" #include "esp_log.h" static const char *TAG = "emotion_manager"; @@ -40,6 +41,12 @@ bool emotionManagerInit(void) { return false; } + // Initialize shy emotion + if (!shyEmotionInit()) { + ESP_LOGE(TAG, "Failed to initialize shy emotion"); + return false; + } + // Future: Initialize other emotions here // surprisedEmotionInit(); // sadEmotionInit(); @@ -101,6 +108,13 @@ void emotionManagerSetEmotion(EmotionType emotion) { ESP_LOGI(TAG, "Emotion %d not yet implemented", emotion); break; + case EMOTION_SHY: + // Stop any other animations and play shy + shakeEmotionStop(); + blinkEmotionPause(); + shyEmotionPlay(); + break; + default: ESP_LOGW(TAG, "Unknown emotion type: %d", emotion); break; @@ -117,6 +131,7 @@ void emotionManagerStop(void) { ESP_LOGI(TAG, "Stopping emotion manager"); blinkEmotionStop(); + shyEmotionStop(); // Future: Stop other emotions initialized = false; diff --git a/main/emotion-engine/emotion_manager.h b/main/emotion-engine/emotion_manager.h index d013234..f988c5b 100644 --- a/main/emotion-engine/emotion_manager.h +++ b/main/emotion-engine/emotion_manager.h @@ -32,6 +32,7 @@ typedef enum { EMOTION_SURPRISED, // Surprised expression EMOTION_SAD, // Sad expression EMOTION_ANGRY, // Angry expression + EMOTION_SHY, // Shy expression EMOTION_COUNT } EmotionType; diff --git a/main/emotion-engine/shy/shy.json b/main/emotion-engine/shy/shy.json index 3491c53..ccbe089 100644 --- a/main/emotion-engine/shy/shy.json +++ b/main/emotion-engine/shy/shy.json @@ -1 +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 +{"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}} diff --git a/main/emotion-engine/shy/shy_emotion.c b/main/emotion-engine/shy/shy_emotion.c new file mode 100644 index 0000000..636c696 --- /dev/null +++ b/main/emotion-engine/shy/shy_emotion.c @@ -0,0 +1,140 @@ +/** + * @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; +} diff --git a/main/emotion-engine/shy/shy_emotion.h b/main/emotion-engine/shy/shy_emotion.h new file mode 100644 index 0000000..e8769a3 --- /dev/null +++ b/main/emotion-engine/shy/shy_emotion.h @@ -0,0 +1,60 @@ +/** + * @file shy_emotion.h + * @brief Shy emotion animation controller + * + * Manages the shy Lottie animation that plays when the device + * responds to touch with a shy expression. + */ + +#ifndef SHY_EMOTION_H +#define SHY_EMOTION_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Initialize the shy emotion module + * + * @return true on success, false on failure + */ +bool shyEmotionInit(void); + +/** + * @brief Start playing the shy animation + * + * Animation will play once (not looping) and transition back to idle + * when complete. + */ +void shyEmotionPlay(void); + +/** + * @brief Update the shy emotion state + * + * Must be called periodically to check if the shy animation has completed. + * + * @return true if animation is complete and ready for idle, false if still + * playing + */ +bool shyEmotionUpdate(void); + +/** + * @brief Stop the shy animation immediately (for cleanup) + */ +void shyEmotionStop(void); + +/** + * @brief Check if shy animation is currently playing + * + * @return true if playing, false otherwise + */ +bool shyEmotionIsPlaying(void); + +#ifdef __cplusplus +} +#endif + +#endif // SHY_EMOTION_H diff --git a/main/main.c b/main/main.c index c0ab0c8..f2f05e7 100644 --- a/main/main.c +++ b/main/main.c @@ -25,7 +25,9 @@ #include "drivers/touch_driver.h" #include "emotion-engine/emotion_manager.h" #include "emotion-engine/shake/shake_emotion.h" +#include "emotion-engine/shy/shy_emotion.h" #include "sensors/shake_detector.h" +#include "sensors/glide_detector.h" #include "ui/calibration_screen.h" #include "ui/loading_anim.h" #include "ui/splash_screen.h" @@ -37,6 +39,106 @@ static const char *TAG = "main"; +// Track touch initialization status +static bool touchInitialized = false; + +// ---------------------------------------------------------------------------- +// Glide Detection Callback +// Triggers shy emotion when a glide gesture is detected. +// Only triggers if currently in idle state for calm, subtle interactions. +// ---------------------------------------------------------------------------- + +static void onGlideDetected(const GlideEvent *event, void *user_data) { + (void)event; // Unused parameter + (void)user_data; // Unused parameter + + // Only trigger shy emotion if currently in idle state + if (emotionManagerGetCurrent() == EMOTION_IDLE) { + ESP_LOGI(TAG, "Glide gesture detected, triggering shy emotion"); + if (displayDriverLock(500)) { + emotionManagerSetEmotion(EMOTION_SHY); + displayDriverUnlock(); + } else { + ESP_LOGW(TAG, "Failed to acquire lock for SHY emotion"); + } + } +} + +// ---------------------------------------------------------------------------- +// Glide Detection Task +// Polls the touch controller for glide gestures and triggers shy emotion. +// Only triggers shy emotion when currently in idle state. +// ---------------------------------------------------------------------------- + +static void glideTask(void *arg) { + ESP_LOGI(TAG, "Glide detection task started"); + + // Check if touch was initialized successfully + if (!touchInitialized) { + ESP_LOGW(TAG, "Touch controller not initialized, glide detection disabled"); + vTaskDelete(NULL); + return; + } + + esp_lcd_touch_handle_t touchHandle = touchDriverGetHandle(); + if (touchHandle == NULL) { + ESP_LOGE(TAG, "Touch handle is NULL even though initialization succeeded, disabling glide detection"); + vTaskDelete(NULL); + return; + } + + ESP_LOGI(TAG, "Glide detection task running with touch handle %p", (void*)touchHandle); + + while (1) { + uint16_t x, y; + uint8_t count = 0; + + // Read touch data from controller + esp_lcd_touch_read_data(touchHandle); + bool pressed = esp_lcd_touch_get_coordinates(touchHandle, &x, &y, NULL, &count, 1); + + // Feed touch events to glide detector + glideDetectorUpdate(x, y, pressed && count > 0); + + // Poll at 60Hz for responsive touch detection + vTaskDelay(pdMS_TO_TICKS(16)); + } +} + +// ---------------------------------------------------------------------------- +// Shy Emotion Task +// Monitors shy emotion state and transitions back to idle when complete. +// The shy emotion is a one-shot animation that plays once then returns to idle. +// ---------------------------------------------------------------------------- + +static void shyTask(void *arg) { + ESP_LOGI(TAG, "Shy emotion task started"); + + while (1) { + // Check if shy emotion is currently playing + if (shyEmotionIsPlaying()) { + // Update shy emotion state + bool animationComplete = false; + if (displayDriverLock(100)) { + animationComplete = shyEmotionUpdate(); + displayDriverUnlock(); + } + + // Transition back to idle when animation completes + if (animationComplete) { + ESP_LOGI(TAG, "Shy animation complete, returning to idle"); + if (displayDriverLock(500)) { + emotionManagerSetEmotion(EMOTION_IDLE); + displayDriverUnlock(); + } + } + } + + // Poll at 20Hz for emotion state updates + vTaskDelay(pdMS_TO_TICKS(50)); + } +} + // ---------------------------------------------------------------------------- // Shake Detection Task // Polls the accelerometer for shake events and triggers emotions. @@ -138,6 +240,10 @@ static void ui_entry_task(void *arg) { // Initialize touch controller if (!touchDriverInit()) { ESP_LOGW(TAG, "Touch initialization failed (continuing)"); + touchInitialized = false; + } else { + touchInitialized = true; + ESP_LOGI(TAG, "Touch controller initialized successfully"); } // Initialize shake detector @@ -145,6 +251,14 @@ static void ui_entry_task(void *arg) { ESP_LOGW(TAG, "Shake detector initialization failed (continuing)"); } + // Initialize glide detector + if (!glideDetectorInit()) { + ESP_LOGW(TAG, "Glide detector initialization failed (continuing)"); + } else { + // Register callback to trigger shy emotion on glide detection + glideDetectorRegisterCallback(onGlideDetected, NULL); + } + // Initialize NVS (Critical for first boot check) nvsDriverInit(); @@ -210,6 +324,18 @@ static void ui_entry_task(void *arg) { // Start shake detection task xTaskCreate(shakeTask, "shake_task", 4096, NULL, 5, NULL); + // Start glide detection task only if touch controller is initialized + if (touchInitialized) { + xTaskCreate(glideTask, "glide_task", 4096, NULL, 5, NULL); + } else { + ESP_LOGW(TAG, "Skipping glide detection task - touch controller not initialized"); + } + + // Start shy emotion task + // Use 8KB stack (same as ui_entry_task) to handle complex shy animation + // Shy emotion has large JSON (~3KB) and 300 frames requiring more stack + xTaskCreate(shyTask, "shy_task", 8192, NULL, 5, NULL); + ESP_LOGI(TAG, "iroBot Display System initialized successfully"); vTaskDelete(NULL); } diff --git a/main/sensors/glide_detector.c b/main/sensors/glide_detector.c new file mode 100644 index 0000000..577f16f --- /dev/null +++ b/main/sensors/glide_detector.c @@ -0,0 +1,317 @@ +/** + * @file glide_detector.c + * @brief Glide gesture detection implementation for touch input + * + * This module implements glide gesture detection using touch coordinates. + * It tracks consecutive touch points during a touch session and determines + * if the motion qualifies as a glide gesture based on distance and timing. + */ + +#include "sensors/glide_detector.h" +#include "esp_log.h" +#include "esp_timer.h" +#include +#include + +static const char *TAG = "glide_detector"; + +// ---------------------------------------------------------------------------- +// Private State +// ---------------------------------------------------------------------------- + +/** + * @brief Detector state machine states + */ +typedef enum { + GLIDE_STATE_IDLE = 0, // No touch detected + GLIDE_STATE_TRACKING, // Touch detected, tracking movement + GLIDE_STATE_GLIDE_DETECTED // Glide gesture recognized +} GlideState; + +// Current detector state +static GlideState state = GLIDE_STATE_IDLE; + +// Touch point buffer for tracking gesture +static TouchPoint touchPoints[GLIDE_MAX_TOUCH_POINTS]; +static uint8_t pointCount = 0; + +// Gesture timing +static uint32_t gestureStartTime = 0; + +// Callback registration +static GlideCallback glideCallback = NULL; +static void *callbackUserData = NULL; + +// Statistics for debugging +static float totalDistance = 0.0f; +static float deltaX = 0.0f; +static float deltaY = 0.0f; + +// ---------------------------------------------------------------------------- +// Helper Functions +// ---------------------------------------------------------------------------- + +/** + * @brief Get current time in milliseconds + */ +static uint32_t getMillis(void) { + return (uint32_t)(esp_timer_get_time() / 1000); +} + +/** + * @brief Calculate Euclidean distance between two points + */ +static float calculateDistance(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { + float dx = (float)(x2 - x1); + float dy = (float)(y2 - y1); + return sqrtf(dx * dx + dy * dy); +} + +/** + * @brief Determine glide direction based on delta values + */ +static GlideDirection determineDirection(float dx, float dy) { + float absDx = fabsf(dx); + float absDy = fabsf(dy); + + // Use a ratio threshold to determine if motion is primarily horizontal, + // vertical, or diagonal + const float directionRatio = 0.5f; // 50% tolerance + + if (absDx > absDy * (1.0f + directionRatio)) { + return GLIDE_DIRECTION_HORIZONTAL; + } else if (absDy > absDx * (1.0f + directionRatio)) { + return GLIDE_DIRECTION_VERTICAL; + } else { + return GLIDE_DIRECTION_DIAGONAL; + } +} + +/** + * @brief Check if a new point is valid (not too close to previous point) + */ +static bool isValidNewPoint(uint16_t x, uint16_t y) { + if (pointCount == 0) { + return true; + } + + TouchPoint *lastPoint = &touchPoints[pointCount - 1]; + float distance = calculateDistance(x, y, lastPoint->x, lastPoint->y); + + // Require minimum movement between points to avoid jitter + const float minPointDistance = 5.0f; // 5 pixels minimum + return distance >= minPointDistance; +} + +/** + * @brief Check if gesture has timed out + */ +static bool isGestureTimedOut(uint32_t now) { + if (pointCount == 0) { + return false; + } + + uint32_t elapsed = now - gestureStartTime; + return elapsed > GLIDE_MAX_GESTURE_TIME; +} + +/** + * @brief Check if time between points is too long for continuous motion + */ +static bool isTimeBetweenPointsTooLong(uint32_t now) { + if (pointCount < 2) { + return false; + } + + TouchPoint *lastPoint = &touchPoints[pointCount - 1]; + uint32_t elapsed = now - lastPoint->timestamp; + return elapsed > GLIDE_MAX_TIME_BETWEEN_POINTS; +} + +/** + * @brief Calculate total distance and delta for current gesture + */ +static void calculateGestureMetrics(void) { + if (pointCount < 2) { + totalDistance = 0.0f; + deltaX = 0.0f; + deltaY = 0.0f; + return; + } + + TouchPoint *firstPoint = &touchPoints[0]; + TouchPoint *lastPoint = &touchPoints[pointCount - 1]; + + // Calculate total path distance + totalDistance = 0.0f; + for (uint8_t i = 1; i < pointCount; i++) { + totalDistance += calculateDistance(touchPoints[i - 1].x, touchPoints[i - 1].y, + touchPoints[i].x, touchPoints[i].y); + } + + // Calculate net displacement + deltaX = (float)(lastPoint->x - firstPoint->x); + deltaY = (float)(lastPoint->y - firstPoint->y); +} + +/** + * @brief Check if current tracked points qualify as a glide + */ +static bool isGlideDetected(void) { + if (pointCount < 2) { + return false; + } + + calculateGestureMetrics(); + + // Check minimum distance threshold + if (totalDistance < GLIDE_MIN_DISTANCE) { + return false; + } + + return true; +} + +/** + * @brief Invoke the registered callback with glide event data + */ +static void invokeGlideCallback(void) { + if (glideCallback == NULL) { + return; + } + + GlideEvent event = { + .direction = determineDirection(deltaX, deltaY), + .distance = totalDistance, + .deltaX = deltaX, + .deltaY = deltaY, + .duration = getMillis() - gestureStartTime + }; + + glideCallback(&event, callbackUserData); +} + +// ---------------------------------------------------------------------------- +// Public API Implementation +// ---------------------------------------------------------------------------- + +bool glideDetectorInit(void) { + ESP_LOGI(TAG, "Initializing glide detector"); + + // Reset state + state = GLIDE_STATE_IDLE; + pointCount = 0; + gestureStartTime = 0; + totalDistance = 0.0f; + deltaX = 0.0f; + deltaY = 0.0f; + + ESP_LOGI(TAG, "Glide detector initialized (min_distance=%d, max_time=%dms)", + GLIDE_MIN_DISTANCE, GLIDE_MAX_GESTURE_TIME); + + return true; +} + +bool glideDetectorUpdate(uint16_t x, uint16_t y, bool pressed) { + uint32_t now = getMillis(); + bool glideDetected = false; + + // Handle release event + if (!pressed) { + if (state == GLIDE_STATE_TRACKING) { + // Check if we have a valid glide on release + if (isGlideDetected()) { + state = GLIDE_STATE_GLIDE_DETECTED; + invokeGlideCallback(); + glideDetected = true; + ESP_LOGI(TAG, "Glide detected on release: dist=%.1f, delta=(%.1f,%.1f), " + "dir=%d, duration=%lums", + totalDistance, deltaX, deltaY, + determineDirection(deltaX, deltaY), + (unsigned long)(now - gestureStartTime)); + } + } + // Reset state on any release + glideDetectorReset(); + return glideDetected; + } + + // Handle press/move event + switch (state) { + case GLIDE_STATE_IDLE: + // Start tracking on first touch point + if (pointCount == 0) { + touchPoints[pointCount].x = x; + touchPoints[pointCount].y = y; + touchPoints[pointCount].timestamp = now; + pointCount++; + gestureStartTime = now; + state = GLIDE_STATE_TRACKING; + ESP_LOGD(TAG, "Started tracking gesture at (%d,%d)", x, y); + } + break; + + case GLIDE_STATE_TRACKING: + // Check for timeout + if (isGestureTimedOut(now)) { + ESP_LOGD(TAG, "Gesture timed out, resetting"); + glideDetectorReset(); + return false; + } + + // Check if time between points is too long + if (isTimeBetweenPointsTooLong(now)) { + ESP_LOGD(TAG, "Time between points too long, resetting"); + glideDetectorReset(); + return false; + } + + // Add new point if valid and buffer not full + if (pointCount < GLIDE_MAX_TOUCH_POINTS && isValidNewPoint(x, y)) { + touchPoints[pointCount].x = x; + touchPoints[pointCount].y = y; + touchPoints[pointCount].timestamp = now; + pointCount++; + + // Check if we have a glide already (detect during motion) + if (isGlideDetected()) { + // Continue tracking to get more accurate metrics + ESP_LOGD(TAG, "Glide in progress: dist=%.1f, points=%d", + totalDistance, pointCount); + } + } + break; + + case GLIDE_STATE_GLIDE_DETECTED: + // Should not reach here - reset after detection + glideDetectorReset(); + break; + } + + return glideDetected; +} + +void glideDetectorRegisterCallback(GlideCallback callback, void *user_data) { + glideCallback = callback; + callbackUserData = user_data; + + ESP_LOGI(TAG, "Glide callback registered: %s", + callback != NULL ? "yes" : "no"); +} + +void glideDetectorReset(void) { + if (state != GLIDE_STATE_IDLE) { + ESP_LOGD(TAG, "Resetting detector (had %d points)", pointCount); + } + + state = GLIDE_STATE_IDLE; + pointCount = 0; + gestureStartTime = 0; + totalDistance = 0.0f; + deltaX = 0.0f; + deltaY = 0.0f; +} + +uint8_t glideDetectorGetPointCount(void) { + return pointCount; +} diff --git a/main/sensors/glide_detector.h b/main/sensors/glide_detector.h new file mode 100644 index 0000000..3d09ff7 --- /dev/null +++ b/main/sensors/glide_detector.h @@ -0,0 +1,136 @@ +/** + * @file glide_detector.h + * @brief Glide gesture detection interface for touch input + * + * This module provides glide gesture detection using touch coordinates. + * It detects when a finger glides across the screen with continuous motion + * and can trigger emotional responses in the display system. + */ + +#ifndef GLIDE_DETECTOR_H +#define GLIDE_DETECTOR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// ---------------------------------------------------------------------------- +// Configuration +// ---------------------------------------------------------------------------- + +// Minimum distance (in pixels) to qualify as a glide gesture +#define GLIDE_MIN_DISTANCE 80 + +// Maximum time (in milliseconds) between touch points to consider continuous +#define GLIDE_MAX_TIME_BETWEEN_POINTS 300 + +// Maximum time (in milliseconds) for a complete glide gesture +#define GLIDE_MAX_GESTURE_TIME 1000 + +// Maximum number of touch points to track per gesture +#define GLIDE_MAX_TOUCH_POINTS 32 + +// ---------------------------------------------------------------------------- +// Type Definitions +// ---------------------------------------------------------------------------- + +/** + * @brief Glide direction types + */ +typedef enum { + GLIDE_DIRECTION_NONE = 0, // No direction + GLIDE_DIRECTION_HORIZONTAL, // Horizontal glide (left or right) + GLIDE_DIRECTION_VERTICAL, // Vertical glide (up or down) + GLIDE_DIRECTION_DIAGONAL // Diagonal glide +} GlideDirection; + +/** + * @brief Touch point data structure + */ +typedef struct { + uint16_t x; // X coordinate + uint16_t y; // Y coordinate + uint32_t timestamp; // Timestamp in milliseconds +} TouchPoint; + +/** + * @brief Glide event data + */ +typedef struct { + GlideDirection direction; // Direction of glide + float distance; // Total distance in pixels + float deltaX; // X displacement + float deltaY; // Y displacement + uint32_t duration; // Gesture duration in milliseconds +} GlideEvent; + +/** + * @brief Glide event callback function type + * + * @param event Pointer to the glide event data + * @param user_data User-provided data passed during registration + */ +typedef void (*GlideCallback)(const GlideEvent *event, void *user_data); + +// ---------------------------------------------------------------------------- +// Public API +// ---------------------------------------------------------------------------- + +/** + * @brief Initialize the glide detector + * + * Initializes internal state and prepares the detector for touch events. + * Call this once during system initialization. + * + * @return true on successful initialization, false on failure + */ +bool glideDetectorInit(void); + +/** + * @brief Update the glide detector with a touch event + * + * Should be called for each touch event (press, move, release) from the + * touch input system. The detector tracks touch points and determines if + * a glide gesture has occurred. + * + * @param x Touch X coordinate (0 to DISPLAY_WIDTH) + * @param y Touch Y coordinate (0 to DISPLAY_HEIGHT) + * @param pressed true if touch is pressed, false if released + * @return true if a glide was detected in this update, false otherwise + */ +bool glideDetectorUpdate(uint16_t x, uint16_t y, bool pressed); + +/** + * @brief Register a callback for glide events + * + * The callback will be invoked when a glide gesture is detected. + * Only one callback can be registered at a time. + * + * @param callback Function pointer to the callback + * @param user_data User data to pass to the callback (can be NULL) + */ +void glideDetectorRegisterCallback(GlideCallback callback, void *user_data); + +/** + * @brief Reset the glide detector state + * + * Clears all tracked touch points and resets the state machine to IDLE. + * Use this to abort an in-progress gesture or after a timeout. + */ +void glideDetectorReset(void); + +/** + * @brief Get the current number of tracked touch points + * + * @return Number of touch points currently being tracked + */ +uint8_t glideDetectorGetPointCount(void); + +#ifdef __cplusplus +} +#endif + +#endif // GLIDE_DETECTOR_H diff --git a/main/sensors/shake_detector.h b/main/sensors/shake_detector.h index 18c5811..766e7f8 100644 --- a/main/sensors/shake_detector.h +++ b/main/sensors/shake_detector.h @@ -21,8 +21,8 @@ extern "C" { // ---------------------------------------------------------------------------- // Acceleration deviation threshold to detect shake (in G) -// Set above 1G to account for gravity and require actual vigorous shaking -#define SHAKE_ACCEL_THRESHOLD 1.3f +// Set above 2.2 to require vigorous shaking +#define SHAKE_ACCEL_THRESHOLD 2.2f // Number of consecutive readings above threshold to confirm shake #define SHAKE_CONTINUOUS_THRESHOLD 10