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

RotaryEncoder.cpp

Committer:
isonno
Date:
2013-02-11
Revision:
4:cfef06d8bb96
Parent:
0:6da5625a6946

File content as of revision 4:cfef06d8bb96:

// 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 );
}