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.cpp
- Revision:
- 2:965388eecf95
- Parent:
- 0:6da5625a6946
--- a/LightString.cpp Sun Jan 15 09:07:04 2012 +0000 +++ b/LightString.cpp Mon Jan 16 06:33:34 2012 +0000 @@ -6,43 +6,42 @@ #include "HoldInterrupts.h" -void LightString::AttachUSBSerial() +LightString::LightString( PinName pin, int numLights ) + : fPort( pin, NC ), fUSBPort( NC, USBRX ), fSnoop( numLights ) { - fUSBPort.attach( this, &LightString::HandleUSBToLights ); + fNumLights = numLights; } -void LightString::HandleUSBToLights() +void LightString::AttachUSBSerial() { - uint8_t buffer[512]; - int i, count = 0; - while (fUSBPort.readable() && (count < sizeof(buffer))) + fUSBPort.attach( this, &LightString::HandleUSBToLights, MODSERIAL::RxIrq ); +} + +void LightString::HandleUSBToLights(MODSERIAL_IRQ_INFO * serialInfo) +{ + while (fUSBPort.readable()) { - buffer[count++] = fUSBPort.getc(); - } - for (i = 0; i < count; ++i) - { - while (! fPort.writeable()) {}; // Spin wait on the output - fPort.putc( buffer[i] ); + fPort.putc( fUSBPort.getc() ); } } void LightString::sendCommand1( uint8_t ch ) { - HoldInterrupts noint(); +// HoldInterrupts noint(); fPort.putc( ch ); } void LightString::sendCommand2( uint8_t ch1, uint8_t ch2 ) { - HoldInterrupts noint(); +// HoldInterrupts noint(); fPort.putc( ch1 ); fPort.putc( ch2 ); } void LightString::sendCommand3( uint8_t ch1, uint8_t ch2, uint8_t ch3 ) { - HoldInterrupts noint(); +// HoldInterrupts noint(); fPort.putc( ch1 ); fPort.putc( ch2 ); fPort.putc( ch3 );