mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	[remote_receiver] Fix idle validation (#9819)
This commit is contained in:
		| @@ -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): | def validate_tolerance(value): | ||||||
|     if isinstance(value, dict): |     if isinstance(value, dict): | ||||||
|         return TOLERANCE_SCHEMA(value) |         return TOLERANCE_SCHEMA(value) | ||||||
| @@ -136,7 +150,9 @@ CONFIG_SCHEMA = remote_base.validate_triggers( | |||||||
|                 cv.boolean, |                 cv.boolean, | ||||||
|             ), |             ), | ||||||
|         } |         } | ||||||
|     ).extend(cv.COMPONENT_SCHEMA) |     ) | ||||||
|  |     .extend(cv.COMPONENT_SCHEMA) | ||||||
|  |     .add_extra(validate_config) | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -86,10 +86,9 @@ void RemoteReceiverComponent::setup() { | |||||||
|  |  | ||||||
|   uint32_t event_size = sizeof(rmt_rx_done_event_data_t); |   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_filter_ns = 255u * 1000 / (RMT_CLK_FREQ / 1000000); | ||||||
|   uint32_t max_idle_ns = 65535u * 1000; |  | ||||||
|   memset(&this->store_.config, 0, sizeof(this->store_.config)); |   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_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_.filter_symbols = this->filter_symbols_; | ||||||
|   this->store_.receive_size = this->receive_symbols_ * sizeof(rmt_symbol_word_t); |   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_); |   this->store_.buffer_size = std::max((event_size + this->store_.receive_size) * 2, this->buffer_size_); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user