mirror of
https://github.com/esphome/esphome.git
synced 2026-09-25 14:00:25 +00:00
[remote_transmitter] Queue RMT transmissions instead of blocking the main loop
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""max_pending defaults to twice queue_depth and may not be smaller than it."""
|
||||
|
||||
import pytest
|
||||
|
||||
from esphome.components.remote_transmitter import (
|
||||
CONF_MAX_PENDING,
|
||||
CONF_QUEUE_DEPTH,
|
||||
_validate_queue,
|
||||
)
|
||||
import esphome.config_validation as cv
|
||||
|
||||
|
||||
def test_max_pending_defaults_to_twice_queue_depth() -> None:
|
||||
config = {CONF_QUEUE_DEPTH: 4}
|
||||
_validate_queue(config)
|
||||
assert config[CONF_MAX_PENDING] == 8
|
||||
|
||||
|
||||
def test_max_pending_explicit_is_kept() -> None:
|
||||
config = {CONF_QUEUE_DEPTH: 4, CONF_MAX_PENDING: 4}
|
||||
_validate_queue(config)
|
||||
assert config[CONF_MAX_PENDING] == 4
|
||||
|
||||
|
||||
def test_max_pending_below_queue_depth_is_rejected() -> None:
|
||||
with pytest.raises(cv.Invalid, match="max_pending must be at least queue_depth"):
|
||||
_validate_queue({CONF_QUEUE_DEPTH: 4, CONF_MAX_PENDING: 2})
|
||||
|
||||
|
||||
def test_no_queue_depth_without_rmt() -> None:
|
||||
config: dict[str, int] = {}
|
||||
_validate_queue(config)
|
||||
assert CONF_MAX_PENDING not in config
|
||||
@@ -5,6 +5,8 @@ remote_transmitter:
|
||||
non_blocking: true
|
||||
clock_resolution: ${clock_resolution}
|
||||
rmt_symbols: ${rmt_symbols}
|
||||
queue_depth: 4
|
||||
max_pending: 8
|
||||
|
||||
packages:
|
||||
buttons: !include common-buttons.yaml
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
substitutions:
|
||||
pin: GPIO2
|
||||
|
||||
remote_transmitter:
|
||||
- id: xmitr
|
||||
pin: ${pin}
|
||||
carrier_duty_percent: 50%
|
||||
non_blocking: true
|
||||
queue_depth: 1
|
||||
|
||||
packages:
|
||||
buttons: !include common-buttons.yaml
|
||||
Reference in New Issue
Block a user