This library creates the interface to operate the TLC5940. This device manages 16 PWM outputs.

Files at this revision

API Documentation at this revision

Comitter:
Fiuba
Date:
Sat Nov 27 00:50:01 2010 +0000
Parent:
1:e8c8347fa919
Child:
3:40cb2f9adc4d
Commit message:
The number of ICs is defined by the constructor.

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	Sat Nov 27 00:37:33 2010 +0000
+++ b/tlc5940.cpp	Sat Nov 27 00:50:01 2010 +0000
@@ -20,7 +20,9 @@
 #include "tlc5940.h"
 #include "mbed.h"
 
-tlc5940::tlc5940 (int DC_data[]) : VPROG(p21), SIN(p22), SCLK(p23), XLAT(p24), BLANK(p25), DCPROG(p27), GSCLK(p26), SOUT(p28), XERR(p29) {
+tlc5940::tlc5940 (int num_ics, int DC_data[]) :
+        num_ic(num_ics), VPROG(p21), SIN(p22), SCLK(p23), XLAT(p24),
+        BLANK(p25), DCPROG(p27), GSCLK(p26), SOUT(p28), XERR(p29) {
     first_cycle_flag = false;
 
     // Pins in startup state
@@ -36,7 +38,7 @@
     DCPROG = 1;
     VPROG = 1;
 
-    for (int counter=0; counter < (2*96); counter++) {
+    for (int counter=0; counter < (num_ic*96); counter++) {
         SIN = DC_data[counter];
         SCLK = 1;
         wait_us(5);
@@ -64,7 +66,7 @@
     // Send the new data
     BLANK = 0;
     for (GSCLK_counter = 0; GSCLK_counter <= 4095; GSCLK_counter++) {
-        if (data_counter < 2*192) {
+        if (data_counter < num_ic*192) {
             // Every new led consists of 12 bits
             aux_ind = data_counter % 12;
             if ( aux_ind == 0 ) aux_value = data[data_counter/12];
--- a/tlc5940.h	Sat Nov 27 00:37:33 2010 +0000
+++ b/tlc5940.h	Sat Nov 27 00:50:01 2010 +0000
@@ -27,6 +27,7 @@
     bool first_cycle_flag;
     int GSCLK_counter, data_counter;
     int aux_value, aux_ind;
+    int num_ic;
 
     DigitalOut VPROG;
     DigitalOut SIN;
@@ -42,9 +43,10 @@
 public:
     /** Create a tlc5940 interface object connected to some specifics pins
      *
+     * @param num_ics Number of TLC5940 connected in series
      * @param DC_data[] Dot Correction values for initialization
      */
-    tlc5940 (int DC_data[]);
+    tlc5940 (int num_ics, int DC_data[]);
 
     /** Send the specified set of grayscale values
      *