mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
[lvgl] Bug fixes (#7370)
Some checks are pending
CI for docker images / Build docker containers (armv7, docker) (push) Waiting to run
CI for docker images / Build docker containers (aarch64, docker) (push) Waiting to run
CI for docker images / Build docker containers (aarch64, ha-addon) (push) Waiting to run
CI for docker images / Build docker containers (aarch64, lint) (push) Waiting to run
CI for docker images / Build docker containers (amd64, docker) (push) Waiting to run
CI for docker images / Build docker containers (amd64, ha-addon) (push) Waiting to run
CI for docker images / Build docker containers (amd64, lint) (push) Waiting to run
CI for docker images / Build docker containers (armv7, ha-addon) (push) Waiting to run
CI for docker images / Build docker containers (armv7, lint) (push) Waiting to run
CI / Run script/ci-custom (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.10) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.9) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Component test ${{ matrix.file }} (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
Some checks are pending
CI for docker images / Build docker containers (armv7, docker) (push) Waiting to run
CI for docker images / Build docker containers (aarch64, docker) (push) Waiting to run
CI for docker images / Build docker containers (aarch64, ha-addon) (push) Waiting to run
CI for docker images / Build docker containers (aarch64, lint) (push) Waiting to run
CI for docker images / Build docker containers (amd64, docker) (push) Waiting to run
CI for docker images / Build docker containers (amd64, ha-addon) (push) Waiting to run
CI for docker images / Build docker containers (amd64, lint) (push) Waiting to run
CI for docker images / Build docker containers (armv7, ha-addon) (push) Waiting to run
CI for docker images / Build docker containers (armv7, lint) (push) Waiting to run
CI / Run script/ci-custom (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.10) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.9) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Component test ${{ matrix.file }} (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
This commit is contained in:
parent
1922f2bbee
commit
f28418d0b4
7 changed files with 45 additions and 25 deletions
|
@ -327,6 +327,8 @@ CONFIG_SCHEMA = (
|
|||
{
|
||||
cv.Optional(df.CONF_GRID_CELL_X_ALIGN): grid_alignments,
|
||||
cv.Optional(df.CONF_GRID_CELL_Y_ALIGN): grid_alignments,
|
||||
cv.Optional(df.CONF_PAD_ROW): lvalid.pixels,
|
||||
cv.Optional(df.CONF_PAD_COLUMN): lvalid.pixels,
|
||||
}
|
||||
)
|
||||
),
|
||||
|
|
|
@ -52,9 +52,7 @@ opacity = LValidator(opacity_validator, uint32, retmapper=literal)
|
|||
def color(value):
|
||||
if value == SCHEMA_EXTRACT:
|
||||
return ["hex color value", "color ID"]
|
||||
if isinstance(value, int):
|
||||
return value
|
||||
return cv.use_id(ColorStruct)(value)
|
||||
return cv.Any(cv.int_, cv.use_id(ColorStruct))(value)
|
||||
|
||||
|
||||
def color_retmapper(value):
|
||||
|
@ -82,10 +80,10 @@ def pixels_or_percent_validator(value):
|
|||
"""A length in one axis - either a number (pixels) or a percentage"""
|
||||
if value == SCHEMA_EXTRACT:
|
||||
return ["pixels", "..%"]
|
||||
value = cv.Any(cv.int_, cv.percentage)(value)
|
||||
if isinstance(value, int):
|
||||
return cv.int_(value)
|
||||
# Will throw an exception if not a percentage.
|
||||
return f"lv_pct({int(cv.percentage(value) * 100)})"
|
||||
return value
|
||||
return f"lv_pct({int(value * 100)})"
|
||||
|
||||
|
||||
pixels_or_percent = LValidator(pixels_or_percent_validator, uint32, retmapper=literal)
|
||||
|
@ -116,10 +114,7 @@ def size_validator(value):
|
|||
if value.upper() == "SIZE_CONTENT":
|
||||
return "LV_SIZE_CONTENT"
|
||||
raise cv.Invalid("must be 'size_content', a percentage or an integer (pixels)")
|
||||
if isinstance(value, int):
|
||||
return cv.int_(value)
|
||||
# Will throw an exception if not a percentage.
|
||||
return f"lv_pct({int(cv.percentage(value) * 100)})"
|
||||
return pixels_or_percent_validator(value)
|
||||
|
||||
|
||||
size = LValidator(size_validator, uint32, retmapper=literal)
|
||||
|
|
|
@ -359,7 +359,13 @@ LVGL_SCHEMA = cv.Schema(
|
|||
}
|
||||
)
|
||||
|
||||
ALL_STYLES = {**STYLE_PROPS, **GRID_CELL_SCHEMA, **FLEX_OBJ_SCHEMA}
|
||||
ALL_STYLES = {
|
||||
**STYLE_PROPS,
|
||||
**GRID_CELL_SCHEMA,
|
||||
**FLEX_OBJ_SCHEMA,
|
||||
cv.Optional(df.CONF_PAD_ROW): lvalid.pixels,
|
||||
cv.Optional(df.CONF_PAD_COLUMN): lvalid.pixels,
|
||||
}
|
||||
|
||||
|
||||
def container_validator(schema, widget_type: WidgetType):
|
||||
|
|
|
@ -13,11 +13,13 @@ from ..defines import (
|
|||
CONF_KEY_CODE,
|
||||
CONF_MAIN,
|
||||
CONF_ONE_CHECKED,
|
||||
CONF_PAD_COLUMN,
|
||||
CONF_PAD_ROW,
|
||||
CONF_ROWS,
|
||||
CONF_SELECTED,
|
||||
)
|
||||
from ..helpers import lvgl_components_required
|
||||
from ..lv_validation import key_code, lv_bool
|
||||
from ..lv_validation import key_code, lv_bool, pixels
|
||||
from ..lvcode import lv, lv_add, lv_expr
|
||||
from ..schemas import automation_schema
|
||||
from ..types import (
|
||||
|
@ -57,6 +59,8 @@ BUTTONMATRIX_BUTTON_SCHEMA = cv.Schema(
|
|||
BUTTONMATRIX_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Optional(CONF_ONE_CHECKED, default=False): lv_bool,
|
||||
cv.Optional(CONF_PAD_ROW): pixels,
|
||||
cv.Optional(CONF_PAD_COLUMN): pixels,
|
||||
cv.GenerateID(CONF_BUTTON_TEXT_LIST_ID): cv.declare_id(char_ptr),
|
||||
cv.Required(CONF_ROWS): cv.ensure_list(
|
||||
cv.Schema(
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from esphome.config_validation import Optional
|
||||
from esphome.const import CONF_TEXT
|
||||
|
||||
from ..defines import CONF_INDICATOR, CONF_MAIN
|
||||
from ..lv_validation import lv_text
|
||||
from ..defines import CONF_INDICATOR, CONF_MAIN, CONF_PAD_COLUMN
|
||||
from ..lv_validation import lv_text, pixels
|
||||
from ..lvcode import lv
|
||||
from ..schemas import TEXT_SCHEMA
|
||||
from ..types import LvBoolean
|
||||
|
@ -16,7 +17,11 @@ class CheckboxType(WidgetType):
|
|||
CONF_CHECKBOX,
|
||||
LvBoolean("lv_checkbox_t"),
|
||||
(CONF_MAIN, CONF_INDICATOR),
|
||||
TEXT_SCHEMA,
|
||||
TEXT_SCHEMA.extend(
|
||||
{
|
||||
Optional(CONF_PAD_COLUMN): pixels,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
async def to_code(self, w: Widget, config):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from esphome import automation
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID, CONF_ON_VALUE, CONF_ROW, CONF_TRIGGER_ID
|
||||
from esphome.const import CONF_ID, CONF_ROW
|
||||
|
||||
from ..automation import action_to_code
|
||||
from ..defines import (
|
||||
|
@ -29,6 +29,7 @@ lv_tileview_t = LvType(
|
|||
"lv_tileview_t",
|
||||
largs=[(lv_obj_t_ptr, "tile")],
|
||||
lvalue=lambda w: w.get_property("tile_act"),
|
||||
has_on_value=True,
|
||||
)
|
||||
|
||||
tile_spec = WidgetType("lv_tileview_tile_t", lv_tile_t, (CONF_MAIN,), {})
|
||||
|
@ -46,13 +47,6 @@ TILEVIEW_SCHEMA = cv.Schema(
|
|||
},
|
||||
)
|
||||
),
|
||||
cv.Optional(CONF_ON_VALUE): automation.validate_automation(
|
||||
{
|
||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
|
||||
automation.Trigger.template(lv_obj_t_ptr)
|
||||
)
|
||||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -337,11 +337,25 @@ lvgl:
|
|||
- tileview:
|
||||
id: tileview_id
|
||||
scrollbar_mode: active
|
||||
on_value:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return tile == id(tile_1);
|
||||
then:
|
||||
- logger.log: "tile 1 is now showing"
|
||||
tiles:
|
||||
- id: page_1
|
||||
- id: tile_1
|
||||
row: 0
|
||||
column: 0
|
||||
dir: HOR
|
||||
dir: ALL
|
||||
widgets:
|
||||
- obj:
|
||||
bg_color: 0x000000
|
||||
- id: tile_2
|
||||
row: 1
|
||||
column: 0
|
||||
dir: [VER, HOR]
|
||||
widgets:
|
||||
- obj:
|
||||
bg_color: 0x000000
|
||||
|
|
Loading…
Reference in a new issue