OK, I've gone over to
Sparkfun to try out their WS2812 scripts, but I have a problem - this is the script:
#include <Adafruit_NeoPixel.h>
#define PIN 2
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
rainbow(20);
rainbowCycle(20);
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
And this is the result:
Arduino: 1.0.5 (Mac OS X), Board: "Teensy 3.1"
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=96000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=117 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_RAWHID -DLAYOUT_US_ENGLISH -I/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/cores/teensy3 -I/../Arduino/libraries/Adafruit_NeoPixel /var/folders/aN/aNFmcZ3w2RWeak+8ZOYbV++++TI/-Tmp-/build1167403267062598903.tmp/strandtest.cpp -o /var/folders/aN/aNFmcZ3w2RWeak+8ZOYbV++++TI/-Tmp-/build1167403267062598903.tmp/strandtest.cpp.o
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=96000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=117 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_RAWHID -DLAYOUT_US_ENGLISH -I/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/cores/teensy3 -I/../Arduino/libraries/Adafruit_NeoPixel -I/../Arduino/libraries/Adafruit_NeoPixel/utility /../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp -o /var/folders/aN/aNFmcZ3w2RWeak+8ZOYbV++++TI/-Tmp-/build1167403267062598903.tmp/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp.o
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp: In member function 'void Adafruit_NeoPixel::show()':
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:773:3: error: 'Pio' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:773:19: error: 'port' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:774:12: error: 'WoReg' does not name a type
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:777:29: error: 'pmc_set_writeprotect' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:778:35: error: 'TC3_IRQn' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:778:43: error: 'pmc_enable_periph_clk' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:779:16: error: 'TC1' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:780:5: error: 'TC_CMR_WAVE' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:780:19: error: 'TC_CMR_WAVSEL_UP' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:780:38: error: 'TC_CMR_TCCLKS_TIMER_CLOCK1' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:780:64: error: 'TC_Configure' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:781:18: error: 'TC_Start' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:783:15: error: 'g_APinDescription' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:785:3: error: 'portSet' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:786:3: error: 'portClear' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:787:3: error: 'timeValue' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:788:3: error: 'timeReset' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:795:14: error: 'VARIANT_MCK' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:799:14: error: 'VARIANT_MCK' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:808:18: error: 'TC_CCR_CLKEN' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:808:33: error: 'TC_CCR_SWTRG' was not declared in this scope
/../Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:818:17: error: 'TC_Stop' was not declared in this scope
OK, again the problem is 'simple', this script does not work with the 3.1 module, but works fine with ++2.
Interesting, but a bit frustrating as I thought that 3.1 was a superset of 2 and thus 2 code would work on 3.1 - however that is not the case.
In any case the Sparkfun does work on Teensy++ 2, so I'll play with that for now.
I need to find the differences between Teensy++ 2 and Teensy 3.1 it appears, and look for ways to work around them.