mirror of
https://github.com/esphome/esphome.git
synced 2024-11-30 18:54:14 +01:00
Merge branch 'dev' into dev
This commit is contained in:
commit
729a47bb9e
22 changed files with 114 additions and 116 deletions
|
@ -5,6 +5,7 @@ namespace cst226 {
|
|||
|
||||
void CST226Touchscreen::setup() {
|
||||
esph_log_config(TAG, "Setting up CST226 Touchscreen...");
|
||||
if (this->reset_pin_ != nullptr) {
|
||||
this->reset_pin_->setup();
|
||||
this->reset_pin_->digital_write(true);
|
||||
delay(5);
|
||||
|
@ -12,6 +13,9 @@ void CST226Touchscreen::setup() {
|
|||
delay(5);
|
||||
this->reset_pin_->digital_write(true);
|
||||
this->set_timeout(30, [this] { this->continue_setup_(); });
|
||||
} else {
|
||||
this->continue_setup_();
|
||||
}
|
||||
}
|
||||
|
||||
void CST226Touchscreen::update_touches() {
|
||||
|
|
|
@ -35,7 +35,7 @@ class CST226Touchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice
|
|||
void continue_setup_();
|
||||
|
||||
InternalGPIOPin *interrupt_pin_{};
|
||||
GPIOPin *reset_pin_{NULL_PIN};
|
||||
GPIOPin *reset_pin_{};
|
||||
uint8_t chip_id_{};
|
||||
bool setup_complete_{};
|
||||
};
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
import re
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
|
||||
from esphome import automation, core
|
||||
from esphome.automation import maybe_simple_id
|
||||
import esphome.codegen as cg
|
||||
from esphome.components.number import Number
|
||||
from esphome.components.select import Select
|
||||
from esphome.components.switch import Switch
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_TYPE,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_ON_VALUE,
|
||||
CONF_ACTIVE,
|
||||
CONF_COMMAND,
|
||||
CONF_CUSTOM,
|
||||
CONF_NUMBER,
|
||||
CONF_FORMAT,
|
||||
CONF_ID,
|
||||
CONF_ITEMS,
|
||||
CONF_MODE,
|
||||
CONF_ACTIVE,
|
||||
CONF_NUMBER,
|
||||
CONF_ON_VALUE,
|
||||
CONF_TEXT,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_TYPE,
|
||||
)
|
||||
from esphome.automation import maybe_simple_id
|
||||
from esphome.components.select import Select
|
||||
from esphome.components.number import Number
|
||||
from esphome.components.switch import Switch
|
||||
|
||||
CODEOWNERS = ["@numo68"]
|
||||
|
||||
|
@ -29,10 +32,8 @@ CONF_JOYSTICK = "joystick"
|
|||
CONF_LABEL = "label"
|
||||
CONF_MENU = "menu"
|
||||
CONF_BACK = "back"
|
||||
CONF_TEXT = "text"
|
||||
CONF_SELECT = "select"
|
||||
CONF_SWITCH = "switch"
|
||||
CONF_ITEMS = "items"
|
||||
CONF_ON_TEXT = "on_text"
|
||||
CONF_OFF_TEXT = "off_text"
|
||||
CONF_VALUE_LAMBDA = "value_lambda"
|
||||
|
|
|
@ -10,12 +10,12 @@ import esphome.config_validation as cv
|
|||
from esphome.const import (
|
||||
CONF_BACKGROUND_COLOR,
|
||||
CONF_DISPLAY,
|
||||
CONF_FONT,
|
||||
CONF_FOREGROUND_COLOR,
|
||||
CONF_ID,
|
||||
CONF_TRIGGER_ID,
|
||||
)
|
||||
|
||||
CONF_FONT = "font"
|
||||
CONF_MENU_ITEM_VALUE = "menu_item_value"
|
||||
CONF_ON_REDRAW = "on_redraw"
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ from esphome.helpers import write_file_if_changed
|
|||
from . import defines as df, helpers, lv_validation as lvalid
|
||||
from .automation import disp_update, update_to_code
|
||||
from .defines import CONF_SKIP
|
||||
from .encoders import ENCODERS_CONFIG, encoders_to_code
|
||||
from .lv_validation import lv_bool, lv_images_used
|
||||
from .lvcode import LvContext, LvglComponent
|
||||
from .rotary_encoders import ROTARY_ENCODER_CONFIG, rotary_encoders_to_code
|
||||
from .schemas import (
|
||||
DISP_BG_SCHEMA,
|
||||
FLEX_OBJ_SCHEMA,
|
||||
|
@ -256,7 +256,7 @@ async def to_code(config):
|
|||
|
||||
async with LvContext(lv_component):
|
||||
await touchscreens_to_code(lv_component, config)
|
||||
await rotary_encoders_to_code(lv_component, config)
|
||||
await encoders_to_code(lv_component, config)
|
||||
await theme_to_code(config)
|
||||
await styles_to_code(config)
|
||||
await set_obj_properties(lv_scr_act, config)
|
||||
|
@ -336,7 +336,7 @@ CONFIG_SCHEMA = (
|
|||
{cv.Optional(name): obj_schema(w) for name, w in WIDGET_TYPES.items()}
|
||||
),
|
||||
cv.GenerateID(df.CONF_TOUCHSCREENS): touchscreen_schema,
|
||||
cv.GenerateID(df.CONF_ROTARY_ENCODERS): ROTARY_ENCODER_CONFIG,
|
||||
cv.GenerateID(df.CONF_ENCODERS): ENCODERS_CONFIG,
|
||||
}
|
||||
)
|
||||
.extend(DISP_BG_SCHEMA)
|
||||
|
|
|
@ -5,6 +5,7 @@ Constants already defined in esphome.const are not duplicated here and must be i
|
|||
"""
|
||||
|
||||
from esphome import codegen as cg, config_validation as cv
|
||||
from esphome.const import CONF_ITEMS
|
||||
from esphome.core import ID, Lambda
|
||||
from esphome.cpp_generator import MockObj
|
||||
from esphome.cpp_types import uint32
|
||||
|
@ -115,7 +116,6 @@ CONF_SCROLLBAR = "scrollbar"
|
|||
CONF_INDICATOR = "indicator"
|
||||
CONF_KNOB = "knob"
|
||||
CONF_SELECTED = "selected"
|
||||
CONF_ITEMS = "items"
|
||||
CONF_TICKS = "ticks"
|
||||
CONF_CURSOR = "cursor"
|
||||
CONF_TEXTAREA_PLACEHOLDER = "textarea_placeholder"
|
||||
|
@ -388,6 +388,7 @@ CONF_DEFAULT = "default"
|
|||
CONF_DEFAULT_FONT = "default_font"
|
||||
CONF_DIR = "dir"
|
||||
CONF_DISPLAYS = "displays"
|
||||
CONF_ENCODERS = "encoders"
|
||||
CONF_END_ANGLE = "end_angle"
|
||||
CONF_END_VALUE = "end_value"
|
||||
CONF_ENTER_BUTTON = "enter_button"
|
||||
|
@ -441,7 +442,6 @@ CONF_RECOLOR = "recolor"
|
|||
CONF_RIGHT_BUTTON = "right_button"
|
||||
CONF_ROLLOVER = "rollover"
|
||||
CONF_ROOT_BACK_BTN = "root_back_btn"
|
||||
CONF_ROTARY_ENCODERS = "rotary_encoders"
|
||||
CONF_ROWS = "rows"
|
||||
CONF_SCALE_LINES = "scale_lines"
|
||||
CONF_SCROLLBAR_MODE = "scrollbar_mode"
|
||||
|
@ -460,7 +460,6 @@ CONF_SKIP = "skip"
|
|||
CONF_SYMBOL = "symbol"
|
||||
CONF_TAB_ID = "tab_id"
|
||||
CONF_TABS = "tabs"
|
||||
CONF_TEXT = "text"
|
||||
CONF_TILE = "tile"
|
||||
CONF_TILE_ID = "tile_id"
|
||||
CONF_TILES = "tiles"
|
||||
|
|
|
@ -5,25 +5,26 @@ import esphome.config_validation as cv
|
|||
from esphome.const import CONF_GROUP, CONF_ID, CONF_SENSOR
|
||||
|
||||
from .defines import (
|
||||
CONF_ENCODERS,
|
||||
CONF_ENTER_BUTTON,
|
||||
CONF_LEFT_BUTTON,
|
||||
CONF_LONG_PRESS_REPEAT_TIME,
|
||||
CONF_LONG_PRESS_TIME,
|
||||
CONF_RIGHT_BUTTON,
|
||||
CONF_ROTARY_ENCODERS,
|
||||
)
|
||||
from .helpers import lvgl_components_required
|
||||
from .lvcode import lv, lv_add, lv_expr
|
||||
from .helpers import lvgl_components_required, requires_component
|
||||
from .lvcode import lv, lv_add, lv_assign, lv_expr, lv_Pvariable
|
||||
from .schemas import ENCODER_SCHEMA
|
||||
from .types import lv_indev_type_t
|
||||
from .widgets import add_group
|
||||
from .types import lv_group_t, lv_indev_type_t
|
||||
|
||||
ROTARY_ENCODER_CONFIG = cv.ensure_list(
|
||||
ENCODERS_CONFIG = cv.ensure_list(
|
||||
ENCODER_SCHEMA.extend(
|
||||
{
|
||||
cv.Required(CONF_ENTER_BUTTON): cv.use_id(BinarySensor),
|
||||
cv.Required(CONF_SENSOR): cv.Any(
|
||||
cv.use_id(RotaryEncoderSensor),
|
||||
cv.All(
|
||||
cv.use_id(RotaryEncoderSensor), requires_component("rotary_encoder")
|
||||
),
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_LEFT_BUTTON): cv.use_id(BinarySensor),
|
||||
|
@ -36,10 +37,9 @@ ROTARY_ENCODER_CONFIG = cv.ensure_list(
|
|||
)
|
||||
|
||||
|
||||
async def rotary_encoders_to_code(var, config):
|
||||
for enc_conf in config.get(CONF_ROTARY_ENCODERS, ()):
|
||||
async def encoders_to_code(var, config):
|
||||
for enc_conf in config.get(CONF_ENCODERS, ()):
|
||||
lvgl_components_required.add("KEY_LISTENER")
|
||||
lvgl_components_required.add("ROTARY_ENCODER")
|
||||
lpt = enc_conf[CONF_LONG_PRESS_TIME].total_milliseconds
|
||||
lprt = enc_conf[CONF_LONG_PRESS_REPEAT_TIME].total_milliseconds
|
||||
listener = cg.new_Pvariable(
|
||||
|
@ -57,7 +57,9 @@ async def rotary_encoders_to_code(var, config):
|
|||
lv_add(listener.set_sensor(sensor_config))
|
||||
b_sensor = await cg.get_variable(enc_conf[CONF_ENTER_BUTTON])
|
||||
cg.add(listener.set_enter_button(b_sensor))
|
||||
if group := add_group(enc_conf.get(CONF_GROUP)):
|
||||
if group := enc_conf.get(CONF_GROUP):
|
||||
group = lv_Pvariable(lv_group_t, group)
|
||||
lv_assign(group, lv_expr.group_create())
|
||||
lv.indev_set_group(lv_expr.indev_drv_register(listener.get_drv()), group)
|
||||
else:
|
||||
lv.indev_drv_register(listener.get_drv())
|
|
@ -127,7 +127,7 @@ void LVTouchListener::update(const touchscreen::TouchPoints_t &tpoints) {
|
|||
}
|
||||
#endif // USE_LVGL_TOUCHSCREEN
|
||||
|
||||
#ifdef USE_LVGL_ROTARY_ENCODER
|
||||
#ifdef USE_LVGL_KEY_LISTENER
|
||||
LVEncoderListener::LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt) {
|
||||
lv_indev_drv_init(&this->drv_);
|
||||
this->drv_.type = type;
|
||||
|
@ -143,7 +143,7 @@ LVEncoderListener::LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_
|
|||
data->continue_reading = false;
|
||||
};
|
||||
}
|
||||
#endif // USE_LVGL_ROTARY_ENCODER
|
||||
#endif // USE_LVGL_KEY_LISTENER
|
||||
|
||||
#ifdef USE_LVGL_BUTTONMATRIX
|
||||
void LvButtonMatrixType::set_obj(lv_obj_t *lv_obj) {
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
#pragma once
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#ifdef USE_LVGL_BINARY_SENSOR
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
#endif // USE_LVGL_BINARY_SENSOR
|
||||
#ifdef USE_LVGL_ROTARY_ENCODER
|
||||
#include "esphome/components/rotary_encoder/rotary_encoder.h"
|
||||
#endif // USE_LVGL_ROTARY_ENCODER
|
||||
|
||||
// required for clang-tidy
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_SKIP 1 // NOLINT
|
||||
|
@ -12,12 +19,7 @@
|
|||
#include "esphome/core/log.h"
|
||||
#include <lvgl.h>
|
||||
#include <vector>
|
||||
|
||||
#ifdef USE_LVGL_ROTARY_ENCODER
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
#include "esphome/components/rotary_encoder/rotary_encoder.h"
|
||||
#endif // USE_LVGL_ROTARY_ENCODER
|
||||
|
||||
#include <map>
|
||||
#ifdef USE_LVGL_IMAGE
|
||||
#include "esphome/components/image/image.h"
|
||||
#endif // USE_LVGL_IMAGE
|
||||
|
@ -202,7 +204,7 @@ class LVTouchListener : public touchscreen::TouchListener, public Parented<LvglC
|
|||
};
|
||||
#endif // USE_LVGL_TOUCHSCREEN
|
||||
|
||||
#ifdef USE_LVGL_ROTARY_ENCODER
|
||||
#ifdef USE_LVGL_KEY_LISTENER
|
||||
class LVEncoderListener : public Parented<LvglComponent> {
|
||||
public:
|
||||
LVEncoderListener(lv_indev_type_t type, uint16_t lpt, uint16_t lprt);
|
||||
|
@ -218,9 +220,11 @@ class LVEncoderListener : public Parented<LvglComponent> {
|
|||
enter_button->add_on_state_callback([this](bool state) { this->event(LV_KEY_ENTER, state); });
|
||||
}
|
||||
|
||||
#ifdef USE_LVGL_ROTARY_ENCODER
|
||||
void set_sensor(rotary_encoder::RotaryEncoderSensor *sensor) {
|
||||
sensor->register_listener([this](int32_t count) { this->set_count(count); });
|
||||
}
|
||||
#endif // USE_LVGL_ROTARY_ENCODER
|
||||
|
||||
void event(int key, bool pressed) {
|
||||
if (!this->parent_->is_paused()) {
|
||||
|
@ -243,7 +247,8 @@ class LVEncoderListener : public Parented<LvglComponent> {
|
|||
int32_t last_count_{};
|
||||
int key_{};
|
||||
};
|
||||
#endif // USE_LVGL_ROTARY_ENCODER
|
||||
#endif // USE_LVGL_KEY_LISTENER
|
||||
|
||||
#ifdef USE_LVGL_BUTTONMATRIX
|
||||
class LvButtonMatrixType : public key_provider::KeyProvider, public LvCompound {
|
||||
public:
|
||||
|
|
|
@ -7,6 +7,7 @@ from esphome.const import (
|
|||
CONF_ID,
|
||||
CONF_ON_VALUE,
|
||||
CONF_STATE,
|
||||
CONF_TEXT,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_TYPE,
|
||||
)
|
||||
|
@ -15,9 +16,9 @@ from esphome.schema_extractors import SCHEMA_EXTRACT
|
|||
|
||||
from . import defines as df, lv_validation as lvalid, types as ty
|
||||
from .helpers import add_lv_use, requires_component, validate_printf
|
||||
from .lv_validation import id_name, lv_color, lv_font, lv_image
|
||||
from .lv_validation import lv_color, lv_font, lv_image
|
||||
from .lvcode import LvglComponent
|
||||
from .types import WidgetType
|
||||
from .types import WidgetType, lv_group_t
|
||||
|
||||
# this will be populated later, in __init__.py to avoid circular imports.
|
||||
WIDGET_TYPES: dict = {}
|
||||
|
@ -25,7 +26,7 @@ WIDGET_TYPES: dict = {}
|
|||
# A schema for text properties
|
||||
TEXT_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Optional(df.CONF_TEXT): cv.Any(
|
||||
cv.Optional(CONF_TEXT): cv.Any(
|
||||
cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
|
@ -60,7 +61,7 @@ ENCODER_SCHEMA = cv.Schema(
|
|||
cv.GenerateID(): cv.All(
|
||||
cv.declare_id(ty.LVEncoderListener), requires_component("binary_sensor")
|
||||
),
|
||||
cv.Optional(CONF_GROUP): lvalid.id_name,
|
||||
cv.Optional(CONF_GROUP): cv.declare_id(lv_group_t),
|
||||
cv.Optional(df.CONF_LONG_PRESS_TIME, default="400ms"): PRESS_TIME,
|
||||
cv.Optional(df.CONF_LONG_PRESS_REPEAT_TIME, default="100ms"): PRESS_TIME,
|
||||
}
|
||||
|
@ -248,7 +249,7 @@ def obj_schema(widget_type: WidgetType):
|
|||
cv.Schema(
|
||||
{
|
||||
cv.Optional(CONF_STATE): SET_STATE_SCHEMA,
|
||||
cv.Optional(CONF_GROUP): id_name,
|
||||
cv.Optional(CONF_GROUP): cv.use_id(lv_group_t),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -330,7 +331,7 @@ DISP_BG_SCHEMA = cv.Schema(
|
|||
|
||||
# A style schema that can include text
|
||||
STYLED_TEXT_SCHEMA = cv.maybe_simple_value(
|
||||
STYLE_SCHEMA.extend(TEXT_SCHEMA), key=df.CONF_TEXT
|
||||
STYLE_SCHEMA.extend(TEXT_SCHEMA), key=CONF_TEXT
|
||||
)
|
||||
|
||||
# For use by platform components
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import sys
|
||||
|
||||
from esphome import automation, codegen as cg
|
||||
from esphome.const import CONF_MAX_VALUE, CONF_MIN_VALUE, CONF_VALUE
|
||||
from esphome.const import CONF_MAX_VALUE, CONF_MIN_VALUE, CONF_TEXT, CONF_VALUE
|
||||
from esphome.cpp_generator import MockObj, MockObjClass
|
||||
|
||||
from .defines import CONF_TEXT, lvgl_ns
|
||||
from .defines import lvgl_ns
|
||||
from .lvcode import lv_expr
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from esphome.config_validation import Invalid
|
|||
from esphome.const import CONF_GROUP, CONF_ID, CONF_STATE, CONF_TYPE
|
||||
from esphome.core import ID, TimePeriod
|
||||
from esphome.coroutine import FakeAwaitable
|
||||
from esphome.cpp_generator import AssignmentExpression, CallExpression, MockObj
|
||||
from esphome.cpp_generator import CallExpression, MockObj
|
||||
|
||||
from ..defines import (
|
||||
CONF_DEFAULT,
|
||||
|
@ -44,15 +44,7 @@ from ..lvcode import (
|
|||
lv_Pvariable,
|
||||
)
|
||||
from ..schemas import ALL_STYLES, STYLE_REMAP, WIDGET_TYPES
|
||||
from ..types import (
|
||||
LV_STATE,
|
||||
LvType,
|
||||
WidgetType,
|
||||
lv_coord_t,
|
||||
lv_group_t,
|
||||
lv_obj_t,
|
||||
lv_obj_t_ptr,
|
||||
)
|
||||
from ..types import LV_STATE, LvType, WidgetType, lv_coord_t, lv_obj_t, lv_obj_t_ptr
|
||||
|
||||
EVENT_LAMB = "event_lamb__"
|
||||
|
||||
|
@ -317,7 +309,8 @@ async def set_obj_properties(w: Widget, config):
|
|||
value = await ALL_STYLES[prop].process(value)
|
||||
prop_r = STYLE_REMAP.get(prop, prop)
|
||||
w.set_style(prop_r, value, lv_state)
|
||||
if group := add_group(config.get(CONF_GROUP)):
|
||||
if group := config.get(CONF_GROUP):
|
||||
group = await cg.get_variable(group)
|
||||
lv.group_add_obj(group, w.obj)
|
||||
flag_clr = set()
|
||||
flag_set = set()
|
||||
|
@ -404,20 +397,3 @@ async def widget_to_code(w_cnfig, w_type: WidgetType, parent):
|
|||
|
||||
lv_scr_act_spec = LvScrActType()
|
||||
lv_scr_act = Widget.create(None, literal("lv_scr_act()"), lv_scr_act_spec, {})
|
||||
|
||||
lv_groups = {} # Widget group names
|
||||
|
||||
|
||||
def add_group(name):
|
||||
if name is None:
|
||||
return None
|
||||
fullname = f"lv_esp_group_{name}"
|
||||
if name not in lv_groups:
|
||||
gid = ID(fullname, True, type=lv_group_t.operator("ptr"))
|
||||
lv_add(
|
||||
AssignmentExpression(
|
||||
type_=gid.type, modifier="", name=fullname, rhs=lv_expr.group_create()
|
||||
)
|
||||
)
|
||||
lv_groups[name] = literal(fullname)
|
||||
return lv_groups[name]
|
||||
|
|
|
@ -2,7 +2,7 @@ from esphome import automation
|
|||
import esphome.codegen as cg
|
||||
from esphome.components.key_provider import KeyProvider
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID, CONF_WIDTH
|
||||
from esphome.const import CONF_ID, CONF_ITEMS, CONF_TEXT, CONF_WIDTH
|
||||
from esphome.cpp_generator import MockObj
|
||||
|
||||
from ..automation import action_to_code
|
||||
|
@ -10,13 +10,11 @@ from ..defines import (
|
|||
BUTTONMATRIX_CTRLS,
|
||||
CONF_BUTTONS,
|
||||
CONF_CONTROL,
|
||||
CONF_ITEMS,
|
||||
CONF_KEY_CODE,
|
||||
CONF_MAIN,
|
||||
CONF_ONE_CHECKED,
|
||||
CONF_ROWS,
|
||||
CONF_SELECTED,
|
||||
CONF_TEXT,
|
||||
)
|
||||
from ..helpers import lvgl_components_required
|
||||
from ..lv_validation import key_code, lv_bool
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from ..defines import CONF_INDICATOR, CONF_MAIN, CONF_TEXT
|
||||
from esphome.const import CONF_TEXT
|
||||
|
||||
from ..defines import CONF_INDICATOR, CONF_MAIN
|
||||
from ..lv_validation import lv_text
|
||||
from ..lvcode import lv
|
||||
from ..schemas import TEXT_SCHEMA
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from esphome.components.key_provider import KeyProvider
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_MODE
|
||||
from esphome.const import CONF_ITEMS, CONF_MODE
|
||||
from esphome.cpp_types import std_string
|
||||
|
||||
from ..defines import CONF_ITEMS, CONF_MAIN, KEYBOARD_MODES, literal
|
||||
from ..defines import CONF_MAIN, KEYBOARD_MODES, literal
|
||||
from ..helpers import add_lv_use, lvgl_components_required
|
||||
from ..types import LvCompound, LvType
|
||||
from . import Widget, WidgetType, get_widgets
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_TEXT
|
||||
|
||||
from ..defines import (
|
||||
CONF_LONG_MODE,
|
||||
|
@ -6,7 +7,6 @@ from ..defines import (
|
|||
CONF_RECOLOR,
|
||||
CONF_SCROLLBAR,
|
||||
CONF_SELECTED,
|
||||
CONF_TEXT,
|
||||
LV_LONG_MODES,
|
||||
)
|
||||
from ..lv_validation import lv_bool, lv_text
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from esphome import config_validation as cv
|
||||
from esphome.const import CONF_BUTTON, CONF_ID
|
||||
from esphome.const import CONF_BUTTON, CONF_ID, CONF_TEXT
|
||||
from esphome.core import ID
|
||||
from esphome.cpp_generator import new_Pvariable, static_const_array
|
||||
from esphome.cpp_types import nullptr
|
||||
|
@ -9,7 +9,6 @@ from ..defines import (
|
|||
CONF_BUTTONS,
|
||||
CONF_CLOSE_BUTTON,
|
||||
CONF_MSGBOXES,
|
||||
CONF_TEXT,
|
||||
CONF_TITLE,
|
||||
TYPE_FLEX,
|
||||
literal,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_MAX_LENGTH
|
||||
from esphome.const import CONF_MAX_LENGTH, CONF_TEXT
|
||||
|
||||
from ..defines import (
|
||||
CONF_ACCEPTED_CHARS,
|
||||
|
@ -10,7 +10,6 @@ from ..defines import (
|
|||
CONF_PLACEHOLDER_TEXT,
|
||||
CONF_SCROLLBAR,
|
||||
CONF_SELECTED,
|
||||
CONF_TEXT,
|
||||
CONF_TEXTAREA_PLACEHOLDER,
|
||||
)
|
||||
from ..lv_validation import lv_bool, lv_int, lv_text
|
||||
|
|
|
@ -308,6 +308,7 @@ CONF_FLASH_LENGTH = "flash_length"
|
|||
CONF_FLASH_TRANSITION_LENGTH = "flash_transition_length"
|
||||
CONF_FLOW = "flow"
|
||||
CONF_FLOW_CONTROL_PIN = "flow_control_pin"
|
||||
CONF_FONT = "font"
|
||||
CONF_FOR = "for"
|
||||
CONF_FORCE_UPDATE = "force_update"
|
||||
CONF_FOREGROUND_COLOR = "foreground_color"
|
||||
|
@ -407,6 +408,7 @@ CONF_INVERTED = "inverted"
|
|||
CONF_IP_ADDRESS = "ip_address"
|
||||
CONF_IRQ_PIN = "irq_pin"
|
||||
CONF_IS_RGBW = "is_rgbw"
|
||||
CONF_ITEMS = "items"
|
||||
CONF_JS_INCLUDE = "js_include"
|
||||
CONF_JS_URL = "js_url"
|
||||
CONF_JVC = "jvc"
|
||||
|
@ -841,6 +843,7 @@ CONF_TEMPERATURE = "temperature"
|
|||
CONF_TEMPERATURE_OFFSET = "temperature_offset"
|
||||
CONF_TEMPERATURE_SOURCE = "temperature_source"
|
||||
CONF_TEMPERATURE_STEP = "temperature_step"
|
||||
CONF_TEXT = "text"
|
||||
CONF_TEXT_SENSORS = "text_sensors"
|
||||
CONF_THEN = "then"
|
||||
CONF_THRESHOLD = "threshold"
|
||||
|
|
|
@ -62,24 +62,6 @@ class GPIOPin {
|
|||
virtual bool is_internal() { return false; }
|
||||
};
|
||||
|
||||
/**
|
||||
* A pin to replace those that don't exist.
|
||||
*/
|
||||
class NullPin : public GPIOPin {
|
||||
public:
|
||||
void setup() override {}
|
||||
|
||||
void pin_mode(gpio::Flags _) override {}
|
||||
|
||||
bool digital_read() override { return false; }
|
||||
|
||||
void digital_write(bool _) override {}
|
||||
|
||||
std::string dump_summary() const override { return {"Not used"}; }
|
||||
};
|
||||
|
||||
static GPIOPin *const NULL_PIN = new NullPin();
|
||||
|
||||
/// Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
|
||||
class ISRInternalGPIOPin {
|
||||
public:
|
||||
|
|
|
@ -24,6 +24,33 @@ display:
|
|||
invert_colors: false
|
||||
update_interval: never
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
internal: true
|
||||
id: up_button
|
||||
pin:
|
||||
number: GPIO38
|
||||
inverted: true
|
||||
- platform: gpio
|
||||
internal: true
|
||||
id: down_button
|
||||
pin:
|
||||
number: GPIO37
|
||||
inverted: true
|
||||
- platform: gpio
|
||||
internal: true
|
||||
id: select_button
|
||||
pin:
|
||||
number: GPIO39
|
||||
inverted: true
|
||||
lvgl:
|
||||
encoders:
|
||||
group: switches
|
||||
enter_button: select_button
|
||||
sensor:
|
||||
left_button: up_button
|
||||
right_button: down_button
|
||||
|
||||
packages:
|
||||
lvgl: !include lvgl-package.yaml
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ lvgl:
|
|||
displays:
|
||||
- tft_display
|
||||
- second_display
|
||||
rotary_encoders:
|
||||
encoders:
|
||||
sensor: encoder
|
||||
enter_button: pushbutton
|
||||
group: general
|
||||
|
|
Loading…
Reference in a new issue