mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 06:06:33 +00:00
[const] Create component-level const repository (#8385)
This commit is contained in:
parent
2d3f141140
commit
22c0e1079e
@ -98,6 +98,7 @@ esphome/components/climate/* @esphome/core
|
|||||||
esphome/components/climate_ir/* @glmnet
|
esphome/components/climate_ir/* @glmnet
|
||||||
esphome/components/color_temperature/* @jesserockz
|
esphome/components/color_temperature/* @jesserockz
|
||||||
esphome/components/combination/* @Cat-Ion @kahrendt
|
esphome/components/combination/* @Cat-Ion @kahrendt
|
||||||
|
esphome/components/const/* @esphome/core
|
||||||
esphome/components/coolix/* @glmnet
|
esphome/components/coolix/* @glmnet
|
||||||
esphome/components/copy/* @OttoWinter
|
esphome/components/copy/* @OttoWinter
|
||||||
esphome/components/cover/* @esphome/core
|
esphome/components/cover/* @esphome/core
|
||||||
|
5
esphome/components/const/__init__.py
Normal file
5
esphome/components/const/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
"""Constants used by esphome components."""
|
||||||
|
|
||||||
|
CODEOWNERS = ["@esphome/core"]
|
||||||
|
|
||||||
|
CONF_DRAW_ROUNDING = "draw_rounding"
|
@ -2,6 +2,7 @@ import logging
|
|||||||
|
|
||||||
from esphome.automation import build_automation, register_action, validate_automation
|
from esphome.automation import build_automation, register_action, validate_automation
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
|
from esphome.components.const import CONF_DRAW_ROUNDING
|
||||||
from esphome.components.display import Display
|
from esphome.components.display import Display
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
@ -24,7 +25,7 @@ from esphome.helpers import write_file_if_changed
|
|||||||
|
|
||||||
from . import defines as df, helpers, lv_validation as lvalid
|
from . import defines as df, helpers, lv_validation as lvalid
|
||||||
from .automation import disp_update, focused_widgets, update_to_code
|
from .automation import disp_update, focused_widgets, update_to_code
|
||||||
from .defines import CONF_DRAW_ROUNDING, add_define
|
from .defines import add_define
|
||||||
from .encoders import (
|
from .encoders import (
|
||||||
ENCODERS_CONFIG,
|
ENCODERS_CONFIG,
|
||||||
encoders_to_code,
|
encoders_to_code,
|
||||||
@ -323,7 +324,7 @@ async def to_code(configs):
|
|||||||
displays,
|
displays,
|
||||||
frac,
|
frac,
|
||||||
config[df.CONF_FULL_REFRESH],
|
config[df.CONF_FULL_REFRESH],
|
||||||
config[df.CONF_DRAW_ROUNDING],
|
config[CONF_DRAW_ROUNDING],
|
||||||
config[df.CONF_RESUME_ON_INPUT],
|
config[df.CONF_RESUME_ON_INPUT],
|
||||||
)
|
)
|
||||||
await cg.register_component(lv_component, config)
|
await cg.register_component(lv_component, config)
|
||||||
@ -413,7 +414,7 @@ LVGL_SCHEMA = cv.All(
|
|||||||
df.CONF_DEFAULT_FONT, default="montserrat_14"
|
df.CONF_DEFAULT_FONT, default="montserrat_14"
|
||||||
): lvalid.lv_font,
|
): lvalid.lv_font,
|
||||||
cv.Optional(df.CONF_FULL_REFRESH, default=False): cv.boolean,
|
cv.Optional(df.CONF_FULL_REFRESH, default=False): cv.boolean,
|
||||||
cv.Optional(df.CONF_DRAW_ROUNDING, default=2): cv.positive_int,
|
cv.Optional(CONF_DRAW_ROUNDING, default=2): cv.positive_int,
|
||||||
cv.Optional(CONF_BUFFER_SIZE, default="100%"): cv.percentage,
|
cv.Optional(CONF_BUFFER_SIZE, default="100%"): cv.percentage,
|
||||||
cv.Optional(df.CONF_LOG_LEVEL, default="WARN"): cv.one_of(
|
cv.Optional(df.CONF_LOG_LEVEL, default="WARN"): cv.one_of(
|
||||||
*df.LV_LOG_LEVELS, upper=True
|
*df.LV_LOG_LEVELS, upper=True
|
||||||
|
@ -424,7 +424,6 @@ CONF_DEFAULT_FONT = "default_font"
|
|||||||
CONF_DEFAULT_GROUP = "default_group"
|
CONF_DEFAULT_GROUP = "default_group"
|
||||||
CONF_DIR = "dir"
|
CONF_DIR = "dir"
|
||||||
CONF_DISPLAYS = "displays"
|
CONF_DISPLAYS = "displays"
|
||||||
CONF_DRAW_ROUNDING = "draw_rounding"
|
|
||||||
CONF_EDITING = "editing"
|
CONF_EDITING = "editing"
|
||||||
CONF_ENCODERS = "encoders"
|
CONF_ENCODERS = "encoders"
|
||||||
CONF_END_ANGLE = "end_angle"
|
CONF_END_ANGLE = "end_angle"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
CODEOWNERS = ["@clydebarrow"]
|
CODEOWNERS = ["@clydebarrow"]
|
||||||
|
|
||||||
CONF_DRAW_FROM_ORIGIN = "draw_from_origin"
|
CONF_DRAW_FROM_ORIGIN = "draw_from_origin"
|
||||||
CONF_DRAW_ROUNDING = "draw_rounding"
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from esphome import pins
|
from esphome import pins
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components import display, spi
|
from esphome.components import display, spi
|
||||||
|
from esphome.components.const import CONF_DRAW_ROUNDING
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_BRIGHTNESS,
|
CONF_BRIGHTNESS,
|
||||||
@ -24,7 +25,7 @@ from esphome.const import (
|
|||||||
)
|
)
|
||||||
from esphome.core import TimePeriod
|
from esphome.core import TimePeriod
|
||||||
|
|
||||||
from . import CONF_DRAW_FROM_ORIGIN, CONF_DRAW_ROUNDING
|
from . import CONF_DRAW_FROM_ORIGIN
|
||||||
from .models import DriverChip
|
from .models import DriverChip
|
||||||
|
|
||||||
DEPENDENCIES = ["spi"]
|
DEPENDENCIES = ["spi"]
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# Commands
|
# Commands
|
||||||
|
from esphome.components.const import CONF_DRAW_ROUNDING
|
||||||
from esphome.const import CONF_INVERT_COLORS, CONF_SWAP_XY
|
from esphome.const import CONF_INVERT_COLORS, CONF_SWAP_XY
|
||||||
|
|
||||||
from . import CONF_DRAW_ROUNDING
|
|
||||||
|
|
||||||
SW_RESET_CMD = 0x01
|
SW_RESET_CMD = 0x01
|
||||||
SLEEP_IN = 0x10
|
SLEEP_IN = 0x10
|
||||||
SLEEP_OUT = 0x11
|
SLEEP_OUT = 0x11
|
||||||
|
44
tests/components/const/common.yaml
Normal file
44
tests/components/const/common.yaml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
spi:
|
||||||
|
id: quad_spi
|
||||||
|
clk_pin: 15
|
||||||
|
type: quad
|
||||||
|
data_pins: [14, 10, 16, 12]
|
||||||
|
|
||||||
|
display:
|
||||||
|
- platform: qspi_dbi
|
||||||
|
model: RM690B0
|
||||||
|
data_rate: 80MHz
|
||||||
|
spi_mode: mode0
|
||||||
|
dimensions:
|
||||||
|
width: 450
|
||||||
|
height: 600
|
||||||
|
offset_width: 16
|
||||||
|
color_order: rgb
|
||||||
|
invert_colors: false
|
||||||
|
brightness: 255
|
||||||
|
cs_pin: 11
|
||||||
|
reset_pin: 13
|
||||||
|
enable_pin: 9
|
||||||
|
|
||||||
|
- platform: qspi_dbi
|
||||||
|
model: CUSTOM
|
||||||
|
id: main_lcd
|
||||||
|
draw_from_origin: true
|
||||||
|
dimensions:
|
||||||
|
height: 240
|
||||||
|
width: 536
|
||||||
|
transform:
|
||||||
|
mirror_x: true
|
||||||
|
swap_xy: true
|
||||||
|
color_order: rgb
|
||||||
|
brightness: 255
|
||||||
|
cs_pin: 6
|
||||||
|
reset_pin: 17
|
||||||
|
enable_pin: 38
|
||||||
|
init_sequence:
|
||||||
|
- [0x3A, 0x66]
|
||||||
|
- [0x11]
|
||||||
|
- delay 120ms
|
||||||
|
- [0x29]
|
||||||
|
- delay 20ms
|
||||||
|
|
1
tests/components/const/test.esp32-s3-idf.yaml
Normal file
1
tests/components/const/test.esp32-s3-idf.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
Loading…
x
Reference in New Issue
Block a user