ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
led_strip.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_RP2
4
8
12
13#include <hardware/dma.h>
14#include <hardware/pio.h>
15#include <hardware/structs/pio.h>
16#include <pico/stdio.h>
17#include <pico/sem.h>
18#include <map>
19
21
30
31using init_fn = void (*)(PIO pio, uint sm, uint offset, uint pin, float freq);
32
34 public:
35 void setup() override;
36 void write_state(light::LightState *state) override;
37 float get_setup_priority() const override;
38
39 int32_t size() const override { return this->num_leds_; }
41 void set_pin(uint8_t pin) { this->pin_ = pin; }
42 void set_num_leds(uint32_t num_leds) { this->num_leds_ = num_leds; }
44 this->internal_accessor_.channel_colors = channel_colors;
45 }
46
47 void set_max_refresh_rate(float interval_us) { this->max_refresh_rate_ = interval_us; }
48
49 void set_pio(int pio_num) { pio_num ? this->pio_ = pio1 : this->pio_ = pio0; }
50 void set_program(const pio_program_t *program) { this->program_ = program; }
51 void set_init_function(init_fn init) { this->init_ = init; }
52
53 void set_chipset(Chipset chipset) { this->chipset_ = chipset; };
55
56 void dump_config() override;
57
58 protected:
60
61 static void dma_write_complete_handler();
62
64
65 uint8_t pin_;
67
68 pio_hw_t *pio_;
69 uint sm_;
71 dma_channel_config dma_config_;
72
74
76
77 const pio_program_t *program_;
79
80 private:
81 inline static int num_instance[2];
82 inline static std::map<Chipset, bool> conf_count;
83 inline static std::map<Chipset, int> chipset_offsets;
84 inline static bool dma_chan_active[NUM_DMA_CHANNELS];
85 inline static struct semaphore dma_write_complete_sem[NUM_DMA_CHANNELS];
86};
87
88} // namespace esphome::rp2040_pio_led_strip
89
90#endif // USE_RP2
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:68
This class is used to represent the capabilities of a light.
Definition light_traits.h:9
void set_channel_colors(light::ChannelColors channel_colors)
Definition led_strip.h:43
void write_state(light::LightState *state) override
light::CorrectedBufferColorAccessor internal_accessor_
Definition led_strip.h:63
bool state
Definition fan.h:2
void(*)(PIO pio, uint sm, uint offset, uint pin, float freq) init_fn
Definition led_strip.h:31
static void uint32_t
Which byte of an addressable LED's data carries each colour.
LightTraits traits() const
Colour modes of a strip with this channel order.