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
SystemState.h@4:cfef06d8bb96, 2013-02-11 (annotated)
- Committer:
- isonno
- Date:
- Mon Feb 11 05:04:18 2013 +0000
- Revision:
- 4:cfef06d8bb96
- Parent:
- 3:0ac64c4ca40f
Minor changes to add backlight routines. Not hooked up yet, shouldn't affect build operation.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
isonno |
0:6da5625a6946 | 1 | #ifndef _SYSTEMSTATE_ |
isonno |
0:6da5625a6946 | 2 | #define _SYSTEMSTATE_ |
isonno |
0:6da5625a6946 | 3 | |
isonno |
0:6da5625a6946 | 4 | #ifndef _USERINTERFACE_ |
isonno |
0:6da5625a6946 | 5 | #include "UserInterface.h" |
isonno |
0:6da5625a6946 | 6 | #endif |
isonno |
0:6da5625a6946 | 7 | |
isonno |
0:6da5625a6946 | 8 | #ifndef MBED_H |
isonno |
0:6da5625a6946 | 9 | #include "mbed.h" |
isonno |
0:6da5625a6946 | 10 | #endif |
isonno |
0:6da5625a6946 | 11 | |
isonno |
0:6da5625a6946 | 12 | #include <string> |
isonno |
0:6da5625a6946 | 13 | |
isonno |
0:6da5625a6946 | 14 | #define DEFINE_GET_SET_VAR( vtype, name ) \ |
isonno |
0:6da5625a6946 | 15 | public:\ |
isonno |
0:6da5625a6946 | 16 | vtype Get ## name() const { return f ## name; };\ |
isonno |
0:6da5625a6946 | 17 | void Set ## name( const vtype& var ) { if (f ## name != var) { f ## name = var; Modified(); } };\ |
isonno |
0:6da5625a6946 | 18 | private:\ |
isonno |
0:6da5625a6946 | 19 | vtype f ## name; |
isonno |
0:6da5625a6946 | 20 | |
isonno |
0:6da5625a6946 | 21 | |
isonno |
0:6da5625a6946 | 22 | class SystemState |
isonno |
0:6da5625a6946 | 23 | { |
isonno |
0:6da5625a6946 | 24 | public: |
isonno |
0:6da5625a6946 | 25 | SystemState(); |
isonno |
0:6da5625a6946 | 26 | ~SystemState() {}; |
isonno |
0:6da5625a6946 | 27 | bool LoadState(); |
isonno |
0:6da5625a6946 | 28 | void DumpState(); // Debug |
isonno |
0:6da5625a6946 | 29 | |
isonno |
0:6da5625a6946 | 30 | DEFINE_GET_SET_VAR( ESelector, ModeSelector ) |
isonno |
0:6da5625a6946 | 31 | DEFINE_GET_SET_VAR( int, BrightLevel ) |
isonno |
0:6da5625a6946 | 32 | DEFINE_GET_SET_VAR( int, SatColorIndex) |
isonno |
0:6da5625a6946 | 33 | DEFINE_GET_SET_VAR( int, PatternIndex ) |
isonno |
3:0ac64c4ca40f | 34 | DEFINE_GET_SET_VAR( int, LightSensor ) |
isonno |
0:6da5625a6946 | 35 | |
isonno |
0:6da5625a6946 | 36 | private: |
isonno |
0:6da5625a6946 | 37 | Timeout fStateTimer; |
isonno |
0:6da5625a6946 | 38 | void SaveState(); |
isonno |
0:6da5625a6946 | 39 | void Modified(); |
isonno |
0:6da5625a6946 | 40 | }; |
isonno |
0:6da5625a6946 | 41 | |
isonno |
0:6da5625a6946 | 42 | extern SystemState& gSystemState; |
isonno |
0:6da5625a6946 | 43 | |
isonno |
0:6da5625a6946 | 44 | #endif |