Refactor project structure and update display logic

Reorganized source files into new directories for config, drivers, sensors, emotion engine, and UI. Removed legacy assets and code related to previous eye animation implementation. Added new display and touch drivers, emotion manager, shake detector, and UI components. Updated CMake project name to 'irobot_display'.
This commit is contained in:
2026-01-24 15:21:50 +05:30
parent 2c731c72e3
commit 8aeaed8a15
69 changed files with 2650 additions and 10338 deletions

View File

@@ -0,0 +1,202 @@
/**
* @file blink_data.h
* @brief Embedded blink Lottie animation data
*
* This file contains the blink.json Lottie animation stored as a C string.
* The animation shows two eyes blinking on a 368x448 display at 60fps.
* Source file: assets/emotions/blink.json
*/
#ifndef BLINK_DATA_H
#define BLINK_DATA_H
// Lottie JSON animation data stored in flash
// Animation: 368x448, 60fps, 36 frames
const char blinkAnimationData[] =
"{\"fr\":60,\"h\":448,\"ip\":0,\"layers\":["
"{\"ind\":3,\"ty\":4,\"parent\":2,\"ks\":{},\"ip\":0,\"op\":37,\"st\":0,"
"\"shapes\":["
"{\"ty\":\"rc\",\"p\":{\"a\":1,\"k\":["
"{\"t\":0,\"s\":[48.5,68],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":2.952,\"s\":[48.5,13.753],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":5.898,\"s\":[48.5,-2.831],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":11.802,\"s\":[48.5,0.118],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":17.76,\"s\":[48.5,-0.005],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":18,\"s\":[48.5,-0.005],\"h\":1},"
"{\"t\":18,\"s\":[48.5,0],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":20.952,\"s\":[48.5,54.247],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":23.898,\"s\":[48.5,70.831],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":29.802,\"s\":[48.5,67.882],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":35.76,\"s\":[48.5,68.005],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":36,\"s\":[48.5,68.005],\"h\":1}"
"]},\"r\":{\"a\":0,\"k\":20},\"s\":{\"a\":1,\"k\":["
"{\"t\":0,\"s\":[97,136],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":2.952,\"s\":[97,27.505],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":5.898,\"s\":[97,-5.662],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":11.802,\"s\":[97,0.236],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":17.76,\"s\":[97,-0.01],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":18,\"s\":[97,-0.01],\"h\":1},"
"{\"t\":18,\"s\":[97,0],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":20.952,\"s\":[97,108.495],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":23.898,\"s\":[97,141.662],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":29.802,\"s\":[97,135.764],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":35.76,\"s\":[97,136.01],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":36,\"s\":[97,136.01],\"h\":1}"
"]}},"
"{\"ty\":\"fl\",\"c\":{\"a\":0,\"k\":[1,1,1]},\"o\":{\"a\":0,\"k\":100}}"
"]},"
"{\"ind\":2,\"ty\":3,\"parent\":1,\"ks\":{\"p\":{\"a\":1,\"k\":["
"{\"t\":0,\"s\":[211,88],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":2.952,\"s\":[211,142.247],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":5.898,\"s\":[211,158.831],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":11.802,\"s\":[211,155.882],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":17.76,\"s\":[211,156.005],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":18,\"s\":[211,156.005],\"h\":1},"
"{\"t\":18,\"s\":[211,156],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":20.952,\"s\":[211,101.753],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":23.898,\"s\":[211,85.169],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":29.802,\"s\":[211,88.118],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":35.76,\"s\":[211,87.995],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":36,\"s\":[211,87.995],\"h\":1}"
"]}},\"ip\":0,\"op\":37,\"st\":0},"
"{\"ind\":5,\"ty\":4,\"parent\":4,\"ks\":{},\"ip\":0,\"op\":37,\"st\":0,"
"\"shapes\":["
"{\"ty\":\"rc\",\"p\":{\"a\":1,\"k\":["
"{\"t\":0,\"s\":[48.5,66],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":2.952,\"s\":[48.5,13.348],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":5.898,\"s\":[48.5,-2.748],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":11.802,\"s\":[48.5,0.114],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":17.76,\"s\":[48.5,-0.005],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":18,\"s\":[48.5,-0.005],\"h\":1},"
"{\"t\":18,\"s\":[48.5,0],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":20.952,\"s\":[48.5,54.247],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":23.898,\"s\":[48.5,70.831],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":29.802,\"s\":[48.5,67.882],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":35.76,\"s\":[48.5,68.005],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":36,\"s\":[48.5,68.005],\"h\":1}"
"]},\"r\":{\"a\":0,\"k\":20},\"s\":{\"a\":1,\"k\":["
"{\"t\":0,\"s\":[97,132],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":2.952,\"s\":[97,26.696],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":5.898,\"s\":[97,-5.496],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":11.802,\"s\":[97,0.229],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":17.76,\"s\":[97,-0.01],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":18,\"s\":[97,-0.009],\"h\":1},"
"{\"t\":18,\"s\":[97,0],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":20.952,\"s\":[97,108.495],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":23.898,\"s\":[97,141.662],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":29.802,\"s\":[97,135.764],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":35.76,\"s\":[97,136.01],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":36,\"s\":[97,136.01],\"h\":1}"
"]}},"
"{\"ty\":\"fl\",\"c\":{\"a\":0,\"k\":[1,1,1]},\"o\":{\"a\":0,\"k\":100}}"
"]},"
"{\"ind\":4,\"ty\":3,\"parent\":1,\"ks\":{\"a\":{\"a\":1,\"k\":["
"{\"t\":0,\"s\":[48.5,66],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":2.952,\"s\":[48.5,13.348],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":5.898,\"s\":[48.5,-2.748],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":11.802,\"s\":[48.5,0.114],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":17.76,\"s\":[48.5,-0.005],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":18,\"s\":[48.5,-0.005],\"h\":1},"
"{\"t\":18,\"s\":[48.5,0],\"i\":{\"x\":[1,0.537],\"y\":[1,0.625]},\"o\":{"
"\"x\":[0,0.283],\"y\":[0,0.035]}},"
"{\"t\":20.952,\"s\":[48.5,54.247],\"i\":{\"x\":[1,0.69],\"y\":[1,0.998]},"
"\"o\":{"
"\"x\":[0,0.343],\"y\":[0,0.908]}},"
"{\"t\":23.898,\"s\":[48.5,70.831],\"i\":{\"x\":[1,0.282],\"y\":[1,0.996]},"
"\"o\":{"
"\"x\":[0,0.262],\"y\":[0,0.033]}},"
"{\"t\":29.802,\"s\":[48.5,67.882],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":35.76,\"s\":[48.5,68.005],\"i\":{\"x\":[1,1],\"y\":[1,1]},\"o\":{"
"\"x\":[0,0],\"y\":[0,0]}},"
"{\"t\":36,\"s\":[48.5,68.005],\"h\":1}"
"]},\"p\":{\"a\":0,\"k\":[108.5,157]}},\"ip\":0,\"op\":37,\"st\":0},"
"{\"ind\":1,\"ty\":3,\"parent\":0,\"ks\":{},\"ip\":0,\"op\":37,\"st\":0},"
"{\"ind\":6,\"ty\":4,\"parent\":0,\"ks\":{},\"ip\":0,\"op\":37,\"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\":37,\"st\":0}"
"],\"meta\":{\"g\":\"https://"
"jitter.video\"},\"op\":36,\"v\":\"5.7.4\",\"w\":368}";
#endif // BLINK_DATA_H

