init update

Files at this revision

API Documentation at this revision

Comitter:
slisgrinder
Date:
Fri Mar 22 16:46:41 2013 +0000
Parent:
0:1fb7b50d16b1
Commit message:
v1

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
diff -r 1fb7b50d16b1 -r 05d2234c0965 TLC5940.cpp
--- a/TLC5940.cpp	Fri Jan 25 21:54:56 2013 +0000
+++ b/TLC5940.cpp	Fri Mar 22 16:46:41 2013 +0000
@@ -1,47 +1,44 @@
 #include "TLC5940.h"
 
-
+int num_drivers = 1;
 
-void setup (SPI &driver, PwmOut &gsclk, PinName xlat, PinName blank, PinName dcprg, PinName vprg, int num_ics)
+void setup (SPI &driver, DigitalOut &vprg, DigitalOut &xlat, DigitalOut &blank, DigitalOut &dcprg, PwmOut &gsclk, int num_ics)
 {
     xlat = 0;               // hold GS/DC data constant
-    blank = 1;              // Blank (squelch) all outputs
+    blank = 0;
+    blank = 1;
+    blank = 0;              // Blank (squelch) all outputs
     dcprg = 1;              // dcprg points DC data to DC register.
     vprg = 0;               // sets drivers to GS mode. Set to 1 to change to DC mode
-    gsclk.period_us (1);    // set grayscale clock to 1 MHz
+    gsclk.period_us (1);    // set grayscale clock to 1000 Hz
     gsclk = 0.5;            // turn on grayscale clock to 50% duty cycle at afore mentioned frequency
     
     if (num_ics <= 0)
     {
         num_drivers = 1;
-    {
+    }
     else
     {
         num_drivers = num_ics;
     }
     
     
-    driver.format (16,0);
+    driver.format (12,0);
     driver.frequency (30000000);
 }
 
 
-
-void update_led (SPI &driver, uint16_t LEDS [][])
+void update_led (SPI &driver, DigitalOut &xlat, DigitalOut &blank, unsigned short* LEDS)
 {
     blank = 1;
-    dcprg = 1;
-    vprg = 0;
-    xlat = 0;
-    
-    for (int k = 0; k < num_drivers; k++)
+    blank = 0;
+    for (int k = (num_drivers - 1); k >= 0; k--)
     {
-        for (int i = 0; i < 16; i++)
+        for (int i = (16 - 1); i >= 0; i--)
         {
-            driver.write (LEDS [k][i]);
+            driver.write (*(LEDS + k + i));
         }
     }
     xlat = 1;
     xlat = 0;
-    blank = 0;
 }
\ No newline at end of file
diff -r 1fb7b50d16b1 -r 05d2234c0965 TLC5940.h
--- a/TLC5940.h	Fri Jan 25 21:54:56 2013 +0000
+++ b/TLC5940.h	Fri Mar 22 16:46:41 2013 +0000
@@ -1,8 +1,5 @@
 #include "mbed.h"
 
 
-int num_drivers = 1;
-
-
-void setup (SPI &driver, PwmOut &gsclk, PinName xlat, PinName blank, PinName dcprg, PinName vprg, int num ics);
-void update_led (SPI &driver, uint16_t LEDS [][]);
\ No newline at end of file
+void setup (SPI &driver, DigitalOut &vprg, DigitalOut &xlat, DigitalOut &blank, DigitalOut &dcprg, PwmOut &gsclk, int num_ics);
+void update_led (SPI &driver, DigitalOut &xlat, DigitalOut &blank, unsigned short* LEDS);
\ No newline at end of file