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
LightSnoop.h@0:6da5625a6946, 2011-12-29 (annotated)
- Committer:
- isonno
- Date:
- Thu Dec 29 01:59:53 2011 +0000
- Revision:
- 0:6da5625a6946
Contest submission version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
isonno |
0:6da5625a6946 | 1 | // |
isonno |
0:6da5625a6946 | 2 | // LightSnoop.h - Listen to a serial stream, and determine light |
isonno |
0:6da5625a6946 | 3 | // colors and settings from it. |
isonno |
0:6da5625a6946 | 4 | // |
isonno |
0:6da5625a6946 | 5 | |
isonno |
0:6da5625a6946 | 6 | #ifndef __LIGHTSNOOP__ |
isonno |
0:6da5625a6946 | 7 | #define __LIGHTSNOOP__ |
isonno |
0:6da5625a6946 | 8 | |
isonno |
0:6da5625a6946 | 9 | #ifndef MBED_H |
isonno |
0:6da5625a6946 | 10 | #include "mbed.h" |
isonno |
0:6da5625a6946 | 11 | #endif |
isonno |
0:6da5625a6946 | 12 | |
isonno |
0:6da5625a6946 | 13 | #include <vector> |
isonno |
0:6da5625a6946 | 14 | |
isonno |
0:6da5625a6946 | 15 | class LightString; |
isonno |
0:6da5625a6946 | 16 | |
isonno |
0:6da5625a6946 | 17 | typedef enum { kAwaitCommand, kAwaitID, kAwaitValue } ESnoopState; |
isonno |
0:6da5625a6946 | 18 | |
isonno |
0:6da5625a6946 | 19 | const int kBufferMax = 600; |
isonno |
0:6da5625a6946 | 20 | |
isonno |
0:6da5625a6946 | 21 | class LightSnoop |
isonno |
0:6da5625a6946 | 22 | { |
isonno |
0:6da5625a6946 | 23 | public: |
isonno |
0:6da5625a6946 | 24 | LightSnoop( int numLights ); |
isonno |
0:6da5625a6946 | 25 | ~LightSnoop() {} |
isonno |
0:6da5625a6946 | 26 | |
isonno |
0:6da5625a6946 | 27 | void SaveSnoop(); |
isonno |
0:6da5625a6946 | 28 | void Listen( const uint8_t ch ); |
isonno |
0:6da5625a6946 | 29 | |
isonno |
0:6da5625a6946 | 30 | bool IsActive(); |
isonno |
0:6da5625a6946 | 31 | |
isonno |
0:6da5625a6946 | 32 | private: |
isonno |
0:6da5625a6946 | 33 | void Process( const uint8_t ch ); |
isonno |
0:6da5625a6946 | 34 | |
isonno |
0:6da5625a6946 | 35 | vector<uint16_t> fLightValues; |
isonno |
0:6da5625a6946 | 36 | ESnoopState fSnoopState; |
isonno |
0:6da5625a6946 | 37 | uint8_t fCommand; |
isonno |
0:6da5625a6946 | 38 | uint8_t fID; |
isonno |
0:6da5625a6946 | 39 | uint8_t fBuffer[kBufferMax]; |
isonno |
0:6da5625a6946 | 40 | int fBufferIndex, fLastBufferIndex; |
isonno |
0:6da5625a6946 | 41 | }; |
isonno |
0:6da5625a6946 | 42 | |
isonno |
0:6da5625a6946 | 43 | #endif |