forked from Integreight/1Sheeld-Arduino-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatternShield.h
68 lines (51 loc) · 1.11 KB
/
PatternShield.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
/*
Project: 1Sheeld Library
File: PatternShield.h
Version: 1.4
Compiler: Arduino avr-gcc 4.3.2
Author: Integreight
Date: 2015.1
*/
#ifndef PatternShield_h
#define PatternShield_h
#include "ShieldParent.h"
// Input Function ID
#define PATTERN_VALUE 0x01
#define MAX_PATTERN_SIZE 9
struct PatternNode{
byte row;
byte col;
void setValue(byte val)
{
row=val&0x0F;
col=(val&0xF0)>>4;
}
bool operator==(const PatternNode& other)
{
return (row==other.row)&&(col==other.col);
}
bool operator!=(const PatternNode& other)
{
return !(*this == other);
}
};
class PatternShield : public ShieldParent
{
public:
//Constructor
PatternShield();
PatternNode * getLastPattern();
int getLastPatternLength();
bool isNewPatternReceived();
void setOnNewPattern(void (*)(PatternNode[] ,int ));
private:
int length;
bool isNewPattern;
bool isCallBackAssigned;
PatternNode nodes[MAX_PATTERN_SIZE];
void processData();
void (*changeCallBack)(PatternNode[], int );
};
//Extern Object
extern PatternShield Pattern;
#endif