Skip to content

Commit 26e818b

Browse files
committed
Code formatting cleanups; markdown corrections
Improve formatting consistency Fix comment/docstring/markdown typos Remove unused file
1 parent 8b38771 commit 26e818b

Some content is hidden

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

66 files changed

+2733
-3517
lines changed

FastLED.cpp

+26-26
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ CFastLED::CFastLED() {
3131
}
3232

3333
CLEDController &CFastLED::addLeds(CLEDController *pLed,
34-
struct CRGB *data,
35-
int nLedsOrOffset, int nLedsIfOffset) {
34+
struct CRGB *data,
35+
int nLedsOrOffset, int nLedsIfOffset) {
3636
int nOffset = (nLedsIfOffset > 0) ? nLedsOrOffset : 0;
3737
int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset;
3838

@@ -204,33 +204,33 @@ extern int noise_min;
204204
extern int noise_max;
205205

206206
void CFastLED::countFPS(int nFrames) {
207-
static int br = 0;
208-
static uint32_t lastframe = 0; // millis();
209-
210-
if(br++ >= nFrames) {
211-
uint32_t now = millis();
212-
now -= lastframe;
213-
if( now == 0 ) {
214-
now = 1; // prevent division by zero below
215-
}
216-
m_nFPS = (br * 1000) / now;
217-
br = 0;
218-
lastframe = millis();
219-
}
207+
static int br = 0;
208+
static uint32_t lastframe = 0; // millis();
209+
210+
if(br++ >= nFrames) {
211+
uint32_t now = millis();
212+
now -= lastframe;
213+
if(now == 0) {
214+
now = 1; // prevent division by zero below
215+
}
216+
m_nFPS = (br * 1000) / now;
217+
br = 0;
218+
lastframe = millis();
219+
}
220220
}
221221

222222
void CFastLED::setMaxRefreshRate(uint16_t refresh, bool constrain) {
223-
if(constrain) {
224-
// if we're constraining, the new value of m_nMinMicros _must_ be higher than previously (because we're only
225-
// allowed to slow things down if constraining)
226-
if(refresh > 0) {
227-
m_nMinMicros = ( (1000000/refresh) > m_nMinMicros) ? (1000000/refresh) : m_nMinMicros;
228-
}
229-
} else if(refresh > 0) {
230-
m_nMinMicros = 1000000 / refresh;
231-
} else {
232-
m_nMinMicros = 0;
233-
}
223+
if(constrain) {
224+
// if we're constraining, the new value of m_nMinMicros _must_ be higher than previously (because we're only
225+
// allowed to slow things down if constraining)
226+
if(refresh > 0) {
227+
m_nMinMicros = ((1000000 / refresh) > m_nMinMicros) ? (1000000 / refresh) : m_nMinMicros;
228+
}
229+
} else if(refresh > 0) {
230+
m_nMinMicros = 1000000 / refresh;
231+
} else {
232+
m_nMinMicros = 0;
233+
}
234234
}
235235

236236
extern "C" int atexit(void (* /*func*/ )()) { return 0; }

FastLED.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,11 @@ class CFastLED {
316316
}
317317

318318
#if defined(__FASTLED_HAS_FIBCC) && (__FASTLED_HAS_FIBCC == 1)
319-
template<uint8_t NUM_LANES, template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
320-
static CLEDController &addLeds(struct CRGB *data, int nLeds) {
321-
static __FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
322-
return addLeds(&c, data, nLeds);
323-
}
319+
template<uint8_t NUM_LANES, template<uint8_t DATA_PIN, EOrder RGB_ORDER> class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER=RGB>
320+
static CLEDController &addLeds(struct CRGB *data, int nLeds) {
321+
static __FIBCC<CHIPSET, DATA_PIN, NUM_LANES, RGB_ORDER> c;
322+
return addLeds(&c, data, nLeds);
323+
}
324324
#endif
325325

326326
#ifdef FASTSPI_USE_DMX_SIMPLE
@@ -556,19 +556,19 @@ class CFastLED {
556556
uint16_t getFPS() { return m_nFPS; }
557557

558558
/// Get how many controllers have been registered
559-
/// @returns the number of controllers (strips) that have been added with addLeds
559+
/// @returns the number of controllers (strips) that have been added with addLeds
560560
int count();
561561

562562
/// Get a reference to a registered controller
563-
/// @returns a reference to the Nth controller
563+
/// @returns a reference to the Nth controller
564564
CLEDController & operator[](int x);
565565

566566
/// Get the number of leds in the first controller
567-
/// @returns the number of LEDs in the first controller
567+
/// @returns the number of LEDs in the first controller
568568
int size() { return (*this)[0].size(); }
569569

570570
/// Get a pointer to led data for the first controller
571-
/// @returns pointer to the CRGB buffer for the first controller
571+
/// @returns pointer to the CRGB buffer for the first controller
572572
CRGB *leds() { return (*this)[0].leds(); }
573573
};
574574

PORTING.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
=New platform porting guide=
1+
New platform porting guide
2+
==========================
23

3-
== Fast porting for a new board on existing hardware ==
4+
# Fast porting for a new board on existing hardware
45

56
Sometimes "porting" FastLED simply consists of supplying new pin definitions for the given platform. For example, platforms/avr/fastpin_avr.h contains various pin definitions for all the AVR variant chipsets/boards that FastLED supports. Defining a set of pins involves setting up a set of definitions - for example here's one full set from the avr fastpin file:
67

@@ -26,7 +27,7 @@ The ```_FL_IO``` macro is used to define the port registers for the platform whi
2627

2728
The ```HAS_HARDWARE_PIN_SUPPORT``` define tells the rest of the FastLED library that there is hardware pin support available. There may be other platform specific defines for things like hardware SPI ports and such.
2829

29-
== Setting up the basic files/folders ==
30+
## Setting up the basic files/folders
3031

3132
* Create platform directory (e.g. platforms/arm/kl26)
3233
* Create configuration header led_sysdefs_arm_kl26.h:
@@ -38,18 +39,18 @@ The ```HAS_HARDWARE_PIN_SUPPORT``` define tells the rest of the FastLED library
3839
* Modify led_sysdefs.h to conditionally include platform sysdefs header file
3940
* Modify platforms.h to conditionally include platform fastled header
4041

41-
== Porting fastpin.h ==
42+
## Porting fastpin.h
4243

4344
The heart of the FastLED library is the fast pin accesss. This is a templated class that provides 1-2 cycle pin access, bypassing digital write and other such things. As such, this will usually be the first bit of the library that you will want to port when moving to a new platform. Once you have FastPIN up and running then you can do some basic work like testing toggles or running bit-bang'd SPI output.
4445

4546
There's two low level FastPin classes. There's the base FastPIN template class, and then there is FastPinBB which is for bit-banded access on those MCUs that support bitbanding. Note that the bitband class is optional and primarily useful in the implementation of other functionality internal to the platform. This file is also where you would do the pin to port/bit mapping defines.
4647

4748
Explaining how the macros work and should be used is currently beyond the scope of this document.
4849

49-
== Porting fastspi.h ==
50+
## Porting fastspi.h
5051

5152
This is where you define the low level interface to the hardware SPI system (including a writePixels method that does a bunch of housekeeping for writing led data). Use the fastspi_nop.h file as a reference for the methods that need to be implemented. There are ofteh other useful methods that can help with the internals of the SPI code, I recommend taking a look at how the various platforms implement their SPI classes.
5253

53-
== Porting clockless.h ==
54+
## Porting clockless.h
5455

5556
This is where you define the code for the clockless controllers. Across ARM platforms this will usually be fairly similar - though different arm platforms will have different clock sources that you can/should use.

bitswap.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
/// Simplified form of bits rotating function. Based on code found here - http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt - rotating
55
/// data into LSB for a faster write (the code using this data can happily walk the array backwards)
66
void transpose8x1_noinline(unsigned char *A, unsigned char *B) {
7-
uint32_t x, y, t;
7+
uint32_t x, y, t;
88

9-
// Load the array and pack it into x and y.
10-
y = *(unsigned int*)(A);
11-
x = *(unsigned int*)(A+4);
9+
// Load the array and pack it into x and y.
10+
y = *(unsigned int*)(A);
11+
x = *(unsigned int*)(A+4);
1212

13-
// pre-transform x
14-
t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
15-
t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
13+
// pre-transform x
14+
t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
15+
t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
1616

17-
// pre-transform y
18-
t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
19-
t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
17+
// pre-transform y
18+
t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
19+
t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
2020

21-
// final transform
22-
t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
23-
y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
24-
x = t;
21+
// final transform
22+
t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
23+
y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
24+
x = t;
2525

26-
*((uint32_t*)B) = y;
27-
*((uint32_t*)(B+4)) = x;
26+
*((uint32_t*)B) = y;
27+
*((uint32_t*)(B+4)) = x;
2828
}

chipsets.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ template<uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
2828
class PixieController : public CPixelLEDController<RGB_ORDER> {
2929
SoftwareSerial Serial;
3030
CMinWait<2000> mWait;
31+
3132
public:
3233
PixieController() : Serial(-1, DATA_PIN) {}
3334

@@ -92,8 +93,8 @@ class LPD8806Controller : public CPixelLEDController<RGB_ORDER> {
9293
};
9394

9495
SPI mSPI;
95-
public:
9696

97+
public:
9798
LPD8806Controller() {}
9899
virtual void init() {
99100
mSPI.init();
@@ -123,6 +124,7 @@ class WS2801Controller : public CPixelLEDController<RGB_ORDER> {
123124
typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
124125
SPI mSPI;
125126
CMinWait<1000> mWaitDelay;
127+
126128
public:
127129
WS2801Controller() {}
128130

@@ -132,7 +134,6 @@ class WS2801Controller : public CPixelLEDController<RGB_ORDER> {
132134
}
133135

134136
protected:
135-
136137
virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
137138
mWaitDelay.wait();
138139
mSPI.template writePixels<0, DATA_NOP, RGB_ORDER>(pixels);
@@ -166,7 +167,6 @@ class LPD6803Controller : public CPixelLEDController<RGB_ORDER> {
166167
}
167168

168169
protected:
169-
170170
virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
171171
mSPI.select();
172172

@@ -232,7 +232,6 @@ class APA102Controller : public CPixelLEDController<RGB_ORDER> {
232232
}
233233

234234
protected:
235-
236235
virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
237236
mSPI.select();
238237

@@ -297,7 +296,6 @@ class SK9822Controller : public CPixelLEDController<RGB_ORDER> {
297296
}
298297

299298
protected:
300-
301299
virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
302300
mSPI.select();
303301

@@ -360,7 +358,6 @@ class P9813Controller : public CPixelLEDController<RGB_ORDER> {
360358
}
361359

362360
protected:
363-
364361
virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
365362
mSPI.select();
366363

@@ -418,7 +415,6 @@ class SM16716Controller : public CPixelLEDController<RGB_ORDER> {
418415
}
419416

420417
protected:
421-
422418
virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
423419
// Make sure the FLAG_START_BIT flag is set to ensure that an extra 1 bit is sent at the start
424420
// of each triplet of bytes for rgb data

color.h

+53-53
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,71 @@ FASTLED_NAMESPACE_BEGIN
1111
/// definitions for color correction and light temperatures
1212
///@{
1313
typedef enum {
14-
// Color correction starting points
14+
// Color correction starting points
1515

16-
/// typical values for SMD5050 LEDs
17-
///@{
16+
/// typical values for SMD5050 LEDs
17+
///@{
1818
TypicalSMD5050=0xFFB0F0 /* 255, 176, 240 */,
1919
TypicalLEDStrip=0xFFB0F0 /* 255, 176, 240 */,
20-
///@}
20+
///@}
2121

22-
/// typical values for 8mm "pixels on a string"
23-
/// also for many through-hole 'T' package LEDs
24-
///@{
25-
Typical8mmPixel=0xFFE08C /* 255, 224, 140 */,
26-
TypicalPixelString=0xFFE08C /* 255, 224, 140 */,
27-
///@}
22+
/// typical values for 8mm "pixels on a string"
23+
/// also for many through-hole 'T' package LEDs
24+
///@{
25+
Typical8mmPixel=0xFFE08C /* 255, 224, 140 */,
26+
TypicalPixelString=0xFFE08C /* 255, 224, 140 */,
27+
///@}
2828

29-
/// uncorrected color
30-
UncorrectedColor=0xFFFFFF
29+
/// uncorrected color
30+
UncorrectedColor=0xFFFFFF
3131

3232
} LEDColorCorrection;
3333

3434

3535
typedef enum {
36-
/// @name Black-body radiation light sources
37-
/// Black-body radiation light sources emit a (relatively) continuous
38-
/// spectrum, and can be described as having a Kelvin 'temperature'
39-
///@{
40-
/// 1900 Kelvin
41-
Candle=0xFF9329 /* 1900 K, 255, 147, 41 */,
42-
/// 2600 Kelvin
43-
Tungsten40W=0xFFC58F /* 2600 K, 255, 197, 143 */,
44-
/// 2850 Kelvin
45-
Tungsten100W=0xFFD6AA /* 2850 K, 255, 214, 170 */,
46-
/// 3200 Kelvin
47-
Halogen=0xFFF1E0 /* 3200 K, 255, 241, 224 */,
48-
/// 5200 Kelvin
49-
CarbonArc=0xFFFAF4 /* 5200 K, 255, 250, 244 */,
50-
/// 5400 Kelvin
51-
HighNoonSun=0xFFFFFB /* 5400 K, 255, 255, 251 */,
52-
/// 6000 Kelvin
53-
DirectSunlight=0xFFFFFF /* 6000 K, 255, 255, 255 */,
54-
/// 7000 Kelvin
55-
OvercastSky=0xC9E2FF /* 7000 K, 201, 226, 255 */,
56-
/// 20000 Kelvin
57-
ClearBlueSky=0x409CFF /* 20000 K, 64, 156, 255 */,
58-
///@}
36+
/// @name Black-body radiation light sources
37+
/// Black-body radiation light sources emit a (relatively) continuous
38+
/// spectrum, and can be described as having a Kelvin 'temperature'
39+
///@{
40+
/// 1900 Kelvin
41+
Candle=0xFF9329 /* 1900 K, 255, 147, 41 */,
42+
/// 2600 Kelvin
43+
Tungsten40W=0xFFC58F /* 2600 K, 255, 197, 143 */,
44+
/// 2850 Kelvin
45+
Tungsten100W=0xFFD6AA /* 2850 K, 255, 214, 170 */,
46+
/// 3200 Kelvin
47+
Halogen=0xFFF1E0 /* 3200 K, 255, 241, 224 */,
48+
/// 5200 Kelvin
49+
CarbonArc=0xFFFAF4 /* 5200 K, 255, 250, 244 */,
50+
/// 5400 Kelvin
51+
HighNoonSun=0xFFFFFB /* 5400 K, 255, 255, 251 */,
52+
/// 6000 Kelvin
53+
DirectSunlight=0xFFFFFF /* 6000 K, 255, 255, 255 */,
54+
/// 7000 Kelvin
55+
OvercastSky=0xC9E2FF /* 7000 K, 201, 226, 255 */,
56+
/// 20000 Kelvin
57+
ClearBlueSky=0x409CFF /* 20000 K, 64, 156, 255 */,
58+
///@}
5959

60-
/// @name Gaseous light sources
61-
/// Gaseous light sources emit discrete spectral bands, and while we can
62-
/// approximate their aggregate hue with RGB values, they don't actually
63-
/// have a proper Kelvin temperature.
64-
///@{
65-
WarmFluorescent=0xFFF4E5 /* 0 K, 255, 244, 229 */,
66-
StandardFluorescent=0xF4FFFA /* 0 K, 244, 255, 250 */,
67-
CoolWhiteFluorescent=0xD4EBFF /* 0 K, 212, 235, 255 */,
68-
FullSpectrumFluorescent=0xFFF4F2 /* 0 K, 255, 244, 242 */,
69-
GrowLightFluorescent=0xFFEFF7 /* 0 K, 255, 239, 247 */,
70-
BlackLightFluorescent=0xA700FF /* 0 K, 167, 0, 255 */,
71-
MercuryVapor=0xD8F7FF /* 0 K, 216, 247, 255 */,
72-
SodiumVapor=0xFFD1B2 /* 0 K, 255, 209, 178 */,
73-
MetalHalide=0xF2FCFF /* 0 K, 242, 252, 255 */,
74-
HighPressureSodium=0xFFB74C /* 0 K, 255, 183, 76 */,
75-
///@}
60+
/// @name Gaseous light sources
61+
/// Gaseous light sources emit discrete spectral bands, and while we can
62+
/// approximate their aggregate hue with RGB values, they don't actually
63+
/// have a proper Kelvin temperature.
64+
///@{
65+
WarmFluorescent=0xFFF4E5 /* 0 K, 255, 244, 229 */,
66+
StandardFluorescent=0xF4FFFA /* 0 K, 244, 255, 250 */,
67+
CoolWhiteFluorescent=0xD4EBFF /* 0 K, 212, 235, 255 */,
68+
FullSpectrumFluorescent=0xFFF4F2 /* 0 K, 255, 244, 242 */,
69+
GrowLightFluorescent=0xFFEFF7 /* 0 K, 255, 239, 247 */,
70+
BlackLightFluorescent=0xA700FF /* 0 K, 167, 0, 255 */,
71+
MercuryVapor=0xD8F7FF /* 0 K, 216, 247, 255 */,
72+
SodiumVapor=0xFFD1B2 /* 0 K, 255, 209, 178 */,
73+
MetalHalide=0xF2FCFF /* 0 K, 242, 252, 255 */,
74+
HighPressureSodium=0xFFB74C /* 0 K, 255, 183, 76 */,
75+
///@}
7676

77-
/// Uncorrected temperature 0xFFFFFF
78-
UncorrectedTemperature=0xFFFFFF
77+
/// Uncorrected temperature 0xFFFFFF
78+
UncorrectedTemperature=0xFFFFFF
7979
} ColorTemperature;
8080

8181
FASTLED_NAMESPACE_END

0 commit comments

Comments
 (0)