Compare commits

...

2 Commits

Author SHA1 Message Date
J. Nick Koston
d4110bf650 [lock] Store state strings in flash and avoid heap allocation in set_state (#13729) 2026-02-03 05:29:24 +01:00
Andrew Gillis
ff6f7d3248 [mipi_dsi] Add WAVESHARE-ESP32-P4-WIFI6-TOUCH-LCD-7B (#13608) 2026-02-03 14:59:51 +11:00
3 changed files with 37 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#include "esphome/core/controller_registry.h" #include "esphome/core/controller_registry.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/progmem.h"
namespace esphome::lock { namespace esphome::lock {
@@ -84,21 +85,21 @@ LockCall &LockCall::set_state(optional<LockState> state) {
this->state_ = state; this->state_ = state;
return *this; return *this;
} }
LockCall &LockCall::set_state(const std::string &state) { LockCall &LockCall::set_state(const char *state) {
if (str_equals_case_insensitive(state, "LOCKED")) { if (ESPHOME_strcasecmp_P(state, ESPHOME_PSTR("LOCKED")) == 0) {
this->set_state(LOCK_STATE_LOCKED); this->set_state(LOCK_STATE_LOCKED);
} else if (str_equals_case_insensitive(state, "UNLOCKED")) { } else if (ESPHOME_strcasecmp_P(state, ESPHOME_PSTR("UNLOCKED")) == 0) {
this->set_state(LOCK_STATE_UNLOCKED); this->set_state(LOCK_STATE_UNLOCKED);
} else if (str_equals_case_insensitive(state, "JAMMED")) { } else if (ESPHOME_strcasecmp_P(state, ESPHOME_PSTR("JAMMED")) == 0) {
this->set_state(LOCK_STATE_JAMMED); this->set_state(LOCK_STATE_JAMMED);
} else if (str_equals_case_insensitive(state, "LOCKING")) { } else if (ESPHOME_strcasecmp_P(state, ESPHOME_PSTR("LOCKING")) == 0) {
this->set_state(LOCK_STATE_LOCKING); this->set_state(LOCK_STATE_LOCKING);
} else if (str_equals_case_insensitive(state, "UNLOCKING")) { } else if (ESPHOME_strcasecmp_P(state, ESPHOME_PSTR("UNLOCKING")) == 0) {
this->set_state(LOCK_STATE_UNLOCKING); this->set_state(LOCK_STATE_UNLOCKING);
} else if (str_equals_case_insensitive(state, "NONE")) { } else if (ESPHOME_strcasecmp_P(state, ESPHOME_PSTR("NONE")) == 0) {
this->set_state(LOCK_STATE_NONE); this->set_state(LOCK_STATE_NONE);
} else { } else {
ESP_LOGW(TAG, "'%s' - Unrecognized state %s", this->parent_->get_name().c_str(), state.c_str()); ESP_LOGW(TAG, "'%s' - Unrecognized state %s", this->parent_->get_name().c_str(), state);
} }
return *this; return *this;
} }

View File

@@ -83,7 +83,8 @@ class LockCall {
/// Set the state of the lock device. /// Set the state of the lock device.
LockCall &set_state(optional<LockState> state); LockCall &set_state(optional<LockState> state);
/// Set the state of the lock device based on a string. /// Set the state of the lock device based on a string.
LockCall &set_state(const std::string &state); LockCall &set_state(const char *state);
LockCall &set_state(const std::string &state) { return this->set_state(state.c_str()); }
void perform(); void perform();

View File

@@ -94,3 +94,29 @@ DriverChip(
(0x29, 0x00), (0x29, 0x00),
], ],
) )
DriverChip(
"WAVESHARE-ESP32-P4-WIFI6-TOUCH-LCD-7B",
height=600,
width=1024,
hsync_back_porch=160,
hsync_pulse_width=10,
hsync_front_porch=160,
vsync_back_porch=23,
vsync_pulse_width=1,
vsync_front_porch=12,
pclk_frequency="52MHz",
lane_bit_rate="900Mbps",
no_transform=True,
color_order="RGB",
initsequence=[
(0x80, 0x8B),
(0x81, 0x78),
(0x82, 0x84),
(0x83, 0x88),
(0x84, 0xA8),
(0x85, 0xE3),
(0x86, 0x88),
(0xB2, 0x10),
],
)