yeah, i’m not interested in the web ide at all really. thanks for the examples link.
i’ve just added a commit to my pull request that adds support for a “libraries” directory within the applications directory, which is how arduino works, and it seems how the new cloud ide works.
only issue i’m struggling with now is that you have to specify
APP=bmp085_test for every make recipe, e.g.
make program-dfu will try to build tinker even though you’ve already built bmp085_test, as tinker is the default if APP isn’t specified.
p.s. bosch bmp180’s work well with the spark too, uses same code as bmp085 and only 4 wires, plus its a 3.3v device, not all bmp085 boards are.
changed my pull request to use the LIB_CORE_LIBRARIES_PATH directory from the Serial2 commit instead of applications/libraries/
I’ve just started building the spark firmware locally and i found the changes made trough this thread pretty awesome.
Next step was to add some libraries and i’m not quite sure how to do that. Are the changes from tis thread already in the main code for spark core?
I tried to add a library to the spark-firmware/libraries directory (near Serial2) in its own directory, but it seems that the build system is not considering it for includes (an error occurs saying the .h file is not found)
I’ve included the file like this:
in the application.cpp file of my test appliction.
If I put all the files near application.cpp and change my include to
everything works great!
I’ve tried googling to figure out how to add libraries, with no success.
Thank you for your time.
In the makefile in the build directory, add a reference to your library:
INCLUDE_DIRS += $(LIB_CORE_LIBRARIES_PATH)Serial2 INCLUDE_DIRS += $(LIB_CORE_LIBRARIES_PATH)Adafruit_PCD8544
Thanks! This solves the problem with the include files (.h) but does not solve the problem with the source files of those libraries (.cpp) as they don’t get build and linked with the final binary.
I’m looking at the makefile right now to figure it out, i just wanted to ask in case there’s an already established way for including libraries similar to the web ide.
not all of my pull request got merged, and it was tweaked a bit too - for instance, no need to modify/add any makefiles.
for libraries, put them in a subdirectory of your application (not core-firmware/libraries/ as originally planned) and call include the same way as the web ide, so from bmp085_cloud.cpp:
#include "application.h" #include "bmp085/bmp085.h"
with the directory structure like this, where “bmp085” is the library and “bmp085_cloud” is the application:
bmp085_cloud/ ├── bmp085 │ ├── bmp085.cpp │ └── bmp085.h └── bmp085_cloud.cpp
then compile with:
Thanks, @sej7278 ! It works great!
I’ve created a directory with all my libraries and i’m symlinking the ones i need to the current project.
yup that’s a great way to do it!
i think libraries are going to get some more focus soon, hopefully like arduino where you have one place for all your libraries and you can call them from whatever sketch you want.