[remote_receiver] Fix idle validation (#9819)

This commit is contained in:
Jonathan Swoboda 2025-07-22 22:57:42 -04:00 committed by GitHub
parent b636b844fc
commit bb6f8aeb94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View File

@ -60,6 +60,20 @@ RemoteReceiverComponent = remote_receiver_ns.class_(
)
def validate_config(config):
if CORE.is_esp32:
variant = esp32.get_esp32_variant()
if variant in (esp32.const.VARIANT_ESP32, esp32.const.VARIANT_ESP32S2):
max_idle = 65535
else:
max_idle = 32767
if CONF_CLOCK_RESOLUTION in config:
max_idle = int(max_idle * 1000000 / config[CONF_CLOCK_RESOLUTION])
if config[CONF_IDLE].total_microseconds > max_idle:
raise cv.Invalid(f"config 'idle' exceeds the maximum value of {max_idle}us")
return config
def validate_tolerance(value):
if isinstance(value, dict):
return TOLERANCE_SCHEMA(value)
@ -136,7 +150,9 @@ CONFIG_SCHEMA = remote_base.validate_triggers(
cv.boolean,
),
}
).extend(cv.COMPONENT_SCHEMA)
)
.extend(cv.COMPONENT_SCHEMA)
.add_extra(validate_config)
)

View File

@ -86,10 +86,9 @@ void RemoteReceiverComponent::setup() {
uint32_t event_size = sizeof(rmt_rx_done_event_data_t);
uint32_t max_filter_ns = 255u * 1000 / (RMT_CLK_FREQ / 1000000);
uint32_t max_idle_ns = 65535u * 1000;
memset(&this->store_.config, 0, sizeof(this->store_.config));
this->store_.config.signal_range_min_ns = std::min(this->filter_us_ * 1000, max_filter_ns);
this->store_.config.signal_range_max_ns = std::min(this->idle_us_ * 1000, max_idle_ns);
this->store_.config.signal_range_max_ns = this->idle_us_ * 1000;
this->store_.filter_symbols = this->filter_symbols_;
this->store_.receive_size = this->receive_symbols_ * sizeof(rmt_symbol_word_t);
this->store_.buffer_size = std::max((event_size + this->store_.receive_size) * 2, this->buffer_size_);