This library allows control of the TLC5940 PWM driver IC. It supports both normal operation and controlling multiplexed displays.

Dependencies:   FastPWM

Dependents:   TLC5940LEDtreiber

Embed: (wiki syntax)

« Back to documentation index

TLC5940 Class Reference

This class controls a TLC5940 PWM driver IC. More...

#include <TLC5940.h>

Inherited by TLC5940Mux [private].

Public Member Functions

 TLC5940 (PinName SCLK, PinName MOSI, PinName GSCLK, PinName BLANK, PinName XLAT, PinName DCPRG, PinName VPRG, const int number=1)
 Set up the TLC5940.
void setNewGSData (unsigned short *data)
 Set the next chunk of grayscale data to be sent.
void setNewDCData (unsigned char *data)
 Set the next chunk of dot correction data to be sent.

Protected Member Functions

virtual void setNextData ()
 Set the next chunk of grayscale data to be sent while in the current reset cycle.

Detailed Description

This class controls a TLC5940 PWM driver IC.

It supports sending dot correction and grayscale data. However, it does not support error checking or writing the EEPROM. This class uses the FastPWM library by Erik Olieman to continuously pulse the GSLCK pin without CPU intervention. After 4096 pulses, the private member funciton reset is called by the ticker. It resets the display by pulsing the BLANK pin. If new data has been set to be sent by the functions setNewGSData or setNewDCData, it is sent here. The definition GSCLK_SPEED in TLC5940.h controls how often this function is called. A higher GSCLK_SPEED will increase the rate at which the screen is updated but also increase CPU time spent in that function. The default value is 1Mhz. The rate at which the reset function is called can be calculated by: (1/GSCLK_SPEED) * 4096.

Using the TLC5940 class to control an LED:

  #include "mbed.h"
  #include "TLC5940.h"
  
  // Create the TLC5940 instance
  TLC5940 tlc(p7, p5, p21, p9, p10, p11, p12, 1);
  
  int main()
  {   
      // Create a buffer to store the data to be sent
      unsigned short GSData[16] = { 0x0000 };
  
      // Enable the first LED
      GSData[0] = 0xFFF;
      
      // Set the new data
      tlc.setNewGSData(GSData);
      
      while(1)
      {
  
      }
  }

Definition at line 69 of file TLC5940.h.


Constructor & Destructor Documentation

TLC5940 ( PinName  SCLK,
PinName  MOSI,
PinName  GSCLK,
PinName  BLANK,
PinName  XLAT,
PinName  DCPRG,
PinName  VPRG,
const int  number = 1 
)

Set up the TLC5940.

Parameters:
SCLK- The SCK pin of the SPI bus
MOSI- The MOSI pin of the SPI bus
GSCLK- The GSCLK pin of the TLC5940(s)
BLANK- The BLANK pin of the TLC5940(s)
XLAT- The XLAT pin of the TLC5940(s)
DCPRG- The DCPRG pin of the TLC5940(s)
VPRG- The VPRG pin of the TLC5940(s)
number- The number of TLC5940s (if you are daisy chaining)

Definition at line 3 of file TLC5940.cpp.


Member Function Documentation

void setNewDCData ( unsigned char *  data )

Set the next chunk of dot correction data to be sent.

Parameters:
data- Array of 8 bit chars containing 16 6 bit dot correction data chunks per TLC5940
Note:
These must be in intervals of at least (1/GSCLK_SPEED) * 4096 to be sent. Also, this function is optional. If you do not use it, then the TLC5940 will use the EEPROM, which (by default) conatins the data 0x3F.

Definition at line 41 of file TLC5940.cpp.

void setNewGSData ( unsigned short *  data )

Set the next chunk of grayscale data to be sent.

Parameters:
data- Array of 16 bit shorts containing 16 12 bit grayscale data chunks per TLC5940
Note:
These must be in intervals of at least (1/GSCLK_SPEED) * 4096 to be sent

Definition at line 33 of file TLC5940.cpp.

virtual void setNextData (  ) [protected, virtual]

Set the next chunk of grayscale data to be sent while in the current reset cycle.

Note:
This is useful to send the next set of data right after the first is finished being displayed. The primary purpose for this is multiplexing, although it could be used for anything else.

Definition at line 107 of file TLC5940.h.