From 6e4e7531aac5b4ab8f068bad648b3c4b3c8952b8 Mon Sep 17 00:00:00 2001 From: ainyan03 <205502311+ainyan03@users.noreply.github.com> Date: Mon, 14 Sep 2026 02:30:16 +0000 Subject: [PATCH] ESP-IDF build: give Panel_LT8912B the M5Unified headers when that component is in the build Panel_LT8912B (the PoE-P4 display output board) talks to the bridge through M5Unified I2C_Class, picked up with __has_include(). In an ESP-IDF component build that header was never on this library include path, so the display output always failed with "M5Unified I2C_Class is not available" (Arduino builds pass every library path, which is why it worked there). The M5Unified component source directory is now added as a private include directory whenever such a component is part of the build, in the same way the Arduino component is picked up; several candidates at once are rejected like the Arduino case. Checked on Unit PoE-P4 + display output board with ESP-IDF 6.1: the output comes up and refreshes. --- CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63ada4df..760a207b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,3 +79,36 @@ if(_m5gfx_arduino_enabled) target_link_libraries(${COMPONENT_LIB} PUBLIC ${_m5gfx_arduino_lib}) endif() endif() + +# Panel_LT8912B (the PoE-P4 display output board) talks to the bridge through M5Unified's I2C_Class, which it +# picks up with __has_include(). In an ESP-IDF build that header is only +# visible when this library is given M5Unified's source directory, so add it whenever an +# M5Unified component is part of the build (headers only; the symbols resolve at link time as +# the component libraries are linked as one group). +# M5GFX_M5UNIFIED_COMPONENT= use a differently named M5Unified component +# M5GFX_M5UNIFIED_COMPONENT=OFF disable the automatic include path +set(_m5gfx_m5unified_candidates M5Unified m5unified m5stack__m5unified) +set(_m5gfx_m5unified_enabled ON) +if(DEFINED M5GFX_M5UNIFIED_COMPONENT AND NOT "${M5GFX_M5UNIFIED_COMPONENT}" STREQUAL "") + if(M5GFX_M5UNIFIED_COMPONENT) + set(_m5gfx_m5unified_candidates ${M5GFX_M5UNIFIED_COMPONENT}) + else() + set(_m5gfx_m5unified_enabled OFF) + endif() +endif() +if(_m5gfx_m5unified_enabled) + idf_build_get_property(_m5gfx_m5unified_build_components BUILD_COMPONENTS) + set(_m5gfx_m5unified_hits) + foreach(_m5gfx_m5unified_name ${_m5gfx_m5unified_candidates}) + if(_m5gfx_m5unified_name IN_LIST _m5gfx_m5unified_build_components) + list(APPEND _m5gfx_m5unified_hits ${_m5gfx_m5unified_name}) + endif() + endforeach() + list(LENGTH _m5gfx_m5unified_hits _m5gfx_m5unified_count) + if(_m5gfx_m5unified_count GREATER 1) + message(FATAL_ERROR "M5GFX: several M5Unified components are in the build (${_m5gfx_m5unified_hits}). Set M5GFX_M5UNIFIED_COMPONENT to the one to use.") + elseif(_m5gfx_m5unified_count EQUAL 1) + idf_component_get_property(_m5gfx_m5unified_dir ${_m5gfx_m5unified_hits} COMPONENT_DIR) + target_include_directories(${COMPONENT_LIB} PRIVATE ${_m5gfx_m5unified_dir}/src) + endif() +endif()