ledstrip - wolfen351/public-micropython-iot-platform GitHub Wiki

Overview

This module provides control over an LED strip using a web-based interface and animations. It allows users to adjust brightness, colors, and effects, and supports various animations such as fade, cycle, bounce, and rainbow.

Features

  • Web-based interface for controlling the LED strip.
  • Adjustable brightness (1-255).
  • Primary and secondary color selection.
  • Multiple animation effects:
    • None
    • Switch
    • Fade
    • Cycle
    • Bounce
    • Rainbow
  • Real-time telemetry updates for LED state, colors, brightness, and duration.

UI Hardware / Pinout Configuration

  • LED Strip:
    • Pin: Configurable via basicSettings['led']['pin'].
    • Length: Configurable via basicSettings['led']['length'].
  • Microcontroller:
    • Uses NeoPixel library for controlling the LED strip.

Telemetry Provided

  • ledaction: Current animation action (e.g., none, fade, cycle).
  • ledstate: Current state of the LED strip (ON or OFF).
  • ledduration: Duration of the animation in milliseconds.
  • ledcolormode: Current color mode (e.g., rgb).
  • ledprimary: Primary color in hexadecimal format (e.g., #FF0000).
  • ledprimaryr, ledprimaryg, ledprimaryb: Primary color components (red, green, blue).
  • ledsecondary: Secondary color in hexadecimal format (e.g., #00FF00).
  • ledsecondaryr, ledsecondaryg, ledsecondaryb: Secondary color components (red, green, blue).
  • ledbrightness: Current brightness level (1-255).

Telemetry Consumed

  • None.

Commands Provided

  • Set Colors:
    • Set primary and secondary colors via /led/color endpoint.
    • Example:
      {
        "primary": "FF0000",
        "secondary": "00FF00"
      }
      
  • Set Action:
    • Set the animation action via /led/action endpoint.
    • Example:
      {
        "action": "fade"
      }
      
  • Set Brightness:
    • Adjust brightness via /led/brightness endpoint.
    • Example:
      {
        "brightness": 128
      }
      
  • Set Duration:
    • Adjust animation duration via /led/duration endpoint.
    • Example:
      {
        "duration": 2000
      }
      

Commands Consumed

  • Commands are processed via the /ledprimary/ and /ledsecondary/ endpoints. These commands allow integration with external systems like Home Assistant. Examples include:
    • Adjusting brightness.
    • Changing colors.
    • Setting effects.

Additional Information

  • Brightness Control:
    • Brightness is applied as a multiplier to the RGB values of the colors.
    • Range: 1-255.
  • Animations:
    • Switch: Alternates between primary and secondary colors.
    • Fade: Smoothly transitions between primary and secondary colors.
    • Cycle: Cycles through the LED strip with the primary color.
    • Bounce: Animates a bouncing effect with the primary color.
    • Rainbow: Displays a rainbow effect across the LED strip.
  • Web Interface:
    • The module includes a web-based settings page (settings.html) for real-time control of colors, brightness, and animations.
    • The index.html page provides telemetry data and a button to access the settings page.
  • NeoPixel Integration:
    • The module uses the NeoPixel library to control the LED strip.
    • The calculateRainbow function generates a rainbow effect for the LED strip.
  • Persistence:
    • User preferences (e.g., colors, brightness, duration) are saved and restored on restart.

This module is designed to provide a flexible and user-friendly interface for controlling LED strips, making it suitable for various applications such as home automation, decorative lighting, and more.