Skip to content

Commit

Permalink
fix compilation errors with esp32-arduino 3.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Oct 12, 2023
1 parent aada45c commit f3ad7c4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/lgfx/v1/platforms/esp32/Bus_SPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ Original Source:
#include "../../Bus.hpp"
#include "../common.hpp"

#if defined ( ARDUINO )
#if __has_include(<esp_arduino_version.h>) // platformio has optional esp_arduino_version
#include <esp_arduino_version.h>
#endif

#if defined ESP_ARDUINO_VERSION_VAL
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3,0,0)
#include <rom/gpio.h> // import gpio_matrix_out
#endif
#endif
#endif

namespace lgfx
{
inline namespace v1
Expand Down
15 changes: 12 additions & 3 deletions src/lgfx/v1/platforms/esp32/Light_PWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ namespace lgfx

#if defined ( ARDUINO )

ledcSetup(_cfg.pwm_channel, _cfg.freq, PWM_BITS);
ledcAttachPin(_cfg.pin_bl, _cfg.pwm_channel);
#if defined SOC_DAC_SUPPORTED // esp32-arduino core version >= 3.0.0
ledcAttach( _cfg.pin_bl, _cfg.freq, PWM_BITS ); // Note: auto channel ?
#else
ledcSetup(_cfg.pwm_channel, _cfg.freq, PWM_BITS);
ledcAttachPin(_cfg.pin_bl, _cfg.pwm_channel);
#endif

setBrightness(brightness);

#else
Expand Down Expand Up @@ -96,7 +101,11 @@ namespace lgfx
if (_cfg.invert) duty = (1 << PWM_BITS) - duty;

#if defined ( ARDUINO )
ledcWrite(_cfg.pwm_channel, duty);
#if defined SOC_DAC_SUPPORTED // esp32-arduino core version >= 3.0.0
ledcWrite(_cfg.pin_bl, duty);
#else
ledcWrite(_cfg.pwm_channel, duty);
#endif
#elif SOC_LEDC_SUPPORT_HS_MODE
ledc_set_duty(LEDC_HIGH_SPEED_MODE, (ledc_channel_t)_cfg.pwm_channel, duty);
ledc_update_duty(LEDC_HIGH_SPEED_MODE, (ledc_channel_t)_cfg.pwm_channel);
Expand Down
17 changes: 17 additions & 0 deletions src/lgfx/v1/platforms/esp32/Light_PWM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ Original Source:

#include "../../Light.hpp"


#if defined ( ARDUINO )
#if __has_include(<esp_arduino_version.h>) // platformio has optional esp_arduino_version
#include <esp_arduino_version.h>
#endif

#if defined ESP_ARDUINO_VERSION_VAL
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3,0,0)
#define SOC_DAC_SUPPORTED 1 // why ???
#include <esp32-hal.h>
#include <esp32-hal-ledc.h>
#include <esp32-hal-dac.h>
#endif
#endif
#endif


namespace lgfx
{
inline namespace v1
Expand Down

0 comments on commit f3ad7c4

Please sign in to comment.