-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathIRFShowControl.h
More file actions
139 lines (121 loc) · 3.29 KB
/
IRFShowControl.h
File metadata and controls
139 lines (121 loc) · 3.29 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* IRFShowControl.h
*
* Created on: Mar 19, 2013
* Author: Greg Scull
*
* Updated: May 20, 2014 - Mat Mrosko, Materdaddy, rfpixelcontrol@matmrosko.com
*
* License:
* Users of this software agree to hold harmless the creators and
* contributors of this software. By using this software you agree that
* you are doing so at your own risk, you could kill yourself or someone
* else by using this software and/or modifying the factory controller.
* By using this software you are assuming all legal responsibility for
* the use of the software and any hardware it is used on.
*
* The Commercial Use of this Software is Prohibited.
*/
#ifndef __IRFSHOWCONTROL_H__
#define __IRFSHOWCONTROL_H__
#include <Arduino.h>
#include <SPI.h>
// Define RGB orderings
enum ColorOrder {
RGB_ORDER=0012,
RBG_ORDER=0021,
GRB_ORDER=0102,
GBR_ORDER=0120,
BRG_ORDER=0201,
BGR_ORDER=0210
};
//base class for pixels
class IRFShowControl
{
public:
IRFShowControl(void);
virtual ~IRFShowControl(void);
/*
* Begin so we can have some initialization
*
*/
void Begin(uint8_t *pDataPointer, int pNumLEDs);
/*
* Return the protected value of the number
* of pixels this instance is configured for.
*
* @return the pixel count as a uint16_t
*/
uint16_t GetElementCount(void);
/*
* Sets a new value of pixels. The function
* allocates the proper amount of memory to store
* each pixel's color data.
*
* @param count - Number of pixels in string
*/
void SetElementCount(uint16_t count);
/*
* Helper function to get the color of one pixel.
*
* @param n - Retrieve color for the nth pixel
*
* @return - uint32_t packed color of the nth pixel
*/
uint32_t GetElementColor(uint16_t n);
/*
* Sets pixel n to color c
*
* @param n - Pixel number to set
* @param c - Color to set the nth pixel to
*/
void SetElementColor(uint16_t n, uint32_t c, uint8_t colorOrder = RGB_ORDER);
/*
* Sets pixel n to values r, g, b
*
* @param n - Pixel number to set
* @param r - red 0-255 value
* @param g - green 0-255 value
* @param b - blue 0-255 value
*/
void SetElementColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t colorOrder = RGB_ORDER);
/*
* Create a 24 bit color value from R,G,B
*
* @param r - red 0-255 value
* @param g - green 0-255 value
* @param b - blue 0-255 value
*
* @return the color in a 24 bit pattern
*/
uint32_t Color(byte r, byte g, byte b);
/*
* Pure virtual functions that must be implemented by all pixel
* type implementations. This function loops and actually writes
* the color data stored in "pixels" to the LED string attached.
*/
void virtual Paint(void) = 0;
/*
* Set the base data pointer as provided by
* RFShowControl and the OTAConfig
*/
void SetDataBasePointer(uint8_t *dataPointer);
protected:
/*
* This stores our pixel data. Pointer to a byte array that has
* numLEDs*3 worth of data. One byte per "red", "green", and
* "blue" value is stored.
*/
uint8_t *pixels;
/*
* Number of pixels we're configured for
*/
uint16_t numLEDs;
/*
* Data pin we're configured to use to write to our pixels.
*/
uint8_t dataPin;
bool invertOutputOrder;
int groupingBy;
};
#endif //__IRFSHOWCONTROL_H__