This library allows control of the TLC5940 PWM driver IC. It supports both normal operation and controlling multiplexed displays.
Revision 2:69e40ccf506f, committed 2013-05-26
- Comitter:
- Spencer
- Date:
- Sun May 26 03:08:58 2013 +0000
- Parent:
- 1:013a9737441d
- Child:
- 3:e5ed5650eb15
- Commit message:
- Various updates and bug fixes
Changed in this revision
TLC5940.cpp | Show annotated file Show diff for this revision Revisions of this file |
TLC5940.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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)
--- a/TLC5940.h Mon May 20 19:11:44 2013 +0000 +++ b/TLC5940.h Sun May 26 03:08:58 2013 +0000 @@ -28,7 +28,7 @@ * before the completion of a GSCLK cycle (4096 pulses). If you are daisy chaining multiple TLC5940s, * divide 32Mhz by the number of chips to get a good maximum rate. */ -#define GSCLK_SPEED 2500000 +#define GSCLK_SPEED 1000000 /** * This class controls a TLC5940 PWM driver IC.