This library creates the interface to operate the TLC5940. This device manages 16 PWM outputs.
Diff: tlc5940.cpp
- Revision:
- 2:500ec33cd4b6
- Parent:
- 1:e8c8347fa919
--- 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];