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

Revision:
0:6da5625a6946
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RotaryEncoder.cpp	Thu Dec 29 01:59:53 2011 +0000
@@ -0,0 +1,30 @@
+// Rotary Encoder
+// Support for the rotary encoder control
+
+#include "RotaryEncoder.h"
+
+RotaryEncoder::RotaryEncoder( PinName a, PinName b, PinMode mode )
+        : fPinA( a ), fPinB( b, mode )
+{
+    fPinA.mode( mode );
+    fPinB.setSampleFrequency( 3000 );
+
+    fPinB.attach_asserted( this, &RotaryEncoder::bRise );
+}
+
+void RotaryEncoder::debug( const char * where )
+{
+//    printf("%s: as: %d, bs: %d: aCh: %c, bCh: %c\r\n",
+//           where, aState, bState, aChanged ? 'T' : 'F', bChanged ? 'T' : 'F' );
+}
+
+
+void RotaryEncoder::bRise() 
+{
+    // The status of the A channel on the B channel's rising edge
+    // determines which way the shaft is turning.
+    if (fPinA.read())
+        fCallback.call( 1 );
+    else
+        fCallback.call( -1 );
+}