mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
add is_wrgb to rp2040_pio_led_strip
This commit is contained in:
parent
5e27a8df1f
commit
28f8382a12
3 changed files with 19 additions and 8 deletions
|
@ -189,11 +189,13 @@ light::ESPColorView RP2040PIOLEDStripLightOutput::get_view_internal(int32_t inde
|
||||||
b = 0;
|
b = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint8_t multiplier = this->is_rgbw_ ? 4 : 3;
|
uint8_t multiplier = this->is_rgbw_ || this->is_wrgb_ ? 4 : 3;
|
||||||
return {this->buf_ + (index * multiplier) + r,
|
uint8_t white = this->is_wrgb_ ? 0 : 3;
|
||||||
this->buf_ + (index * multiplier) + g,
|
|
||||||
this->buf_ + (index * multiplier) + b,
|
return {this->buf_ + (index * multiplier) + r + this->is_wrgb_,
|
||||||
this->is_rgbw_ ? this->buf_ + (index * multiplier) + 3 : nullptr,
|
this->buf_ + (index * multiplier) + g + this->is_wrgb_,
|
||||||
|
this->buf_ + (index * multiplier) + b + this->is_wrgb_,
|
||||||
|
this->is_rgbw_ || this->is_wrgb_ ? this->buf_ + (index * multiplier) + white : nullptr,
|
||||||
&this->effect_data_[index],
|
&this->effect_data_[index],
|
||||||
&this->correction_};
|
&this->correction_};
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,13 +67,18 @@ class RP2040PIOLEDStripLightOutput : public light::AddressableLight {
|
||||||
int32_t size() const override { return this->num_leds_; }
|
int32_t size() const override { return this->num_leds_; }
|
||||||
light::LightTraits get_traits() override {
|
light::LightTraits get_traits() override {
|
||||||
auto traits = light::LightTraits();
|
auto traits = light::LightTraits();
|
||||||
this->is_rgbw_ ? traits.set_supported_color_modes({light::ColorMode::RGB_WHITE, light::ColorMode::WHITE})
|
|
||||||
: traits.set_supported_color_modes({light::ColorMode::RGB});
|
if (this->is_rgbw_ || this->is_wrgb_) {
|
||||||
|
traits.set_supported_color_modes({light::ColorMode::RGB_WHITE, light::ColorMode::WHITE});
|
||||||
|
} else {
|
||||||
|
traits.set_supported_color_modes({light::ColorMode::RGB});
|
||||||
|
}
|
||||||
return traits;
|
return traits;
|
||||||
}
|
}
|
||||||
void set_pin(uint8_t pin) { this->pin_ = pin; }
|
void set_pin(uint8_t pin) { this->pin_ = pin; }
|
||||||
void set_num_leds(uint32_t num_leds) { this->num_leds_ = num_leds; }
|
void set_num_leds(uint32_t num_leds) { this->num_leds_ = num_leds; }
|
||||||
void set_is_rgbw(bool is_rgbw) { this->is_rgbw_ = is_rgbw; }
|
void set_is_rgbw(bool is_rgbw) { this->is_rgbw_ = is_rgbw; }
|
||||||
|
void set_is_wrgb(bool is_wrgb) { this->is_wrgb_ = is_wrgb; }
|
||||||
|
|
||||||
void set_max_refresh_rate(float interval_us) { this->max_refresh_rate_ = interval_us; }
|
void set_max_refresh_rate(float interval_us) { this->max_refresh_rate_ = interval_us; }
|
||||||
|
|
||||||
|
@ -94,7 +99,7 @@ class RP2040PIOLEDStripLightOutput : public light::AddressableLight {
|
||||||
protected:
|
protected:
|
||||||
light::ESPColorView get_view_internal(int32_t index) const override;
|
light::ESPColorView get_view_internal(int32_t index) const override;
|
||||||
|
|
||||||
size_t get_buffer_size_() const { return this->num_leds_ * (3 + this->is_rgbw_); }
|
size_t get_buffer_size_() const { return this->num_leds_ * (this->is_rgbw_ || this->is_wrgb_ ? 4 : 3); }
|
||||||
|
|
||||||
static void dma_write_complete_handler_();
|
static void dma_write_complete_handler_();
|
||||||
|
|
||||||
|
@ -104,6 +109,7 @@ class RP2040PIOLEDStripLightOutput : public light::AddressableLight {
|
||||||
uint8_t pin_;
|
uint8_t pin_;
|
||||||
uint32_t num_leds_;
|
uint32_t num_leds_;
|
||||||
bool is_rgbw_;
|
bool is_rgbw_;
|
||||||
|
bool is_wrgb_;
|
||||||
|
|
||||||
pio_hw_t *pio_;
|
pio_hw_t *pio_;
|
||||||
uint sm_;
|
uint sm_;
|
||||||
|
|
|
@ -179,6 +179,7 @@ CHIPSET_TIMINGS = {
|
||||||
"SM16703": LEDStripTimings(17, 52, 52, 17),
|
"SM16703": LEDStripTimings(17, 52, 52, 17),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONF_IS_WRGB = "is_wrgb"
|
||||||
CONF_BIT0_HIGH = "bit0_high"
|
CONF_BIT0_HIGH = "bit0_high"
|
||||||
CONF_BIT0_LOW = "bit0_low"
|
CONF_BIT0_LOW = "bit0_low"
|
||||||
CONF_BIT1_HIGH = "bit1_high"
|
CONF_BIT1_HIGH = "bit1_high"
|
||||||
|
@ -207,6 +208,7 @@ CONFIG_SCHEMA = cv.All(
|
||||||
cv.Required(CONF_PIO): cv.one_of(0, 1, int=True),
|
cv.Required(CONF_PIO): cv.one_of(0, 1, int=True),
|
||||||
cv.Optional(CONF_CHIPSET): cv.enum(CHIPSETS, upper=True),
|
cv.Optional(CONF_CHIPSET): cv.enum(CHIPSETS, upper=True),
|
||||||
cv.Optional(CONF_IS_RGBW, default=False): cv.boolean,
|
cv.Optional(CONF_IS_RGBW, default=False): cv.boolean,
|
||||||
|
cv.Optional(CONF_IS_WRGB, default=False): cv.boolean,
|
||||||
cv.Inclusive(
|
cv.Inclusive(
|
||||||
CONF_BIT0_HIGH,
|
CONF_BIT0_HIGH,
|
||||||
"custom",
|
"custom",
|
||||||
|
@ -240,6 +242,7 @@ async def to_code(config):
|
||||||
|
|
||||||
cg.add(var.set_rgb_order(config[CONF_RGB_ORDER]))
|
cg.add(var.set_rgb_order(config[CONF_RGB_ORDER]))
|
||||||
cg.add(var.set_is_rgbw(config[CONF_IS_RGBW]))
|
cg.add(var.set_is_rgbw(config[CONF_IS_RGBW]))
|
||||||
|
cg.add(var.set_is_wrgb(config[CONF_IS_WRGB]))
|
||||||
|
|
||||||
cg.add(var.set_pio(config[CONF_PIO]))
|
cg.add(var.set_pio(config[CONF_PIO]))
|
||||||
cg.add(var.set_program(cg.RawExpression(f"&rp2040_pio_led_strip_{id}_program")))
|
cg.add(var.set_program(cg.RawExpression(f"&rp2040_pio_led_strip_{id}_program")))
|
||||||
|
|
Loading…
Reference in a new issue