[nextion] Batch UART reads to reduce loop overhead

This commit is contained in:
J. Nick Koston
2026-02-07 00:02:10 +01:00
parent 86f91eed2f
commit 6b7c52799d
+14 -4
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<char *>(buf), to_read);
}
}
// nextion.tech/instruction-set/