Addressable updates

This commit is contained in:
Otto Winter
2019-04-25 10:36:55 +02:00
parent 766f6c045d
commit 595dfe7e24
13 changed files with 193 additions and 41 deletions
@@ -144,29 +144,24 @@ class NeoPixelBusLightOutputBase : public Component, public light::AddressableLi
template<typename T_METHOD, typename T_COLOR_FEATURE = NeoRgbFeature>
class NeoPixelRGBLightOutput : public NeoPixelBusLightOutputBase<T_METHOD, T_COLOR_FEATURE> {
public:
inline light::ESPColorView operator[](int32_t index) const override {
uint8_t *base = this->controller_->Pixels() + 3ULL * index;
return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
nullptr, this->effect_data_ + index, &this->correction_);
}
light::LightTraits get_traits() override {
auto traits = light::LightTraits();
traits.set_supports_brightness(true);
traits.set_supports_rgb(true);
return traits;
}
protected:
light::ESPColorView get_view_internal(int32_t index) const override {
uint8_t *base = this->controller_->Pixels() + 3ULL * index;
return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
nullptr, this->effect_data_ + index, &this->correction_);
}
};
template<typename T_METHOD, typename T_COLOR_FEATURE = NeoRgbwFeature>
class NeoPixelRGBWLightOutput : public NeoPixelBusLightOutputBase<T_METHOD, T_COLOR_FEATURE> {
public:
inline light::ESPColorView operator[](int32_t index) const override {
uint8_t *base = this->controller_->Pixels() + 4ULL * index;
return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
base + this->rgb_offsets_[3], this->effect_data_ + index, &this->correction_);
}
light::LightTraits get_traits() override {
auto traits = light::LightTraits();
traits.set_supports_brightness(true);
@@ -174,6 +169,13 @@ class NeoPixelRGBWLightOutput : public NeoPixelBusLightOutputBase<T_METHOD, T_CO
traits.set_supports_rgb_white_value(true);
return traits;
}
protected:
light::ESPColorView get_view_internal(int32_t index) const override {
uint8_t *base = this->controller_->Pixels() + 4ULL * index;
return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
base + this->rgb_offsets_[3], this->effect_data_ + index, &this->correction_);
}
};
} // namespace neopixelbus