Skip to content

StatusLight - LED Status Indicator Component

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.

  • Hardware:
    • Digital GPIO pin for controlling an LED
  • Software:
    • Configuration for pin assignment in config.h
    • Modbus address configuration in config-modbus.h
  • 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

StatusLight

Component

Bridge

Arduino

ArduinoLog

macros

xmath

enums

config

configmodbus

ModbusTCP

set(1)

set(0)

set(0,1)

set(1,1)

set(0,0)

set(1,0)

OFF

ON

BLINK

  • Consider using hardware PWM for smoother blinking effects
  • Review blinking implementation for efficiency (currently using polling in loop)
  • Add validation for input parameters in set() method
  • Consider authentication for Modbus write operations
  • Ensure blinking rates are appropriate for industrial environments
  • Comply with industrial standards for visual indicators
  • 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

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