FastLED Light Output

Since version 1.5.0 esphomelib supports many types of addressable LEDs using the FastLED library.

Example Usage

// Binary
auto fast_led = App.make_fast_led_light("Fast LED Light");
// 60 NEOPIXEL LEDS on pin GPIO23
fast_led.fast_led->add_leds<NEOPIXEL, 23>(60);

See Application::make_fast_led_light().

API Reference

FastLEDLightOutputComponent

class FastLEDLightOutputComponent : public light::LightOutput, public Component

This component implements support for many types of addressable LED lights.

To do this, it uses the FastLED library. The API for setting up the different types of lights FastLED supports is intentionally kept as close to FastLEDs defaults as possible. To use FastLED lights with esphomelib, first set up the component using the helper in Application, then add the LEDs using the add_leds helper functions.

These add_leds helpers can, however, only be called once on a FastLEDLightOutput. Also, with this component you cannot pass in the CRGB array and offset values as you would be able to do with FastLED as the component manage the lights itself.

Public Functions

void schedule_show()

Only for custom effects: Tell this component to write the new color values on the next loop() iteration.

CLEDController *get_controller() const

Only for custom effects: Get the internal controller.

CRGB *leds() const
int size() const
CRGB &operator[](int index) const
CRGB *begin()
CRGB *end()
uint8_t *effect_data() const
void set_max_refresh_rate(uint32_t interval_us)

Set a maximum refresh rate in µs as some lights do not like being updated too often.

void prevent_writing_leds()

Only for custom effects: Prevent the LightState from writing over all color values in CRGB.

void unprevent_writing_leds()

Only for custom effects: Stop prevent_writing_leds. Call this when your effect terminates.

void set_power_supply(PowerSupplyComponent *power_supply)
void set_correction(float red, float green, float blue)
CLEDController &add_leds(CLEDController *controller, int num_leds)

Add some LEDS, can only be called once.

template <ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE>
CLEDController &add_leds(int num_leds)
template <ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN>
CLEDController &add_leds(int num_leds)
template <ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER>
CLEDController &add_leds(int num_leds)
template <ESPIChipsets CHIPSET>
CLEDController &add_leds(int num_leds)
template <ESPIChipsets CHIPSET, EOrder RGB_ORDER>
CLEDController &add_leds(int num_leds)
template <ESPIChipsets CHIPSET, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE>
CLEDController &add_leds(int num_leds)
template <template< uint8_t DATA_PIN, EOrder RGB_ORDER > class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER>
CLEDController &add_leds(int num_leds)
template <template< uint8_t DATA_PIN, EOrder RGB_ORDER > class CHIPSET, uint8_t DATA_PIN>
CLEDController &add_leds(int num_leds)
template <template< uint8_t DATA_PIN > class CHIPSET, uint8_t DATA_PIN>
CLEDController &add_leds(int num_leds)
template <template< EOrder RGB_ORDER > class CHIPSET, EOrder RGB_ORDER>
CLEDController &add_leds(int num_leds)
template <template< EOrder RGB_ORDER > class CHIPSET>
CLEDController &add_leds(int num_leds)
template <OWS2811 CHIPSET, EOrder RGB_ORDER>
CLEDController &add_leds(int num_leds)
template <OWS2811 CHIPSET>
CLEDController &add_leds(int num_leds)
template <SWS2812 CHIPSET, int DATA_PIN, EOrder RGB_ORDER>
CLEDController &add_leds(int num_leds)
template <ESM CHIPSET>
CLEDController &add_leds(int num_leds)
template <EBlockChipsets CHIPSET, int NUM_LANES, EOrder RGB_ORDER>
CLEDController &add_leds(int num_leds)
template <EBlockChipsets CHIPSET, int NUM_LANES>
CLEDController &add_leds(int num_leds)
LightTraits get_traits()

Return the LightTraits of this LightOutput.

void write_state(LightState *state)
void setup()

Where the component’s initialization should happen.

Analogous to Arduino’s setup(). This method is guaranteed to only be called once. Defaults to doing nothing.

void dump_config()
void loop()

This method will be called repeatedly.

Analogous to Arduino’s loop(). setup() is guaranteed to be called before this. Defaults to doing nothing.

float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

Protected Attributes

CLEDController *controller_ = {nullptr}
CRGB *leds_ = {nullptr}
CRGB correction_ = {UncorrectedColor}
uint8_t *effect_data_ = {nullptr}
int num_leds_ = {0}
uint32_t last_refresh_ = {0}
optional<uint32_t> max_refresh_rate_ = {}
bool prevent_writing_leds_ = {false}
bool next_show_ = {true}
PowerSupplyComponent *power_supply_ = {nullptr}
bool has_requested_high_power_ = {false}