diff --git a/CMakeLists.txt b/CMakeLists.txt index e0a1898..f623f44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,10 +5,10 @@ cmake_minimum_required(VERSION 3.5) idf_build_get_property(target IDF_TARGET) -if(ARDUINO_ARCH_ESP32) - list(APPEND arduino_build arduino Adafruit-GFX-Library) +if(ARDUINO_ARCH_ESP32 OR CONFIG_ESP32_HUB75_USE_GFX) + list(APPEND build_dependencies arduino Adafruit-GFX-Library) else() - list(APPEND esp_idf_build esp_lcd driver) + list(APPEND build_dependencies esp_lcd driver) endif() if(${target} STREQUAL "esp32s3") @@ -17,9 +17,18 @@ endif() idf_component_register(SRCS "src/platforms/esp32/esp32_i2s_parallel_dma.cpp" "src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp" "src/ESP32-HUB75-MatrixPanel-leddrivers.cpp" ${extra_srcs} INCLUDE_DIRS "./src" - REQUIRES ${arduino_build} ${esp_idf_build} ) +# Dependencies cannot be added to the REQUIRES argument of `idf_component_register` because (according to the build process +# listed at https://docs.espressif.com/projects/esp-idf/en/v4.2/esp32/api-guides/build-system.html#build-process) +# `idf_component_register` is processed during the "Enumeration" stage which happens before the sdkconfig file is loaded +# in the "Processing" stage. So if dependencies are going to be loaded based on certain CONFIG_* variables we must +# use `target_link_libraries` instead. This is the method used by Arduino's CMakeLists.txt file. +foreach(component_name IN LISTS build_dependencies) + idf_component_get_property(lib_name ${component_name} COMPONENT_LIB) + target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name}) +endforeach() + # In case you are running into issues with "missing" header files from 3rd party libraries # you can add them to the REQUIRES section above. If you use some of the build options below # you probably want to remove (NO_GFX) or replace Adafruit-GFX-Library (USE_GFX_ROOT) @@ -29,7 +38,7 @@ idf_component_register(SRCS "src/platforms/esp32/esp32_i2s_parallel_dma.cpp" "sr # target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX) # esp-idf does not have any GFX library support yet, so we need to define NO_GFX -if(ARDUINO_ARCH_ESP32) +if(ARDUINO_ARCH_ESP32 OR CONFIG_ESP32_HUB75_USE_GFX) else() target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX) if(${target} STREQUAL "esp32s3") diff --git a/Kconfig.projbuild b/Kconfig.projbuild new file mode 100644 index 0000000..1668a97 --- /dev/null +++ b/Kconfig.projbuild @@ -0,0 +1,9 @@ +menu "ESP32 HUB75 Configuration" + + config ESP32_HUB75_USE_GFX + bool "Use Adafruit GFX library." + default y + help + This option enables use of the Adafruit GFX library using the `Adafruit-GFX-Library` component. + +endmenu diff --git a/src/platforms/esp32/esp32_i2s_parallel_dma.cpp b/src/platforms/esp32/esp32_i2s_parallel_dma.cpp index 5511d6f..181503c 100644 --- a/src/platforms/esp32/esp32_i2s_parallel_dma.cpp +++ b/src/platforms/esp32/esp32_i2s_parallel_dma.cpp @@ -28,7 +28,10 @@ Modified heavily for the ESP32 HUB75 DMA library by: #include #include -#include // Need to make sure this is uncommented to get ESP_LOG output on (Arduino) Serial output!!!! +#if defined (ARDUINO_ARCH_ESP32) +#include +#endif + #include #include