Skip to content

Conversation

@arunkumar-mourougappane
Copy link
Owner

This commit implements Phase 6 of the RTOS implementation requirements, adding a dedicated LED controller task for smooth animations and visual feedback without interfering with other operations.

Major Features:

  • LEDTask class for managing LED animations in dedicated task

  • Support for multiple LED states:

    • IDLE - Blue pulse animation
    • SCANNING - Cyan blink
    • CONNECTING - Yellow pulse
    • CONNECTED - Green solid
    • AP_MODE - Orange blink
    • ANALYZING - Purple pulse
    • ERROR - Red blink
    • WARNING - Amber pulse
    • SUCCESS - Green flash sequence
    • OFF - LED off
  • Support for multiple animation patterns:

    • SOLID - Solid color, no animation
    • BLINK - Blink on/off
    • PULSE - Smooth sine-wave pulse (fade in/out)
    • FADE - Smooth fade transition between colors
    • FLASH - Quick flash sequence
  • Smooth 60 FPS animations (16ms frame time)

  • Queue-based state changes with priority support

  • Smooth fade transitions when changing states

  • Brightness control (0-100%)

  • Custom color support with predefined color palette

  • Support for both standard LED and NeoPixel

Implementation Details:

  • LEDState enum for system status representation
  • LEDPattern enum for animation types
  • LEDColor struct with predefined colors (Red, Green, Blue, etc.)
  • LEDStateRequest structure for queue-based state changes
  • Priority-based pattern changes (higher priority overrides lower)
  • Smooth interpolation for fade transitions
  • Task runs on Core 1 (Application Core) with LOW priority
  • Stack size: 4096 bytes
  • Non-blocking queue operations

Animation Algorithms:

  • Pulse: Sine-wave based brightness modulation (2s cycle default)
  • Blink: Simple on/off toggle (500ms cycle default)
  • Fade: Linear interpolation between colors (5% per frame = ~330ms)
  • Flash: 100ms on, 100ms off, 100ms on sequence
  • Solid: Constant color output

Conditional Compilation:

  • Standard LED mode (ESP32dev): Simple on/off based on brightness
  • NeoPixel mode (Feather ESP32-S3): Full RGB color control
  • Automatically selects based on USE_NEOPIXEL flag

Public API Functions:

  • initializeLEDTask(): Initialize and start LED task
  • setLEDState(): Set LED state (IDLE, SCANNING, etc.)
  • setLEDPattern(): Set animation pattern (PULSE, BLINK, etc.)
  • setLEDColor(): Set custom LED color
  • setLEDBrightness(): Set brightness level (0-100)
  • getLEDState(): Get current LED state

Integration:

  • Integrated into main.cpp after AnalysisTask initialization
  • Only initialized in RTOS mode
  • Legacy LED controller still used in non-RTOS mode
  • All builds verified:
    • esp32dev_rtos: 86.2% flash, 16.5% RAM
    • adafruit_feather_esp32s3_tft_rtos: 74.8% flash, 16.1% RAM
    • esp32dev (legacy): 83.1% flash, 16.4% RAM

Benefits:

  • Smooth animations without blocking other operations
  • No CPU time wasted on LED updates during critical tasks
  • Responsive pattern changes (<100ms via queue)
  • Clean separation of visual feedback from core functionality
  • Easy to extend with new states and patterns

Future Enhancements:

  • Status queue integration for automatic updates
  • Multi-LED support for status indicators
  • More complex animation sequences
  • Brightness auto-adjustment based on ambient light

Addresses: #18 (LED Controller Task Enhancement, Phase 6)
Part of: #12 (RTOS Implementation Requirements) for v4.1.0 milestone

This commit implements Phase 6 of the RTOS implementation requirements,
adding a dedicated LED controller task for smooth animations and visual
feedback without interfering with other operations.

