Skip to content

Shared-core maintenance: BFF font RLE guard, AMOLED mirrored rotation, LEDC guard fixes - #248

Merged
lovyan03 merged 5 commits into
m5stack:developfrom
ainyan03:font_rotation_ledc_fixes
Aug 13, 2026
Merged

Shared-core maintenance: BFF font RLE guard, AMOLED mirrored rotation, LEDC guard fixes#248
lovyan03 merged 5 commits into
m5stack:developfrom
ainyan03:font_rotation_ledc_fixes

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

Summary

Four pending fixes for the shared graphics core, batched into one sync PR:

  1. BFF font: correct first-pixel guard in decode_rle_bitmap (cherry-picked, original author credited)
    The guard for reusing the previous run value keyed off bs->bit_pos != bpp, which misfires on the first pixel of a glyph; it now keys off out != 0.

  2. Panel_AMOLED: mirrored rotation support (modes 4..7) (cherry-picked, original author credited)
    Adds the missing MADCTL values for the four mirrored orientations.

  3. Light_PWM: consolidate LEDC conditional blocks and correct the IDF v6 intr_type guard
    ledc_channel_config_t.intr_type carries __attribute__((deprecated)) from ESP-IDF v6 (components/esp_driver_ledc/include/driver/ledc.h) — interrupts are handled inside the driver — so the field is now assigned only when building against an earlier IDF. On IDF 5.x the field is still current and the assignment is kept. The Arduino / ESP-IDF code paths are consolidated behind macros selected once at the top of the file; behavior on the success path is unchanged (Arduino 2.x keeps ledcSetup/ledcAttachPin, 3.x+ keeps ledcAttach).

  4. common.hpp: guard optional soc headers with __has_include
    Robustness for toolchains/targets where soc/i2s_reg.h etc. are absent.

Testing

  • Compile-checked (native SDL build recompiles lgfx_fonts.cpp / Panel_AMOLED.cpp); the ESP32 paths are exercised by this repository's CI matrix.

sweetlilmre and others added 4 commits August 13, 2026 04:59
… intr_type guard

ledc_channel_config_t.intr_type carries a deprecated attribute from
ESP-IDF v6 (interrupts are handled inside the driver), so it is now
assigned only when building against an earlier IDF. The Arduino and
IDF code paths are consolidated behind LGFX_LEDCINIT /
LGFX_LEDC_SPEED_MODE macros selected once at the top of the file.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR batches four maintenance fixes to the shared LovyanGFX core, targeting correctness and portability across font decoding, AMOLED rotation handling, ESP32 PWM backlight configuration, and ESP32 SoC header availability.

Changes:

  • Fixes the BFF RLE font decoder’s “first pixel” run-guard condition.
  • Adds missing MADCTL values for mirrored AMOLED rotations (modes 4–7).
  • Refactors ESP32 Light_PWM to consolidate Arduino/ESP-IDF LEDC handling and gates intr_type assignment for ESP-IDF < v6.
  • Guards optional ESP32 soc/* headers with __has_include for better toolchain/target robustness.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/lgfx/v1/platforms/esp32/Light_PWM.cpp Consolidates Arduino LEDC init/write macros and ESP-IDF speed-mode handling; adjusts intr_type assignment guard.
src/lgfx/v1/platforms/esp32/common.hpp Splits SoC header includes into individual __has_include guards.
src/lgfx/v1/panel/Panel_AMOLED.cpp Adds MADCTL mappings for mirrored rotation modes 4–7.
src/lgfx/v1/lgfx_fonts.cpp Corrects RLE repeated-run detection to avoid misfiring on the first output pixel.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +35 to +43
#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)
#elif ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0)
#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
#endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 83d0b75: the new-API branch now applies only on cores that provably report 3.0.0+, and everything else (2.x, and 1.x where the version macro doesn't exist) falls back to the legacy ledcSetup/ledcAttachPin/ledcWrite(channel) API. Verified the branch selection against the esp32-hal-ledc.h headers of 1.0.6 / 2.0.0 / 2.0.17 / 3.0.0 / 3.3.x.

…ro is absent

ESP_ARDUINO_VERSION was introduced with arduino-esp32 2.0.0, so on the
1.x cores neither branch defined LGFX_LEDCINIT / LGFX_LEDCWRITE and the
calls below failed to compile. Define the new API variant only when the
version is known to be 3.0.0 or later, and fall back to
ledcSetup/ledcAttachPin/ledcWrite(channel) everywhere else, which is the
only API those old cores provide.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@lovyan03
lovyan03 merged commit 67ba764 into m5stack:develop Aug 13, 2026
23 checks passed
@ainyan03
ainyan03 deleted the font_rotation_ledc_fixes branch August 13, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants