This library allows control of the TLC5940 PWM driver IC. It supports both normal operation and controlling multiplexed displays.
Diff: TLC5940.cpp
- Revision:
- 2:69e40ccf506f
- Parent:
- 0:be9399a34b15
--- a/TLC5940.cpp Mon May 20 19:11:44 2013 +0000 +++ b/TLC5940.cpp Sun May 26 03:08:58 2013 +0000 @@ -26,7 +26,7 @@ reset_ticker.attach_us(this, &TLC5940::reset, (1000000.0/GSCLK_SPEED) * 4096.0); // Configure FastPWM output for GSCLK frequency at 50% duty cycle - gsclk.period_us(1000000.0/GSCLK_SPEED); + gsclk.period_us(1000000.0/(GSCLK_SPEED * 1.05)); gsclk.write(.5); } @@ -48,9 +48,14 @@ void TLC5940::reset() { + gsclk.write(0); // Turn off LEDs blank = 1; + // Virtual function that allows the next data chunk to be set after every GSCLK cycle + // Useful for setting the next frame when multiplexing (e.g. LED matrices) + setNextData(); + // Latch in data from previous cycle if needed if (need_xlat) { @@ -62,13 +67,9 @@ need_xlat = false; } - // Virtual function that allows the next data chunk to be set after every GSCLK cycle - // Useful for setting the next frame when multiplexing (e.g. LED matrices) - setNextData(); - // Reset the screen so that it is updating while data is being sent blank = 0; - + gsclk.write(.5); // Do we have new DC data to send? if (newDCData)