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
|
#include "FastSPI_LED2.h"
#if defined(__SAM3X8E__)
volatile uint32_t fuckit;
#endif
CFastSPI_LED2 LEDS;
CFastSPI_LED2 & FastSPI_LED = LEDS;
CFastSPI_LED2 & FastSPI_LED2 = LEDS;
CFastSPI_LED2 & FastLED = LEDS;
uint32_t CRGB::Squant = ((uint32_t)((__TIME__[4]-'0') * 28))<<16 | ((__TIME__[6]-'0')*50)<<8 | ((__TIME__[7]-'0')*28);
CFastSPI_LED2::CFastSPI_LED2() {
// clear out the array of led controllers
m_nControllers = NUM_CONTROLLERS;
m_nScale = 255;
memset8(m_Controllers, 0, m_nControllers * sizeof(CControllerInfo));
}
CLEDController *CFastSPI_LED2::addLeds(CLEDController *pLed,
const struct CRGB *data,
int nLedsOrOffset, int nLedsIfOffset) {
int nOffset = (nLedsIfOffset > 0) ? nLedsOrOffset : 0;
int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset;
int target = -1;
// Figure out where to put the new led controller
for(int i = 0; i < m_nControllers; i++) {
if(m_Controllers[i].pLedController == NULL) {
target = i;
break;
}
}
// if we have a spot, use it!
if(target != -1) {
m_Controllers[target].pLedController = pLed;
m_Controllers[target].pLedData = data;
m_Controllers[target].nOffset = nOffset;
m_Controllers[target].nLeds = nLeds;
pLed->init();
return pLed;
}
return NULL;
}
void CFastSPI_LED2::show(uint8_t scale) {
for(int i = 0; i < m_nControllers; i++) {
if(m_Controllers[i].pLedController != NULL) {
m_Controllers[i].pLedController->show(m_Controllers[i].pLedData + m_Controllers[i].nOffset,
m_Controllers[i].nLeds, scale);
} else {
return;
}
}
}
void CFastSPI_LED2::showColor(const struct CRGB & color, uint8_t scale) {
for(int i = 0; i < m_nControllers; i++) {
if(m_Controllers[i].pLedController != NULL) {
m_Controllers[i].pLedController->showColor(color, m_Controllers[i].nLeds, scale);
} else {
return;
}
}
}
void CFastSPI_LED2::clear(boolean includeLedData) {
showColor(CRGB(0,0,0), 0);
if(includeLedData) {
for(int i = 0; i < m_nControllers; i++) {
if(m_Controllers[i].pLedData != NULL) {
memset8((void*)m_Controllers[i].pLedData, 0, sizeof(struct CRGB) * m_Controllers[i].nLeds);
} else {
return;
}
}
}
}
|