1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-05 21:02:20 +01:00

[lvgl] Various validation fixes (#10141)

This commit is contained in:
Clyde Stubbs
2025-08-11 08:27:54 +10:00
committed by GitHub
parent da02f970d4
commit 581b4ef5a1
8 changed files with 52 additions and 31 deletions

View File

@@ -287,10 +287,14 @@ def angle(value):
:param value: The input in the range 0..360
:return: An angle in 1/10 degree units.
"""
return int(cv.float_range(0.0, 360.0)(cv.angle(value)) * 10)
return cv.float_range(0.0, 360.0)(cv.angle(value))
lv_angle = LValidator(angle, uint32)
# Validator for angles in LVGL expressed in 1/10 degree units.
lv_angle = LValidator(angle, uint32, retmapper=lambda x: int(x * 10))
# Validator for angles in LVGL expressed in whole degrees
lv_angle_degrees = LValidator(angle, uint32, retmapper=int)
@schema_extractor("one_of")