Skip to content

Commit d292444

Browse files
committed
esp-idf: Add menuconfig option ESP32_HUB75_USE_GFX.
This pull requests adds a menuconfig option named `ESP32_HUB75_USE_GFX` which is used to determine if the Adafruit GFX component should be required and used for the build. menuconfig options are the standard way to change behavior of components in `esp-idf`. [Commit b8367d9](mrcodetastic@b8367d9) introduced a backwards incompatible change that caused `idf-idf` to only require the Adafruit-GFX-Library component if `ARDUINO_ARCH_ESP32` was set. `ARDUINO_ARCH_ESP32` is set in platformIO, the arduino software but not in the standalone `esp-idf` installation.
1 parent 5d82b98 commit d292444

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

CMakeLists.txt

+14-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
cmake_minimum_required(VERSION 3.5)
66
idf_build_get_property(target IDF_TARGET)
77

8-
if(ARDUINO_ARCH_ESP32)
9-
list(APPEND arduino_build arduino Adafruit-GFX-Library)
8+
if(ARDUINO_ARCH_ESP32 OR CONFIG_ESP32_HUB75_USE_GFX)
9+
list(APPEND build_dependencies arduino Adafruit-GFX-Library)
1010
else()
11-
list(APPEND esp_idf_build esp_lcd driver)
11+
list(APPEND build_dependencies esp_lcd driver)
1212
endif()
1313

1414
if(${target} STREQUAL "esp32s3")
@@ -17,9 +17,18 @@ endif()
1717

1818
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}
1919
INCLUDE_DIRS "./src"
20-
REQUIRES ${arduino_build} ${esp_idf_build}
2120
)
2221

22+
# Dependencies cannot be added to the REQUIRES argument of `idf_component_register` because (according to the build process
23+
# listed at https://docs.espressif.com/projects/esp-idf/en/v4.2/esp32/api-guides/build-system.html#build-process)
24+
# `idf_component_register` is processed during the "Enumeration" stage which happens before the sdkconfig file is loaded
25+
# in the "Processing" stage. So if dependencies are going to be loaded based on certain CONFIG_* variables we must
26+
# use `target_link_libraries` instead. This is the method used by Arduino's CMakeLists.txt file.
27+
foreach(component_name IN LISTS build_dependencies)
28+
idf_component_get_property(lib_name ${component_name} COMPONENT_LIB)
29+
target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name})
30+
endforeach()
31+
2332
# In case you are running into issues with "missing" header files from 3rd party libraries
2433
# you can add them to the REQUIRES section above. If you use some of the build options below
2534
# 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
2938
# target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX)
3039

3140
# esp-idf does not have any GFX library support yet, so we need to define NO_GFX
32-
if(ARDUINO_ARCH_ESP32)
41+
if(ARDUINO_ARCH_ESP32 OR CONFIG_ESP32_HUB75_USE_GFX)
3342
else()
3443
target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX)
3544
if(${target} STREQUAL "esp32s3")

Kconfig.projbuild

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
menu "ESP32 HUB75 Configuration"
2+
3+
config ESP32_HUB75_USE_GFX
4+
bool "Use Adafruit GFX library."
5+
default y
6+
help
7+
This option enables use of the Adafruit GFX library using the `Adafruit-GFX-Library` component.
8+
9+
endmenu

src/platforms/esp32/esp32_i2s_parallel_dma.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ Modified heavily for the ESP32 HUB75 DMA library by:
2828
#include <driver/periph_ctrl.h>
2929
#include <soc/gpio_sig_map.h>
3030

31-
#include <Arduino.h> // Need to make sure this is uncommented to get ESP_LOG output on (Arduino) Serial output!!!!
31+
#if defined (ARDUINO_ARCH_ESP32)
32+
#include <Arduino.h>
33+
#endif
34+
3235
#include <esp_err.h>
3336
#include <esp_log.h>
3437

0 commit comments

Comments
 (0)