sl-android 49628bcc61 feat: Add Issue #507 - Face display animations on STM32 LCD
Implements expressive face animations with 5 core emotions (happy/sad/curious/angry/sleeping) and smooth transitions on small LCD displays.

Features:
- State machine with smooth 0.5s emotion transitions (ease-in-out cubic easing)
- Automatic idle blinking (4-6s intervals, 100-150ms duration per blink)
- UART command interface via USART3 @ 115200 (text-based protocol)
- 30Hz target refresh rate via systick integration
- Low-level LCD abstraction supporting monochrome and RGB565
- Rendering primitives: pixel, line (Bresenham), circle (midpoint), filled rect

Architecture:
- face_lcd.h/c: Hardware-agnostic framebuffer & display driver
- face_animation.h/c: Emotion state machine & parameterized face rendering
- face_uart.h/c: UART command parser (HAPPY/SAD/CURIOUS/ANGRY/SLEEP/NEUTRAL/BLINK/STATUS)
- Unit tests (14 test cases): emotion transitions, blinking, rendering, all emotions

Integration:
- main.c: Added includes, initialization (servo_init), systick tick, main loop processing
- Pending: LCD hardware initialization (SPI/I2C config, display controller setup)

Files: 9 new (headers, source, tests, docs), 1 modified (main.c)
Lines: ~1450 total (345 headers, 650 source, 350 tests, 900 docs)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-06 10:27:36 -05:00

77 lines
2.2 KiB
C

/*
* face_uart.h — UART Command Interface for Face Animations
*
* Receives emotion commands from Jetson Orin via UART (USART3 by default).
* Parses simple text commands and updates face animation state.
*
* PROTOCOL:
* Text-based commands (newline-terminated):
* HAPPY — Set emotion to happy
* SAD — Set emotion to sad
* CURIOUS — Set emotion to curious
* ANGRY — Set emotion to angry
* SLEEP — Set emotion to sleeping
* NEUTRAL — Set emotion to neutral
* BLINK — Trigger immediate blink
* STATUS — Echo current emotion + animation state
*
* Example:
* > HAPPY\n
* < OK: HAPPY\n
*
* INTERFACE:
* - UART3 (PB10=TX, PB11=RX) at 115200 baud
* - RX ISR pushes bytes into ring buffer
* - face_uart_process() checks for complete commands (polling)
* - Case-insensitive command parsing
* - Echoes command results to TX for debugging
*
* API:
* - face_uart_init() — Configure UART3 @ 115200
* - face_uart_process() — Parse and execute commands (call from main loop)
* - face_uart_rx_isr() — Called by UART3 RX interrupt
* - face_uart_send() — Send response string (used internally)
*/
#ifndef FACE_UART_H
#define FACE_UART_H
#include <stdint.h>
#include <stdbool.h>
/* === Configuration === */
#define FACE_UART_INSTANCE USART3 /* USART3 (PB10=TX, PB11=RX) */
#define FACE_UART_BAUD 115200 /* 115200 baud */
#define FACE_UART_RX_BUF_SZ 128 /* RX ring buffer size */
/* === Public API === */
/**
* Initialize UART for face commands.
* Configures USART3 @ 115200, enables RX interrupt.
*/
void face_uart_init(void);
/**
* Process any pending RX data and execute commands.
* Should be called periodically from main loop (or low-priority task).
* Returns immediately if no complete command available.
*/
void face_uart_process(void);
/**
* UART3 RX interrupt handler.
* Called by HAL when a byte is received.
* Pushes byte into ring buffer.
*/
void face_uart_rx_isr(uint8_t byte);
/**
* Send a response string to UART3 TX.
* Used for echoing status/ack messages.
* Non-blocking (pushes to TX queue).
*/
void face_uart_send(const char *str);
#endif // FACE_UART_H