Skip to content

Commit

Permalink
Update api adapt esp core 3.0.0-alpha2 (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe authored Oct 28, 2023
1 parent 556f37f commit 039fa0f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ArduinoHal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,16 @@ void inline ArduinoHal::tone(uint32_t pin, unsigned int frequency, unsigned long
// ESP32 tone() emulation
(void)duration;
if(prev == -1) {
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL);
#endif
}
if(prev != frequency) {
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, frequency);
#else
ledcWriteTone(pin, frequency);
#endif
}
prev = frequency;
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
Expand Down Expand Up @@ -178,8 +184,13 @@ void inline ArduinoHal::noTone(uint32_t pin) {
return;
}
// ESP32 tone() emulation
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0)
ledcDetachPin(pin);
ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0);
#else
ledcDetach(pin);
ledcWrite(pin, 0);
#endif
prev = -1;
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
if(pin == RADIOLIB_NC) {
Expand Down

0 comments on commit 039fa0f

Please sign in to comment.