Skip to content

Commit 4508448

Browse files
committed
Merging 3.1 back to master
2 parents d6f662c + 3cb612d commit 4508448

File tree

104 files changed

+12474
-3472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+12474
-3472
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
html/

FastLED.cpp

Lines changed: 107 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
#define FASTLED_INTERNAL
12
#include "FastLED.h"
23

4+
35
#if defined(__SAM3X8E__)
46
volatile uint32_t fuckit;
57
#endif
68

9+
FASTLED_NAMESPACE_BEGIN
10+
711
void *pSmartMatrix = NULL;
812

9-
CFastLED LEDS;
10-
CFastLED & FastSPI_LED = LEDS;
11-
CFastLED & FastSPI_LED2 = LEDS;
12-
CFastLED & FastLED = LEDS;
13+
CFastLED FastLED;
1314

1415
CLEDController *CLEDController::m_pHead = NULL;
1516
CLEDController *CLEDController::m_pTail = NULL;
17+
static uint32_t lastshow = 0;
1618

1719
// uint32_t CRGB::Squant = ((uint32_t)((__TIME__[4]-'0') * 28))<<16 | ((__TIME__[6]-'0')*50)<<8 | ((__TIME__[7]-'0')*28);
1820

@@ -31,10 +33,15 @@ CLEDController &CFastLED::addLeds(CLEDController *pLed,
3133

3234
pLed->init();
3335
pLed->setLeds(data + nOffset, nLeds);
36+
FastLED.setMaxRefreshRate(pLed->getMaxRefreshRate(),true);
3437
return *pLed;
3538
}
3639

3740
void CFastLED::show(uint8_t scale) {
41+
// guard against showing too rapidly
42+
while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
43+
lastshow = micros();
44+
3845
CLEDController *pCur = CLEDController::head();
3946
while(pCur) {
4047
uint8_t d = pCur->getDither();
@@ -69,6 +76,9 @@ CLEDController & CFastLED::operator[](int x) {
6976
}
7077

7178
void CFastLED::showColor(const struct CRGB & color, uint8_t scale) {
79+
while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
80+
lastshow = micros();
81+
7282
CLEDController *pCur = CLEDController::head();
7383
while(pCur) {
7484
uint8_t d = pCur->getDither();
@@ -98,7 +108,11 @@ void CFastLED::clearData() {
98108
void CFastLED::delay(unsigned long ms) {
99109
unsigned long start = millis();
100110
while((millis()-start) < ms) {
111+
#ifndef FASTLED_ACCURATE_CLOCK
112+
// make sure to allow at least one ms to pass to ensure the clock moves
113+
// forward
101114
::delay(1);
115+
#endif
102116
show();
103117
}
104118
}
@@ -127,6 +141,48 @@ void CFastLED::setDither(uint8_t ditherMode) {
127141
}
128142
}
129143

144+
//
145+
// template<int m, int n> void transpose8(unsigned char A[8], unsigned char B[8]) {
146+
// uint32_t x, y, t;
147+
//
148+
// // Load the array and pack it into x and y.
149+
// y = *(unsigned int*)(A);
150+
// x = *(unsigned int*)(A+4);
151+
//
152+
// // x = (A[0]<<24) | (A[m]<<16) | (A[2*m]<<8) | A[3*m];
153+
// // y = (A[4*m]<<24) | (A[5*m]<<16) | (A[6*m]<<8) | A[7*m];
154+
//
155+
// // pre-transform x
156+
// t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
157+
// t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
158+
//
159+
// // pre-transform y
160+
// t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
161+
// t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
162+
//
163+
// // final transform
164+
// t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
165+
// y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
166+
// x = t;
167+
//
168+
// B[7*n] = y; y >>= 8;
169+
// B[6*n] = y; y >>= 8;
170+
// B[5*n] = y; y >>= 8;
171+
// B[4*n] = y;
172+
//
173+
// B[3*n] = x; x >>= 8;
174+
// B[2*n] = x; x >>= 8;
175+
// B[n] = x; x >>= 8;
176+
// B[0] = x;
177+
// // B[0]=x>>24; B[n]=x>>16; B[2*n]=x>>8; B[3*n]=x>>0;
178+
// // B[4*n]=y>>24; B[5*n]=y>>16; B[6*n]=y>>8; B[7*n]=y>>0;
179+
// }
180+
//
181+
// void transposeLines(Lines & out, Lines & in) {
182+
// transpose8<1,2>(in.bytes, out.bytes);
183+
// transpose8<1,2>(in.bytes + 8, out.bytes + 1);
184+
// }
185+
130186
extern int noise_min;
131187
extern int noise_max;
132188

@@ -142,3 +198,50 @@ void CFastLED::countFPS(int nFrames) {
142198
lastframe = millis();
143199
}
144200
}
201+
202+
void CFastLED::setMaxRefreshRate(uint16_t refresh, bool constrain) {
203+
if(constrain) {
204+
// if we're constraining, the new value of m_nMinMicros _must_ be higher than previously (because we're only
205+
// allowed to slow things down if constraining)
206+
if(refresh > 0) {
207+
m_nMinMicros = ( (1000000/refresh) > m_nMinMicros) ? (1000000/refresh) : m_nMinMicros;
208+
}
209+
} else if(refresh > 0) {
210+
m_nMinMicros = 1000000 / refresh;
211+
} else {
212+
m_nMinMicros = 0;
213+
}
214+
}
215+
216+
217+
#ifdef NEED_CXX_BITS
218+
namespace __cxxabiv1
219+
{
220+
extern "C" void __cxa_pure_virtual (void) {}
221+
/* guard variables */
222+
223+
/* The ABI requires a 64-bit type. */
224+
__extension__ typedef int __guard __attribute__((mode(__DI__)));
225+
226+
extern "C" int __cxa_guard_acquire (__guard *);
227+
extern "C" void __cxa_guard_release (__guard *);
228+
extern "C" void __cxa_guard_abort (__guard *);
229+
230+
extern "C" int __cxa_guard_acquire (__guard *g)
231+
{
232+
return !*(char *)(g);
233+
}
234+
235+
extern "C" void __cxa_guard_release (__guard *g)
236+
{
237+
*(char *)g = 1;
238+
}
239+
240+
extern "C" void __cxa_guard_abort (__guard *)
241+
{
242+
243+
}
244+
}
245+
#endif
246+
247+
FASTLED_NAMESPACE_END

0 commit comments

Comments
 (0)