Skip to content

Develop#188

Merged
lovyan03 merged 5 commits intom5stack:developfrom
lovyan03:develop
Apr 10, 2026
Merged

Develop#188
lovyan03 merged 5 commits intom5stack:developfrom
lovyan03:develop

Conversation

@lovyan03
Copy link
Copy Markdown
Collaborator

This pull request introduces multiple compatibility and bugfix improvements for ESP32 platforms, especially targeting ESP-IDF v6, ESP32P4, and Arduino Core v6. The changes address GPIO and DMA handling, UTF-8 decoding, font rendering, and build configuration to ensure better support for new SDK versions and hardware targets.

Platform compatibility improvements:

  • Added conditional macros and includes in Bus_Parallel8.cpp, Bus_SPI.cpp, and related headers to handle ESP-IDF v6 changes, ESP32P4 target, and new/renamed SDK APIs for GPIO and DMA operations. This includes new wrapper macros for GPIO matrix functions and proper header selection for I2S and GDMA. [1] [2] [3] [4]
  • Updated Light_PWM.cpp to recognize and adapt to ESP32 Arduino Core v6, including disabling deprecated fields and updating feature macros. [1] [2]

Bug fixes and code correctness:

  • Fixed signed/unsigned comparison warnings by casting loop variables in LGFXBase.cpp. [1] [2]
  • Corrected type casting in Bus_EPD.cpp for ESP-IDF compatibility.
  • Added missing #include <driver/gpio.h> for non-Arduino builds in Light_PWM.cpp.

Font rendering and UTF-8 handling:

  • Improved UTF-8 decoding logic in LGFXBase.cpp to support up to 4-byte sequences and fixed the state machine for multibyte characters. Added a new decode state for 4-byte UTF-8. [1] [2]
  • Removed unnecessary #ifdef checks for LVGL font glyph formats, as these are enum values, not macros, in lgfx_fonts.cpp.
  • Added an #undef abs guard to avoid macro conflicts in lgfx_fonts.cpp.

Build system and configuration:

  • Fixed a file glob pattern in CMakeLists.txt to include all LVGL font .c files.

ESP32-specific enhancements:

  • Updated SPI DMA and peripheral reset handling for ESP32P4 and other variants, including cache synchronization and register selection. [1] [2] [3] [4] [5] [6]
  • Improved I2C clock source selection for ESP-IDF v6 in common.cpp.

Apply two LovyanGFX develop commits that fix ESP32P4 SPI issues:
  - 16a37c7 Fix for #743 (ESP32P4 Bus_SPI stalling after 32 pixels) (#822)
  - cd4cd02 ESP32P4: Include DMA channel for link2 reg write (see #743)

Both commits address the same root cause: ESP32P4 DMA/cache handling
for SPI transfers. Files affected: Bus_SPI.cpp, Bus_SPI.hpp.
Apply LovyanGFX develop commits that add ESP-IDF v6 build support:
  - c9b05f7 feat: Update ESP-IDF and HAL for v6 compatibility (#831)
  - 72280f3 Attempt to fix [[noreturn]] compilation error with idfv6 + esp32p4
  - eb3b405 [idf v6] Fix ledc_channel_config_t.intr_type deprecation warning

Files touched: result.hpp, common.cpp, common.hpp, Bus_EPD.cpp,
Bus_Parallel8.cpp/hpp, Bus_SPI.cpp/hpp, Light_PWM.cpp,
esp32c3/Bus_Parallel8.cpp, esp32p4/Panel_DSI.cpp,
esp32s2/Bus_Parallel16.cpp/hpp, Bus_Parallel8.cpp/hpp,
esp32s3/Bus_Parallel16.cpp, Bus_Parallel8.cpp.

Key changes (all guarded by ESP_IDF_VERSION checks, backward compatible):
  - Add i2s_port_t typedef compat for IDF v6 (where it was removed)
  - Include soc/gpio_reg.h, soc/gpio_periph.h, hal/gdma_ll.h where needed
  - gpio_matrix_out -> rom_gpio_matrix_out on IDF v6
  - gpio_iomux_out -> gpio_iomux_output on IDF v6
  - VSPI_HOST fallback to SPI3_HOST / SPI2_HOST when undefined
  - hal/gdma_channel.h fallback when soc/gdma_channel.h is absent
  - SOC_GDMA_PAIRS_PER_GROUP_MAX fallback via GDMA_LL_PAIRS_PER_INST
  - getPeriphModule return type switches to auto on C++14+
  - periph_module_reset PERIPH_HSPI/VSPI_MODULE fallback
  - i2c_ll_reset_register detection relaxed for IDF v6
  - ESP32P4 Bus_SPI: pragma diagnostic push/pop around hal headers
  - Light_PWM: guard ledc_channel_config_t.intr_type (deprecated on v6)

For common.cpp/hpp specifically: investigation confirmed that M5GFX's
independent SFINAE + ESP32-H2 work (586d60b and ff337c6) produced
bit-identical content to the set of commits LovyanGFX landed
separately (87915d6, 89c9be3, 318f82a, 338c593, bd8cdd5). The only
real delta between the two sides for these two files was c9b05f7
itself.
Apply LovyanGFX develop commit:
  - 53f52c8 UTF8 decoding improvements by @d4rkmen (see #828)

Rewrites LGFXBase::decodeUTF8 to add support for 4-byte UTF-8
sequences (21-bit code points, U+10000..U+10FFFF). The state machine
is restructured into a switch on _decoderState with a new utf8_state3
entry added to utf8_decode_state_t.

This change is disjoint from the loadFont() font_type extension
already on M5GFX develop (f1de0e8) and merges cleanly with it.
After this commit, LGFXBase.cpp/hpp are identical on both repos.
Backport the build fixes applied on the LovyanGFX side (develop 2e5119f)
so the same code paths compile cleanly on M5GFX for environments that
surfaced issues on a Seeed Wio Terminal (SAMD51, Arduino) build.

1. Arduino.h defines abs() as a preprocessor macro, which collides
   with std::abs used inside lgfx_fonts.cpp. Add abs to the existing
   min/max #undef block at the top of the file so std::abs resolves
   cleanly on every toolchain.

2. The switch on gd.format in LVGLfont::drawChar was guarded with
   #ifdef LV_FONT_GLYPH_FORMAT_A1 etc, but these identifiers are enum
   values defined in lv_font/font.h, not preprocessor macros - so the
   guards always evaluated false, every case body became unreachable,
   and glyph_bpp was never updated. Drop the broken #ifdef guards and
   use the enum labels directly.

3. fill_rect_radial_gradient / fill_rect_linear_gradient in LGFXBase
   compared int loop counters against uint32_t dimensions, producing
   -Wsign-compare warnings. Cast the upper bounds to int so the loop
   variables keep their signed type (leaving downstream x/y pushImage
   arithmetic unchanged).
The file(GLOB) used to enumerate both src/lgfx/Fonts/lvgl/lv_font_*.c
(narrow) and src/lgfx/Fonts/lvgl/*.c (broad), matching the same set
of files twice. Every .c file currently in that directory starts
with lv_font_, so the narrow glob was a subset of the broad one.

Keep the broad glob (to catch any future non-lv_font_ helper source
added to the directory) and drop the redundant narrow one. Also
reorder so that the Fonts/ entries are grouped in efont -> IPA ->
lvgl order, matching the layout used on the LovyanGFX side.
@lovyan03 lovyan03 merged commit 6baaa4c into m5stack:develop Apr 10, 2026
22 checks passed
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.

1 participant