StatusLight - LED Status Indicator Component
StatusLight
Section titled “StatusLight”Path: src/StatusLight.h
Revision History: Initial documentation
StatusLight is a component for controlling a status LED, providing simple on/off and blinking capabilities. It supports Modbus integration for remote monitoring and control of the status indicator.
REQUIREMENTS
Section titled “REQUIREMENTS”- Hardware:
- Digital GPIO pin for controlling an LED
- Software:
- Configuration for pin assignment in
config.h
- Modbus address configuration in
config-modbus.h
- Configuration for pin assignment in
FEATURES
Section titled “FEATURES”- Steady on/off LED control
- Blinking functionality with configurable interval
- Modbus integration for remote monitoring and control
- Support for multiple instances with different Modbus addresses
- Component state tracking
DEPENDENCIES
Section titled “DEPENDENCIES”- Arduino.h
- ArduinoLog.h
- Component.h
- macros.h
- xmath.h
- Bridge.h
- enums.h
- config.h
- config-modbus.h
- modbus/ModbusTCP.h
BEHAVIOUR
Section titled “BEHAVIOUR”PERFORMANCE
Section titled “PERFORMANCE”- Consider using hardware PWM for smoother blinking effects
- Review blinking implementation for efficiency (currently using polling in loop)
SECURITY
Section titled “SECURITY”- Add validation for input parameters in set() method
- Consider authentication for Modbus write operations
COMPLIANCE
Section titled “COMPLIANCE”- Ensure blinking rates are appropriate for industrial environments
- Comply with industrial standards for visual indicators
RECOMMENDATIONS
Section titled “RECOMMENDATIONS”- Use hardware with appropriate LED drivers for high-brightness applications
- Consider adding additional blink patterns for varied status indications
- Add support for RGB LEDs for multi-state visualization
EXAMPLE
Section titled “EXAMPLE”Below is an example of how to initialize and use the StatusLight component:
#ifdef PIN_STATUS_LIGHT statusLight = new StatusLight( this, // owner PIN_STATUS_LIGHT, // pin COMPONENT_KEY_FEEDBACK_0, // id MB_MONITORING_STATUS_FEEDBACK_0 // modbusAddress ); if (statusLight) { components.push_back(statusLight); Log.infoln(F("StatusLight initialized. Pin:%d, ID:%d, MB:%d"), PIN_STATUS_LIGHT, COMPONENT_KEY_FEEDBACK_0, MB_MONITORING_STATUS_FEEDBACK_0);
// Example usage statusLight->on(); // Turn the LED on // statusLight->off(); // Turn the LED off // statusLight->setBlink(true); // Make the LED blink } else { Log.errorln(F("StatusLight initialization failed.")); }#endif