FastLED code compiles & works for 2.0 but not 3.0?

Status
Not open for further replies.
I am working on an LED project and I'm using code that references the FastLED library (got it from Adafruit). I have a Teensy 2.0 on my breadboard, and everything was going swimmingly til I tried to upload the same code (after switching to 3.0 in the drop-down) to a 3.0, which is all I have for this project at the moment. It is not compiling and giving me these errors:

Arduino: 1.6.5 (Windows 7), TD: 1.24, Board: "Teensy 3.0, Serial, 96 MHz (overclock), US English"

Using library FastLED in folder: C:\Users\Alysia\Documents\Arduino\libraries\FastLED (1.0.x format)



C:\Program Files (x86)\Arduino/hardware/tools/arm/bin/arm-none-eabi-g++ -c -Os -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -D__MK20DX128__ -DTEENSYDUINO=124 -DARDUINO=10605 -DF_CPU=96000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3 -IC:\Users\Alysia\Documents\Arduino\libraries\FastLED C:\Users\Alysia\AppData\Local\Temp\build3932117977441704667.tmp\Mode_Set_1.cpp -o C:\Users\Alysia\AppData\Local\Temp\build3932117977441704667.tmp\Mode_Set_1.cpp.o

In file included from Mode_Set_1.ino:1:0:
C:\Users\Alysia\Documents\Arduino\libraries\FastLED/FastLED.h:11:2: warning: #warning FastLED version 3.000.002 (Not really a warning, just telling you here.) [-Wcpp]
#warning FastLED version 3.000.002 (Not really a warning, just telling you here.)
^
In file included from C:\Users\Alysia\Documents\Arduino\libraries\FastLED/fastspi.h:50:0,
from C:\Users\Alysia\Documents\Arduino\libraries\FastLED/FastLED.h:31,
from Mode_Set_1.ino:1:
C:\Users\Alysia\Documents\Arduino\libraries\FastLED/fastspi_arm_k20.h: In member function 'void ARMHardwareSPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER, pSPIX>::init()':
C:\Users\Alysia\Documents\Arduino\libraries\FastLED/fastspi_arm_k20.h:194:24: error: 'SPI0' was not declared in this scope
if((SPI_t*)pSPIX == &SPI0) {
^
Error compiling.

If I go back to the drop-down and switch back to 2.0, it compiles fine. Not sure what's going on or how to troubleshoot it? Help!
 
And here is the code (running just beautifully on my 2.0 as I type this):

#include <FastLED.h>

#define LED_PIN 1 // which pin your pixels are connected to
#define NUM_LEDS 7 // how many LEDs you have
#define BRIGHTNESS 255 // 0-255, higher number is brighter.
#define SATURATION 255 // 0-255, 0 is pure white, 255 is fully saturated color
#define SPEED 10 // How fast the colors move. Higher numbers = faster motion
#define STEPS 10 // How wide the bands of color are. 1 = more like a gradient, 10 = more like stripes
#define BUTTON_PIN 2 // button is connected to pin 2 and GND

#define COLOR_ORDER GRB // Try mixing up the letters (RGB, GBR, BRG, etc) for a whole new world of color combinations

CRGB leds[NUM_LEDS];
CRGBPalette16 currentPalette;
CRGBPalette16 targetPalette( PartyColors_p );
TBlendType currentBlending;
int ledMode = 0;


//FastLED comes with several palettes pre-programmed. I like purple a LOT, and so I added a custom purple palette.

const TProgmemPalette16 PurpleColors_p PROGMEM =
{
CRGB::purple,
CRGB::purple,
CRGB::MidnightBlue,
CRGB::MidnightBlue,

CRGB::purple,
CRGB::purple,
CRGB::BlueViolet,
CRGB::BlueViolet,

CRGB::DarkTurquoise,
CRGB::DarkTurquoise,
CRGB::DarkBlue,
CRGB::DarkBlue,

CRGB::purple,
CRGB::purple,
CRGB::BlueViolet,
CRGB::BlueViolet
};


unsigned long keyPrevMillis = 0;
const unsigned long keySampleIntervalMs = 25;
byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms
byte longKeyPressCount = 0;

byte prevKeyState = HIGH; // button is active low

void setup() {
delay( 2000 ); // power-up safety delay
FastLED.addLeds<WS2812B, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentBlending = BLEND;
pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop() {

byte currKeyState = digitalRead(BUTTON_PIN);

if ((prevKeyState == LOW) && (currKeyState == HIGH)) {
shortKeyPress();
}
prevKeyState = currKeyState;

static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */

switch (ledMode) {

case 0:
currentPalette = HeatColors_p; //Red & Yellow, Fire Colors
break;
case 1:
currentPalette = ForestColors_p; //Foresty greens and yellows
break;
case 2:
currentPalette = OceanColors_p; //Oceans are pretty and filled with mermaids
break;
case 3:
currentPalette = PurpleColors_p; //My custom palette from above
break;
case 4:
currentPalette = RainbowColors_p; //All the colors!
break;
case 5:
currentPalette = RainbowStripeColors_p; //Rainbow stripes
break;
case 6:
currentPalette = PartyColors_p; //All the colors except the greens, which make people look a bit washed out
break;
}

FillLEDsFromPaletteColors( startIndex);
FastLED.show();
FastLED.delay(1000 / SPEED);
}

void FillLEDsFromPaletteColors( uint8_t colorIndex) {
for( int i = 0; i < NUM_LEDS; i++) {
leds = ColorFromPalette( currentPalette, colorIndex, BRIGHTNESS, currentBlending);
colorIndex += STEPS;
}
}

void shortKeyPress() {
ledMode++;
if (ledMode > 6) {
ledMode=0;
}
}
 
Seems like an easy enough fix! Kind of a "duh" I suppose, but that's preferable to the alternative. I'll give it a try tomorrow morning, thanks!
 
Replaced the library with 3.0.3 version, didn't work. Tried downgrading my IDE to 1.0.6 because I saw somewhere that maybe FastLED has errors with certain boards in 1.6.5 (though now I can't remember where/find it).

Getting this:

Arduino: 1.0.6 + Td: 1.24 (Windows 7), Board: "Teensy 3.0"
In file included from C:\Users\Alysia\Documents\Arduino\libraries\FastLED/fastspi.h:50:0,
from C:\Users\Alysia\Documents\Arduino\libraries\FastLED/FastLED.h:31,
from sketch_aug19a.ino:1:
C:\Users\Alysia\Documents\Arduino\libraries\FastLED/fastspi_arm_k20.h: In member function 'void ARMHardwareSPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER, pSPIX>::init()':
C:\Users\Alysia\Documents\Arduino\libraries\FastLED/fastspi_arm_k20.h:194:24: error: 'SPI0' was not declared in this scope
if((SPI_t*)pSPIX == &SPI0) {
^
 
Found this but not seeing where to make the change to KINETISK_SPI0? Tried going into the library text for fastspi_arm_k20.h and it seems like there is already a fix in place?
Version 1.20 renamed SPI_t to KINETISK_SPI_t
#if TEENSYDUINO >= 120
#

I'm using Teensyduino 1.24...
 
Maybe try reinstalling Teensyduino and let it install a known-good copy of FastLED? The copy that comes with the installer should work!

Arduino will probably try to keep using your copy in C:\Users\Alysia\Documents\Arduino\libraries. Libraries in your sketchbook folder always override the ones within Arduino, which lets you customize... but it also gives you plenty of rope to hang yourself.

You're still using Arduino 1.0.6, before the helpful message about duplicate conflicting libraries was added. :(

If you try 1.6.5, you should see a message that 2 conflicting libraries exist, and it should tell you which one it is using and which it's ignoring. You can delete or just temporarily move the copy from C:\Users\Alysia\Documents\Arduino\libraries, so it'll use the other one. Arduino rescans library locations at startup, so quit and restart Arduino after you've installed or moved libraries to get it to notice your changes. Unfortunately, with older Arduino 1.0.6, it's hard to tell what's going on. You can turn on verbose info in File > Preference and then pay close attention to the full pathnames that are buried in the huge amount of verbose info it prints. There's a reason that helpful duplicate library message was added!
 
Since my last comment I went into fastspi_arm_k20.h, found he incidence of SPI0, and changed it to KINETISK_SPI0, and now it works! Wahoo. Going to try re-upgrading to 1.6.5 since it seems that is not the problem. Thanks!
 
Also be sure to grab the FastLED3.1 branch - I need to move it over to master soon but it has a bunch of fixes for both teensy 3/3.x as well as teensy-LC support.
 
Status
Not open for further replies.
Back
Top