43 ESP_LOGCONFIG(TAG,
"Setting up RP2040 LED Strip...");
49 if (this->
buf_ ==
nullptr) {
50 ESP_LOGE(TAG,
"Failed to allocate buffer of size %u", buffer_size);
57 ESP_LOGE(TAG,
"Failed to allocate effect data of size %u", this->
num_leds_);
65 if (this->
pio_ ==
nullptr) {
66 ESP_LOGE(TAG,
"Failed to claim PIO instance");
75 if (RP2040PIOLEDStripLightOutput::num_instance_[this->
pio_ == pio0 ? 0 : 1] > 4) {
76 ESP_LOGE(TAG,
"Too many instances of PIO program");
81 RP2040PIOLEDStripLightOutput::num_instance_[this->
pio_ == pio0 ? 0 : 1]++;
84 if (this->conf_count_[this->
chipset_]) {
85 offset = RP2040PIOLEDStripLightOutput::chipset_offsets_[this->
chipset_];
88 offset = pio_add_program(this->pio_, this->
program_);
89 RP2040PIOLEDStripLightOutput::chipset_offsets_[this->
chipset_] = offset;
90 RP2040PIOLEDStripLightOutput::conf_count_[this->
chipset_] =
true;
94 this->
sm_ = pio_claim_unused_sm(this->pio_,
true);
97 ESP_LOGE(TAG,
"Failed to claim PIO state machine");
104 this->
dma_chan_ = dma_claim_unused_channel(
true);
106 ESP_LOGE(TAG,
"Failed to claim DMA channel");
112 RP2040PIOLEDStripLightOutput::dma_chan_active_[this->
dma_chan_] =
true;
115 channel_config_set_transfer_data_size(
118 channel_config_set_read_increment(&this->
dma_config_,
true);
119 channel_config_set_write_increment(&this->
dma_config_,
false);
121 pio_get_dreq(this->pio_, this->
sm_,
true));
124 &this->pio_->txf[this->sm_],
131 sem_init(&RP2040PIOLEDStripLightOutput::dma_write_complete_sem_[this->
dma_chan_], 1, 1);
134 dma_channel_set_irq0_enabled(this->dma_chan_,
true);
135 irq_set_enabled(DMA_IRQ_0,
true);
159 int32_t r = 0, g = 0, b = 0, w = 0;
192 uint8_t multiplier = this->
is_rgbw_ ? 4 : 3;
193 return {this->
buf_ + (index * multiplier) + r,
194 this->
buf_ + (index * multiplier) + g,
195 this->
buf_ + (index * multiplier) + b,
196 this->
is_rgbw_ ? this->
buf_ + (index * multiplier) + 3 :
nullptr,