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

/media/uploads/isonno/nxp3872_controllerclose.jpg

System Block Diagram

/media/uploads/isonno/blockdiagram.png

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?

UserRevisionLine numberNew contents of line
isonno 4:cfef06d8bb96 1 //
isonno 4:cfef06d8bb96 2 // Settings menu implementation
isonno 4:cfef06d8bb96 3 //
isonno 4:cfef06d8bb96 4
isonno 4:cfef06d8bb96 5 #include "SettingsMenu.h"
isonno 4:cfef06d8bb96 6 #include "UserInterface.h"
isonno 4:cfef06d8bb96 7 #include "SystemState.h"
isonno 4:cfef06d8bb96 8
isonno 4:cfef06d8bb96 9 /*
isonno 4:cfef06d8bb96 10 class SettingsMenu : public UIMenu
isonno 4:cfef06d8bb96 11 {
isonno 4:cfef06d8bb96 12 public:
isonno 4:cfef06d8bb96 13 SettingsMenu( CheapLCD * lcd, HomeMenu * parent );
isonno 4:cfef06d8bb96 14 virtual ~SettingsMenu() {};
isonno 4:cfef06d8bb96 15
isonno 4:cfef06d8bb96 16 protected:
isonno 4:cfef06d8bb96 17 virtual void KnobPushed();
isonno 4:cfef06d8bb96 18 virtual void AttachButton( PushButton * button )
isonno 4:cfef06d8bb96 19 { button->attach( this, &SettingsMenu::KnobPushed ); }
isonno 4:cfef06d8bb96 20
isonno 4:cfef06d8bb96 21 private:
isonno 4:cfef06d8bb96 22 HomeMenu * fParent;
isonno 4:cfef06d8bb96 23 CheapLCD * fLCD;
isonno 4:cfef06d8bb96 24 };
isonno 4:cfef06d8bb96 25 */
isonno 4:cfef06d8bb96 26
isonno 4:cfef06d8bb96 27 SettingsMenu::SettingsMenu( CheapLCD * lcd, HomeMenu * parent )
isonno 4:cfef06d8bb96 28 : UIMenu( lcd, "Settings" ),
isonno 4:cfef06d8bb96 29 fParent( parent ),
isonno 4:cfef06d8bb96 30 fLightSensorMenu( lcd, this ),
isonno 4:cfef06d8bb96 31 fDebugMenu( lcd, this )
isonno 4:cfef06d8bb96 32 {
isonno 4:cfef06d8bb96 33 fLabels.push_back( string( "Light Sensor" ) );
isonno 4:cfef06d8bb96 34 fLabels.push_back( string( "Motion Sensor" ) );
isonno 4:cfef06d8bb96 35 fLabels.push_back( string( "Defaults" ) );
isonno 4:cfef06d8bb96 36 fLabels.push_back( string( "Debug" ) );
isonno 4:cfef06d8bb96 37 fLabels.push_back( string( "Exit Settings" ) );
isonno 4:cfef06d8bb96 38 }
isonno 4:cfef06d8bb96 39
isonno 4:cfef06d8bb96 40 void SettingsMenu::KnobPushed()
isonno 4:cfef06d8bb96 41 {
isonno 4:cfef06d8bb96 42 switch( SelectedItem() )
isonno 4:cfef06d8bb96 43 {
isonno 4:cfef06d8bb96 44 case 0:
isonno 4:cfef06d8bb96 45 SwitchTo( &fLightSensorMenu );
isonno 4:cfef06d8bb96 46 break;
isonno 4:cfef06d8bb96 47
isonno 4:cfef06d8bb96 48 case 3:
isonno 4:cfef06d8bb96 49 SwitchTo( &fDebugMenu );
isonno 4:cfef06d8bb96 50 break;
isonno 4:cfef06d8bb96 51
isonno 4:cfef06d8bb96 52 case 4:
isonno 4:cfef06d8bb96 53 SwitchTo( fParent );
isonno 4:cfef06d8bb96 54 break;
isonno 4:cfef06d8bb96 55 }
isonno 4:cfef06d8bb96 56 }
isonno 4:cfef06d8bb96 57
isonno 4:cfef06d8bb96 58 LightSensorMenu::LightSensorMenu( CheapLCD * lcd, SettingsMenu * parent )
isonno 4:cfef06d8bb96 59 : UIMenu( lcd ),
isonno 4:cfef06d8bb96 60 fParent( parent )
isonno 4:cfef06d8bb96 61 {
isonno 4:cfef06d8bb96 62 fLabels.push_back( string( "Enable" ) );
isonno 4:cfef06d8bb96 63 fLabels.push_back( string( "Disable" ) );
isonno 4:cfef06d8bb96 64 fLabels.push_back( string( "Exit" ) );
isonno 4:cfef06d8bb96 65 fLightState = gSystemState.GetLightSensor();
isonno 4:cfef06d8bb96 66 fHeader = string( fLightState ? "Lt Sens On" : "Lt Sens Off" );
isonno 4:cfef06d8bb96 67 }
isonno 4:cfef06d8bb96 68
isonno 4:cfef06d8bb96 69 void LightSensorMenu::KnobPushed()
isonno 4:cfef06d8bb96 70 {
isonno 4:cfef06d8bb96 71 switch( SelectedItem() )
isonno 4:cfef06d8bb96 72 {
isonno 4:cfef06d8bb96 73 case 0:
isonno 4:cfef06d8bb96 74 fLightState = 1;
isonno 4:cfef06d8bb96 75 ChangeHeader( "Lt Sens On" );
isonno 4:cfef06d8bb96 76 break;
isonno 4:cfef06d8bb96 77
isonno 4:cfef06d8bb96 78 case 1:
isonno 4:cfef06d8bb96 79 fLightState = 0;
isonno 4:cfef06d8bb96 80 ChangeHeader( "Lt Sens Off" );
isonno 4:cfef06d8bb96 81 break;
isonno 4:cfef06d8bb96 82
isonno 4:cfef06d8bb96 83 case 2:
isonno 4:cfef06d8bb96 84 gSystemState.SetLightSensor( fLightState );
isonno 4:cfef06d8bb96 85 SwitchTo( fParent );
isonno 4:cfef06d8bb96 86 break;
isonno 4:cfef06d8bb96 87 }
isonno 4:cfef06d8bb96 88 }
isonno 4:cfef06d8bb96 89
isonno 4:cfef06d8bb96 90 DebugMenu::DebugMenu( CheapLCD * lcd, SettingsMenu * parent )
isonno 4:cfef06d8bb96 91 : UIMenu( lcd, "Debug" ), fParent( parent )
isonno 4:cfef06d8bb96 92 {
isonno 4:cfef06d8bb96 93 for (int i = 0; i < 5; ++i)
isonno 4:cfef06d8bb96 94 fLabels.push_back( string( "..." ));
isonno 4:cfef06d8bb96 95 }
isonno 4:cfef06d8bb96 96
isonno 4:cfef06d8bb96 97 void DebugMenu::SetItem( int item, const char * name, int value )
isonno 4:cfef06d8bb96 98 {
isonno 4:cfef06d8bb96 99 char label[20];
isonno 4:cfef06d8bb96 100 sprintf( label, "%s:%d", name, value );
isonno 4:cfef06d8bb96 101 ChangeItem( item, label );
isonno 4:cfef06d8bb96 102 }
isonno 4:cfef06d8bb96 103
isonno 4:cfef06d8bb96 104 void DebugMenu::KnobPushed()
isonno 4:cfef06d8bb96 105 {
isonno 4:cfef06d8bb96 106 // No matter what's selected, just exit
isonno 4:cfef06d8bb96 107 SwitchTo( fParent );
isonno 4:cfef06d8bb96 108 }