Seems like when using the SoftTimer in conjunction with the NeoPixel library an issue arises.
this code should sequentially light all of the 12 pixels on my board, 5 seconds apart. in red
issue is: it only lights the first one, in red.
I have debugged and i can see that both a) the task is being successfully triggered b) the counter variable is incrementing as expected
it is as if the strip.show() is not being processed after the first time the task is being called.
my gut tells me there is some timer (as in AVR timer) conflict. but then again, i have no idea whats actually going on under the hood of the NeoPixel library.
edit: ther SoftTimer library is basically constantly calling micros() - not sure if that helps/points in the right direction
Code: Select all
#include <Adafruit_NeoPixel.h>
#include <SoftTimer.h>
#define PIN 6
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
//variable dec
Task tColorWipeRed(1000,cColorWipeRed);
int counter=0;
void setup() {
//serial init
Serial.begin(19200);
//strip stuff init
strip.begin();
strip.show(); // Initialize all pixels to 'off'
//add the task to the timer manager
SoftTimer.add(&tColorWipeRed);
}
//this is the calback function that is executed by the timer manager at the user defined interval
void cColorWipeRed(Task* me){
//run the actual function
ColorWipe(strip, strip.Color(10,0,0));
}
//this is the actual function
void ColorWipe(Adafruit_NeoPixel sT, uint32_t c) {
//this is here as a debug blinky to make sure that this thread/task is running
digitalWrite(13, digitalRead( 13 ) ^ 1);
//if the current step in the effect is less than total number of pixels
if( counter < sT.numPixels()){
//print current step to double check the step# is actually incrementing.
Serial.print(counter);
//set that pixel in the strip to the inbound color
strip.setPixelColor(counter, c);
//counter seems to incrememnt (when i read it from the serial debug line), but does not result in the next LED turning on.
//increment next step
counter++;
//turn on dem pixelsss
strip.show();
}
strip.show();
//if we're at the end of the strip, start over.
if( tColorWipeRed.rcS() == sT.numPixels()){tColorWipeRed.rcSt(0);}//reset the counter to zero
}//end colorWipe