Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lgfx/v1/lgfx_fonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ namespace lgfx
if (bs->bit_pos + bpp > bs->bit_length) break;
ret = (uint8_t)bs->read_bits(bpp);

if (bs->bit_pos != bpp && prev_v == ret)
if (out != 0 && prev_v == ret)
{
count = 0;
state = RLE_REPEATED;
Expand Down
4 changes: 4 additions & 0 deletions src/lgfx/v1/panel/Panel_AMOLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ namespace lgfx
case 1: madctl = 0x60; break;
case 2: madctl = 0xc0; break;
case 3: madctl = 0xa0; break;
case 4: madctl = 0xc2; break;
case 5: madctl = 0x62; break;
case 6: madctl = 0x02; break;
case 7: madctl = 0xa2; break;
}

startWrite();
Expand Down
86 changes: 43 additions & 43 deletions src/lgfx/v1/platforms/esp32/Light_PWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ Original Source:
#include <driver/ledc.h>
#endif

#if defined ( ARDUINO )

#if defined ESP_ARDUINO_VERSION // use ledc* functions shipped with arduino-esp32 core
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
#define LGFX_LEDCINIT(pin_bl, freq, bits, pwm_channel) ledcAttach(pin_bl, freq, bits)
#define LGFX_LEDCWRITE(pin_bl, pwm_channel, duty) ledcWrite(pin_bl, duty)
#endif
#endif
#if !defined LGFX_LEDCINIT // pre-3.x cores, including 1.x where ESP_ARDUINO_VERSION is absent
#define LGFX_LEDCINIT(pin_bl, freq, bits, pwm_channel) { ledcSetup(pwm_channel, freq, bits); ledcAttachPin(pin_bl, pwm_channel); }
#define LGFX_LEDCWRITE(pin_bl, pwm_channel, duty) ledcWrite(pwm_channel, duty)
#endif

#else // esp-idf

#if SOC_LEDC_SUPPORT_HS_MODE
#define LGFX_LEDC_SPEED_MODE LEDC_HIGH_SPEED_MODE
#else
#define LGFX_LEDC_SPEED_MODE LEDC_LOW_SPEED_MODE
#endif

#endif


namespace lgfx
{
inline namespace v1
Expand All @@ -44,59 +68,38 @@ 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
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(6, 0, 0)
#define LEDC_USE_IDF_V6 // esp32-arduino core 6.x.x
#endif
#endif
LGFX_LEDCINIT(_cfg.pin_bl, _cfg.freq, PWM_BITS, _cfg.pwm_channel);

#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
#else // esp-idf

static ledc_channel_config_t ledc_channel;
{
ledc_channel.gpio_num = (gpio_num_t)_cfg.pin_bl;
#if SOC_LEDC_SUPPORT_HS_MODE
ledc_channel.speed_mode = LEDC_HIGH_SPEED_MODE;
#else
ledc_channel.speed_mode = LEDC_LOW_SPEED_MODE;
#endif
ledc_channel.speed_mode = LGFX_LEDC_SPEED_MODE;
ledc_channel.channel = (ledc_channel_t)_cfg.pwm_channel;
#if !defined LEDC_USE_IDF_V6 // ledc_channel_config_t.intr_type is deprecated, no need to explicitly configure interrupt, handled in the driver
ledc_channel.intr_type = LEDC_INTR_DISABLE;
#endif
ledc_channel.timer_sel = (ledc_timer_t)((_cfg.pwm_channel >> 1) & 3);
ledc_channel.duty = _cfg.invert ? (1 << PWM_BITS) : 0;
ledc_channel.hpoint = 0;
#if defined ESP_IDF_VERSION_VAL
// when ledc_channel_config_t.intr_type is deprecated, no need to explicitly configure interrupt, handled in the driver
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
ledc_channel.intr_type = LEDC_INTR_DISABLE;
#endif
#endif
};
ledc_channel_config(&ledc_channel);
static ledc_timer_config_t ledc_timer;
{
#if SOC_LEDC_SUPPORT_HS_MODE
ledc_timer.speed_mode = LEDC_HIGH_SPEED_MODE; // timer mode
#else
ledc_timer.speed_mode = LEDC_LOW_SPEED_MODE;
#endif
ledc_timer.speed_mode = LGFX_LEDC_SPEED_MODE; // timer mode
ledc_timer.duty_resolution = (ledc_timer_bit_t)PWM_BITS; // resolution of PWM duty
ledc_timer.freq_hz = _cfg.freq; // frequency of PWM signal
ledc_timer.timer_num = ledc_channel.timer_sel; // timer index
};
ledc_timer_config(&ledc_timer);

setBrightness(brightness);

#endif

setBrightness(brightness);
return true;
}

Expand All @@ -115,17 +118,14 @@ namespace lgfx
if (_cfg.invert) duty = (1 << PWM_BITS) - duty;

#if defined ( ARDUINO )
#if defined LEDC_USE_IDF_V5
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);
#else
ledc_set_duty(LEDC_LOW_SPEED_MODE, (ledc_channel_t)_cfg.pwm_channel, duty);
ledc_update_duty(LEDC_LOW_SPEED_MODE, (ledc_channel_t)_cfg.pwm_channel);

LGFX_LEDCWRITE(_cfg.pin_bl, _cfg.pwm_channel, duty);

#else // esp-idf

ledc_set_duty(LGFX_LEDC_SPEED_MODE, (ledc_channel_t)_cfg.pwm_channel, duty);
ledc_update_duty(LGFX_LEDC_SPEED_MODE, (ledc_channel_t)_cfg.pwm_channel);

#endif
}

Expand Down
10 changes: 7 additions & 3 deletions src/lgfx/v1/platforms/esp32/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ Original Source:
#include <soc/soc.h>
#include <soc/spi_reg.h>
#if __has_include(<soc/i2s_reg.h>)
#include <soc/i2s_reg.h>
#include <soc/gpio_reg.h>
#include <soc/gpio_periph.h>
#include <soc/i2s_reg.h>
#endif
#if __has_include(<soc/gpio_reg.h>)
#include <soc/gpio_reg.h>
#endif
#if __has_include(<soc/gpio_periph.h>)
#include <soc/gpio_periph.h>
#endif
#include <soc/gpio_struct.h>
#include <soc/gpio_sig_map.h>
Expand Down
Loading