mirror of
https://github.com/esphome/esphome.git
synced 2025-08-10 20:29:24 +00:00
Avoid polling for GPIO binary sensors when possible
This commit is contained in:
@@ -21,10 +21,13 @@ class GPIOBinarySensorStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool has_changed() {
|
bool has_changed() {
|
||||||
InterruptLock lock;
|
// No lock needed: single writer (ISR) / single reader (main loop) pattern
|
||||||
bool changed = this->changed_;
|
// Volatile bool operations are atomic on all ESPHome-supported platforms
|
||||||
|
if (!this->changed_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this->changed_ = false;
|
this->changed_ = false;
|
||||||
return changed;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Reference in New Issue
Block a user