fix RGBW Mode on RP2040 (#5907)

This commit is contained in:
Clemens 2023-12-12 00:28:16 +01:00 committed by GitHub
parent b62c099d54
commit 86e6a8a503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,9 +70,10 @@ void RP2040PIOLEDStripLightOutput::write_state(light::LightState *state) {
// assemble bits in buffer to 32 bit words with ex for GBR: 0bGGGGGGGGRRRRRRRRBBBBBBBB00000000 // assemble bits in buffer to 32 bit words with ex for GBR: 0bGGGGGGGGRRRRRRRRBBBBBBBB00000000
for (int i = 0; i < this->num_leds_; i++) { for (int i = 0; i < this->num_leds_; i++) {
uint8_t c1 = this->buf_[(i * 3) + 0]; uint8_t multiplier = this->is_rgbw_ ? 4 : 3;
uint8_t c2 = this->buf_[(i * 3) + 1]; uint8_t c1 = this->buf_[(i * multiplier) + 0];
uint8_t c3 = this->buf_[(i * 3) + 2]; uint8_t c2 = this->buf_[(i * multiplier) + 1];
uint8_t c3 = this->buf_[(i * multiplier) + 2];
uint8_t w = this->is_rgbw_ ? this->buf_[(i * 4) + 3] : 0; uint8_t w = this->is_rgbw_ ? this->buf_[(i * 4) + 3] : 0;
uint32_t color = encode_uint32(c1, c2, c3, w); uint32_t color = encode_uint32(c1, c2, c3, w);
pio_sm_put_blocking(this->pio_, this->sm_, color); pio_sm_put_blocking(this->pio_, this->sm_, color);