Skip to content

Commit

Permalink
tweak for ESP-IDFv5 and ArduinoESP32 v3
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Nov 1, 2023
1 parent 462610a commit 49eed9c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
35 changes: 13 additions & 22 deletions src/lgfx/v1/platforms/esp32/Bus_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,20 @@ Original Source:
#if defined (ARDUINO) // Arduino ESP32
#include <soc/periph_defs.h>
#include <esp32-hal-cpu.h>
#else
#include <driver/spi_master.h>

#if defined ( CONFIG_IDF_TARGET_ESP32S3 )
#if __has_include (<esp32s3/rom/gpio.h>)
#include <esp32s3/rom/gpio.h>
#else
#include <rom/gpio.h>
#endif
#elif defined ( CONFIG_IDF_TARGET_ESP32S2 )
#if __has_include (<esp32s2/rom/gpio.h>)
#include <esp32s2/rom/gpio.h>
#else
#include <rom/gpio.h>
#endif
#else
#if __has_include (<esp32/rom/gpio.h>)
#include <esp32/rom/gpio.h>
#else
#include <rom/gpio.h>
#endif
#endif
#endif
#include <driver/spi_master.h>

#if defined ESP_IDF_VERSION_MAJOR && ESP_IDF_VERSION_MAJOR >= 5
#include <rom/gpio.h> // dispatched by core
#elif defined ( CONFIG_IDF_TARGET_ESP32S3 ) && __has_include (<esp32s3/rom/gpio.h>)
#include <esp32s3/rom/gpio.h> // dispatched by config
#elif defined ( CONFIG_IDF_TARGET_ESP32S2 ) && __has_include (<esp32s2/rom/gpio.h>)
#include <esp32s2/rom/gpio.h> // dispatched by config
#elif defined ( CONFIG_IDF_TARGET_ESP32 ) && __has_include (<esp32/rom/gpio.h>)
#include <esp32/rom/gpio.h>
#else
#include <rom/gpio.h> // dispatched by core
#endif

#ifndef SPI_PIN_REG
#define SPI_PIN_REG SPI_MISC_REG
Expand Down
15 changes: 14 additions & 1 deletion src/lgfx/v1/platforms/esp32/Light_PWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Original Source:

#if defined ( ARDUINO )
#include <esp32-hal-ledc.h>
#if __has_include(<esp_arduino_version.h>)
#include <esp_arduino_version.h>
#endif
#else
#include <driver/ledc.h>
#endif
Expand All @@ -40,10 +43,20 @@ namespace lgfx

#if defined ( ARDUINO )

#if defined ESP_ARDUINO_VERSION
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
#define LEDC_USE_IDF_V5 // esp32-arduino core 3.x.x uses the new ledC syntax
#endif
#endif

#if defined LEDC_USE_IDF_V5
ledcAttach(_cfg.pin_bl, _cfg.freq, PWM_BITS);
setBrightness(brightness);
#else
ledcSetup(_cfg.pwm_channel, _cfg.freq, PWM_BITS);
ledcAttachPin(_cfg.pin_bl, _cfg.pwm_channel);
setBrightness(brightness);

#endif
#else

static ledc_channel_config_t ledc_channel;
Expand Down

0 comments on commit 49eed9c

Please sign in to comment.