12 #include "NeoPixelBus.h" 15 namespace neopixelbus {
50 template<
typename T_METHOD,
typename T_COLOR_FEATURE>
53 NeoPixelBus<T_COLOR_FEATURE, T_METHOD> *
get_controller()
const {
return this->controller_; }
56 for (
int i = 0; i < this->size(); i++)
57 this->effect_data_[i] = 0;
61 void add_leds(uint16_t count_pixels, uint8_t pin) {
62 this->add_leds(
new NeoPixelBus<T_COLOR_FEATURE, T_METHOD>(count_pixels, pin));
64 void add_leds(uint16_t count_pixels, uint8_t pin_clock, uint8_t pin_data) {
65 this->add_leds(
new NeoPixelBus<T_COLOR_FEATURE, T_METHOD>(count_pixels, pin_clock, pin_data));
67 void add_leds(uint16_t count_pixels) { this->
add_leds(
new NeoPixelBus<T_COLOR_FEATURE, T_METHOD>(count_pixels)); }
68 void add_leds(NeoPixelBus<T_COLOR_FEATURE, T_METHOD> *controller) {
69 this->controller_ = controller;
76 for (
int i = 0; i < this->size(); i++) {
77 (*this)[i] =
Color(0, 0, 0, 0);
80 this->effect_data_ =
new uint8_t[this->size()];
81 this->controller_->Begin();
86 this->controller_->Dirty();
88 this->controller_->Show();
93 int32_t
size()
const override {
return this->controller_->PixelCount(); }
96 uint8_t u_order =
static_cast<uint8_t
>(order);
97 this->rgb_offsets_[0] = (u_order >> 6) & 0
b11;
98 this->rgb_offsets_[1] = (u_order >> 4) & 0
b11;
99 this->rgb_offsets_[2] = (u_order >> 2) & 0
b11;
100 this->rgb_offsets_[3] = (u_order >> 0) & 0
b11;
104 NeoPixelBus<T_COLOR_FEATURE, T_METHOD> *controller_{
nullptr};
105 uint8_t *effect_data_{
nullptr};
106 uint8_t rgb_offsets_[4]{0, 1, 2, 3};
109 template<
typename T_METHOD,
typename T_COLOR_FEATURE = NeoRgbFeature>
120 uint8_t *base = this->controller_->Pixels() + 3ULL * index;
121 return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
122 nullptr, this->effect_data_ + index, &this->correction_);
126 template<
typename T_METHOD,
typename T_COLOR_FEATURE = NeoRgbwFeature>
137 uint8_t *base = this->controller_->Pixels() + 4ULL * index;
138 return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
139 base + this->rgb_offsets_[3], this->effect_data_ + index, &this->correction_);
146 #endif // USE_ARDUINO void set_pixel_order(ESPNeoPixelOrder order)
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
NeoPixelBus< T_COLOR_FEATURE, T_METHOD > * get_controller() const
light::LightTraits get_traits() override
RGB color output and a separate white output.
light::ESPColorView get_view_internal(int32_t index) const override
void add_leds(uint16_t count_pixels)
void add_leds(NeoPixelBus< T_COLOR_FEATURE, T_METHOD > *controller)
void clear_effect_data() override
void write_state(light::LightState *state) override
light::ESPColorView get_view_internal(int32_t index) const override
void add_leds(uint16_t count_pixels, uint8_t pin)
Add some LEDS, can only be called once.
This class is used to represent the capabilities of a light.
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
light::LightTraits get_traits() override
Implementation of SPI Controller mode.
Color can be controlled using RGB format (includes a brightness control for the color).
float get_setup_priority() const override
int32_t size() const override
void add_leds(uint16_t count_pixels, uint8_t pin_clock, uint8_t pin_data)