diff --git a/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRrecv.cpp b/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRrecv.cpp index 764870706..67238bf69 100644 --- a/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRrecv.cpp +++ b/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRrecv.cpp @@ -248,8 +248,8 @@ static void USE_IRAM_ATTR gpio_intr() { timer->dev->config.alarm_en = 1; #else // _ESP32_IRRECV_TIMER_HACK #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) ) - timerAlarm(timer, MS_TO_USEC(params.timeout), ONCE, 0); - timerAttachInterrupt(timer, &read_timeout); + timerWrite(timer, 0); + timerStart(timer); #else // ESP_ARDUINO_VERSION_MAJOR >= 3 timerWrite(timer, 0); timerAlarmEnable(timer); @@ -344,7 +344,10 @@ IRrecv::IRrecv(const uint16_t recvpin, const uint16_t bufsize, IRrecv::~IRrecv(void) { disableIRIn(); #if defined(ESP32) - if (timer != NULL) timerEnd(timer); // Cleanup the ESP32 timeout timer. + if (timer != NULL) { + timerEnd(timer); // Cleanup the ESP32 timeout timer. + timer = NULL; + } #endif // ESP32 delete[] params.rawbuf; if (params_save != NULL) { @@ -370,9 +373,9 @@ void IRrecv::enableIRIn(const bool pullup) { // Initialise the ESP32 timer. // 80MHz / 80 = 1 uSec granularity. #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) ) - timer = timerBegin(80); + timer = timerBegin(1000000); // 1 MHz #else // ESP_ARDUINO_VERSION_MAJOR >= 3 - timer = timerBegin(_timer_num, 80, true); + timer = timerBegin(_timer_num, 80, true); // 1 MHz : 80 MHz with divider 80 #endif // ESP_ARDUINO_VERSION_MAJOR >= 3 #ifdef DEBUG if (timer == NULL) { @@ -382,8 +385,8 @@ void IRrecv::enableIRIn(const bool pullup) { #endif // DEBUG assert(timer != NULL); // Check we actually got the timer. #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) ) - timerAlarm(timer, MS_TO_USEC(params.timeout), ONCE, 0); timerAttachInterrupt(timer, &read_timeout); + timerAlarm(timer, MS_TO_USEC(params.timeout), ONCE, 0); #else // ESP_ARDUINO_VERSION_MAJOR >= 3 // Set the timer so it only fires once, and set it's trigger in uSeconds. timerAlarmWrite(timer, MS_TO_USEC(params.timeout), ONCE); @@ -418,6 +421,7 @@ void IRrecv::disableIRIn(void) { #endif // ESP8266 #if defined(ESP32) #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) ) + timerDetachInterrupt(timer); timerEnd(timer); #else // ESP_ARDUINO_VERSION_MAJOR >= 3 timerAlarmDisable(timer); @@ -450,7 +454,7 @@ void IRrecv::resume(void) { params.overflow = false; #if defined(ESP32) #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 3) ) - timerEnd(timer); + timerStop(timer); #else // ESP_ARDUINO_VERSION_MAJOR >= 3 timerAlarmDisable(timer); #endif // ESP_ARDUINO_VERSION_MAJOR >= 3