ESPHome  2025.2.0
spi_led_strip.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/log.h"
7 
8 namespace esphome {
9 namespace spi_led_strip {
10 
11 static const char *const TAG = "spi_led_strip";
13  public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING,
14  spi::DATA_RATE_1MHZ> {
15  public:
16  SpiLedStrip(uint16_t num_leds);
17  void setup() override;
18  float get_setup_priority() const override { return setup_priority::IO; }
19 
20  int32_t size() const override { return this->num_leds_; }
21 
22  light::LightTraits get_traits() override;
23 
24  void dump_config() override;
25 
26  void write_state(light::LightState *state) override;
27 
28  void clear_effect_data() override { memset(this->effect_data_, 0, this->num_leds_ * sizeof(this->effect_data_[0])); }
29 
30  protected:
31  light::ESPColorView get_view_internal(int32_t index) const override;
32 
33  size_t buffer_size_{};
34  uint8_t *effect_data_{nullptr};
35  uint8_t *buf_{nullptr};
36  uint16_t num_leds_;
37 };
38 
39 } // namespace spi_led_strip
40 } // namespace esphome
float get_setup_priority() const override
Definition: spi_led_strip.h:18
void write_state(light::LightState *state) override
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:63
light::LightTraits get_traits() override
The SPIDevice is what components using the SPI will create.
Definition: spi.h:410
const char *const TAG
Definition: spi.cpp:8
int32_t size() const override
Definition: spi_led_strip.h:20
This class is used to represent the capabilities of a light.
Definition: light_traits.h:11
light::ESPColorView get_view_internal(int32_t index) const override
const float IO
For components that represent GPIO pins like PCF8573.
Definition: component.cpp:17
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool state
Definition: fan.h:34