PlatformIO Community

Digispark USB, FastLED won't compile because of undeclared variables

About a year ago, I had no problem using FastLED with a Digispark USB with PIO, using the Arduino framework, but I recently started a new project using this combo. It wouldn’t compile, giving many similar errors, of which the following is one example:

In file included from c:\users\personal\.platformio\packages\toolchain-atmelavr\avr\include\avr\io.h:99:0,
                 from c:\users\personal\.platformio\packages\toolchain-atmelavr\avr\include\avr\interrupt.h:38,
                 from C:\Users\personal\.platformio\packages\framework-arduinoavr\cores\digispark_tiny/WProgram.h:8,
                 from C:\Users\personal\.platformio\packages\framework-arduinoavr\cores\digispark_tiny/Arduino.h:4,
                 from C:\Users\personal\.platformio\packages\framework-arduinoavr\libraries\__cores__\digispark\SPI\SPI.h:17,
                 from C:\Users\personal\.platformio\packages\framework-arduinoavr\libraries\__cores__\digispark\SPI\SPI.cpp:14:
C:\Users\personal\.platformio\packages\framework-arduinoavr\libraries\__cores__\digispark\SPI\SPI.h: In member function 'void SPISettings::init_AlwaysInline(uint32_t, uint8_t, uint8_t)':
C:\Users\personal\.platformio\packages\framework-arduinoavr\libraries\__cores__\digispark\SPI\SPI.h:146:16: error: 'SPE' was not declared in this scope

My platformio.ini looks like this:

[env:digispark-tiny]
platform = atmelavr
board = digispark-tiny
framework = arduino
lib_deps =
FastLED

After some searching around, I found this issue https://github.com/MCUdude/MightyCore/pull/158 which indicated that not all preprocessor directives were being evaluated, and suggested a fix of adding lib_ldf_mode = chain+ to the platformio.ini file.

This solved the problem, but I wonder if this is specific to FastLED and the digispark_tiny core, and this one-off solution is the best way to deal with it, or could there be some update to the PIO repo for this core or platform or whatever, which would eliminate the need to find this esoteric issue on a different product’s github page…

1 Like

Thanks for bringing that up here, and sorry i missed your post when you first made it. I just dug my Digispark tree out again (yup, that time of year again!) and thought I’d try and get it going with PlatormIO, as it was last programmed with the Arduino IDE, and I was having problems with two of the LEDs flickering and showing the wrong colours at times (which I have since realised is because 3xAA NiMH isn’t enough for the WS2811s… so 3xAA alkalines or USB power it is. I then hit the ‘not declared’ errors, and was searching to see what other people had come up with, and found this post :slight_smile:

Adding lib_ldf_mode = chain+ worked perfectly. I believe there is work planned on the preprocessor which will essentially make chain+ the default behaviour, and remove annoying edge cases like this, but for now it’s still needed.

1 Like