Merge pull request #7732 from esphome/bump-2024.10.3

2024.10.3
This commit is contained in:
Jesse Hills 2024-11-08 22:41:29 +13:00 committed by GitHub
commit b8eadb2ba5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 54 additions and 18 deletions

View File

@ -60,9 +60,10 @@ class AnimimgType(WidgetType):
lvgl_components_required.add(CONF_IMAGE) lvgl_components_required.add(CONF_IMAGE)
lvgl_components_required.add(CONF_ANIMIMG) lvgl_components_required.add(CONF_ANIMIMG)
if CONF_SRC in config: if CONF_SRC in config:
for x in config[CONF_SRC]: srcs = [
await cg.get_variable(x) await lv_image.process(await cg.get_variable(x))
srcs = [await lv_image.process(x) for x in config[CONF_SRC]] for x in config[CONF_SRC]
]
src_id = cg.static_const_array(config[CONF_SRC_LIST_ID], srcs) src_id = cg.static_const_array(config[CONF_SRC_LIST_ID], srcs)
count = len(config[CONF_SRC]) count = len(config[CONF_SRC])
lv.animimg_set_src(w.obj, src_id, count) lv.animimg_set_src(w.obj, src_id, count)

View File

@ -1,3 +1,4 @@
import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ANGLE, CONF_MODE from esphome.const import CONF_ANGLE, CONF_MODE
@ -64,6 +65,7 @@ class ImgType(WidgetType):
async def to_code(self, w: Widget, config): async def to_code(self, w: Widget, config):
if src := config.get(CONF_SRC): if src := config.get(CONF_SRC):
src = await cg.get_variable(src)
lv.img_set_src(w.obj, await lv_image.process(src)) lv.img_set_src(w.obj, await lv_image.process(src))
if (cf_angle := config.get(CONF_ANGLE)) is not None: if (cf_angle := config.get(CONF_ANGLE)) is not None:
pivot_x = config[CONF_PIVOT_X] pivot_x = config[CONF_PIVOT_X]

View File

