WS2801 LED Strip with SPI

w00t! Very nice @bandgeek80001 One of these days I’ll throw a couple hundred bucks at Adafruit and get a bunch of their various neopixel strips. LEDs are a great way to Bedazzle your project!

Has anyone been able to get this to work using the library as an added file (the plus button to add tabs for .cpp and .h)? If I copy this code directly into the build site, it compiles fine, but if I break out the cpp and h files to tabs, it won’t compile, instead I get a whole list of errors, thoughts?:

SparkCoreWS2801.cpp:11:1: error: ‘Adafruit_WS2801’ does not name a type
SparkCoreWS2801.cpp:18:1: error: ‘Adafruit_WS2801’ does not name a type
SparkCoreWS2801.cpp:28:1: error: ‘Adafruit_WS2801’ does not name a type
SparkCoreWS2801.cpp:37:6: error: ‘Adafruit_WS2801’ has not been declared
SparkCoreWS2801.cpp:37:29: error: variable or field ‘alloc’ declared void
SparkCoreWS2801.cpp:37:29: error: ‘uint16_t’ was not declared in this scope
SparkCoreWS2801.cpp:48:1: error: ‘Adafruit_WS2801’ does not name a type
SparkCoreWS2801.cpp:57:1: error: ‘Adafruit_WS2801’ does not name a type
SparkCoreWS2801.cpp:64:6: error: ‘Adafruit_WS2801’ has not been declared
SparkCoreWS2801.cpp: In function ‘void begin()’:
SparkCoreWS2801.cpp:65:4: error: ‘hardwareSPI’ was not declared in this scope
SparkCoreWS2801.cpp:66:10: error: ‘startSPI’ was not declared in this scope
SparkCoreWS2801.cpp:68:9: error: ‘datapin’ was not declared in this scope
SparkCoreWS2801.cpp:68:18: error: ‘OUTPUT’ was not declared in this scope
SparkCoreWS2801.cpp:68:24: error: ‘pinMode’ was not declared in this scope
SparkCoreWS2801.cpp:69:9: error: ‘clkpin’ was not declared in this scope
SparkCoreWS2801.cpp:71:1: error: ‘begun’ was not declared in this scope
SparkCoreWS2801.cpp: At global scope:
SparkCoreWS2801.cpp:75:6: error: ‘Adafruit_WS2801’ has not been declared
SparkCoreWS2801.cpp: In function ‘void updatePins()’:
SparkCoreWS2801.cpp:76:1: error: ‘hardwareSPI’ was not declared in this scope
SparkCoreWS2801.cpp:77:1: error: ‘datapin’ was not declared in this scope
SparkCoreWS2801.cpp:77:11: error: ‘clkpin’ was not declared in this scope
SparkCoreWS2801.cpp:79:4: error: ‘begun’ was not declared in this scope
SparkCoreWS2801.cpp:79:28: error: ‘startSPI’ was not declared in this scope
SparkCoreWS2801.cpp: At global scope:
SparkCoreWS2801.cpp:87:6: error: ‘Adafruit_WS2801’ has not been declared
SparkCoreWS2801.cpp:87:34: error: variable or field ‘updatePins’ declared void
SparkCoreWS2801.cpp:87:34: error: ‘uint8_t’ was not declared in this scope
SparkCoreWS2801.cpp:87:48: error: ‘uint8_t’ was not declared in this scope
make: *** [SparkCoreWS2801.o] Error 1

UPDATE: I needed to add #include “spark_wiring_spi.h” to the .h file. They must have changed that since an earlier version of the IDE since I didn’t used to need to include it.

1 Like

Typically you should add #include "application.h" in your library, which will actually include all necessary .h files from the spark core-firmware\inc directory.

Is this documented anywhere? I couldn’t find it in the current documentation.

Sadly, no… but it was stickied for a couple weeks here:

@Dave any chance the compilier can suggest adding #include "application.h" to a file if certain errors are found? It might not be a bad idea to also ask one time to add it if it doesn’t find it in the Class .h

This is going to keep coming up again and again and again… even if documented it will be hard to find, and remember. Even I personally have not read every single part of the Docs O_O

1 Like

Honestly I’m tempted to just put an #include "application.h" at the top of all new header files by default with a comment like “Added automatically in case you want access to standard Arduino libraries”, but I suspect that might end up being annoying?

Hmm, can’t really be more annoying than the error messages. Could the compiler be smart about it and add it if it’s not there already? Any bad side effects by adding it when it’s not needed? If the compiler has certain errors, it could silently add the header and then try again one time (and THEN report that it has fixed an error by adding the header file).

2 Likes

Hi. Im so glad I found this post! I was at the point of giving up getting these led’s working on a spark core (I shall move it to a photon soon. I just fried the one I had :frowning: )

Do anyone have any suggestion for fading from one defined colour to another?

PS. I just noticed how old this thread is!

You might want to look at the FastLED library. It has all kinds of useful functions.