Major Features:
- LEDTask class for managing LED animations in dedicated task
- Support for multiple LED states:
  * IDLE - Blue pulse animation
  * SCANNING - Cyan blink
  * CONNECTING - Yellow pulse
  * CONNECTED - Green solid
  * AP_MODE - Orange blink
  * ANALYZING - Purple pulse
  * ERROR - Red blink
  * WARNING - Amber pulse
  * SUCCESS - Green flash sequence
  * OFF - LED off

- Support for multiple animation patterns:
  * SOLID - Solid color, no animation
  * BLINK - Blink on/off
  * PULSE - Smooth sine-wave pulse (fade in/out)
  * FADE - Smooth fade transition between colors
  * FLASH - Quick flash sequence

- Smooth 60 FPS animations (16ms frame time)
- Queue-based state changes with priority support
- Smooth fade transitions when changing states
- Brightness control (0-100%)
- Custom color support with predefined color palette
- Support for both standard LED and NeoPixel

Implementation Details:
- LEDState enum for system status representation
- LEDPattern enum for animation types
- LEDColor struct with predefined colors (Red, Green, Blue, etc.)
- LEDStateRequest structure for queue-based state changes
- Priority-based pattern changes (higher priority overrides lower)
- Smooth interpolation for fade transitions
- Task runs on Core 1 (Application Core) with LOW priority
- Stack size: 4096 bytes
- Non-blocking queue operations

Animation Algorithms:
- Pulse: Sine-wave based brightness modulation (2s cycle default)
- Blink: Simple on/off toggle (500ms cycle default)
- Fade: Linear interpolation between colors (5% per frame = ~330ms)
- Flash: 100ms on, 100ms off, 100ms on sequence
- Solid: Constant color output

Conditional Compilation:
- Standard LED mode (ESP32dev): Simple on/off based on brightness
- NeoPixel mode (Feather ESP32-S3): Full RGB color control
- Automatically selects based on USE_NEOPIXEL flag

Public API Functions:
- initializeLEDTask(): Initialize and start LED task
- setLEDState(): Set LED state (IDLE, SCANNING, etc.)
- setLEDPattern(): Set animation pattern (PULSE, BLINK, etc.)
- setLEDColor(): Set custom LED color
- setLEDBrightness(): Set brightness level (0-100)
- getLEDState(): Get current LED state

Integration:
- Integrated into main.cpp after AnalysisTask initialization
- Only initialized in RTOS mode
- Legacy LED controller still used in non-RTOS mode
- All builds verified:
  * esp32dev_rtos: 86.2% flash, 16.5% RAM
  * adafruit_feather_esp32s3_tft_rtos: 74.8% flash, 16.1% RAM
  * esp32dev (legacy): 83.1% flash, 16.4% RAM

Benefits:
- Smooth animations without blocking other operations
- No CPU time wasted on LED updates during critical tasks
- Responsive pattern changes (<100ms via queue)
- Clean separation of visual feedback from core functionality
- Easy to extend with new states and patterns

Future Enhancements:
- Status queue integration for automatic updates
- Multi-LED support for status indicators
- More complex animation sequences
- Brightness auto-adjustment based on ambient light

Addresses: #18 (LED Controller Task Enhancement, Phase 6)
Part of: #12 (RTOS Implementation Requirements) for v4.1.0 milestone
@github-actions
Copy link

📊 Build Size Analysis

Metric Base (main) Current (PR) Change
Flash Usage 83.1% 83.1% ✅ No change
RAM Usage 16.4% 16.4% ✅ No change

Analysis

  • Flash usage shows the percentage of ESP32 flash memory used
  • RAM usage shows the percentage of runtime memory used
  • Changes in memory usage should be reviewed for optimization opportunities

This analysis helps maintain optimal memory usage across code changes.

@arunkumar-mourougappane arunkumar-mourougappane merged commit 65a36fe into main Oct 19, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in ESP32 WiFi Utility Oct 19, 2025
@arunkumar-mourougappane
Copy link
Owner Author

closing this pull request.

@arunkumar-mourougappane arunkumar-mourougappane deleted the led-controller-task-enhancement branch October 19, 2025 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

LED Controller Task Enhancement

2 participants