1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-07 20:33:47 +01:00

Merge remote-tracking branch 'upstream/dev' into integration

This commit is contained in:
J. Nick Koston
2025-10-06 14:17:33 -05:00
17 changed files with 63 additions and 27 deletions

View File

@@ -179,7 +179,7 @@ void Graph::draw(Display *buff, uint16_t x_offset, uint16_t y_offset, Color colo
if (b) {
int16_t y = (int16_t) roundf((this->height_ - 1) * (1.0 - v)) - thick / 2 + y_offset;
auto draw_pixel_at = [&buff, c, y_offset, this](int16_t x, int16_t y) {
if (y >= y_offset && y < y_offset + this->height_)
if (y >= y_offset && static_cast<uint32_t>(y) < y_offset + this->height_)
buff->draw_pixel_at(x, y, c);
};
if (!continuous || !has_prev || !prev_b || (abs(y - prev_y) <= thick)) {

View File

@@ -213,7 +213,7 @@ haier_protocol::HandlerError HonClimate::status_handler_(haier_protocol::FrameTy
this->real_control_packet_size_);
this->status_message_callback_.call((const char *) data, data_size);
} else {
ESP_LOGW(TAG, "Status packet too small: %d (should be >= %d)", data_size, this->real_control_packet_size_);
ESP_LOGW(TAG, "Status packet too small: %zu (should be >= %zu)", data_size, this->real_control_packet_size_);
}
switch (this->protocol_phase_) {
case ProtocolPhases::SENDING_FIRST_STATUS_REQUEST:
@@ -827,7 +827,7 @@ haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *
size_t expected_size =
2 + this->status_message_header_size_ + this->real_control_packet_size_ + this->real_sensors_packet_size_;
if (size < expected_size) {
ESP_LOGW(TAG, "Unexpected message size %d (expexted >= %d)", size, expected_size);
ESP_LOGW(TAG, "Unexpected message size %u (expexted >= %zu)", size, expected_size);
return haier_protocol::HandlerError::WRONG_MESSAGE_STRUCTURE;
}
uint16_t subtype = (((uint16_t) packet_buffer[0]) << 8) + packet_buffer[1];

View File

@@ -178,7 +178,7 @@ class HonClimate : public HaierClimateBase {
int extra_control_packet_bytes_{0};
int extra_sensors_packet_bytes_{4};
int status_message_header_size_{0};
int real_control_packet_size_{sizeof(hon_protocol::HaierPacketControl)};
size_t real_control_packet_size_{sizeof(hon_protocol::HaierPacketControl)};
int real_sensors_packet_size_{sizeof(hon_protocol::HaierPacketSensors) + 4};
HonControlMethod control_method_;
std::queue<haier_protocol::HaierMessage> control_messages_queue_;

View File

@@ -340,7 +340,7 @@ class MipiSpi : public display::Display,
this->write_cmd_addr_data(0, 0, 0, 0, ptr, w * h, 8);
}
} else {
for (size_t y = 0; y != h; y++) {
for (size_t y = 0; y != static_cast<size_t>(h); y++) {
if constexpr (BUS_TYPE == BUS_TYPE_SINGLE || BUS_TYPE == BUS_TYPE_SINGLE_16) {
this->write_array(ptr, w);
} else if constexpr (BUS_TYPE == BUS_TYPE_QUAD) {
@@ -372,8 +372,8 @@ class MipiSpi : public display::Display,
uint8_t dbuffer[DISPLAYPIXEL * 48];
uint8_t *dptr = dbuffer;
auto stride = x_offset + w + x_pad; // stride in pixels
for (size_t y = 0; y != h; y++) {
for (size_t x = 0; x != w; x++) {
for (size_t y = 0; y != static_cast<size_t>(h); y++) {
for (size_t x = 0; x != static_cast<size_t>(w); x++) {
auto color_val = ptr[y * stride + x];
if constexpr (DISPLAYPIXEL == PIXEL_MODE_18 && BUFFERPIXEL == PIXEL_MODE_16) {
// 16 to 18 bit conversion

View File

@@ -5,6 +5,8 @@ from esphome.config_helpers import filter_source_files_from_platform
import esphome.config_validation as cv
from esphome.const import (
CONF_BUFFER_SIZE,
CONF_CARRIER_DUTY_PERCENT,
CONF_CARRIER_FREQUENCY,
CONF_CLOCK_RESOLUTION,
CONF_DUMP,
CONF_FILTER,
@@ -149,6 +151,14 @@ CONFIG_SCHEMA = remote_base.validate_triggers(
),
cv.boolean,
),
cv.SplitDefault(CONF_CARRIER_DUTY_PERCENT, esp32=100): cv.All(
cv.only_on_esp32,
cv.percentage_int,
cv.Range(min=1, max=100),
),
cv.SplitDefault(CONF_CARRIER_FREQUENCY, esp32="0Hz"): cv.All(
cv.only_on_esp32, cv.frequency, cv.int_
),
}
)
.extend(cv.COMPONENT_SCHEMA)
@@ -168,6 +178,8 @@ async def to_code(config):
cg.add(var.set_clock_resolution(config[CONF_CLOCK_RESOLUTION]))
if CONF_FILTER_SYMBOLS in config:
cg.add(var.set_filter_symbols(config[CONF_FILTER_SYMBOLS]))
cg.add(var.set_carrier_duty_percent(config[CONF_CARRIER_DUTY_PERCENT]))
cg.add(var.set_carrier_frequency(config[CONF_CARRIER_FREQUENCY]))
else:
var = cg.new_Pvariable(config[CONF_ID], pin)

View File

@@ -64,6 +64,8 @@ class RemoteReceiverComponent : public remote_base::RemoteReceiverBase,
void set_filter_symbols(uint32_t filter_symbols) { this->filter_symbols_ = filter_symbols; }
void set_receive_symbols(uint32_t receive_symbols) { this->receive_symbols_ = receive_symbols; }
void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; }
void set_carrier_duty_percent(uint8_t carrier_duty_percent) { this->carrier_duty_percent_ = carrier_duty_percent; }
void set_carrier_frequency(uint32_t carrier_frequency) { this->carrier_frequency_ = carrier_frequency; }
#endif
void set_buffer_size(uint32_t buffer_size) { this->buffer_size_ = buffer_size; }
void set_filter_us(uint32_t filter_us) { this->filter_us_ = filter_us; }
@@ -76,6 +78,8 @@ class RemoteReceiverComponent : public remote_base::RemoteReceiverBase,
uint32_t filter_symbols_{0};
uint32_t receive_symbols_{0};
bool with_dma_{false};
uint32_t carrier_frequency_{0};
uint8_t carrier_duty_percent_{100};
esp_err_t error_code_{ESP_OK};
std::string error_string_{""};
#endif

View File

@@ -72,6 +72,21 @@ void RemoteReceiverComponent::setup() {
return;
}
if (this->carrier_frequency_ > 0 && 0 < this->carrier_duty_percent_ && this->carrier_duty_percent_ < 100) {
rmt_carrier_config_t carrier;
memset(&carrier, 0, sizeof(carrier));
carrier.frequency_hz = this->carrier_frequency_;
carrier.duty_cycle = (float) this->carrier_duty_percent_ / 100.0f;
carrier.flags.polarity_active_low = this->pin_->is_inverted();
error = rmt_apply_carrier(this->channel_, &carrier);
if (error != ESP_OK) {
this->error_code_ = error;
this->error_string_ = "in rmt_apply_carrier";
this->mark_failed();
return;
}
}
rmt_rx_event_callbacks_t callbacks;
memset(&callbacks, 0, sizeof(callbacks));
callbacks.on_recv_done = rmt_callback;
@@ -111,11 +126,13 @@ void RemoteReceiverComponent::dump_config() {
" Filter symbols: %" PRIu32 "\n"
" Receive symbols: %" PRIu32 "\n"
" Tolerance: %" PRIu32 "%s\n"
" Carrier frequency: %" PRIu32 " hz\n"
" Carrier duty: %u%%\n"
" Filter out pulses shorter than: %" PRIu32 " us\n"
" Signal is done after %" PRIu32 " us of no changes",
this->clock_resolution_, this->rmt_symbols_, this->filter_symbols_, this->receive_symbols_,
this->tolerance_, (this->tolerance_mode_ == remote_base::TOLERANCE_MODE_TIME) ? " us" : "%",
this->filter_us_, this->idle_us_);
this->carrier_frequency_, this->carrier_duty_percent_, this->filter_us_, this->idle_us_);
if (this->is_failed()) {
ESP_LOGE(TAG, "Configuring RMT driver failed: %s (%s)", esp_err_to_name(this->error_code_),
this->error_string_.c_str());

View File

@@ -215,7 +215,7 @@ void Rtttl::loop() {
sample[x].right = 0;
}
if (x >= SAMPLE_BUFFER_SIZE || this->samples_sent_ >= this->samples_count_) {
if (static_cast<size_t>(x) >= SAMPLE_BUFFER_SIZE || this->samples_sent_ >= this->samples_count_) {
break;
}
this->samples_sent_++;

View File

@@ -251,7 +251,7 @@ void Tormatic::stop_at_target_() {
// Read a GateStatus from the unit. The unit only sends messages in response to
// status requests or commands, so a message needs to be sent first.
optional<GateStatus> Tormatic::read_gate_status_() {
if (this->available() < sizeof(MessageHeader)) {
if (this->available() < static_cast<int>(sizeof(MessageHeader))) {
return {};
}

View File

@@ -58,7 +58,7 @@ void UponorSmatrixClimate::control(const climate::ClimateCall &call) {
}
void UponorSmatrixClimate::on_device_data(const UponorSmatrixData *data, size_t data_len) {
for (int i = 0; i < data_len; i++) {
for (size_t i = 0; i < data_len; i++) {
switch (data[i].id) {
case UPONOR_ID_TARGET_TEMP_MIN:
this->min_temperature_ = raw_to_celsius(data[i].value);

View File

@@ -18,7 +18,7 @@ void UponorSmatrixSensor::dump_config() {
}
void UponorSmatrixSensor::on_device_data(const UponorSmatrixData *data, size_t data_len) {
for (int i = 0; i < data_len; i++) {
for (size_t i = 0; i < data_len; i++) {
switch (data[i].id) {
case UPONOR_ID_ROOM_TEMP:
if (this->temperature_sensor_ != nullptr)

View File

@@ -122,7 +122,7 @@ bool UponorSmatrixComponent::parse_byte_(uint8_t byte) {
// Decode packet payload data for easy access
UponorSmatrixData data[data_len];
for (int i = 0; i < data_len; i++) {
for (size_t i = 0; i < data_len; i++) {
data[i].id = packet[(i * 3) + 4];
data[i].value = encode_uint16(packet[(i * 3) + 5], packet[(i * 3) + 6]);
}
@@ -135,7 +135,7 @@ bool UponorSmatrixComponent::parse_byte_(uint8_t byte) {
// thermostat sending both room temperature and time information.
bool found_temperature = false;
bool found_time = false;
for (int i = 0; i < data_len; i++) {
for (size_t i = 0; i < data_len; i++) {
if (data[i].id == UPONOR_ID_ROOM_TEMP)
found_temperature = true;
if (data[i].id == UPONOR_ID_DATETIME1)
@@ -181,7 +181,7 @@ bool UponorSmatrixComponent::send(uint16_t device_address, const UponorSmatrixDa
packet.push_back(device_address >> 8);
packet.push_back(device_address >> 0);
for (int i = 0; i < data_len; i++) {
for (size_t i = 0; i < data_len; i++) {
packet.push_back(data[i].id);
packet.push_back(data[i].value >> 8);
packet.push_back(data[i].value >> 0);

View File

@@ -1,6 +1,7 @@
#include "veml7700.h"
#include "esphome/core/application.h"
#include "esphome/core/log.h"
#include <limits>
namespace esphome {
namespace veml7700 {
@@ -12,30 +13,30 @@ static float reduce_to_zero(float a, float b) { return (a > b) ? (a - b) : 0; }
template<typename T, size_t size> T get_next(const T (&array)[size], const T val) {
size_t i = 0;
size_t idx = -1;
while (idx == -1 && i < size) {
size_t idx = std::numeric_limits<size_t>::max();
while (idx == std::numeric_limits<size_t>::max() && i < size) {
if (array[i] == val) {
idx = i;
break;
}
i++;
}
if (idx == -1 || i + 1 >= size)
if (idx == std::numeric_limits<size_t>::max() || i + 1 >= size)
return val;
return array[i + 1];
}
template<typename T, size_t size> T get_prev(const T (&array)[size], const T val) {
size_t i = size - 1;
size_t idx = -1;
while (idx == -1 && i > 0) {
size_t idx = std::numeric_limits<size_t>::max();
while (idx == std::numeric_limits<size_t>::max() && i > 0) {
if (array[i] == val) {
idx = i;
break;
}
i--;
}
if (idx == -1 || i == 0)
if (idx == std::numeric_limits<size_t>::max() || i == 0)
return val;
return array[i - 1];
}

View File

@@ -2274,11 +2274,11 @@ void GDEW0154M09::clear_() {
uint32_t pixsize = this->get_buffer_length_();
for (uint8_t j = 0; j < 2; j++) {
this->command(CMD_DTM1_DATA_START_TRANS);
for (int count = 0; count < pixsize; count++) {
for (uint32_t count = 0; count < pixsize; count++) {
this->data(0x00);
}
this->command(CMD_DTM2_DATA_START_TRANS2);
for (int count = 0; count < pixsize; count++) {
for (uint32_t count = 0; count < pixsize; count++) {
this->data(0xff);
}
this->command(CMD_DISPLAY_REFRESH);
@@ -2291,11 +2291,11 @@ void HOT GDEW0154M09::display() {
this->init_internal_();
// "Mode 0 display" for now
this->command(CMD_DTM1_DATA_START_TRANS);
for (int i = 0; i < this->get_buffer_length_(); i++) {
for (uint32_t i = 0; i < this->get_buffer_length_(); i++) {
this->data(0xff);
}
this->command(CMD_DTM2_DATA_START_TRANS2); // write 'new' data to SRAM
for (int i = 0; i < this->get_buffer_length_(); i++) {
for (uint32_t i = 0; i < this->get_buffer_length_(); i++) {
this->data(this->buffer_[i]);
}
this->command(CMD_DISPLAY_REFRESH);

View File

@@ -13,7 +13,7 @@ esptool==5.1.0
click==8.1.7
esphome-dashboard==20250904.0
aioesphomeapi==41.11.0
zeroconf==0.147.2
zeroconf==0.148.0
puremagic==1.30
ruamel.yaml==0.18.15 # dashboard_import
ruamel.yaml.clib==0.2.12 # dashboard_import

View File

@@ -1,4 +1,4 @@
pylint==3.3.8
pylint==3.3.9
flake8==7.3.0 # also change in .pre-commit-config.yaml when updating
ruff==0.13.3 # also change in .pre-commit-config.yaml when updating
pyupgrade==3.20.0 # also change in .pre-commit-config.yaml when updating

View File

@@ -1,6 +1,8 @@
substitutions:
pin: GPIO2
clock_resolution: "2000000"
carrier_duty_percent: "25"
carrier_frequency: "30000"
filter_symbols: "2"
receive_symbols: "4"
rmt_symbols: "64"