Clark Jarvis
/
FRDM_GE_ColorEffects
Example project for controlling GE ColorEffect Lights
Revision 1:93c7d040444d, committed 2015-01-19
- Comitter:
- clarkjarvis
- Date:
- Mon Jan 19 20:31:32 2015 +0000
- Parent:
- 0:d9cf7fb66406
- Commit message:
- Updated comments
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r d9cf7fb66406 -r 93c7d040444d main.cpp --- a/main.cpp Fri Dec 19 16:38:26 2014 +0000 +++ b/main.cpp Mon Jan 19 20:31:32 2015 +0000 @@ -1,6 +1,6 @@ #include "mbed.h" -DigitalOut gpo(D12); +DigitalOut gpo(D12); // Output pin for lights DigitalOut led_red(LED_RED); DigitalOut led_green(LED_GREEN); DigitalOut led_blue(LED_BLUE); @@ -9,11 +9,12 @@ #define NB 50 // Number of Bulbs #define LUM 0xFF // Brightness -//RGB (array) (18) +//Example RGB Color 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}; +// GPIO output to send a logical 0 void s0() { gpo=0; @@ -22,6 +23,7 @@ wait_us(20); } +// GPIO output to send a logical 1 void s1() { gpo=0; @@ -30,12 +32,14 @@ wait_us(10); } +// GPIO output to send an "End of Frame" marker void end_frame() { gpo=0; wait_us(30); } +// Parse data value to serial process 0/1's void sdata(unsigned int data, int length) { unsigned int data_bit; @@ -50,6 +54,7 @@ } } +// Send frame of data to control a single pixel void sframe(int channel, unsigned int lumm, unsigned int R, unsigned int G, unsigned int B) { // Send "1" value to start Frame @@ -77,11 +82,12 @@ wait_ms(1000); - // Init + // Initialize the light addresses (required after initially powering lights) for (int i=0; i<=NB; i++) { sframe(i,0,0,0,0); } + // Example light sequence while(1) { for (int i=0; i<AL; i++) { for (int j=0; j<NB; j++) {