led.h 954 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "esp_err.h"
  3. #include <stdbool.h>
  4. #include <stddef.h>
  5. #include <stdint.h>
  6. typedef enum {
  7. LED_OFF,
  8. LED_STEADY,
  9. LED_BLINK_SLOW, // 100ms on, 2500ms off (standby)
  10. LED_BLINK_MEDIUM, // 500ms on/off (paused)
  11. LED_BLINK_FAST, // 250ms on/off
  12. LED_VU, // Audio visualization
  13. } led_mode_t;
  14. /**
  15. * Initialize LED subsystem and register for RTSP events.
  16. */
  17. void led_init(void);
  18. /**
  19. * Feed audio samples for VU meter mode.
  20. * Call this from the audio path when playing.
  21. */
  22. void led_audio_feed(const int16_t *pcm, size_t stereo_samples);
  23. /**
  24. * Set error state (e.g., speaker fault, decode failure).
  25. * Clears automatically on next playback state change.
  26. */
  27. void led_set_error(bool error);
  28. /**
  29. * Set LED brightness (0–255). Persists to NVS and takes effect immediately.
  30. */
  31. esp_err_t led_set_brightness(uint8_t brightness);
  32. /**
  33. * Get current LED brightness (0–255).
  34. */
  35. uint8_t led_get_brightness(void);