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: ZMotionDetector.cpp
- Revision:
- 0:6da5625a6946
- Child:
- 3:0ac64c4ca40f
diff -r 000000000000 -r 6da5625a6946 ZMotionDetector.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ZMotionDetector.cpp Thu Dec 29 01:59:53 2011 +0000 @@ -0,0 +1,56 @@ +// Motion detector support for the Zilog ePIR Motion Detection ZDots SBC + +#include "mbed.h" +#include "ZMotionDetector.h" +#include "HoldInterrupts.h" + +//const char NACK = 0x15; +const char ACK = 0x06; + +ZMotionDetector::ZMotionDetector( PinName ztx, PinName zrx ) +: fMDPort( ztx, zrx ) +{} + +bool +ZMotionDetector::IsMotionDetected() +{ + HoldInterrupts noir; + + fMDPort.putc('a'); // Read Motion status + return fMDPort.getc() == 'Y'; +} + +void +ZMotionDetector::SetExtendedRange( bool on ) +{ + HoldInterrupts noir; + + fMDPort.putc('E'); + fMDPort.getc(); // Current value + fMDPort.putc( on ? 'Y' : 'N' ); + if (fMDPort.getc() != ACK) + printf("Error setting extended motion detector range\r\n"); +} + +void +ZMotionDetector::SetAsyncMode( bool on ) +{ + HoldInterrupts noir; + + if (! on) + fMDPort.attach( NULL ); + fMDPort.putc('M'); + fMDPort.getc(); // Gets the current mode setting) + fMDPort.putc( on ? 'Y' : 'N' ); + if (fMDPort.getc() != ACK) + printf("Error setting motion detector async mode\r\n"); + else + if (on) + fMDPort.attach( this, &ZMotionDetector::Motion ); +} + +void +ZMotionDetector::Motion() +{ + printf("Motion!!\r\n"); +}