[pmsx003] Keep active-mode reads aligned (#14832)

This commit is contained in:
Jason Kölker
2026-03-22 20:21:08 +00:00
committed by GitHub
parent c917b8ce06
commit 2b6d63fd09
+4 -7
View File
@@ -95,10 +95,6 @@ void PMSX003Component::loop() {
// Just go ahead and read stuff // Just go ahead and read stuff
break; break;
} }
} else if (now - this->last_update_ < this->update_interval_) {
// Otherwise just leave the sensor powered up and come back when we hit the update
// time
return;
} }
if (now - this->last_transmission_ >= 500) { if (now - this->last_transmission_ >= 500) {
@@ -114,10 +110,11 @@ void PMSX003Component::loop() {
this->read_byte(&this->data_[this->data_index_]); this->read_byte(&this->data_[this->data_index_]);
auto check = this->check_byte_(); auto check = this->check_byte_();
if (!check.has_value()) { if (!check.has_value()) {
// finished if (this->update_interval_ > STABILISING_MS || now - this->last_update_ >= this->update_interval_) {
this->parse_data_(); this->parse_data_();
this->data_index_ = 0;
this->last_update_ = now; this->last_update_ = now;
}
this->data_index_ = 0;
} else if (!*check) { } else if (!*check) {
// wrong data // wrong data
this->data_index_ = 0; this->data_index_ = 0;
@@ -138,7 +135,7 @@ optional<bool> PMSX003Component::check_byte_() {
return true; return true;
} }
ESP_LOGW(TAG, "Start character %u mismatch: 0x%02X != 0x%02X", index + 1, byte, START_CHARACTER_1); ESP_LOGW(TAG, "Start character %u mismatch: 0x%02X != 0x%02X", index + 1, byte, start_char);
return false; return false;
} }