Example project for controlling GE ColorEffect Lights

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
clarkjarvis
Date:
Fri Dec 19 16:38:26 2014 +0000
Child:
1:93c7d040444d
Commit message:
Base example project for controlling GE ColorEffect Lights

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 19 16:38:26 2014 +0000
@@ -0,0 +1,93 @@
+#include "mbed.h"
+
+DigitalOut gpo(D12);
+DigitalOut led_red(LED_RED);
+DigitalOut led_green(LED_GREEN);
+DigitalOut led_blue(LED_BLUE);
+
+#define AL 18 // Array Length
+#define NB 50 // Number of Bulbs
+#define LUM 0xFF // Brightness
+
+//RGB (array) (18)
+unsigned int rval[AL] = {0xF,0xF,0xF,0xF,0xA,0x8,0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x8,0xA};
+unsigned int gval[AL] = {0x0,0x0,0x0,0x0,0x6,0x8,0xA,0xF,0xF,0xF,0xA,0x8,0x6,0x0,0x0,0x0,0x0,0x0};
+unsigned int bval[AL] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x8,0xA,0xF,0xF,0xA,0x8,0x6};
+
+void s0()
+{
+    gpo=0;
+    wait_us(10);
+    gpo=1;
+    wait_us(20);
+}
+
+void s1()
+{
+    gpo=0;
+    wait_us(20);
+    gpo=1;
+    wait_us(10);
+}
+
+void end_frame()
+{
+    gpo=0;
+    wait_us(30);
+}
+
+void sdata(unsigned int data, int length)
+{
+    unsigned int data_bit;
+
+    for (int i=(length-1); i>=0; i--) {
+        data_bit = (data>>i)&0x01;
+        if (data_bit==0) {
+            s0();
+        } else if (data_bit==1) {
+            s1();
+        }
+    }
+}
+
+void sframe(int channel, unsigned int lumm, unsigned int R, unsigned int G, unsigned int B)
+{
+// Send "1" value to start Frame
+    s1();
+// Send Address
+    sdata(channel,6);
+// Send Luminosity
+    sdata(lumm,8);
+// Send Blue 4-bits
+    sdata(B,4);
+// Send Green 4-bits
+    sdata(G,4);
+// Send Red 4-bits
+    sdata(R,4);
+// Send End of Frame Marker
+    end_frame();
+}
+
+int main()
+{
+    led_red=1;
+    led_green=1;
+    led_blue=1;
+    gpo=0;
+
+    wait_ms(1000);
+
+    // Init
+    for (int i=0; i<=NB; i++) {
+        sframe(i,0,0,0,0);
+    }
+
+    while(1) {
+        for (int i=0; i<AL; i++) {
+            for (int j=0; j<NB; j++) {
+                sframe(j,LUM,rval[(i+j)%AL],gval[(i+j)%AL],bval[(i+j)%AL]);
+            }
+            wait_ms(10);
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Dec 19 16:38:26 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file