View File

@@ -0,0 +1,90 @@
/**
* @file blink_emotion.c
* @brief Blink emotion animation implementation
*
* This module implements the idle blink animation using the Lottie player.
* It loads the blink animation data and manages playback with natural timing.
*/
#include "emotion-engine/blink/blink_emotion.h"
#include "drivers/display_driver.h"
#include "emotion-engine/blink/blink_data.h"
#include "esp_log.h"
#include "ui/lottie_player.h"
static const char *TAG = "blink_emotion";
// ----------------------------------------------------------------------------
// Private State
// ----------------------------------------------------------------------------
static lottie_player_handle_t blinkPlayer = NULL;
static bool initialized = false;
// ----------------------------------------------------------------------------
// Public API Implementation
// ----------------------------------------------------------------------------
bool blinkEmotionInit(void) {
ESP_LOGI(TAG, "Initializing blink emotion");
// Don't reinitialize if already done
if (initialized && blinkPlayer != NULL) {
ESP_LOGW(TAG, "Blink emotion already initialized");
return true;
}
initialized = true;
ESP_LOGI(TAG, "Blink emotion initialized (deferred player creation)");
return true;
}
void blinkEmotionPlay(void) {
if (!initialized) {
ESP_LOGE(TAG, "Blink emotion not initialized");
return;
}
// Create player on first play (ensures display is ready)
if (blinkPlayer == NULL) {
ESP_LOGI(TAG, "Creating blink player");
lv_obj_t *screen = displayDriverGetActiveScreen();
if (screen == NULL) {
ESP_LOGE(TAG, "No active screen available");
return;
}
blinkPlayer = lottieCreateFromData(screen, blinkAnimationData);
if (blinkPlayer == NULL) {
ESP_LOGE(TAG, "Failed to create blink player");
return;
}
}
// Lottie player auto-starts with natural blink mode
ESP_LOGI(TAG, "Blink animation active");
}
void blinkEmotionPause(void) {
if (blinkPlayer != NULL) {
lottiePause(blinkPlayer);
}
}
void blinkEmotionStop(void) {
if (blinkPlayer != NULL) {
lottieDestroy(blinkPlayer);
blinkPlayer = NULL;
}
initialized = false;
ESP_LOGI(TAG, "Blink emotion stopped");
}
void blinkEmotionTrigger(void) {
if (blinkPlayer != NULL) {
lottieSetFrame(blinkPlayer, 0);
lottiePlay(blinkPlayer);
}
}

View File

@@ -0,0 +1,54 @@
/**
* @file blink_emotion.h
* @brief Blink emotion animation interface
*
* This module handles the idle blink animation using Lottie.
* It plays the eyes open/close animation with natural random intervals.
*/
#ifndef BLINK_EMOTION_H
#define BLINK_EMOTION_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize the blink emotion
*
* Loads the blink animation data and prepares the Lottie player.
* Must be called after display driver initialization.
*
* @return true on success, false on failure
*/
bool blinkEmotionInit(void);
/**
* @brief Start or trigger the blink animation
*
* Starts the natural blink loop with random intervals.
*/
void blinkEmotionPlay(void);
/**
* @brief Pause the blink animation
*/
void blinkEmotionPause(void);
/**
* @brief Stop and cleanup the blink animation
*/
void blinkEmotionStop(void);
/**
* @brief Trigger a single blink immediately
*/
void blinkEmotionTrigger(void);
#ifdef __cplusplus
}
#endif
#endif // BLINK_EMOTION_H