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:
0:6da5625a6946
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 // Rotary Encoder
isonno 0:6da5625a6946 2 // Support for the rotary encoder control
isonno 0:6da5625a6946 3
isonno 0:6da5625a6946 4 #include "RotaryEncoder.h"
isonno 0:6da5625a6946 5
isonno 0:6da5625a6946 6 RotaryEncoder::RotaryEncoder( PinName a, PinName b, PinMode mode )
isonno 0:6da5625a6946 7 : fPinA( a ), fPinB( b, mode )
isonno 0:6da5625a6946 8 {
isonno 0:6da5625a6946 9 fPinA.mode( mode );
isonno 0:6da5625a6946 10 fPinB.setSampleFrequency( 3000 );
isonno 0:6da5625a6946 11
isonno 0:6da5625a6946 12 fPinB.attach_asserted( this, &RotaryEncoder::bRise );
isonno 0:6da5625a6946 13 }
isonno 0:6da5625a6946 14
isonno 0:6da5625a6946 15 void RotaryEncoder::debug( const char * where )
isonno 0:6da5625a6946 16 {
isonno 0:6da5625a6946 17 // printf("%s: as: %d, bs: %d: aCh: %c, bCh: %c\r\n",
isonno 0:6da5625a6946 18 // where, aState, bState, aChanged ? 'T' : 'F', bChanged ? 'T' : 'F' );
isonno 0:6da5625a6946 19 }
isonno 0:6da5625a6946 20
isonno 0:6da5625a6946 21
isonno 0:6da5625a6946 22 void RotaryEncoder::bRise()
isonno 0:6da5625a6946 23 {
isonno 0:6da5625a6946 24 // The status of the A channel on the B channel's rising edge
isonno 0:6da5625a6946 25 // determines which way the shaft is turning.
isonno 0:6da5625a6946 26 if (fPinA.read())
isonno 0:6da5625a6946 27 fCallback.call( 1 );
isonno 0:6da5625a6946 28 else
isonno 0:6da5625a6946 29 fCallback.call( -1 );
isonno 0:6da5625a6946 30 }