/** * @file emotion_manager.c * @brief Central emotion coordination system implementation * * This module coordinates all emotion animations. Currently supports * the blink emotion, with architecture ready for additional emotions. */ #include "emotion-engine/emotion_manager.h" #include "drivers/display_driver.h" #include "emotion-engine/blink/blink_emotion.h" #include "esp_log.h" static const char *TAG = "emotion_manager"; // ---------------------------------------------------------------------------- // Private State // ---------------------------------------------------------------------------- static EmotionType currentEmotion = EMOTION_IDLE; static bool initialized = false; // ---------------------------------------------------------------------------- // Public API Implementation // ---------------------------------------------------------------------------- bool emotionManagerInit(void) { ESP_LOGI(TAG, "Initializing emotion manager"); // Initialize blink emotion if (!blinkEmotionInit()) { ESP_LOGE(TAG, "Failed to initialize blink emotion"); return false; } // Future: Initialize other emotions here // surprisedEmotionInit(); // sadEmotionInit(); // angryEmotionInit(); initialized = true; currentEmotion = EMOTION_IDLE; ESP_LOGI(TAG, "Emotion manager initialized"); return true; } void emotionManagerStart(void) { if (!initialized) { ESP_LOGE(TAG, "Emotion manager not initialized"); return; } ESP_LOGI(TAG, "Starting emotion engine with idle state"); // Start the blink animation (idle state with natural blinking) blinkEmotionPlay(); currentEmotion = EMOTION_IDLE; } void emotionManagerSetEmotion(EmotionType emotion) { if (!initialized) { ESP_LOGE(TAG, "Emotion manager not initialized"); return; } ESP_LOGI(TAG, "Setting emotion: %d", emotion); currentEmotion = emotion; // Handle emotion transitions switch (emotion) { case EMOTION_IDLE: case EMOTION_BLINK: // Play blink animation blinkEmotionPlay(); break; case EMOTION_SURPRISED: case EMOTION_SAD: case EMOTION_ANGRY: // Future: Implement other emotion animations // For now, trigger a blink as visual feedback ESP_LOGI(TAG, "Emotion %d not yet implemented, using blink", emotion); blinkEmotionPlay(); break; default: ESP_LOGW(TAG, "Unknown emotion type: %d", emotion); break; } } EmotionType emotionManagerGetCurrent(void) { return currentEmotion; } void emotionManagerStop(void) { if (!initialized) { return; } ESP_LOGI(TAG, "Stopping emotion manager"); blinkEmotionStop(); // Future: Stop other emotions initialized = false; }