Source code for the Curilights Controller. See http://www.saccade.com/writing/projects/CuriController/ for details.

Dependencies:   FatFileSystem mbed

This is the source code for the Curilights controller. This lets you interactively control a string of Curilights. It provides a simple click-wheel user interface for changing colors, brightness and behavior. It responds to movement and lighting.

Finished Controller

/media/uploads/isonno/nxp3872_controllerclose.jpg

System Block Diagram

/media/uploads/isonno/blockdiagram.png

Revision:
2:965388eecf95
Parent:
0:6da5625a6946
--- a/LightString.h	Sun Jan 15 09:07:04 2012 +0000
+++ b/LightString.h	Mon Jan 16 06:33:34 2012 +0000
@@ -9,6 +9,14 @@
 #include "mbed.h"
 #endif
 
+// Use ModSerial, Andy Kirkham's interrupt based serial library.
+#ifndef MODSERIAL_H
+// For a 128 light string, setting all colors requires 3*127=384
+#define MODSERIAL_DEFAULT_RX_BUFFER_SIZE    384
+#define MODSERIAL_DEFAULT_TX_BUFFER_SIZE    128
+#include <MODSERIAL.h>
+#endif
+
 #ifndef __LIGHTSNOOP__
 #include "LightSnoop.h"
 #endif
@@ -21,11 +29,7 @@
 
     // Note: We rely on the default serial configuration of 9600 8N1,
     // this matches the CuriLights serial parameters.
-    LightString( PinName pin, int numLights )
-     : fPort( pin, NC ), fUSBPort( NC, USBRX ), fSnoop( numLights )
-    {
-        fNumLights = numLights;
-    }
+    LightString( PinName pin, int numLights );
 
     // This sends an initialization to the string and configures it.
     // If numLights is non-zero, the length of the light string is reset
@@ -69,7 +73,7 @@
     void sendCommand2( uint8_t ch1, uint8_t ch2 );
     void sendCommand3( uint8_t ch1, uint8_t ch2, uint8_t ch3 );
     
-    void HandleUSBToLights();
+    void HandleUSBToLights(MODSERIAL_IRQ_INFO * serialInfo);
     
     // Note the top red bit is stripped off to fit in the byte, other
     // code must manually add it back to the top bit if the light ID
@@ -87,8 +91,8 @@
         return color( rgb[0] - '0', rgb[1] - '0', rgb[2] - '0' );
     }
 */    
-    Serial fPort;
-    Serial fUSBPort;
+    MODSERIAL fPort;
+    MODSERIAL fUSBPort;
     int fNumLights;
     LightSnoop fSnoop;
 };