This library allows control of the TLC5940 PWM driver IC. It supports both normal operation and controlling multiplexed displays.
TLC5940Mux Class Reference
This class allows a TLC5940 to be multiplexed. More...
#include <TLC5940.h>
Inherits TLC5940.
Public Member Functions | |
TLC5940Mux (PinName SCLK, PinName MOSI, PinName GSCLK, PinName BLANK, PinName XLAT, PinName DCPRG, PinName VPRG, const int number, const int rows, void(*SetRows)(int)) | |
Set up the TLC5940. | |
unsigned short * | operator= (unsigned short *data) |
Set the contents of the buffer that contains the multiplexed data. | |
unsigned short * | operator[] (int index) |
Get a pointer to one of the rows of the multiplexed data. | |
Private Member Functions | |
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. |
Detailed Description
This class allows a TLC5940 to be multiplexed.
It inherits the TLC5940 class and uses it to control the TLC5940 driver(s). It does not support sending dot corection data. This class sets the new grayscale data every iteration of the GSCLK reset loop. It then updates the current row using the user defined function SetRows. The framerate you will recieve using this function can be calculate by: 1 / (((1/GSCLK_SPEED) * 4096) * rows). I reccomend maintaining a framerate above 30fps. However, keep in mind that as your framerate increases, so does your CPU usage.
Using the TLC5940Mux class to control an 8x8 LED matrix:
#include "mbed.h" #include "TLC5940.h" // Bus connecting to the rows of the LED matrix through PNP transistors BusOut rows(p22, p23, p24, p25, p26, p27, p28, p29); // Function to update the rows using the BusOut class void SetRows(int nextRow) { // I am using PNP transistors, so inversion is necessary rows = ~(1 << nextRow); } // Create the TLC5940Mux instance TLC5940Mux tlc(p7, p5, p21, p9, p10, p11, p12, 1, 8, &SetRows); int main() { tlc[0][0] = 0xFFF; // Turn on the top left LED while(1) { } }
Definition at line 180 of file TLC5940.h.
Constructor & Destructor Documentation
TLC5940Mux | ( | PinName | SCLK, |
PinName | MOSI, | ||
PinName | GSCLK, | ||
PinName | BLANK, | ||
PinName | XLAT, | ||
PinName | DCPRG, | ||
PinName | VPRG, | ||
const int | number, | ||
const int | rows, | ||
void(*)(int) | SetRows | ||
) |
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) rows - The number of rows you are multiplexing SetRows - The function pointer to your function that sets the current row.
- Note:
- The SetRows function allows you to set exactly how you want your rows to be updated. The TLC5940Mux class calls this function with an argument of int that contains the number of the row to be turned on. If the TLC5940Mux class needs the first row to be turned on, the int will be 0.
Definition at line 5 of file TLC5940Mux.cpp.
Member Function Documentation
unsigned short * operator= | ( | unsigned short * | data ) |
Set the contents of the buffer that contains the multiplexed data.
- Parameters:
-
data - The data to set to the buffer containing 16 12 bit grayscale data chunks per TLC5940
- Returns:
- The data provided
Definition at line 26 of file TLC5940Mux.cpp.
unsigned short * operator[] | ( | int | index ) |
Get a pointer to one of the rows of the multiplexed data.
- Parameters:
-
index - The row that you would like the contents of
- Returns:
- A pointer to the data containing the requested row containing 16 12 bit grayscale data chunks per TLC5940
- Note:
- This operator can also be used to change or get the value of an individual LED. For example:
TLC5940Mux[0][0] = 0xFFF;
Definition at line 34 of file TLC5940Mux.cpp.
Generated on Tue Jul 12 2022 17:55:54 by 1.7.2