File tree Expand file tree Collapse file tree 4 files changed +36
-10
lines changed
idf_component_examples/Hello_world Expand file tree Collapse file tree 4 files changed +36
-10
lines changed Original file line number Diff line number Diff line change
1
+ arduino_libs
2
+ build
3
+ .cache
4
+ managed_components
5
+ dependencies.lock
6
+ sdkconfig
7
+ sdkconfig.old
Original file line number Diff line number Diff line change 1
- # For more information about build system see
2
- # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3
- # The following five lines of boilerplate have to be in your project's
4
- # CMakeLists in this exact order for cmake to work correctly
5
- cmake_minimum_required (VERSION 3.16 )
1
+ cmake_minimum_required (VERSION 3.17 )
6
2
7
3
include ($ENV{IDF_PATH} /tools/cmake/project.cmake )
8
- project (main )
4
+ project (hello_world )
5
+
6
+ # Download BufferUtils library
7
+ include (FetchContent )
8
+ FetchContent_Populate (BufferUtils
9
+ URL https://github.com/bakercp/BufferUtils/archive/refs/tags/3.0.0.zip
10
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} /arduino_libs/BufferUtils
11
+ )
12
+
13
+ # Add Arduino libraries to the project
14
+ add_arduino_libraries (${CMAKE_CURRENT_LIST_DIR} /arduino_libs )
Original file line number Diff line number Diff line change 1
1
#include " Arduino.h"
2
+ #include " CircularBuffer.h"
2
3
3
4
void setup () {
4
5
Serial.begin (115200 );
6
+
7
+ uint8_t data[10 ];
8
+ CircularBuffer buffer (data, sizeof (data));
9
+ buffer.put (1 );
5
10
}
6
11
7
12
void loop () {
Original file line number Diff line number Diff line change 1
1
function (add_arduino_libraries libs_dir )
2
2
# Construct the absolute path for libs_dir relative to the CMake project root
3
- set (libs_dir_abs "${CMAKE_SOURCE_DIR} /${libs_dir} " )
4
-
3
+ if (IS_ABSOLUTE "${libs_dir} " )
4
+ set (libs_dir_abs "${libs_dir} " )
5
+ else ()
6
+ set (libs_dir_abs "${CMAKE_SOURCE_DIR} /${libs_dir} " )
7
+ endif ()
8
+
5
9
# Verify if libs_dir_abs is a valid directory
6
10
if (NOT IS_DIRECTORY "${libs_dir_abs} " )
7
11
message (FATAL_ERROR "The specified libs_dir (${libs_dir_abs} ) is not a valid directory." )
8
12
return () # Stop processing if the directory is invalid
9
13
endif ()
10
14
11
- idf_component_get_property (arduino_esp32_lib arduino COMPONENT_LIB )
12
-
15
+ # Get the name of the arduino component. It is the same as the name of the current directory.
16
+ get_filename_component (arduino_component_name ${CMAKE_CURRENT_FUNCTION_LIST_DIR} NAME )
17
+ message (STATUS "Adding Arduino libraries to ${arduino_component_name} component" )
18
+
19
+ idf_component_get_property (arduino_esp32_lib ${arduino_component_name} COMPONENT_LIB )
20
+
13
21
# Loop through each folder in the libs_dir
14
22
file (GLOB children RELATIVE ${libs_dir_abs} ${libs_dir_abs} /* )
15
23
foreach (child ${children} )
You can’t perform that action at this time.
0 commit comments