mirror of
https://github.com/esphome/esphome.git
synced 2025-10-29 22:24:26 +00:00
Remove double scheduling from addressable lights (#1963)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user