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
System Block Diagram
Diff: LightString.h
- Revision:
- 3:0ac64c4ca40f
- Parent:
- 0:6da5625a6946
- Child:
- 4:cfef06d8bb96
--- a/LightString.h Sun Jan 15 09:07:04 2012 +0000 +++ b/LightString.h Tue Jan 17 13:45:17 2012 +0000 @@ -21,11 +21,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 @@ -58,18 +54,17 @@ void Ouch() { SetAllLights( 777 ); } - // Attaches the USB port to the light port, so - // data is passed straight through from the host to the lights. - void AttachUSBSerial(); + LightSnoop * Snoop() { return &fSnoop; } - LightSnoop * Snoop() { return &fSnoop; } + void FlushOutput() { HandleOutgoingData(); }; private: void sendCommand1( uint8_t ch ); void sendCommand2( uint8_t ch1, uint8_t ch2 ); void sendCommand3( uint8_t ch1, uint8_t ch2, uint8_t ch3 ); - void HandleUSBToLights(); + void HandleIncomingData(); + void HandleOutgoingData(); // 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,9 +82,12 @@ return color( rgb[0] - '0', rgb[1] - '0', rgb[2] - '0' ); } */ - Serial fPort; + Serial fLightsPort; Serial fUSBPort; int fNumLights; LightSnoop fSnoop; + uint8_t fBuffer[384]; + int fBufferInPos; + int fBufferOutPos; }; #endif