firmware-base/docs/LEDFeedback.md

2.7 KiB

title description keywords
LEDFeedback Component LED-based visual feedback system for indicating device status LED, visual feedback, NeoPixel, status indicator, ESP32

LEDFeedback

Path: 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

graph TD
    LEDFeedback --> Component
    LEDFeedback --> Adafruit_NeoPixel

BEHAVIOUR

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:

#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