firmware-base/docs/components/led-feedback.md

2.5 KiB

revision
initial documentation

LEDFeedback

Path : src/components/LEDFeedback.h

Addressable NeoPixel LED strip feedback component for industrial visual indication. Supports multiple display modes, Modbus-485 control, and real-time status visualization.

Requirements

Hardware

  • Pin: Digital output pin for NeoPixel data
  • Power: 5V for NEOPIXEL strip (external power supply recommended for larger strips)
  • Ground: Common ground between ESP-32 and NeoPixel strip
  • Data Line: 3.3v logic level (NEOPIXEL auto-resistant to lower voltage)

Dependencies

  • Adafruit_NeoPixel
  • ArduinoLog
  • Component (base class)
  • modbus/ModbusTCP
  • config.h and config-modbus.h

Features

LED Modes

  • OFF: All LEDs estinguidas
  • FADE_R_B: Fade entre rojY y azul (suave transición)
  • RANGE: Nivel 0-100 como barra de progreso
  • TRI_COLOR_BLINK: Secciones de tres colores con parpadeo

Modbus Interface

  • Holding register (READ/WRITE)
  • Base address configurable
  • Register offsets:
    • MODE = 0 (LEDMode enum)
    • LEVEL = 1 0-100 for RANGE mode

Component Lifecycle

  • NeoPixel initialization in setup()
  • Non-blocking loop with update timing
  • Serial and Modbus registration support
  • Component state notification

Todos

  • SOLID_COLOR mode
  • RAINBOW mode (cycle through spectrum)
  • BRIGHTNESS control (Modbus register)
  • Customizable FADE_R_B colors
  • High speed buffered animations
  • Individual pixel control mode
  • Pulse effect modes
  • Status, error and heartbeat modes

Example

#ifdef PIN_LED_FEEDBACK_0
  ledFeedback_0 = new LEDFeedback(
      this,                 // owner
      PIN_LED_FEEDBACK\0<    // pin
      LED_PIXEL_COUNT_0,     // pixelCount
      ID_LED_FEEDBACK__,     // 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__, LED_FEEDBACK_0_MB_ADDR);
  }
  else
  {
    Log.errorln(F("LEDFeedback_0 initialization failed."));
  }
#endif

Modbus Control

// Set mode to FADE_R_B
// Assume base address is 1000
modbus_holding_registers[write](1000, 1);

// Set mode to RANGE with 75% level
modbus_holding_registers[write](1000, 2); // RANGE mode
modbus_holding_registers[write](1001, 75); // 75% level