ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
brizlabs_led_string.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ESP32
4
8#include "driver/spi_master.h"
9#include "encoder.h"
10
12
13// Set from num_zones by light.py
14static constexpr int NUM_ZONES = BRIZLABS_LED_STRING_ZONE_COUNT;
15
16// Two-wire LED string: color frames are pulse-coded power dips, shaped by SPI MOSI (encoder.h)
17// One addressable "pixel" per zone, with each zone comprising one or more actual LED modules
19 public:
20 explicit BrizLabsLEDString(int pin) : pin_(pin) {}
21 void setup() override;
22 void dump_config() override;
23 float get_setup_priority() const override { return setup_priority::HARDWARE; }
24 int32_t size() const override { return NUM_ZONES; }
26 void write_state(light::LightState *state) override;
27 void clear_effect_data() override { this->internal_accessor_.clear_effect_data(NUM_ZONES); }
28
29 protected:
30 bool queue_frame_(uint8_t zone, uint8_t r, uint8_t g, uint8_t b); // zone 0 = whole string
31 bool transmit_all_();
32
33 int pin_;
34 spi_device_handle_t dev_{nullptr};
35 // A queued frame and its transaction belong to the SPI driver until write_state() collects the result
36 spi_transaction_t trans_[NUM_ZONES]{};
37 uint8_t frames_[NUM_ZONES][FRAME_BYTES]{};
38 uint8_t in_flight_{0};
39 uint8_t buf_[NUM_ZONES * 3]{};
40 uint8_t effect_data_[NUM_ZONES]{};
42};
43
44} // namespace esphome::brizlabs_led_string
45
46#endif // USE_ESP32
bool queue_frame_(uint8_t zone, uint8_t r, uint8_t g, uint8_t b)
light::CorrectedBufferColorAccessor internal_accessor_
void write_state(light::LightState *state) override
void clear_effect_data(size_t num_leds)
Zero the effect data of the first num_leds LEDs; does nothing before the effect data is allocated.
Color accessor backed by a buffer whose contents have color correction applied.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:73
This class is used to represent the capabilities of a light.
Definition light_traits.h:9
bool state
Definition fan.h:2
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:43
LightTraits traits() const
Colour modes of a strip with this channel order.