-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLedCube.h
72 lines (60 loc) · 2.02 KB
/
LedCube.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
LedCube.h - Library for controlling a LED cube
Created by Gamaiel Zavala (gzip), 2009-2012
MIT License. See accompanying LICENSE file for terms.
*/
#ifndef LedCube_h
#define LedCube_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
struct cubeFrame {
unsigned int size;
unsigned int delay;
byte *sequence;
};
class LedCube
{
public:
LedCube(byte size, byte levelPins[], byte colPins[]);
~LedCube();
byte getCols(){ return cols; }
byte getLevels(){ return levels; }
byte getNumLights(){ return num; }
void light(byte level, byte col, byte val);
void lightOn(byte level, byte col);
void lightOff(byte level, byte col);
void lightPulse(byte level, byte col, unsigned int wait = 5);
void lightSequence(byte seq[], byte length, unsigned int time = 5, byte gap = 1);
void lightLevel(byte r, unsigned int wait = 50);
void lightRow(byte r, byte level, unsigned int wait = 50);
void lightPlane(byte r, unsigned int wait = 50);
void lightColumn(byte col, unsigned int wait = 50);
void lightDrop(byte col, unsigned int wait = 50);
void lightPerimeter(byte level, byte rotations, unsigned int wait = 50);
void randomLight(byte numLights, unsigned int wait = 50);
void randomColumn(byte numColumns = 1, unsigned int wait = 50);
void lightsOut(unsigned int wait = 5);
cubeFrame* createFrame(byte sequence[], unsigned int length, unsigned int delay);
void destroyFrame(cubeFrame* frame);
void lightFrames(cubeFrame* frames[], unsigned int length);
void enableBuffer(boolean enable = true);
void invertBuffer(boolean invert = true);
void clearBuffer();
void fillBuffer();
void drawBuffer(unsigned int wait = 1);
byte getBufferAt(byte lv, byte col);
private:
byte levels;
byte cols;
byte num;
byte **buffer;
byte *colPins;
byte *levelPins;
boolean bufferEnabled;
boolean bufferInverted;
void setBuffer (byte val);
};
#endif