Driver for WS2812

Dependents:   ChrisRGB-Ring

Revision:
5:a07522fe36d4
Parent:
4:b230e85fc5e7
--- a/WS2812.cpp	Wed Aug 06 08:34:32 2014 +0000
+++ b/WS2812.cpp	Mon Aug 18 13:25:57 2014 +0000
@@ -25,6 +25,25 @@
 }
 
 
+void WS2812::write_offsets(int buf[], int r_offset, int g_offset, int b_offset)
+{
+    // for each of the data points in the buffer
+    for (int i = 0; i < __size ; i++) {
+
+        unsigned int argb = 0x0;
+        // index and extract colour fields from IIRRGGBB buf[]
+        // 0 = blue, 1 = green, 2 = red, 3 = brightness
+        argb |=  (buf[(i+b_offset)%__size] & 0x000000FF);
+        argb |= ((buf[(i+g_offset)%__size] & 0x0000FF00));
+        argb |= ((buf[(i+r_offset)%__size] & 0x00FF0000));
+        argb |= (buf[i] & 0xFF000000);
+        __write(argb);
+    }
+}
+
+
+
+
 void WS2812::setAll(int colour)
 {
     // for each of the data points in the buffer