Go Down

Topic: Timing issues with RGB Display - TLC5940 and 74HC595 (Read 5048 times) previous topic - next topic

djbro

It would be nice to get a proper solution for this.

Here's the best I can do without someone fixing the driver:




void clearLEDS()
{
  digitalWrite(layerLatchPin, LOW);
  shiftOut(layerDataPin, layerClockPin, MSBFIRST, B00000000 );
  shiftOut(layerDataPin, layerClockPin, MSBFIRST, B00000000 );
  shiftOut(layerDataPin, layerClockPin, MSBFIRST, B00000000 );
  digitalWrite(layerLatchPin, HIGH);
}
void openCol(int col)
{
  digitalWrite(layerLatchPin, LOW);
  shiftOut(layerDataPin, layerClockPin, MSBFIRST, colMasks[col] >> 16 );
  shiftOut(layerDataPin, layerClockPin, MSBFIRST, colMasks[col] >> 8 );
  shiftOut(layerDataPin, layerClockPin, MSBFIRST, colMasks[col] );
  digitalWrite(layerLatchPin, HIGH);
}



void printBuffer(int counter)
{
  int r,g,b;
  int ndx = 0;
 
  for(int x = 23; x >= 0; x--)
  {

    clearLEDS();
    openCol(x);

    for(int y = 0; y < 15; y++)
    {
      //each byte holds a value from 0-255           
      r = buffer[ndx] ; 
      g = buffer[ndx+1] ; 
      b = buffer[ndx+2] ;

      int red = getRedSinkValue(y);
      int green = red+1;
      int blue = red+2; 
     
        Tlc.set(blue, b <<2);
        Tlc.set(red, r <<1);
        Tlc.set(green, g <<2);
     
      ndx+=3;
    }

    Tlc.update();
  }
}

Go Up