This library lets you control the addressable RGB LED strips from Pololu Robotics. Forked to add selectable colour order (Support RGB or GRB Leds)

Fork of PololuLedStrip by David Grayson

Revision:
12:b6df8ac053c8
Parent:
10:f1bb84b97788
Child:
13:9c72841ec45e
--- a/PololuLedStrip.cpp	Fri Mar 01 04:16:44 2013 +0000
+++ b/PololuLedStrip.cpp	Fri Mar 01 04:34:54 2013 +0000
@@ -4,6 +4,8 @@
 
 uint8_t led_strip_write_delays[3];
 
+static const uint8_t delay_fudges[] = { 32, 0, 0 };
+
 void PololuLedStrip::calculateDelays()
 {
     // Get the clock frequency in MHz.
@@ -14,15 +16,24 @@
     
     // Arrange for a 600 nanosecond delay between the fall time for a 0 bit and the fall time for a 1 bit.
     // This means the pulses representing a 1 will be 700+600 = 1300 nanoseconds.
-    led_strip_write_delays[1] = 600*f_mhz/1000 - 19;
+    led_strip_write_delays[1] = 600*f_mhz/1000;
     
     // Arrange for a 1200 nanosecond delay between the fall time for a 1 bit and rise time of the next bit.
     // This means the period of the signal will be 2500 nanoseconds.
-    led_strip_write_delays[2] = 1200*f_mhz/1000 - 24;
+    led_strip_write_delays[2] = 1200*f_mhz/1000;
     
-    led_strip_write_delays[0] <<= 1;
-    led_strip_write_delays[1] <<= 1;
-    led_strip_write_delays[2] <<= 1;
+    for(int i = 0; i < 3; i++)
+    {
+        if (led_strip_write_delays[i] < delay_fudges[i])
+        {
+            led_strip_write_delays[i] = 0;
+        }
+        else
+        {
+            led_strip_write_delays[i] -= delay_fudges[i];
+            led_strip_write_delays[i] <<= 1;
+        }
+    }
 }
 
 PololuLedStrip::PololuLedStrip(PinName pinName)