Skip to content

Commit

Permalink
Merge pull request #169 from brentru/fix-for-esp32-backwards-compat
Browse files Browse the repository at this point in the history
Add backwards compatibility with ESP32 BSP's stable release
  • Loading branch information
brentru authored Oct 12, 2023
2 parents a76e50b + e9867fb commit 7f04b63
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions examples/adafruitio_13_rgb/adafruitio_13_rgb.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit IO Arduino
version=4.2.8
version=4.2.9
author=Adafruit
maintainer=Adafruit <[email protected]>
sentence=Arduino library to access Adafruit IO.
Expand Down

0 comments on commit 7f04b63

Please sign in to comment.