stephanschulz
Well-known member
i am porting code that used to run on a maple mini.
in it i set a timer overflow which called a function that caused 16 LEDs to be set to a specific brightness
i am now trying to use the teensy3 IntervalTimer but the LEDs flicker.
in the maple code i used a library called digitalWriteFaster, maybe that helped?
http://forums.leaflabs.com/topic.php?id=737&page=2#post-25151
but maybe i am just doing some wrong ???
thanks, stephan.
maple code:
teensy code:
in it i set a timer overflow which called a function that caused 16 LEDs to be set to a specific brightness
i am now trying to use the teensy3 IntervalTimer but the LEDs flicker.
in the maple code i used a library called digitalWriteFaster, maybe that helped?
http://forums.leaflabs.com/topic.php?id=737&page=2#post-25151
but maybe i am just doing some wrong ???
thanks, stephan.
maple code:
Code:
setup(){
Timer3.setPrescaleFactor(1);
Timer3.setOverflow(255); //2000); //500); //1079);
Timer3.attachCompare1Interrupt(timer3_dimming_handler);
}
void timer3_dimming_handler(void) {
for(int i=0; i<DMX_NUM_CHANNELS; i++){
if(dmx_data[i] > counter){
dimStates[i] = true;
}
else{
dimStates[i] = false;
}
digitalWriteFaster(ledPin[i],dimStates[i]);
}
counter++;
if(counter > counterLimit) counter = 0;
}
teensy code:
Code:
void setup(){
for(int i=0; i<DMX_NUM_CHANNELS; i++){
pinMode(ledPin[i],OUTPUT);
}
dimmingTimer.begin(dimming_handler, 100);
}
void dimming_handler(void) {
for(int i=0; i<DMX_NUM_CHANNELS; i++){
if(dmx_data[i] > counter){
dimStates[i] = true;
}
else{
dimStates[i] = false;
}
digitalWrite(ledPin[i],dimStates[i]);
}
counter++;
if(counter > counterLimit) counter = 0;
}