[ltr390] Reduce data polling delay and timeout (#15507)

This commit is contained in:
J. Nick Koston
2026-04-21 04:40:24 +02:00
committed by GitHub
parent a5b1f3eece
commit 37608c2656
+4 -3
View File
@@ -45,6 +45,7 @@ optional<uint32_t> LTR390Component::read_sensor_data_(LTR390MODE mode) {
uint8_t buffer[num_bytes];
// Wait until data available
constexpr uint32_t max_wait_ms = 25;
const uint32_t now = millis();
while (true) {
std::bitset<8> status = this->reg(LTR390_MAIN_STATUS).get();
@@ -52,12 +53,12 @@ optional<uint32_t> LTR390Component::read_sensor_data_(LTR390MODE mode) {
if (available)
break;
if (millis() - now > 100) {
if (millis() - now > max_wait_ms) {
ESP_LOGW(TAG, "Sensor didn't return any data, aborting");
return {};
}
ESP_LOGD(TAG, "Waiting for data");
delay(2);
ESP_LOGV(TAG, "Waiting for data");
delay(1);
}
if (!this->read_bytes(MODEADDRESSES[mode], buffer, num_bytes)) {