firmware-base/docs/LEDFeedback.md

107 lines
2.7 KiB
Markdown

---
title: LEDFeedback Component
description: LED-based visual feedback system for indicating device status
keywords: LED, visual feedback, NeoPixel, status indicator, ESP32
---
## LEDFeedback
**Path**: [src/LEDFeedback.cpp](../src/LEDFeedback.cpp)
**Revision History**: Initial documentation
The LEDFeedback component provides visual status indication through addressable LEDs (NeoPixels). It allows for controlling color, intensity, and pattern of LEDs to convey system status or feedback to users.
## REQUIREMENTS
### Hardware
- Addressable LED strip/array (NeoPixels)
- Data pin connected to ESP32 GPIO
- Appropriate power supply for LEDs
### Software
- Adafruit_NeoPixel library
## FEATURES
- Control of individual addressable LEDs
- Multiple color patterns for status indication
- Modbus integration for remote control
- Configurable update interval
- Support for various LED counts
## DEPENDENCIES
- [Component](../src/Component.h) - Base component class
- [Adafruit_NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) - Library for controlling NeoPixels
```mermaid
graph TD
LEDFeedback --> Component
LEDFeedback --> Adafruit_NeoPixel
```
## BEHAVIOUR
```mermaid
stateDiagram-v2
[*] --> Initialize
Initialize --> Idle
Idle --> UpdateLEDs: Update interval reached
UpdateLEDs --> Idle
Idle --> ChangePattern: Modbus command received
ChangePattern --> Idle
```
## TODOS
### PERFORMANCE
- Optimize LED update frequency to minimize CPU usage
- Consider implementing brightness scaling based on system load
### SECURITY
- None identified - LED feedback is output-only
### COMPLIANCE
- Ensure power consumption stays within device specifications
### RECOMMENDATIONS
- Consider adding support for more complex animation patterns
- Add power-saving modes that reduce brightness during idle periods
- Implement error indication patterns for system diagnostics
## EXAMPLE
The LEDFeedback component is constructed and mounted as follows:
```cpp
#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
```
### References
- [NeoPixel Documentation](https://learn.adafruit.com/adafruit-neopixel-uberguide)