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

LightSnoop.h

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

File content as of revision 4:cfef06d8bb96:

//
// LightSnoop.h - Listen to a serial stream, and determine light
// colors and settings from it.
//

#ifndef __LIGHTSNOOP__
#define __LIGHTSNOOP__

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

#include <vector>

class LightString;

typedef enum { kAwaitCommand, kAwaitID, kAwaitValue } ESnoopState;

const int kBufferMax = 600;

class LightSnoop
{
public:
    LightSnoop( int numLights );
    ~LightSnoop() {}
    
    void SaveSnoop();
    void Listen( const uint8_t ch );
    
    bool IsActive();
    
private:
    void Process( const uint8_t ch );

    vector<uint16_t> fLightValues;
    ESnoopState fSnoopState;
    uint8_t fCommand;
    uint8_t fID;
    uint8_t fBuffer[kBufferMax];
    int fBufferIndex, fLastBufferIndex;
};

#endif