diff --git a/src/IRrecv.cpp b/src/IRrecv.cpp index 6ff9fd70b..95f7c2af9 100644 --- a/src/IRrecv.cpp +++ b/src/IRrecv.cpp @@ -405,6 +405,17 @@ void IRrecv::disableIRIn(void) { #endif // UNIT_TEST } +/// Pause collection of received IR data. +/// @see IRrecv class constructor +void IRrecv::pause(void) { + params.rcvstate = kStopState; + params.rawlen = 0; + params.overflow = false; +#if defined(ESP32) + gpio_intr_disable((gpio_num_t)params.recvpin); +#endif // ESP32 +} + /// Resume collection of received IR data. /// @note This is required if `decode()` is successful and `save_buffer` was /// not set when the class was instanciated. @@ -415,6 +426,7 @@ void IRrecv::resume(void) { params.overflow = false; #if defined(ESP32) timerAlarmDisable(timer); + gpio_intr_enable((gpio_num_t)params.recvpin); #endif // ESP32 } diff --git a/src/IRrecv.h b/src/IRrecv.h index 025de5272..ad09f6d35 100644 --- a/src/IRrecv.h +++ b/src/IRrecv.h @@ -137,6 +137,7 @@ class IRrecv { uint8_t max_skip = 0, uint16_t noise_floor = 0); void enableIRIn(const bool pullup = false); void disableIRIn(void); + void pause(void); void resume(void); uint16_t getBufSize(void); #if DECODE_HASH