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 0:6da5625a6946 1 //
isonno 0:6da5625a6946 2 // RGBLED - Control the RGB LED on the Sparkfun display breakout board
isonno 0:6da5625a6946 3 ///
isonno 0:6da5625a6946 4
isonno 0:6da5625a6946 5 #ifndef __RGBLED__
isonno 0:6da5625a6946 6 #define __RGBLED__
isonno 0:6da5625a6946 7
isonno 0:6da5625a6946 8 const float kLEDPWMTable[8] = { 0, 0.01, 0.02, 0.046, 0.1, 0.215, 0.464, 1.0 };
isonno 0:6da5625a6946 9
isonno 0:6da5625a6946 10 class RGBLED
isonno 0:6da5625a6946 11 {
isonno 0:6da5625a6946 12 public:
isonno 0:6da5625a6946 13 RGBLED( PinName r, PinName g, PinName b )
isonno 0:6da5625a6946 14 : fRedPWM( r ), fGrnPWM( g ), fBluPWM( b )
isonno 0:6da5625a6946 15 {
isonno 0:6da5625a6946 16 fRedPWM = 1.0;
isonno 0:6da5625a6946 17 fGrnPWM = 1.0;
isonno 0:6da5625a6946 18 fBluPWM = 1.0;
isonno 0:6da5625a6946 19 fRGBValue = 0;
isonno 0:6da5625a6946 20 }
isonno 0:6da5625a6946 21
isonno 0:6da5625a6946 22 // We use the same "777" RGB values the CuriLights use
isonno 0:6da5625a6946 23 void Set( int rgb )
isonno 0:6da5625a6946 24 {
isonno 0:6da5625a6946 25 if (rgb == fRGBValue)
isonno 0:6da5625a6946 26 return; // No change
isonno 0:6da5625a6946 27
isonno 0:6da5625a6946 28 fRGBValue = rgb;
isonno 0:6da5625a6946 29
isonno 0:6da5625a6946 30 int red = rgb / 100;
isonno 0:6da5625a6946 31 int grn = rgb % 100 / 10;
isonno 0:6da5625a6946 32 int blu = rgb % 10;
isonno 0:6da5625a6946 33
isonno 0:6da5625a6946 34 fRedPWM = 1.0 - kLEDPWMTable[red];
isonno 0:6da5625a6946 35 fGrnPWM = 1.0 - kLEDPWMTable[grn];
isonno 0:6da5625a6946 36 fBluPWM = 1.0 - kLEDPWMTable[blu];
isonno 0:6da5625a6946 37
isonno 3:0ac64c4ca40f 38 // printf("RGB: %d, %f %f %f\r\n", rgb, 1.0 - kLEDPWMTable[red], 1.0 - kLEDPWMTable[grn], 1.0 - kLEDPWMTable[blu] );
isonno 0:6da5625a6946 39 }
isonno 0:6da5625a6946 40
isonno 0:6da5625a6946 41 private:
isonno 0:6da5625a6946 42 PwmOut fRedPWM, fGrnPWM, fBluPWM;
isonno 0:6da5625a6946 43 int fRGBValue;
isonno 0:6da5625a6946 44 };
isonno 0:6da5625a6946 45
isonno 3:0ac64c4ca40f 46 // Defined in main for now.
isonno 3:0ac64c4ca40f 47 extern RGBLED gDebugLED;
isonno 3:0ac64c4ca40f 48
isonno 0:6da5625a6946 49 #endif
isonno 0:6da5625a6946 50