I wrote a library that I intend to use in several project and I published it via platform.io's library management system.
https://platformio.org/lib/show/12820/FastLED-SectionManager
This is the first time I've published via platform.io (first time I've published any c++ library). I read over platform.io's docs on creating a library and structured my library accordingly with my headers in the include
directory and the implementation files in the src
directory:
And created the following library.json file:
{
"name": "FastLED-SectionManager",
"version": "1.0.2",
"description": "A led strip index manager that allows for logical groupings of strip sections.",
"repository": {
"type": "git",
"url": "[email protected]:chris-schmitz/FastLED-Section-Manager.git"
},
"authors": [
{
"name": "Christopher Schmitz",
"email": "[email protected]",
"url": "https://light-inspiration.com/"
}
],
"homepage": "https://github.com/chris-schmitz/FastLED-Section-Manager",
"license": "MIT",
"dependencies": {
"fastled/FastLED": "^3.4.0"
},
"frameworks": "*",
"platforms": "*"
}
The problem that I'm running into is that when I install the library in a different project via platform.io and try to include a header, the header can't be found:
I double checked in the pio
directory for the project and I can definitely see the header and implementation files:
So I'm not sure why platform.io can't find the headers.
I can't quite tell what I'm doing wrong. any ideas?
1 Answer 1
I woke up this morning and looked back at the documentation.
A part I mis-read was this:
We recommend to use src folder for your C/C++ source files and include folder for your headers. You can also have nested sub-folders in src or include.
I had my headers stored in the lib
folder :facepalm:
I tried to search around in the platformio docs for the explanation of the lib vs include vs src folders (I knew I saw it at one point) but couldn't find it.
I then remembered that I read the purpose of each directory in the Readme files in the project structure itself generated when you create a new platformio project:
The gist being:
src
: your compiled files, i.e. yourcpp
files- It's worth noting that you could just shove all of the files in here and it would work
lib
: libraries private to your project/library itselfinclude
: declaration and macro definition files, i.e. your header files
This explains how the header files in the lib
directory worked in the SectionManager project itself but didn't work when using the SectionManager as an installed library; the lib
directory is only "visible" local to a project, so when I tried to include the header files from another project they couldn't be found.
So in my SectionManager project I moved the headers to the include
directory, bumped the version number, and published:
Then I switched to my main project that I'm pulling the SectionManager library into, adjusted the dependency version to include the minor bump, updated, and now it works!
Makes sense, I'm just still getting used to c++ and platform.io.
want to flip the direction on every other row with the third boolean argument
....sectionManager.addRangeToSection(0, 0, 3, true);
.... the boolean is 4th argument