Remove double scheduling from addressable lights (#1963)

This commit is contained in:
Oxan van Leeuwen
2021-08-23 10:00:38 +02:00
committed by GitHub
parent 5ec9bb0fb5
commit 2f33cd2db5
12 changed files with 57 additions and 45 deletions
+3 -5
View File
@@ -51,9 +51,9 @@ class AddressableLight : public LightOutput, public Component {
amnt = this->size();
this->range(amnt, this->size()) = this->range(0, -amnt);
}
// Indicates whether an effect that directly updates the output buffer is active to prevent overwriting
bool is_effect_active() const { return this->effect_active_; }
void set_effect_active(bool effect_active) { this->effect_active_ = effect_active; }
void write_state(LightState *state) override;
std::unique_ptr<LightTransformer> create_default_transition() override;
void set_correction(float red, float green, float blue, float white = 1.0f) {
this->correction_.set_max_brightness(
@@ -63,7 +63,8 @@ class AddressableLight : public LightOutput, public Component {
this->correction_.calculate_gamma_table(state->get_gamma_correct());
this->state_parent_ = state;
}
void schedule_show() { this->next_show_ = true; }
void update_state(LightState *state) override;
void schedule_show() { this->state_parent_->next_write_ = true; }
#ifdef USE_POWER_SUPPLY
void set_power_supply(power_supply::PowerSupply *power_supply) { this->power_.set_parent(power_supply); }
@@ -74,9 +75,7 @@ class AddressableLight : public LightOutput, public Component {
protected:
friend class AddressableLightTransformer;
bool should_show_() const { return this->effect_active_ || this->next_show_; }
void mark_shown_() {
this->next_show_ = false;
#ifdef USE_POWER_SUPPLY
for (auto c : *this) {
if (c.get().is_on()) {
@@ -90,7 +89,6 @@ class AddressableLight : public LightOutput, public Component {
virtual ESPColorView get_view_internal(int32_t index) const = 0;
bool effect_active_{false};
bool next_show_{true};
ESPColorCorrection correction_{};
#ifdef USE_POWER_SUPPLY
power_supply::PowerSupplyRequester power_;