mirror of
https://github.com/esphome/esphome.git
synced 2025-11-02 08:01:50 +00:00
Compare commits
20 Commits
jesserockz
...
2025.4.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bb899bfa1 | ||
|
|
cae3c030d2 | ||
|
|
d7c615ec43 | ||
|
|
1294e8ccd5 | ||
|
|
37a2cb07d1 | ||
|
|
2af3994f79 | ||
|
|
0c0fe81814 | ||
|
|
82c8614315 | ||
|
|
a85dc65038 | ||
|
|
290b8bdca0 | ||
|
|
a96ed0b70a | ||
|
|
5baa034d0d | ||
|
|
7900660bb8 | ||
|
|
f096567ac7 | ||
|
|
5bfb5ccc34 | ||
|
|
1c60038111 | ||
|
|
b940db6549 | ||
|
|
aa6e172e14 | ||
|
|
86033b6612 | ||
|
|
59b4a1f554 |
@@ -1,10 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/as3935/as3935.h"
|
||||
#include "esphome/components/i2c/i2c.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace as3935_i2c {
|
||||
|
||||
@@ -265,6 +265,12 @@ void BluetoothProxy::bluetooth_device_request(const api::BluetoothDeviceRequest
|
||||
connection->get_connection_index(), connection->address_str().c_str());
|
||||
return;
|
||||
} else if (connection->state() == espbt::ClientState::CONNECTING) {
|
||||
if (connection->disconnect_pending()) {
|
||||
ESP_LOGW(TAG, "[%d] [%s] Connection request while pending disconnect, cancelling pending disconnect",
|
||||
connection->get_connection_index(), connection->address_str().c_str());
|
||||
connection->cancel_pending_disconnect();
|
||||
return;
|
||||
}
|
||||
ESP_LOGW(TAG, "[%d] [%s] Connection request ignored, already connecting", connection->get_connection_index(),
|
||||
connection->address_str().c_str());
|
||||
return;
|
||||
|
||||
@@ -69,21 +69,16 @@ bool Rect::inside(int16_t test_x, int16_t test_y, bool absolute) const { // NOL
|
||||
return true;
|
||||
}
|
||||
if (absolute) {
|
||||
return ((test_x >= this->x) && (test_x <= this->x2()) && (test_y >= this->y) && (test_y <= this->y2()));
|
||||
} else {
|
||||
return ((test_x >= 0) && (test_x <= this->w) && (test_y >= 0) && (test_y <= this->h));
|
||||
return test_x >= this->x && test_x < this->x2() && test_y >= this->y && test_y < this->y2();
|
||||
}
|
||||
return test_x >= 0 && test_x < this->w && test_y >= 0 && test_y < this->h;
|
||||
}
|
||||
|
||||
bool Rect::inside(Rect rect, bool absolute) const {
|
||||
bool Rect::inside(Rect rect) const {
|
||||
if (!this->is_set() || !rect.is_set()) {
|
||||
return true;
|
||||
}
|
||||
if (absolute) {
|
||||
return ((rect.x <= this->x2()) && (rect.x2() >= this->x) && (rect.y <= this->y2()) && (rect.y2() >= this->y));
|
||||
} else {
|
||||
return ((rect.x <= this->w) && (rect.w >= 0) && (rect.y <= this->h) && (rect.h >= 0));
|
||||
}
|
||||
return this->x2() >= rect.x && this->x <= rect.x2() && this->y2() >= rect.y && this->y <= rect.y2();
|
||||
}
|
||||
|
||||
void Rect::info(const std::string &prefix) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class Rect {
|
||||
void extend(Rect rect);
|
||||
void shrink(Rect rect);
|
||||
|
||||
bool inside(Rect rect, bool absolute = true) const;
|
||||
bool inside(Rect rect) const;
|
||||
bool inside(int16_t test_x, int16_t test_y, bool absolute = true) const;
|
||||
bool equal(Rect rect) const;
|
||||
void info(const std::string &prefix = "rect info:");
|
||||
|
||||
@@ -187,7 +187,7 @@ void ENS160Component::update() {
|
||||
}
|
||||
return;
|
||||
case INVALID_OUTPUT:
|
||||
ESP_LOGE(TAG, "ENS160 Invalid Status - No Invalid Output");
|
||||
ESP_LOGE(TAG, "ENS160 Invalid Status - No valid output");
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
#include "ble.h"
|
||||
|
||||
#ifdef USE_ESP32_VARIANT_ESP32C6
|
||||
#include "const_esp32c6.h"
|
||||
#endif // USE_ESP32_VARIANT_ESP32C6
|
||||
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
@@ -127,11 +123,7 @@ bool ESP32BLE::ble_setup_() {
|
||||
if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
// start bt controller
|
||||
if (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
#ifdef USE_ESP32_VARIANT_ESP32C6
|
||||
esp_bt_controller_config_t cfg = BT_CONTROLLER_CONFIG;
|
||||
#else
|
||||
esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||
#endif
|
||||
err = esp_bt_controller_init(&cfg);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_bt_controller_init failed: %s", esp_err_to_name(err));
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_ESP32_VARIANT_ESP32C6
|
||||
|
||||
#include <esp_bt.h>
|
||||
|
||||
namespace esphome {
|
||||
namespace esp32_ble {
|
||||
|
||||
static const esp_bt_controller_config_t BT_CONTROLLER_CONFIG = {
|
||||
.config_version = CONFIG_VERSION,
|
||||
.ble_ll_resolv_list_size = CONFIG_BT_LE_LL_RESOLV_LIST_SIZE,
|
||||
.ble_hci_evt_hi_buf_count = DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT,
|
||||
.ble_hci_evt_lo_buf_count = DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT,
|
||||
.ble_ll_sync_list_cnt = DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST,
|
||||
.ble_ll_sync_cnt = DEFAULT_BT_LE_MAX_PERIODIC_SYNCS,
|
||||
.ble_ll_rsp_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT,
|
||||
.ble_ll_adv_dup_list_count = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT,
|
||||
.ble_ll_tx_pwr_dbm = BLE_LL_TX_PWR_DBM_N,
|
||||
.rtc_freq = RTC_FREQ_N,
|
||||
.ble_ll_sca = CONFIG_BT_LE_LL_SCA,
|
||||
.ble_ll_scan_phy_number = BLE_LL_SCAN_PHY_NUMBER_N,
|
||||
.ble_ll_conn_def_auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N,
|
||||
.ble_ll_jitter_usecs = BLE_LL_JITTER_USECS_N,
|
||||
.ble_ll_sched_max_adv_pdu_usecs = BLE_LL_SCHED_MAX_ADV_PDU_USECS_N,
|
||||
.ble_ll_sched_direct_adv_max_usecs = BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N,
|
||||
.ble_ll_sched_adv_max_usecs = BLE_LL_SCHED_ADV_MAX_USECS_N,
|
||||
.ble_scan_rsp_data_max_len = DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N,
|
||||
.ble_ll_cfg_num_hci_cmd_pkts = BLE_LL_CFG_NUM_HCI_CMD_PKTS_N,
|
||||
.ble_ll_ctrl_proc_timeout_ms = BLE_LL_CTRL_PROC_TIMEOUT_MS_N,
|
||||
.nimble_max_connections = DEFAULT_BT_LE_MAX_CONNECTIONS,
|
||||
.ble_whitelist_size = DEFAULT_BT_NIMBLE_WHITELIST_SIZE, // NOLINT
|
||||
.ble_acl_buf_size = DEFAULT_BT_LE_ACL_BUF_SIZE,
|
||||
.ble_acl_buf_count = DEFAULT_BT_LE_ACL_BUF_COUNT,
|
||||
.ble_hci_evt_buf_size = DEFAULT_BT_LE_HCI_EVT_BUF_SIZE,
|
||||
.ble_multi_adv_instances = DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES,
|
||||
.ble_ext_adv_max_size = DEFAULT_BT_LE_EXT_ADV_MAX_SIZE,
|
||||
.controller_task_stack_size = NIMBLE_LL_STACK_SIZE,
|
||||
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO,
|
||||
.controller_run_cpu = 0,
|
||||
.enable_qa_test = RUN_QA_TEST,
|
||||
.enable_bqb_test = RUN_BQB_TEST,
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 1)
|
||||
// The following fields have been removed since ESP IDF version 5.3.1, see commit:
|
||||
// https://github.com/espressif/esp-idf/commit/e761c1de8f9c0777829d597b4d5a33bb070a30a8
|
||||
.enable_uart_hci = HCI_UART_EN,
|
||||
.ble_hci_uart_port = DEFAULT_BT_LE_HCI_UART_PORT,
|
||||
.ble_hci_uart_baud = DEFAULT_BT_LE_HCI_UART_BAUD,
|
||||
.ble_hci_uart_data_bits = DEFAULT_BT_LE_HCI_UART_DATA_BITS,
|
||||
.ble_hci_uart_stop_bits = DEFAULT_BT_LE_HCI_UART_STOP_BITS,
|
||||
.ble_hci_uart_flow_ctrl = DEFAULT_BT_LE_HCI_UART_FLOW_CTRL,
|
||||
.ble_hci_uart_uart_parity = DEFAULT_BT_LE_HCI_UART_PARITY,
|
||||
#endif
|
||||
.enable_tx_cca = DEFAULT_BT_LE_TX_CCA_ENABLED,
|
||||
.cca_rssi_thresh = 256 - DEFAULT_BT_LE_CCA_RSSI_THRESH,
|
||||
.sleep_en = NIMBLE_SLEEP_ENABLE,
|
||||
.coex_phy_coded_tx_rx_time_limit = DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF,
|
||||
.dis_scan_backoff = NIMBLE_DISABLE_SCAN_BACKOFF,
|
||||
.ble_scan_classify_filter_enable = 1,
|
||||
.main_xtal_freq = CONFIG_XTAL_FREQ,
|
||||
.version_num = (uint8_t) efuse_hal_chip_revision(),
|
||||
.cpu_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ,
|
||||
.ignore_wl_for_direct_adv = 0,
|
||||
.enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED,
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 3)
|
||||
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT,
|
||||
#endif
|
||||
.config_magic = CONFIG_MAGIC,
|
||||
};
|
||||
|
||||
} // namespace esp32_ble
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_ESP32_VARIANT_ESP32C6
|
||||
@@ -173,6 +173,8 @@ class ESPBTClient : public ESPBTDeviceListener {
|
||||
virtual void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) = 0;
|
||||
virtual void connect() = 0;
|
||||
virtual void disconnect() = 0;
|
||||
bool disconnect_pending() const { return this->want_disconnect_; }
|
||||
void cancel_pending_disconnect() { this->want_disconnect_ = false; }
|
||||
virtual void set_state(ClientState st) {
|
||||
this->state_ = st;
|
||||
if (st == ClientState::IDLE) {
|
||||
|
||||
@@ -69,7 +69,7 @@ void HLW8012Component::update() {
|
||||
|
||||
float power = cf_hz * this->power_multiplier_;
|
||||
|
||||
if (this->change_mode_at_ != 0) {
|
||||
if (this->change_mode_at_ != 0 || this->change_mode_every_ == 0) {
|
||||
// Only read cf1 after one cycle. Apparently it's quite unstable after being changed.
|
||||
if (this->current_mode_) {
|
||||
float current = cf1_hz * this->current_multiplier_;
|
||||
|
||||
@@ -16,7 +16,7 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.core import CORE, ID, Lambda
|
||||
from esphome.cpp_generator import MockObj
|
||||
from esphome.cpp_types import ESPTime, uint32
|
||||
from esphome.cpp_types import ESPTime, int32, uint32
|
||||
from esphome.helpers import cpp_string_escape
|
||||
from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor
|
||||
|
||||
@@ -263,6 +263,15 @@ def pixels_validator(value):
|
||||
pixels = LValidator(pixels_validator, uint32, retmapper=literal)
|
||||
|
||||
|
||||
def padding_validator(value):
|
||||
if isinstance(value, str) and value.lower().endswith("px"):
|
||||
value = value[:-2]
|
||||
return cv.int_(value)
|
||||
|
||||
|
||||
padding = LValidator(padding_validator, int32, retmapper=literal)
|
||||
|
||||
|
||||
def zoom_validator(value):
|
||||
value = cv.float_range(0.1, 10.0)(value)
|
||||
return value
|
||||
|
||||
@@ -120,6 +120,7 @@ void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_ev
|
||||
void LvglComponent::add_page(LvPageType *page) {
|
||||
this->pages_.push_back(page);
|
||||
page->set_parent(this);
|
||||
lv_disp_set_default(this->disp_);
|
||||
page->setup(this->pages_.size() - 1);
|
||||
}
|
||||
void LvglComponent::show_page(size_t index, lv_scr_load_anim_t anim, uint32_t time) {
|
||||
|
||||
@@ -156,13 +156,13 @@ STYLE_PROPS = {
|
||||
"opa_layered": lvalid.opacity,
|
||||
"outline_color": lvalid.lv_color,
|
||||
"outline_opa": lvalid.opacity,
|
||||
"outline_pad": lvalid.pixels,
|
||||
"outline_pad": lvalid.padding,
|
||||
"outline_width": lvalid.pixels,
|
||||
"pad_all": lvalid.pixels,
|
||||
"pad_bottom": lvalid.pixels,
|
||||
"pad_left": lvalid.pixels,
|
||||
"pad_right": lvalid.pixels,
|
||||
"pad_top": lvalid.pixels,
|
||||
"pad_all": lvalid.padding,
|
||||
"pad_bottom": lvalid.padding,
|
||||
"pad_left": lvalid.padding,
|
||||
"pad_right": lvalid.padding,
|
||||
"pad_top": lvalid.padding,
|
||||
"shadow_color": lvalid.lv_color,
|
||||
"shadow_ofs_x": lvalid.lv_int,
|
||||
"shadow_ofs_y": lvalid.lv_int,
|
||||
@@ -226,8 +226,8 @@ FULL_STYLE_SCHEMA = STYLE_SCHEMA.extend(
|
||||
{
|
||||
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,
|
||||
cv.Optional(df.CONF_PAD_ROW): lvalid.padding,
|
||||
cv.Optional(df.CONF_PAD_COLUMN): lvalid.padding,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -370,8 +370,8 @@ LAYOUT_SCHEMA = {
|
||||
cv.Required(df.CONF_GRID_COLUMNS): [grid_spec],
|
||||
cv.Optional(df.CONF_GRID_COLUMN_ALIGN): grid_alignments,
|
||||
cv.Optional(df.CONF_GRID_ROW_ALIGN): grid_alignments,
|
||||
cv.Optional(df.CONF_PAD_ROW): lvalid.pixels,
|
||||
cv.Optional(df.CONF_PAD_COLUMN): lvalid.pixels,
|
||||
cv.Optional(df.CONF_PAD_ROW): lvalid.padding,
|
||||
cv.Optional(df.CONF_PAD_COLUMN): lvalid.padding,
|
||||
},
|
||||
df.TYPE_FLEX: {
|
||||
cv.Optional(
|
||||
@@ -380,8 +380,8 @@ LAYOUT_SCHEMA = {
|
||||
cv.Optional(df.CONF_FLEX_ALIGN_MAIN, default="start"): flex_alignments,
|
||||
cv.Optional(df.CONF_FLEX_ALIGN_CROSS, default="start"): flex_alignments,
|
||||
cv.Optional(df.CONF_FLEX_ALIGN_TRACK, default="start"): flex_alignments,
|
||||
cv.Optional(df.CONF_PAD_ROW): lvalid.pixels,
|
||||
cv.Optional(df.CONF_PAD_COLUMN): lvalid.pixels,
|
||||
cv.Optional(df.CONF_PAD_ROW): lvalid.padding,
|
||||
cv.Optional(df.CONF_PAD_COLUMN): lvalid.padding,
|
||||
},
|
||||
},
|
||||
lower=True,
|
||||
@@ -427,8 +427,8 @@ 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,
|
||||
cv.Optional(df.CONF_PAD_ROW): lvalid.padding,
|
||||
cv.Optional(df.CONF_PAD_COLUMN): lvalid.padding,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -67,12 +67,13 @@ class ArcType(NumberType):
|
||||
lv.arc_set_mode(w.obj, literal(config[CONF_MODE]))
|
||||
lv.arc_set_change_rate(w.obj, config[CONF_CHANGE_RATE])
|
||||
|
||||
if config.get(CONF_ADJUSTABLE) is False:
|
||||
lv_obj.remove_style(w.obj, nullptr, literal("LV_PART_KNOB"))
|
||||
w.clear_flag("LV_OBJ_FLAG_CLICKABLE")
|
||||
elif CONF_GROUP not in config:
|
||||
# For some reason arc does not get automatically added to the default group
|
||||
lv.group_add_obj(lv_expr.group_get_default(), w.obj)
|
||||
if CONF_ADJUSTABLE in config:
|
||||
if not config[CONF_ADJUSTABLE]:
|
||||
lv_obj.remove_style(w.obj, nullptr, literal("LV_PART_KNOB"))
|
||||
w.clear_flag("LV_OBJ_FLAG_CLICKABLE")
|
||||
elif CONF_GROUP not in config:
|
||||
# For some reason arc does not get automatically added to the default group
|
||||
lv.group_add_obj(lv_expr.group_get_default(), w.obj)
|
||||
|
||||
value = await get_start_value(config)
|
||||
if value is not None:
|
||||
|
||||
@@ -19,7 +19,7 @@ from ..defines import (
|
||||
CONF_SELECTED,
|
||||
)
|
||||
from ..helpers import lvgl_components_required
|
||||
from ..lv_validation import key_code, lv_bool, pixels
|
||||
from ..lv_validation import key_code, lv_bool, padding
|
||||
from ..lvcode import lv, lv_add, lv_expr
|
||||
from ..schemas import automation_schema
|
||||
from ..types import (
|
||||
@@ -59,8 +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.Optional(CONF_PAD_ROW): padding,
|
||||
cv.Optional(CONF_PAD_COLUMN): padding,
|
||||
cv.GenerateID(CONF_BUTTON_TEXT_LIST_ID): cv.declare_id(char_ptr),
|
||||
cv.Required(CONF_ROWS): cv.ensure_list(
|
||||
cv.Schema(
|
||||
|
||||
@@ -2,7 +2,7 @@ from esphome.config_validation import Optional
|
||||
from esphome.const import CONF_TEXT
|
||||
|
||||
from ..defines import CONF_INDICATOR, CONF_MAIN, CONF_PAD_COLUMN
|
||||
from ..lv_validation import lv_text, pixels
|
||||
from ..lv_validation import lv_text, padding
|
||||
from ..lvcode import lv
|
||||
from ..schemas import TEXT_SCHEMA
|
||||
from ..types import LvBoolean
|
||||
@@ -19,7 +19,7 @@ class CheckboxType(WidgetType):
|
||||
(CONF_MAIN, CONF_INDICATOR),
|
||||
TEXT_SCHEMA.extend(
|
||||
{
|
||||
Optional(CONF_PAD_COLUMN): pixels,
|
||||
Optional(CONF_PAD_COLUMN): padding,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
@@ -36,7 +36,6 @@ DROPDOWN_BASE_SCHEMA = cv.Schema(
|
||||
cv.Optional(CONF_SYMBOL): lv_text,
|
||||
cv.Exclusive(CONF_SELECTED_INDEX, CONF_SELECTED_TEXT): lv_int,
|
||||
cv.Exclusive(CONF_SELECTED_TEXT, CONF_SELECTED_TEXT): lv_text,
|
||||
cv.Optional(CONF_DIR, default="BOTTOM"): DIRECTIONS.one_of,
|
||||
cv.Optional(CONF_DROPDOWN_LIST): part_schema(dropdown_list_spec.parts),
|
||||
}
|
||||
)
|
||||
@@ -44,12 +43,14 @@ DROPDOWN_BASE_SCHEMA = cv.Schema(
|
||||
DROPDOWN_SCHEMA = DROPDOWN_BASE_SCHEMA.extend(
|
||||
{
|
||||
cv.Required(CONF_OPTIONS): cv.ensure_list(option_string),
|
||||
cv.Optional(CONF_DIR, default="BOTTOM"): DIRECTIONS.one_of,
|
||||
}
|
||||
)
|
||||
|
||||
DROPDOWN_UPDATE_SCHEMA = DROPDOWN_BASE_SCHEMA.extend(
|
||||
{
|
||||
cv.Optional(CONF_OPTIONS): cv.ensure_list(option_string),
|
||||
cv.Optional(CONF_DIR): DIRECTIONS.one_of,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from ..defines import (
|
||||
CONF_ZOOM,
|
||||
LvConstant,
|
||||
)
|
||||
from ..lv_validation import angle, lv_bool, lv_image, size, zoom
|
||||
from ..lv_validation import lv_angle, lv_bool, lv_image, size, zoom
|
||||
from ..lvcode import lv
|
||||
from ..types import lv_img_t
|
||||
from . import Widget, WidgetType
|
||||
@@ -20,9 +20,9 @@ CONF_IMAGE = "image"
|
||||
|
||||
BASE_IMG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Optional(CONF_PIVOT_X, default="50%"): size,
|
||||
cv.Optional(CONF_PIVOT_Y, default="50%"): size,
|
||||
cv.Optional(CONF_ANGLE): angle,
|
||||
cv.Optional(CONF_PIVOT_X): size,
|
||||
cv.Optional(CONF_PIVOT_Y): size,
|
||||
cv.Optional(CONF_ANGLE): lv_angle,
|
||||
cv.Optional(CONF_ZOOM): zoom,
|
||||
cv.Optional(CONF_OFFSET_X): size,
|
||||
cv.Optional(CONF_OFFSET_Y): size,
|
||||
@@ -63,19 +63,22 @@ class ImgType(WidgetType):
|
||||
async def to_code(self, w: Widget, config):
|
||||
if src := config.get(CONF_SRC):
|
||||
lv.img_set_src(w.obj, await lv_image.process(src))
|
||||
if (pivot_x := config.get(CONF_PIVOT_X)) and (
|
||||
pivot_y := config.get(CONF_PIVOT_Y)
|
||||
):
|
||||
lv.img_set_pivot(
|
||||
w.obj, await size.process(pivot_x), await size.process(pivot_y)
|
||||
)
|
||||
if (cf_angle := config.get(CONF_ANGLE)) is not None:
|
||||
pivot_x = config[CONF_PIVOT_X]
|
||||
pivot_y = config[CONF_PIVOT_Y]
|
||||
lv.img_set_pivot(w.obj, pivot_x, pivot_y)
|
||||
lv.img_set_angle(w.obj, cf_angle)
|
||||
lv.img_set_angle(w.obj, await lv_angle.process(cf_angle))
|
||||
if (img_zoom := config.get(CONF_ZOOM)) is not None:
|
||||
lv.img_set_zoom(w.obj, img_zoom)
|
||||
lv.img_set_zoom(w.obj, await zoom.process(img_zoom))
|
||||
if (offset := config.get(CONF_OFFSET_X)) is not None:
|
||||
lv.img_set_offset_x(w.obj, offset)
|
||||
lv.img_set_offset_x(w.obj, await size.process(offset))
|
||||
if (offset := config.get(CONF_OFFSET_Y)) is not None:
|
||||
lv.img_set_offset_y(w.obj, offset)
|
||||
lv.img_set_offset_y(w.obj, await size.process(offset))
|
||||
if CONF_ANTIALIAS in config:
|
||||
lv.img_set_antialias(w.obj, config[CONF_ANTIALIAS])
|
||||
lv.img_set_antialias(w.obj, await lv_bool.process(config[CONF_ANTIALIAS]))
|
||||
if mode := config.get(CONF_MODE):
|
||||
await w.set_property("size_mode", mode)
|
||||
|
||||
|
||||
@@ -134,11 +134,13 @@ MEDIA_PLAYER_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(
|
||||
)
|
||||
|
||||
|
||||
MEDIA_PLAYER_ACTION_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.use_id(MediaPlayer),
|
||||
cv.Optional(CONF_ANNOUNCEMENT, default=False): cv.templatable(cv.boolean),
|
||||
}
|
||||
MEDIA_PLAYER_ACTION_SCHEMA = automation.maybe_simple_id(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.use_id(MediaPlayer),
|
||||
cv.Optional(CONF_ANNOUNCEMENT, default=False): cv.templatable(cv.boolean),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
MEDIA_PLAYER_CONDITION_SCHEMA = automation.maybe_simple_id(
|
||||
|
||||
@@ -111,7 +111,7 @@ void OnlineImage::update() {
|
||||
case ImageFormat::BMP:
|
||||
accept_mime_type = "image/bmp";
|
||||
break;
|
||||
#endif // ONLINE_IMAGE_BMP_SUPPORT
|
||||
#endif // USE_ONLINE_IMAGE_BMP_SUPPORT
|
||||
#ifdef USE_ONLINE_IMAGE_JPEG_SUPPORT
|
||||
case ImageFormat::JPEG:
|
||||
accept_mime_type = "image/jpeg";
|
||||
@@ -121,7 +121,7 @@ void OnlineImage::update() {
|
||||
case ImageFormat::PNG:
|
||||
accept_mime_type = "image/png";
|
||||
break;
|
||||
#endif // ONLINE_IMAGE_PNG_SUPPORT
|
||||
#endif // USE_ONLINE_IMAGE_PNG_SUPPORT
|
||||
default:
|
||||
accept_mime_type = "image/*";
|
||||
}
|
||||
@@ -159,7 +159,7 @@ void OnlineImage::update() {
|
||||
ESP_LOGD(TAG, "Allocating BMP decoder");
|
||||
this->decoder_ = make_unique<BmpDecoder>(this);
|
||||
}
|
||||
#endif // ONLINE_IMAGE_BMP_SUPPORT
|
||||
#endif // USE_ONLINE_IMAGE_BMP_SUPPORT
|
||||
#ifdef USE_ONLINE_IMAGE_JPEG_SUPPORT
|
||||
if (this->format_ == ImageFormat::JPEG) {
|
||||
ESP_LOGD(TAG, "Allocating JPEG decoder");
|
||||
@@ -171,7 +171,7 @@ void OnlineImage::update() {
|
||||
ESP_LOGD(TAG, "Allocating PNG decoder");
|
||||
this->decoder_ = make_unique<PngDecoder>(this);
|
||||
}
|
||||
#endif // ONLINE_IMAGE_PNG_SUPPORT
|
||||
#endif // USE_ONLINE_IMAGE_PNG_SUPPORT
|
||||
|
||||
if (!this->decoder_) {
|
||||
ESP_LOGE(TAG, "Could not instantiate decoder. Image format unsupported: %d", this->format_);
|
||||
@@ -185,7 +185,7 @@ void OnlineImage::update() {
|
||||
this->download_error_callback_.call();
|
||||
return;
|
||||
}
|
||||
ESP_LOGI(TAG, "Downloading image (Size: %d)", total_size);
|
||||
ESP_LOGI(TAG, "Downloading image (Size: %zu)", total_size);
|
||||
this->start_time_ = ::time(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
#ifdef USE_ESP32
|
||||
#include "psram.h"
|
||||
#ifdef USE_ESP_IDF
|
||||
#include <esp_idf_version.h>
|
||||
#if defined(USE_ESP_IDF) && ESP_IDF_VERSION_MAJOR >= 5
|
||||
#include <esp_psram.h>
|
||||
#endif // USE_ESP_IDF
|
||||
|
||||
@@ -15,7 +16,7 @@ static const char *const TAG = "psram";
|
||||
|
||||
void PsramComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "PSRAM:");
|
||||
#ifdef USE_ESP_IDF
|
||||
#if defined(USE_ESP_IDF) && ESP_IDF_VERSION_MAJOR >= 5
|
||||
bool available = esp_psram_is_initialized();
|
||||
|
||||
ESP_LOGCONFIG(TAG, " Available: %s", YESNO(available));
|
||||
|
||||
@@ -68,7 +68,7 @@ void TT21100Touchscreen::setup() {
|
||||
this->x_raw_max_ = this->display_->get_native_width();
|
||||
}
|
||||
if (this->y_raw_max_ == this->y_raw_min_) {
|
||||
this->x_raw_max_ = this->display_->get_native_height();
|
||||
this->y_raw_max_ = this->display_->get_native_height();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cinttypes>
|
||||
#include <cstdint>
|
||||
#ifdef USE_ESP32
|
||||
#include <soc/soc_caps.h>
|
||||
#include "esp_idf_version.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#endif
|
||||
@@ -40,7 +41,7 @@ void WatchdogManager::set_timeout_(uint32_t timeout_ms) {
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
esp_task_wdt_config_t wdt_config = {
|
||||
.timeout_ms = timeout_ms,
|
||||
.idle_core_mask = 0x03,
|
||||
.idle_core_mask = (1 << SOC_CPU_CORES_NUM) - 1,
|
||||
.trigger_panic = true,
|
||||
};
|
||||
esp_task_wdt_reconfigure(&wdt_config);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2025.4.0"
|
||||
__version__ = "2025.4.2"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
|
||||
@@ -74,13 +74,14 @@ def setup_log(
|
||||
|
||||
colorama.init()
|
||||
|
||||
if log_level == logging.DEBUG:
|
||||
CORE.verbose = True
|
||||
elif log_level == logging.CRITICAL:
|
||||
CORE.quiet = True
|
||||
|
||||
# Setup logging - will map log level from string to constant
|
||||
logging.basicConfig(level=log_level)
|
||||
|
||||
if logging.root.level == logging.DEBUG:
|
||||
CORE.verbose = True
|
||||
elif logging.root.level == logging.CRITICAL:
|
||||
CORE.quiet = True
|
||||
|
||||
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
||||
|
||||
logging.getLogger().handlers[0].setFormatter(
|
||||
|
||||
@@ -3,4 +3,9 @@ substitutions:
|
||||
sda_pin: GPIO17
|
||||
irq_pin: GPIO15
|
||||
|
||||
<<: !include common.yaml
|
||||
packages:
|
||||
as3935: !include common.yaml
|
||||
|
||||
# Trigger issue: https://github.com/esphome/issues/issues/6990
|
||||
# Compile with no binary sensor results in error
|
||||
binary_sensor: !remove
|
||||
|
||||
@@ -134,6 +134,15 @@ lvgl:
|
||||
id: style_test
|
||||
bg_color: blue
|
||||
bg_opa: !lambda return 0.5;
|
||||
- lvgl.image.update:
|
||||
id: lv_image
|
||||
zoom: !lambda return 512;
|
||||
angle: !lambda return 100;
|
||||
pivot_x: !lambda return 20;
|
||||
pivot_y: !lambda return 20;
|
||||
offset_x: !lambda return 20;
|
||||
offset_y: !lambda return 20;
|
||||
antialias: !lambda return true;
|
||||
- id: simple_msgbox
|
||||
title: Simple
|
||||
|
||||
@@ -486,6 +495,8 @@ lvgl:
|
||||
align: top_left
|
||||
y: "50"
|
||||
mode: real
|
||||
zoom: 2.0
|
||||
angle: 45
|
||||
- tileview:
|
||||
id: tileview_id
|
||||
scrollbar_mode: active
|
||||
@@ -641,6 +652,8 @@ lvgl:
|
||||
knob:
|
||||
radius: 1
|
||||
width: "4"
|
||||
pad_left: -5
|
||||
pad_top: 5
|
||||
height: 10%
|
||||
bg_color: 0x000000
|
||||
width: 100%
|
||||
|
||||
Reference in New Issue
Block a user