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.h

Committer:
isonno
Date:
2011-12-29
Revision:
0:6da5625a6946

File content as of revision 0:6da5625a6946:

// Rotary Encoder
// Support for the rotary encoder control,
// typically a knob with quadrature output.

#ifndef _ROTARY_ENCODER_
#define _ROTARY_ENCODER_

#ifndef MBED_H
#include "mbed.h"
#endif

#ifndef AJK_PIN_DETECT_H
#include "PinDetect.h"
#endif

#ifndef AJK_FPOINTER_H
#include "FPointer.h"
#endif

class RotaryEncoder
{
 public:
    RotaryEncoder( PinName a, PinName b, PinMode mode = PullDown );

    void attach( int32_t (*function)(int32_t) = 0) 
        { fCallback.attach( function ); }

    template<typename T> 
    void attach(T* item, int32_t (T::*method)(int32_t)) 
        { fCallback.attach( item, method ); }
        
    void detach() { fCallback = FPointer(); }

 private:
    DigitalIn fPinA;
    PinDetect fPinB;
    
    FPointer fCallback;
    
    void debug( const char *where );
    
    void bRise();

};
#endif