1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-14 01:02:19 +01:00

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

View File

@@ -20,13 +20,12 @@ void FastLEDLightOutput::dump_config() {
ESP_LOGCONFIG(TAG, " Num LEDs: %u", this->num_leds_);
ESP_LOGCONFIG(TAG, " Max refresh rate: %u", *this->max_refresh_rate_);
}
void FastLEDLightOutput::loop() {
if (!this->should_show_())
return;
uint32_t now = micros();
void FastLEDLightOutput::write_state(light::LightState *state) {
// protect from refreshing too often
uint32_t now = micros();
if (*this->max_refresh_rate_ != 0 && (now - this->last_refresh_) < *this->max_refresh_rate_) {
// try again next loop iteration, so that this change won't get lost
this->schedule_show();
return;
}
this->last_refresh_ = now;

View File

@@ -213,7 +213,7 @@ class FastLEDLightOutput : public light::AddressableLight {
}
void setup() override;
void dump_config() override;
void loop() override;
void write_state(light::LightState *state) override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
void clear_effect_data() override {