Changed ESP32 tone emulation channel to 1

pull/239/head
jgromes 2020-10-29 07:53:51 +01:00
rodzic dbc35c814e
commit 4cdbcb60c5
2 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -128,7 +128,10 @@
#define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr)
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
#define RADIOLIB_HARDWARE_SERIAL_PORT Serial1
// ESP32 doesn't support tone(), but it can be emulated via LED control peripheral
#define RADIOLIB_TONE_UNSUPPORTED
#define RADIOLIB_TONE_ESP32_CHANNEL (1)
#elif defined(ARDUINO_ARCH_STM32)
// official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32)

Wyświetl plik

@ -344,12 +344,9 @@ void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value) {
::tone(pin, value);
#else
#if defined(ESP32)
// ESP32 - emulate tone() via LED driver on channel 15
if(ledcRead(15)) {
return;
}
ledcAttachPin(pin, 15);
ledcWriteTone(15, value);
// ESP32 tone() emulation
ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL);
ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, value);
#endif
#endif
}
@ -364,7 +361,7 @@ void Module::noTone(RADIOLIB_PIN_TYPE pin) {
#else
#if defined(ESP32)
ledcDetachPin(pin);
ledcWrite(15, 0);
ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0);
#endif
#endif
}