1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-09 01:01:56 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
J. Nick Koston
33c831dbb8 Update esphome/components/nextion/nextion.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-07 00:07:05 +01:00
J. Nick Koston
6b7c52799d [nextion] Batch UART reads to reduce loop overhead 2026-02-07 00:02:10 +01:00

View File

@@ -397,11 +397,21 @@ bool Nextion::remove_from_q_(bool report_empty) {
}
void Nextion::process_serial_() {
uint8_t d;
int avail = this->available();
if (avail == 0) {
return;
}
while (this->available()) {
read_byte(&d);
this->command_data_ += d;
// Read all available bytes in batches to reduce UART call overhead.
uint8_t buf[64];
while (avail > 0) {
size_t to_read = std::min(static_cast<size_t>(avail), sizeof(buf));
if (!this->read_array(buf, to_read)) {
break;
}
avail -= to_read;
this->command_data_.append(reinterpret_cast<const char *>(buf), to_read);
}
}
// nextion.tech/instruction-set/