1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-14 17:22:20 +01:00

Avoid polling for GPIO binary sensors when possible

This commit is contained in:
J. Nick Koston
2025-06-17 13:18:45 +02:00
parent 0a0c369b88
commit 2bbe08cee0

View File

@@ -36,6 +36,9 @@ class GPIOBinarySensorStore {
class GPIOBinarySensor : public binary_sensor::BinarySensor, public Component { class GPIOBinarySensor : public binary_sensor::BinarySensor, public Component {
public: public:
// No destructor needed: ESPHome components are created at boot and live forever.
// Interrupts are only detached on reboot when memory is cleared anyway.
void set_pin(GPIOPin *pin) { pin_ = pin; } void set_pin(GPIOPin *pin) { pin_ = pin; }
void set_use_interrupt(bool use_interrupt) { use_interrupt_ = use_interrupt; } void set_use_interrupt(bool use_interrupt) { use_interrupt_ = use_interrupt; }
void set_interrupt_type(gpio::InterruptType type) { interrupt_type_ = type; } void set_interrupt_type(gpio::InterruptType type) { interrupt_type_ = type; }