1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 13:22:19 +01:00

[lvgl] Implement canvas widget (#8504)

This commit is contained in:
Clyde Stubbs
2025-04-09 10:15:39 +10:00
committed by GitHub
parent 8c5adfb33f
commit 1f7a84cc8e
10 changed files with 631 additions and 67 deletions

View File

@@ -254,11 +254,27 @@ def pixels_or_percent_validator(value):
pixels_or_percent = LValidator(pixels_or_percent_validator, uint32, retmapper=literal)
def zoom(value):
def pixels_validator(value):
if isinstance(value, str) and value.lower().endswith("px"):
value = value[:-2]
return cv.positive_int(value)
pixels = LValidator(pixels_validator, uint32, retmapper=literal)
def zoom_validator(value):
value = cv.float_range(0.1, 10.0)(value)
return value
def zoom_retmapper(value):
return int(value * 256)
zoom = LValidator(zoom_validator, uint32, retmapper=zoom_retmapper)
def angle(value):
"""
Validation for an angle in degrees, converted to an integer representing 0.1deg units
@@ -286,14 +302,6 @@ def size_validator(value):
size = LValidator(size_validator, uint32, retmapper=literal)
def pixels_validator(value):
if isinstance(value, str) and value.lower().endswith("px"):
return cv.int_(value[:-2])
return cv.int_(value)
pixels = LValidator(pixels_validator, uint32, retmapper=literal)
radius_consts = LvConstant("LV_RADIUS_", "CIRCLE")