[esp32_rmt_led_strip] Check if `max_refresh_rate_` actually has a value

This commit is contained in:
Jesse Hills 2024-08-06 15:45:18 +12:00
parent 3ba9caa118
commit 8d22cbeef5
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
2 changed files with 4 additions and 4 deletions

View file

@ -1,5 +1,5 @@
#include <cinttypes>
#include "led_strip.h" #include "led_strip.h"
#include <cinttypes>
#ifdef USE_ESP32 #ifdef USE_ESP32
@ -84,7 +84,7 @@ void ESP32RMTLEDStripLightOutput::set_led_params(uint32_t bit0_high, uint32_t bi
void ESP32RMTLEDStripLightOutput::write_state(light::LightState *state) { void ESP32RMTLEDStripLightOutput::write_state(light::LightState *state) {
// protect from refreshing too often // protect from refreshing too often
uint32_t now = micros(); uint32_t now = micros();
if (*this->max_refresh_rate_ != 0 && (now - this->last_refresh_) < *this->max_refresh_rate_) { if (this->max_refresh_rate_.has_value() && (now - this->last_refresh_) < this->max_refresh_rate_.value()) {
// try again next loop iteration, so that this change won't get lost // try again next loop iteration, so that this change won't get lost
this->schedule_show(); this->schedule_show();
return; return;

View file

@ -1,9 +1,9 @@
from dataclasses import dataclass from dataclasses import dataclass
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins from esphome import pins
import esphome.codegen as cg
from esphome.components import esp32_rmt, light from esphome.components import esp32_rmt, light
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_CHIPSET, CONF_CHIPSET,
CONF_IS_RGBW, CONF_IS_RGBW,