code using WS2801 will not compile for Gemma

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
klankschap
 
Posts: 26
Joined: Sun Sep 09, 2012 6:50 am

code using WS2801 will not compile for Gemma

Post by klankschap »

My code will not compile for the Gemma board.
It does however with the Flora board.
This is he errors with the Gemma board selected:

Code: Select all

In file included from test.ino:1:
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static byte SPIClass::transfer(byte)':
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h:56: error: 'SPDR' was not declared in this scope
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h:57: error: 'SPSR' was not declared in this scope
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h:57: error: 'SPIF' was not declared in this scope
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static void SPIClass::attachInterrupt()':
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h:63: error: 'SPCR' was not declared in this scope
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h:63: error: 'SPIE' was not declared in this scope
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h: In static member function 'static void SPIClass::detachInterrupt()':
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h:67: error: 'SPCR' was not declared in this scope
/Applications/Adafruit Arduino 1.0.5.app/Contents/Resources/Java/libraries/SPI/SPI.h:67: error: 'SPIE' was not declared in this scope
any hints?

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: code using WS2801 will not compile for Gemma

Post by adafruit_support_bill »

The standard WS2801 library will not compile on the Gemma because it has no hardware SPI. Check this thread for a modified library:
http://forums.adafruit.com/viewtopic.php?f=47&t=44122

User avatar
klankschap
 
Posts: 26
Joined: Sun Sep 09, 2012 6:50 am

Re: code using WS2801 will not compile for Gemma

Post by klankschap »

That makes sense.
It could be useful to have the compiler automatically select the software implementation of the SPI in these cases.

.F

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: code using WS2801 will not compile for Gemma

Post by pburgess »

Fetch the latest version of the library from Github; a recent change adds support for Gemma and Trinket:

https://github.com/adafruit/Adafruit-WS2801-Library

See the strandtest example sketch for usage insights. i.e. at top of sketch:

Code: Select all

#include "Adafruit_WS2801.h"
#include "SPI.h" // Comment out this line if using Trinket or Gemma
#ifdef __AVR_ATtiny85__
 #include <avr/power.h>
#endif
And then in setup():

Code: Select all

void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
  clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
  strip.begin();
}
The "SPI.h" line needs to be commented out or deleted on Gemma/Trinket, it's not enough to put it in the __AVR_ATtiny85__ section. This has to do with the Arduino IDE's weird pre-pre-processor behavior, which skims the entire sketch for #include directories rather aggressively, ignoring any conditional directives.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”