added rgb_order configuration
This commit is contained in:
@@ -16,6 +16,16 @@ enum class SpiLedChipset : uint8_t {
|
||||
SPI_LED_CHIPSET_WS2801,
|
||||
};
|
||||
|
||||
// Order in which the color bytes of one LED are sent over the wire
|
||||
enum class RGBOrder : uint8_t {
|
||||
ORDER_RGB,
|
||||
ORDER_RBG,
|
||||
ORDER_GRB,
|
||||
ORDER_GBR,
|
||||
ORDER_BGR,
|
||||
ORDER_BRG,
|
||||
};
|
||||
|
||||
class SpiLedStrip final : public light::AddressableLight,
|
||||
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH,
|
||||
spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_1MHZ> {
|
||||
@@ -24,6 +34,8 @@ class SpiLedStrip final : public light::AddressableLight,
|
||||
void setup() override;
|
||||
float get_setup_priority() const override { return setup_priority::IO; }
|
||||
|
||||
void set_rgb_order(RGBOrder rgb_order) { this->rgb_order_ = rgb_order; }
|
||||
|
||||
int32_t size() const override { return this->num_leds_; }
|
||||
|
||||
light::LightTraits get_traits() override;
|
||||
@@ -42,6 +54,7 @@ class SpiLedStrip final : public light::AddressableLight,
|
||||
uint8_t *buf_{nullptr};
|
||||
uint16_t num_leds_;
|
||||
SpiLedChipset chipset_;
|
||||
RGBOrder rgb_order_{RGBOrder::ORDER_BGR};
|
||||
};
|
||||
|
||||
} // namespace esphome::spi_led_strip
|
||||
|
||||
Reference in New Issue
Block a user