From e9867fb1d616b20127abebda7576b991afc4ea6a Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 11 Oct 2023 18:27:19 -0400 Subject: [PATCH] backwards compat with stable release --- .../adafruitio_09_analog_out.ino | 9 ++++++++- .../adafruitio_13_rgb/adafruitio_13_rgb.ino | 17 ++++++++++++++--- library.properties | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/examples/adafruitio_09_analog_out/adafruitio_09_analog_out.ino b/examples/adafruitio_09_analog_out/adafruitio_09_analog_out.ino index d10d2a6..c902206 100644 --- a/examples/adafruitio_09_analog_out/adafruitio_09_analog_out.ino +++ b/examples/adafruitio_09_analog_out/adafruitio_09_analog_out.ino @@ -30,7 +30,14 @@ void setup() { // set up led pin as an analog output #if defined(ARDUINO_ARCH_ESP32) - ledcAttach(LED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution + #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1) + // New ESP32 LEDC API + ledcAttach(LED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution + #else + // Legacy ESP32 LEDC API + ledcAttachPin(LED_PIN, 1); + ledcSetup(1, 1200, 8); + #endif #else pinMode(LED_PIN, OUTPUT); #endif diff --git a/examples/adafruitio_13_rgb/adafruitio_13_rgb.ino b/examples/adafruitio_13_rgb/adafruitio_13_rgb.ino index f8ace71..bea7a69 100644 --- a/examples/adafruitio_13_rgb/adafruitio_13_rgb.ino +++ b/examples/adafruitio_13_rgb/adafruitio_13_rgb.ino @@ -39,9 +39,20 @@ void setup() { #if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode - ledcAttach(RED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution - ledcAttach(GREEN_PIN, 12000, 8); - ledcAttach(BLUE_PIN, 12000, 8); + #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 1) + // New ESP32 LEDC API + ledcAttach(RED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution + ledcAttach(GREEN_PIN, 12000, 8); + ledcAttach(BLUE_PIN, 12000, 8); + #else + // Legacy ESP32 LEDC API + ledcAttachPin(RED_PIN, 1); + ledcAttachPin(GREEN_PIN, 2); + ledcAttachPin(BLUE_PIN, 3); + ledcSetup(1, 12000, 8); + ledcSetup(2, 12000, 8); + ledcSetup(3, 12000, 8); + #endif #else pinMode(RED_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT); diff --git a/library.properties b/library.properties index 05c122a..1733e08 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit IO Arduino -version=4.2.8 +version=4.2.9 author=Adafruit maintainer=Adafruit sentence=Arduino library to access Adafruit IO.