3.9 KiB
3.9 KiB
| title | description | keywords |
|---|---|---|
| LED Feedback Component Documentation | Documentation for the LED Feedback component providing visual status indicators using addressable LED strips | LED Feedback, NeoPixel, WS2812B, SK6812, ESP32, visual indicator |
LED Feedback
Path: src/LEDFeedback.cpp
Revision History: Initial documentation
The LED Feedback component provides visual status indication through addressable LED strips (NeoPixel compatible). It offers multiple display modes including fading effects, level indicators, and tri-color blinking patterns that can be controlled via Modbus.
REQUIREMENTS
- Digital output pin connected to WS2812B/SK6812 compatible LED strip
- 5V power supply for the LED strip (separate from microcontroller logic)
- Modbus TCP connection for remote control
FEATURES
- Multiple display modes:
- OFF: All LEDs turned off
- FADE_R_B: Smooth color transition between red and blue
- RANGE: Level indicator (0-100%) using lit LEDs
- TRI_COLOR_BLINK: Three-section traffic light style blinking (red, yellow, green)
- Modbus control interface for mode selection and parameters
- Adjustable update rate for animations
- Configurable pixel count to support different strip lengths
DEPENDENCIES
- Adafruit_NeoPixel - Library for controlling addressable LED strips
- ArduinoLog - Logging functionality
- ModbusTCP - For Modbus communication
graph TD
LEDFeedback --> Component
LEDFeedback --> Adafruit_NeoPixel
LEDFeedback --> ModbusTCP
LEDFeedback --> ArduinoLog
LEDFeedback --> Bridge
BEHAVIOUR
stateDiagram-v2
[*] --> OFF
OFF --> FADE_R_B: Modbus write mode=1
OFF --> RANGE: Modbus write mode=2
OFF --> TRI_COLOR_BLINK: Modbus write mode=3
FADE_R_B --> OFF: Modbus write mode=0
FADE_R_B --> RANGE: Modbus write mode=2
FADE_R_B --> TRI_COLOR_BLINK: Modbus write mode=3
RANGE --> OFF: Modbus write mode=0
RANGE --> FADE_R_B: Modbus write mode=1
RANGE --> TRI_COLOR_BLINK: Modbus write mode=3
RANGE: Update level via Modbus
TRI_COLOR_BLINK --> OFF: Modbus write mode=0
TRI_COLOR_BLINK --> FADE_R_B: Modbus write mode=1
TRI_COLOR_BLINK --> RANGE: Modbus write mode=2
TODOS
PERFORMANCE
- Consider power consumption optimization for battery-powered applications
- Investigate using DMA-based LED control to reduce CPU usage
- Add brightness control via Modbus to manage power usage
SECURITY
- Validate Modbus values more strictly to prevent unexpected behavior
- Consider adding access control for mode changes
COMPLIANCE
- Verify EMC compliance when LEDs change rapidly (potential for EMI)
- Ensure ADA compliance for visual indicators in public/commercial settings
RECOMMENDATIONS
- Use adequate power supply for LED strips (60mA per pixel at full brightness)
- Consider adding a level-shifting circuit when connecting 3.3V microcontrollers to 5V LED strips
- Add physical protection for LEDs in industrial environments
- Implement custom modes for specific application requirements
EXAMPLE
This example shows how to initialize and mount an LED Feedback component in an application:
#ifdef PIN_LED_FEEDBACK_0
ledFeedback_0 = new LEDFeedback(
this, // owner
PIN_LED_FEEDBACK_0, // pin
LED_PIXEL_COUNT_0, // pixelCount
ID_LED_FEEDBACK_0, // id
LED_FEEDBACK_0_MB_ADDR // modbusAddress
);
if (ledFeedback_0)
{
components.push_back(ledFeedback_0);
Log.infoln(F("LEDFeedback_0 initialized. Pin:%d, Count:%d, ID:%d, MB:%d"),
PIN_LED_FEEDBACK_0, LED_PIXEL_COUNT_0,
ID_LED_FEEDBACK_0, LED_FEEDBACK_0_MB_ADDR);
}
else
{
Log.errorln(F("LEDFeedback_0 initialization failed."));
}
#endif