mirror of
https://github.com/esphome/esphome.git
synced 2026-08-22 22:26:21 +00:00
[lvgl] Add pause option to round_trip animation timing (#17574)
This commit is contained in:
@@ -169,14 +169,27 @@ class TestTimingSchema:
|
||||
def test_round_trip_string(self) -> None:
|
||||
assert TIMING_SCHEMA("round_trip")["type"] == "round_trip"
|
||||
|
||||
def test_round_trip_default_pause(self) -> None:
|
||||
# Back-compat default: no pause, matching the pre-existing round_trip behavior.
|
||||
assert TIMING_SCHEMA("round_trip")["pause"] == pytest.approx(0.0)
|
||||
|
||||
def test_round_trip_pause_percentage_string(self) -> None:
|
||||
result = TIMING_SCHEMA({"type": "round_trip", "pause": "50%"})
|
||||
assert result["pause"] == pytest.approx(0.5)
|
||||
|
||||
def test_round_trip_pause_rejects_one(self) -> None:
|
||||
# pause == 1.0 would make moving_length_ zero and divide by zero in map_progress.
|
||||
with pytest.raises((Invalid, MultipleInvalid)):
|
||||
TIMING_SCHEMA({"type": "round_trip", "pause": 1.0})
|
||||
|
||||
def test_ease_in_out_default_weight(self) -> None:
|
||||
result = TIMING_SCHEMA("ease_in_out")
|
||||
assert result["type"] == "ease_in_out"
|
||||
assert result["weight"] == pytest.approx(2.0)
|
||||
assert result["weight"] == pytest.approx(1.0)
|
||||
|
||||
def test_ease_in_out_custom_weight(self) -> None:
|
||||
result = TIMING_SCHEMA({"type": "ease_in_out", "weight": 3})
|
||||
assert result["weight"] == pytest.approx(3.0)
|
||||
result = TIMING_SCHEMA({"type": "ease_in_out", "weight": 0.5})
|
||||
assert result["weight"] == pytest.approx(0.5)
|
||||
|
||||
def test_gravity_defaults(self) -> None:
|
||||
result = TIMING_SCHEMA("gravity")
|
||||
|
||||
@@ -174,7 +174,8 @@ lvgl:
|
||||
- id: anim_color
|
||||
duration: 2s
|
||||
timing:
|
||||
- round_trip
|
||||
- type: round_trip
|
||||
pause: 0.5
|
||||
- type: gravity
|
||||
bounce: 0.3
|
||||
acceleration: 0.8
|
||||
@@ -1557,17 +1558,20 @@ font:
|
||||
|
||||
image:
|
||||
- id: cat_image
|
||||
platform: file
|
||||
resize: 256x48
|
||||
file: $component_dir/logo-text.svg
|
||||
type: RGB565
|
||||
transparency: alpha_channel
|
||||
- id: dog_image
|
||||
platform: file
|
||||
file: $component_dir/logo-text.svg
|
||||
resize: 256x48
|
||||
type: BINARY
|
||||
transparency: chroma_key
|
||||
|
||||
- id: alert
|
||||
platform: file
|
||||
file: $component_dir/logo-text.svg
|
||||
type: grayscale
|
||||
resize: 100x100
|
||||
|
||||
@@ -39,7 +39,7 @@ lvgl:
|
||||
timing:
|
||||
- round_trip
|
||||
- type: ease_in_out
|
||||
weight: 3
|
||||
weight: 0.5
|
||||
on_start:
|
||||
- logger.log: anim started
|
||||
on_stop:
|
||||
|
||||
Reference in New Issue
Block a user