Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add light pause to ESP32 #1871

Merged
merged 1 commit into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down