1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 06:33:51 +00:00

Merge branch 'dev' into multi_device

This commit is contained in:
J. Nick Koston
2025-05-31 10:27:31 -05:00
committed by GitHub
17 changed files with 147 additions and 28 deletions

View File

@@ -42,17 +42,17 @@ void MAX9611Component::setup() {
const uint8_t fast_mode_dat[] = {CONTROL_REGISTER_1_ADRR, MAX9611Multiplexer::MAX9611_MULTIPLEXER_FAST_MODE};
if (this->write(reinterpret_cast<const uint8_t *>(&setup_dat), sizeof(setup_dat)) != ErrorCode::ERROR_OK) {
ESP_LOGE(TAG, "Failed to setup Max9611 during GAIN SET");
ESP_LOGE(TAG, "GAIN SET failed");
return;
}
delay(SETUP_DELAY);
if (this->write(reinterpret_cast<const uint8_t *>(&fast_mode_dat), sizeof(fast_mode_dat)) != ErrorCode::ERROR_OK) {
ESP_LOGE(TAG, "Failed to setup Max9611 during FAST MODE SET");
ESP_LOGE(TAG, "FAST MODE SET failed");
return;
}
}
void MAX9611Component::dump_config() {
ESP_LOGCONFIG(TAG, "Dump Config max9611...");
ESP_LOGCONFIG(TAG, "MAX9611:");
ESP_LOGCONFIG(TAG, " CSA Gain Register: %x", gain_);
LOG_I2C_DEVICE(this);
}
@@ -63,7 +63,7 @@ void MAX9611Component::update() {
// Just read the entire register map in a bulk read, faster than individually querying register.
const ErrorCode read_result = this->read(register_map_, sizeof(register_map_));
if (write_result != ErrorCode::ERROR_OK || read_result != ErrorCode::ERROR_OK) {
ESP_LOGW(TAG, "MAX9611 Update FAILED!");
ESP_LOGW(TAG, "Update failed");
return;
}
uint16_t csa_register = ((register_map_[CSA_DATA_BYTE_MSB_ADRR] << 8) | (register_map_[CSA_DATA_BYTE_LSB_ADRR])) >> 4;

View File

@@ -1003,8 +1003,13 @@ uint16_t Nextion::recv_ret_string_(std::string &response, uint32_t timeout, bool
* @param variable_name Name for the queue
*/
void Nextion::add_no_result_to_queue_(const std::string &variable_name) {
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE);
nextion::NextionQueue *nextion_queue = allocator.allocate(1);
if (nextion_queue == nullptr) {
ESP_LOGW(TAG, "Failed to allocate NextionQueue");
return;
}
new (nextion_queue) nextion::NextionQueue();
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
nextion_queue->component = new nextion::NextionComponentBase;
@@ -1137,8 +1142,13 @@ void Nextion::add_to_get_queue(NextionComponentBase *component) {
if ((!this->is_setup() && !this->ignore_is_setup_))
return;
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE);
nextion::NextionQueue *nextion_queue = allocator.allocate(1);
if (nextion_queue == nullptr) {
ESP_LOGW(TAG, "Failed to allocate NextionQueue");
return;
}
new (nextion_queue) nextion::NextionQueue();
nextion_queue->component = component;
nextion_queue->queue_time = millis();
@@ -1165,8 +1175,13 @@ void Nextion::add_addt_command_to_queue(NextionComponentBase *component) {
if ((!this->is_setup() && !this->ignore_is_setup_) || this->is_sleeping())
return;
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE);
nextion::NextionQueue *nextion_queue = allocator.allocate(1);
if (nextion_queue == nullptr) {
ESP_LOGW(TAG, "Failed to allocate NextionQueue");
return;
}
new (nextion_queue) nextion::NextionQueue();
nextion_queue->component = component;
nextion_queue->queue_time = millis();

View File

@@ -8,7 +8,7 @@ namespace rp2040 {
static const char *const TAG = "rp2040";
static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) {
static int flags_to_mode(gpio::Flags flags, uint8_t pin) {
if (flags == gpio::FLAG_INPUT) { // NOLINT(bugprone-branch-clone)
return INPUT;
} else if (flags == gpio::FLAG_OUTPUT) {
@@ -25,14 +25,16 @@ static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) {
}
struct ISRPinArg {
uint32_t mask;
uint8_t pin;
bool inverted;
};
ISRInternalGPIOPin RP2040GPIOPin::to_isr() const {
auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory)
arg->pin = pin_;
arg->inverted = inverted_;
arg->pin = this->pin_;
arg->inverted = this->inverted_;
arg->mask = 1 << this->pin_;
return ISRInternalGPIOPin((void *) arg);
}
@@ -81,21 +83,36 @@ void RP2040GPIOPin::detach_interrupt() const { detachInterrupt(pin_); }
using namespace rp2040;
bool IRAM_ATTR ISRInternalGPIOPin::digital_read() {
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
return bool(digitalRead(arg->pin)) != arg->inverted; // NOLINT
auto *arg = reinterpret_cast<ISRPinArg *>(this->arg_);
return bool(sio_hw->gpio_in & arg->mask) != arg->inverted;
}
void IRAM_ATTR ISRInternalGPIOPin::digital_write(bool value) {
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
digitalWrite(arg->pin, value != arg->inverted ? 1 : 0); // NOLINT
auto *arg = reinterpret_cast<ISRPinArg *>(this->arg_);
if (value != arg->inverted) {
sio_hw->gpio_set = arg->mask;
} else {
sio_hw->gpio_clr = arg->mask;
}
}
void IRAM_ATTR ISRInternalGPIOPin::clear_interrupt() {
// TODO: implement
// auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
// GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1UL << arg->pin);
}
void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) {
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
pinMode(arg->pin, flags_to_mode(flags, arg->pin)); // NOLINT
auto *arg = reinterpret_cast<ISRPinArg *>(this->arg_);
if (flags & gpio::FLAG_OUTPUT) {
sio_hw->gpio_oe_set = arg->mask;
} else if (flags & gpio::FLAG_INPUT) {
sio_hw->gpio_oe_clr = arg->mask;
hw_write_masked(&padsbank0_hw->io[arg->pin],
(bool_to_bit(flags & gpio::FLAG_PULLUP) << PADS_BANK0_GPIO0_PUE_LSB) |
(bool_to_bit(flags & gpio::FLAG_PULLDOWN) << PADS_BANK0_GPIO0_PDE_LSB),
PADS_BANK0_GPIO0_PUE_BITS | PADS_BANK0_GPIO0_PDE_BITS);
}
}
} // namespace esphome

View File

@@ -16,6 +16,7 @@ CODEOWNERS = ["@DrCoolZic"]
AUTO_LOAD = ["uart"]
MULTI_CONF = True
CONF_DATA_BITS = "data_bits"
CONF_STOP_BITS = "stop_bits"
CONF_PARITY = "parity"
CONF_CRYSTAL = "crystal"
@@ -60,6 +61,7 @@ WKBASE_SCHEMA = cv.Schema(
cv.Required(CONF_ID): cv.declare_id(WeikaiChannel),
cv.Optional(CONF_CHANNEL, default=0): cv.int_range(min=0, max=3),
cv.Required(CONF_BAUD_RATE): cv.int_range(min=1),
cv.Optional(CONF_DATA_BITS, default=8): cv.one_of(8, int=True),
cv.Optional(CONF_STOP_BITS, default=1): cv.one_of(1, 2, int=True),
cv.Optional(CONF_PARITY, default="NONE"): cv.enum(
uart.UART_PARITY_OPTIONS, upper=True

View File

@@ -24,6 +24,11 @@
#define PROGMEM ICACHE_RODATA_ATTR
#endif
#elif defined(USE_RP2040)
#define IRAM_ATTR __attribute__((noinline, long_call, section(".time_critical")))
#define PROGMEM
#else
#define IRAM_ATTR

View File

@@ -604,6 +604,10 @@ class ESPHomeDumper(yaml.SafeDumper):
return self.represent_secret(value.id)
return self.represent_stringify(value.id)
# The below override configures this dumper to indent output YAML properly:
def increase_indent(self, flow=False, indentless=False):
return super().increase_indent(flow, False)
ESPHomeDumper.add_multi_representer(
dict, lambda dumper, value: dumper.represent_mapping("tag:yaml.org,2002:map", value)

View File

@@ -323,6 +323,17 @@ build_flags =
${flags:clangtidy.build_flags}
-DUSE_ESP32_VARIANT_ESP32C3
;;;;;;;; ESP32-C6 ;;;;;;;;
[env:esp32c6-idf]
extends = common:esp32-idf
board = esp32-c6-devkitc-1
board_build.esp-idf.sdkconfig_path = .temp/sdkconfig-esp32c6-idf
build_flags =
${common:esp32-idf.build_flags}
${flags:runtime.build_flags}
-DUSE_ESP32_VARIANT_ESP32C6
;;;;;;;; ESP32-S2 ;;;;;;;;
[env:esp32s2-arduino]

View File

@@ -17,4 +17,10 @@ wk2132_i2c:
parity: none
- id: wk2132_id_1
channel: 1
baud_rate: 19200
baud_rate: 9600
# Ensures a sensor doesn't break validation
sensor:
- platform: a02yyuw
uart_id: wk2132_id_1
id: distance_sensor

View File

@@ -3,3 +3,4 @@ substitutions:
sda_pin: GPIO21
<<: !include common.yaml

View File

@@ -18,4 +18,10 @@ wk2132_spi:
parity: none
- id: wk2132_spi_id1
channel: 1
baud_rate: 921600
baud_rate: 9600
# Ensures a sensor doesn't break validation
sensor:
- platform: a02yyuw
uart_id: wk2132_spi_id1
id: distance_sensor

View File

@@ -24,7 +24,13 @@ wk2168_i2c:
baud_rate: 115200
- id: id3
channel: 3
baud_rate: 115200
baud_rate: 9600
# Ensures a sensor doesn't break validation
sensor:
- platform: a02yyuw
uart_id: id3
id: distance_sensor
# individual binary_sensor inputs
binary_sensor:

View File

@@ -24,7 +24,13 @@ wk2168_spi:
baud_rate: 115200
- id: id3
channel: 3
baud_rate: 115200
baud_rate: 9600
# Ensures a sensor doesn't break validation
sensor:
- platform: a02yyuw
uart_id: id3
id: distance_sensor
# individual binary_sensor inputs
binary_sensor:

View File

@@ -25,4 +25,10 @@ wk2204_i2c:
parity: none
- id: wk2204_id_3
channel: 3
baud_rate: 19200
baud_rate: 9600
# Ensures a sensor doesn't break validation
sensor:
- platform: a02yyuw
uart_id: wk2204_id_3
id: distance_sensor

View File

@@ -26,4 +26,10 @@ wk2204_spi:
parity: none
- id: wk2204_spi_id3
channel: 3
baud_rate: 921600
baud_rate: 9600
# Ensures a sensor doesn't break validation
sensor:
- platform: a02yyuw
uart_id: wk2204_spi_id3
id: distance_sensor

View File

@@ -18,10 +18,16 @@ wk2212_i2c:
parity: none
- id: uart_i2c_id1
channel: 1
baud_rate: 115200
baud_rate: 9600
stop_bits: 1
parity: none
# Ensures a sensor doesn't break validation
sensor:
- platform: a02yyuw
uart_id: uart_i2c_id1
id: distance_sensor
# individual binary_sensor inputs
binary_sensor:
- platform: gpio

View File

@@ -18,7 +18,13 @@ wk2212_spi:
parity: none
- id: id1
channel: 1
baud_rate: 115200
baud_rate: 9600
# Ensures a sensor doesn't break validation
sensor:
- platform: a02yyuw
uart_id: id1
id: distance_sensor
# individual binary_sensor inputs
binary_sensor:
@@ -55,4 +61,3 @@ switch:
mode:
output: true
inverted: true

View File

@@ -0,0 +1,17 @@
esphome:
name: componenttestesp32c6idf
friendly_name: $component_name
esp32:
board: esp32-c6-devkitc-1
framework:
type: esp-idf
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_test_file: $component_test_file