Closed Evs91 closed 6 months ago
Strangely enough, I have ESP32 2.0.15 installed, but when I try to call ledcAttach and ledcDetach, I get errors. It works with the old ledcAttachPin and ledcDetachPin.
Ahh - well I guess we can call it a "pre-release bug fix?" I'm on the 3.0.0 release since I needed the compatibility with the new C6 and H2 boards.
If you figure out what #defines are set for 3 vs 2, we can #ifdef the old and the new...
The version on GitHub now has the following for heltec_led, so it should work on both 2.x and 3.0. Please test if this works for you also.
void heltec_led(int percent) {
if (percent > 0) {
#if ESP_ARDUINO_VERSION_MAJOR == 3
ledcAttach(LED_PIN, LED_FREQ, LED_RES);
#else
ledcSetup(LED_CHAN, LED_FREQ, LED_RES);
ledcAttachPin(LED_PIN, LED_CHAN);
#endif
ledcWrite(LED_CHAN, percent * 255 / 100);
} else {
#if ESP_ARDUINO_VERSION_MAJOR == 3
ledcDetach(LED_PIN);
#else
ledcDetachPin(LED_PIN);
#endif
pinMode(LED_PIN, INPUT);
}
}
I've changed the ==3
to >=3
and added this to the new release that just went live.
Updated LED Control to new API with ledcAttach, ledcWrite, ledcDetach.
https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html