Is it possible to add libraries to the IDE?

I would like to use the AdafruitNeopixel library. Is there any way to add libraries to the IDE?


Thanks for the great question @gsklinger! Here’s the general rule:

If you look at the library .h and .cpp files, and it is platform independent, then you can just paste them into Spark Build — you would paste first the .h file contents, then the .cpp file contents, then your code at the bottom.

The Adafruit Neopixel library includes assembly language and twiddles the microcontroller registers, so it is platform dependent. This will actually be true of most libraries, meaning the “just paste it in” method doesn’t work most of the time.

For libraries like Neopixel, someone needs to port the code to the STM32 microcontroller. We can do it internally at Spark, but only once it rises to the top of the priority list. However, since the Spark firmware is open source, anyone is free to port the library and submit a pull request.

Make sense? Further questions? I’ll add porting Neopixel to our backlog. Cheers!

1 Like

The Neopixel library has platform code for AVR and Teensy which is ARM based so it shouldn’t be to different. I’m going to have a go at it fairly soon.

Will the spark compiler use #ifdef __MK20DX128__ like the Teensy 3.0 or does it need a different directive?

Was going to test programatically but i’m here now so i’ll ask.

Not sure — entirely depends on whether the arm-none-eabi-g++ preprocessor looks for that macro. Test it and let us know!

Thanks for the quick reply Zach! I was hoping the Adafruit Neopixel library was not so Atmel specific, but I guess I can wait for your port. Thanks again! -George

Just having a quick look at the code, there is support for the Arduino Due there as well. Have to wait for the weekend to give it a go.

Is there a place to request library support? Ordered the Adafruit 16-Channel 12-bit PWM/Servo Shield - I2C interface and was wondering about supporting the library. I am going to see if I can just copy in the header and cpp files from the library for now.

@mtuckman until we get something more focused and sustainable in place, starting a new thread here under the firmware category is the place to start. Library work will definitely require the support of the whole community!

Hi all-
I’m one of the two authors of the FastLED (aka FastSPI_LED2) library for driving Neopixels and other addressing LED strips. (Daniel Garcia is the other author and my partner in high-performance crime.) My SparkCores arrived in the mail today and as you can imagine, I’m eager to get the library up and running on them!
We’re most definitely not afraid of ARM (or AVR) assembly language; what we need to get the library ported is the technical info on the particular ARM chip implementation (eg port/pin mappings, and any interrupt issues), and we can take it from there.
Where is the deep tech data to be found? I’ll see what we can do…

1 Like

Eg is this the best (only?) place to start looking at port/pin mappings etc?

Yes! @kriegsman! Go go go!

Pin mapping spreadsheet is here in the hardware repo:

Friendly hardware reference is in the docs:

Useful software pin mapping array is here:

With the pins defined as D0–D7, A0–A7, TX & RX in the header file:

Let us know if you have questions!

Just to answer my own question about using c++ preprocessor defines for hardware targeting.

The most appropriate one for targeting the Spark Core arm chip seems to be.

#ifdef STM32F10X_MD

Perhaps we should move the WS2812 aka NeoPixel discussion over to a new more appropriately named thread.

@kriegsman i’d be keen to see FastSPI_LED2 support the SparkCore, happy to test code.


I have a christmas tree covered in WS2812B LED’s connected to a Arduino Mega and I was hoping to replace the Mega with the Spark Core.
If the library can be altered I would love to help test it with my tree!
I currently have the Spark connected to the Mega via the serial line so I can still use it to control the system.

Do you know how I could add an infrared library by Ken Shirriff in my code? The files are .h and .cpp. I tried copying and pasting them directly from their files with the .h file above the .cpp, but I still get an error that the library doesn’t exist.


Could someone please look over the code in the link (Code)? I am trying to compile the code by including infrared libraries within the code, but the Spark compiler says that it still can’t find the libraries.


Hi @Wilson,

It looks like you have include statements in your code that should be commented out around line 590, and 1607,

#include "IRremote.h"
#include "IRremoteInt.h" 

I am working on ultrasonic sensor,in order to interface the sensor what i have to do about importing libraries :stuck_out_tongue: what procedure has to be followed for working with (newping libraries).