@ -15,23 +15,33 @@ void Modbus::setup() {
void Modbus::loop() { void Modbus::loop() {
const uint32_t now = millis(); const uint32_t now = millis();
if (now - this->last_modbus_byte_ > 50) {
this->rx_buffer_.clear();
this->last_modbus_byte_ = now;
}
// stop blocking new send commands after send_wait_time_ ms regardless if a response has been received since then
if (now - this->last_send_ > send_wait_time_) {
waiting_for_response = 0;
}
while (this->available()) { while (this->available()) {
uint8_t byte; uint8_t byte;
this->read_byte(&byte); this->read_byte(&byte);
if (this->parse_modbus_byte_(byte)) { if (this->parse_modbus_byte_(byte)) {
this->last_modbus_byte_ = now; this->last_modbus_byte_ = now;
} else { } else {
size_t at = this->rx_buffer_.size();
if (at > 0) {
ESP_LOGV(TAG, "Clearing buffer of %d bytes - parse failed", at);
this->rx_buffer_.clear();
}
}
}
if (now - this->last_modbus_byte_ > 50) {
size_t at = this->rx_buffer_.size();
if (at > 0) {
ESP_LOGV(TAG, "Clearing buffer of %d bytes - timeout", at);
this->rx_buffer_.clear(); this->rx_buffer_.clear();
} }
// stop blocking new send commands after sent_wait_time_ ms after response received
if (now - this->last_send_ > send_wait_time_) {
if (waiting_for_response > 0)
ESP_LOGV(TAG, "Stop waiting for response from %d", waiting_for_response);
waiting_for_response = 0;
}
} }
} }
@ -39,7 +49,7 @@ bool Modbus::parse_modbus_byte_(uint8_t byte) {
size_t at = this->rx_buffer_.size(); size_t at = this->rx_buffer_.size();
this->rx_buffer_.push_back(byte); this->rx_buffer_.push_back(byte);
const uint8_t *raw = &this->rx_buffer_[0]; const uint8_t *raw = &this->rx_buffer_[0];
ESP_LOGV(TAG, "Modbus received Byte %d (0X%x)", byte, byte); ESP_LOGVV(TAG, "Modbus received Byte %d (0X%x)", byte, byte);
// Byte 0: modbus address (match all) // Byte 0: modbus address (match all)
if (at == 0) if (at == 0)
return true; return true;
@ -144,8 +154,10 @@ bool Modbus::parse_modbus_byte_(uint8_t byte) {
ESP_LOGW(TAG, "Got Modbus frame from unknown address 0x%02X! ", address); ESP_LOGW(TAG, "Got Modbus frame from unknown address 0x%02X! ", address);
} }
// return false to reset buffer // reset buffer
return false; ESP_LOGV(TAG, "Clearing buffer of %d bytes - parse succeeded", at);
this->rx_buffer_.clear();
return true;
} }
void Modbus::dump_config() { void Modbus::dump_config() {

View File

@ -84,6 +84,26 @@ void RpiDpiRgb::draw_pixels_at(int x_start, int y_start, int w, int h, const uin
ESP_LOGE(TAG, "lcd_lcd_panel_draw_bitmap failed: %s", esp_err_to_name(err)); ESP_LOGE(TAG, "lcd_lcd_panel_draw_bitmap failed: %s", esp_err_to_name(err));
} }
int RpiDpiRgb::get_width() {
switch (this->rotation_) {
case display::DISPLAY_ROTATION_90_DEGREES:
case display::DISPLAY_ROTATION_270_DEGREES:
return this->get_height_internal();
default:
return this->get_width_internal();
}
}
int RpiDpiRgb::get_height() {
switch (this->rotation_) {
case display::DISPLAY_ROTATION_90_DEGREES:
case display::DISPLAY_ROTATION_270_DEGREES:
return this->get_width_internal();
default:
return this->get_height_internal();
}
}
void RpiDpiRgb::draw_pixel_at(int x, int y, Color color) { void RpiDpiRgb::draw_pixel_at(int x, int y, Color color) {
if (!this->get_clipping().inside(x, y)) if (!this->get_clipping().inside(x, y))
return; // NOLINT return; // NOLINT

View File

@ -24,6 +24,7 @@ class RpiDpiRgb : public display::Display {
void update() override { this->do_update_(); } void update() override { this->do_update_(); }
void setup() override; void setup() override;
void loop() override; void loop() override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order,
display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override; display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override;
void draw_pixel_at(int x, int y, Color color) override; void draw_pixel_at(int x, int y, Color color) override;
@ -44,8 +45,8 @@ class RpiDpiRgb : public display::Display {
this->width_ = width; this->width_ = width;
this->height_ = height; this->height_ = height;
} }
int get_width() override { return this->width_; } int get_width() override;
int get_height() override { return this->height_; } int get_height() override;
void set_hsync_back_porch(uint16_t hsync_back_porch) { this->hsync_back_porch_ = hsync_back_porch; } void set_hsync_back_porch(uint16_t hsync_back_porch) { this->hsync_back_porch_ = hsync_back_porch; }
void set_hsync_front_porch(uint16_t hsync_front_porch) { this->hsync_front_porch_ = hsync_front_porch; } void set_hsync_front_porch(uint16_t hsync_front_porch) { this->hsync_front_porch_ = hsync_front_porch; }
void set_hsync_pulse_width(uint16_t hsync_pulse_width) { this->hsync_pulse_width_ = hsync_pulse_width; } void set_hsync_pulse_width(uint16_t hsync_pulse_width) { this->hsync_pulse_width_ = hsync_pulse_width; }

View File

@ -1,6 +1,6 @@
"""Constants used by esphome.""" """Constants used by esphome."""
__version__ = "2024.10.2" __version__ = "2024.10.3"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = ( VALID_SUBSTITUTIONS_CHARACTERS = (