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: UIMenu.h
- Revision:
- 3:0ac64c4ca40f
- Parent:
- 1:d1da77023e6a
- Child:
- 4:cfef06d8bb96
--- a/UIMenu.h Sun Jan 15 09:07:04 2012 +0000 +++ b/UIMenu.h Tue Jan 17 13:45:17 2012 +0000 @@ -21,12 +21,15 @@ #define SETUP_KNOB_CALLBACKS( className ) \ virtual void AttachKnob( RotaryEncoder * knob ) { knob->attach( this, &className::KnobMoved ); }\ virtual void AttachButton( PushButton * button ) { button->attach( this, &className::KnobPushed ); } + +#define SETUP_KNOBPUSH_CALLBACK( className ) \ + virtual void AttachButton( PushButton * button ) { button->attach( this, &className::KnobPushed ); } // This class manages the input hardware class PushKnobUI { public: - PushKnobUI( CheapLCD * lcd ) : fKnob( NULL ), fKnobButton( NULL ), fLCD( lcd ) {} + PushKnobUI( CheapLCD * lcd ) : fLCD( lcd ), fKnob( NULL ), fKnobButton( NULL ) {} virtual ~PushKnobUI() {} // Call this with pointers to the devices when the menu is active. @@ -50,11 +53,12 @@ virtual void Sleep(); SETUP_KNOB_CALLBACKS( PushKnobUI ) + + CheapLCD * fLCD; private: RotaryEncoder * fKnob; PushButton * fKnobButton; - CheapLCD * fLCD; }; // This knob implements a basic menu system @@ -85,22 +89,25 @@ // Change the text of an item (updates display if display is on) virtual void ChangeItem( int item, const char * label ); + // Change the header (title) of the menu + virtual void ChangeHeader( const char * header ); + protected: vector<string> fLabels; string fHeader; virtual int32_t KnobMoved( int32_t step ); virtual void KnobPushed(); + virtual void ClearItem( int i, uint32_t color ); SETUP_KNOB_CALLBACKS( UIMenu ) private: void DrawItem( int item ); + void DrawHeader(); bool fDisplayOn; - bool fUpMenuItem; int fSelectedItem; - CheapLCD * fLCD; }; #endif