--- title: "StatusLight - LED Status Indicator Component" description: "A component for controlling a status LED with simple on/off and blinking capabilities" keywords: ["ESP32", "status LED", "indicator", "modbus", "feedback"] --- ## StatusLight **Path**: [`src/StatusLight.h`](../../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 - **Hardware**: - Digital GPIO pin for controlling an LED - **Software**: - Configuration for pin assignment in `config.h` - Modbus address configuration in `config-modbus.h` ## 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 - [Arduino.h](https://github.com/espressif/arduino-esp32) - [ArduinoLog.h](https://github.com/thijse/Arduino-Log) - [Component.h](../../src/Component.h) - [macros.h](../../src/macros.h) - [xmath.h](../../src/xmath.h) - [Bridge.h](../../src/Bridge.h) - [enums.h](../../src/enums.h) - [config.h](../../src/config.h) - [config-modbus.h](../../src/config-modbus.h) - [modbus/ModbusTCP.h](../../src/modbus/ModbusTCP.h) ```mermaid graph TD StatusLight --> Component StatusLight --> Bridge StatusLight --> Arduino StatusLight --> ArduinoLog StatusLight --> macros StatusLight --> xmath StatusLight --> enums StatusLight --> config StatusLight --> configmodbus StatusLight --> ModbusTCP ``` ## BEHAVIOUR ```mermaid stateDiagram-v2 [*] --> OFF OFF --> ON: set(1) ON --> OFF: set(0) OFF --> BLINK: set(0,1) ON --> BLINK: set(1,1) BLINK --> OFF: set(0,0) BLINK --> ON: set(1,0) ``` ## TODOS ### PERFORMANCE - Consider using hardware PWM for smoother blinking effects - Review blinking implementation for efficiency (currently using polling in loop) ### SECURITY - Add validation for input parameters in set() method - Consider authentication for Modbus write operations ### COMPLIANCE - Ensure blinking rates are appropriate for industrial environments - Comply with industrial standards for visual indicators ### 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 Below is an example of how to initialize and use the StatusLight component: ```cpp #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 ``` ### References