Skip to content

Commit

Permalink
Upgrade to Arduino ESP32 Core version 3.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Jul 26, 2024
1 parent e920c21 commit 4ec67fc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## 0.14.0

### Board Changes

- ESP32 Boards
- Now based on (and requires) the 3.0+ version of the ESP32 Arduino Core.
- Infrared output functionality temporarily disabled, until IR library is compatible with 3.0

### New Peripherals

- ADS1100 Analog-to-Digital Converter:
Expand Down
4 changes: 2 additions & 2 deletions DEPS_CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ arduino-cli core install arduino:sam
arduino-cli core install arduino:samd
arduino-cli core install arduino:renesas_uno
arduino-cli core install esp8266:esp8266
arduino-cli core install esp32:esp32
arduino-cli core install esp32:esp32@3.0.3
arduino-cli core install rp2040:rp2040
arduino-cli lib install Servo
arduino-cli lib install Ethernet
Expand Down Expand Up @@ -71,7 +71,7 @@ arduino-cli lib install "Adafruit NeoPixel"
arduino-cli config init
arduino-cli config add board_manager.additional_urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-cli core update-index
arduino-cli core install esp32:esp32
arduino-cli core install esp32:esp32@3.0.3
arduino-cli lib install ESP32Servo
arduino-cli lib install IRremoteESP8266@2.8.5
arduino-cli lib install "Adafruit NeoPixel"
Expand Down
4 changes: 2 additions & 2 deletions DEPS_IDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ All platforms will require libraries to be installed. To install a library do th
Arduino SAMD Boards (32-bits ARM Cortex-M0+)
Arduino UNO R4 Boards
ESP8266 Boards
ESP32 Boards
ESP32 Boards @ v3.0.3
Raspberry Pi Pico/RP2040
````
* Libraries:
Expand Down Expand Up @@ -104,7 +104,7 @@ All platforms will require libraries to be installed. To install a library do th
````
* Boards (latest version unless specified):
````
ESP32 Boards
ESP32 Boards @ v3.0.3
````
* Libraries (latest version unless specified):
````
Expand Down
3 changes: 2 additions & 1 deletion lib/denko_cli/targets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class DenkoCLI::Generator
ra4m1: STANDARD_PACKAGES - [:ir_out, :led_array],

# ESP8266 + ESP32 use a different IR library.
# Temporarily disabled on ESP32 until library catches up with 3.0+ ESP32 Arduino core.
esp8266: STANDARD_PACKAGES - [:ir_out] + [:ir_out_esp],
esp32: STANDARD_PACKAGES - [:ir_out] + [:ir_out_esp],
esp32: STANDARD_PACKAGES - [:ir_out],

# RP2040 can't use WS2812 yet.
rp2040: STANDARD_PACKAGES - [:led_array],
Expand Down
8 changes: 6 additions & 2 deletions src/lib/Denko.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ void Denko::setRegisterDivider() {
// Set the analog write resolution.
void Denko::setAnalogWriteResolution() {
#ifdef WRITE_RESOLUTION_SETTER
analogWriteResolution(val);
#ifdef ESP32
esp32AnalogWRes = val;
#else
analogWriteResolution(val);
#endif
#endif
}

Expand All @@ -335,7 +339,7 @@ void Denko::setAnalogReadResolution() {
// Use a different blocking microsecond delay on different platforms.
void Denko::microDelay(uint32_t microseconds){
#if defined(ESP32)
ets_delay_us(microseconds);
esp_rom_delay_us(microseconds);
#else
delayMicroseconds(microseconds);
#endif
Expand Down
1 change: 1 addition & 0 deletions src/lib/Denko.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Denko {
byte assignLEDC(byte channel, byte pin);
void releaseLEDC(byte p);
void clearLedcChannels();
uint8_t esp32AnalogWRes = 8;
#endif

//
Expand Down
13 changes: 6 additions & 7 deletions src/lib/DenkoCoreIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void Denko::dWrite(byte p, byte v, boolean echo) {
#if defined(SOC_DAC_SUPPORTED)
dacDisable(p);
#endif
ledcDetachPin(p);
ledcDetach(p);
#endif

if (v == 0) {
Expand Down Expand Up @@ -117,9 +117,9 @@ void Denko::pwmWrite(byte p, int v, boolean echo) {
byte channel = ledcChannel(p);

// Reattach the pin in case dWrite detached it.
ledcAttachPin(p, channel);
ledcAttachChannel(p, 1000, esp32AnalogWRes, channel);

ledcWrite(channel, v);
ledcWrite(p, v);
#else
analogWrite(p,v);
#endif
Expand Down Expand Up @@ -158,8 +158,7 @@ byte Denko::assignLEDC(byte channel, byte p){
// First 8 channels: up to 40Mhz @ 16-bits
// Last 8 channels: up to 500kHz @ 13-bits
// Just use similar settings to ATmega for now.
ledcSetup(channel, 1000, 8);
ledcAttachPin(p, channel);
ledcAttachChannel(p, 1000, esp32AnalogWRes, channel);

// Save the pin and mark it as in use.
ledcPins[channel][0] = 1;
Expand All @@ -170,7 +169,7 @@ byte Denko::assignLEDC(byte channel, byte p){
// Release a LEDC channel when done with it.
void Denko::releaseLEDC(byte p){
// Detach the pin from the channel.
ledcDetachPin(p);
ledcDetach(p);

// Mark any channel associated with the pin as unused.
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
Expand All @@ -182,7 +181,7 @@ void Denko::releaseLEDC(byte p){
void Denko::clearLedcChannels(){
for (int i = LEDC_CHANNEL_COUNT -1; i > 0; i--){
// Stop the channel if it was still enabled.
if (ledcPins[i][0] != 0) ledcDetachPin(ledcPins[i][1]);
if (ledcPins[i][0] != 0) ledcDetach(ledcPins[i][1]);

// Mark the channel as unused.
ledcPins[i][0] = 0;
Expand Down

0 comments on commit 4ec67fc

Please sign in to comment.