Skip to content

Commit

Permalink
Update library.properties, README, clean up some stray spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
PaintYourDragon committed Nov 6, 2018
1 parent fe67ad2 commit 9b10b8a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 34 deletions.
55 changes: 24 additions & 31 deletions Adafruit_NeoPixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

// Constructor when length, pin and type are known at compile-time:
Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t n, uint8_t p, neoPixelType t) :
begun(false), brightness(0), pixels(NULL), endTime(0)
begun(false), brightness(0), pixels(NULL), endTime(0)
{
updateType(t);
updateLength(n);
Expand Down Expand Up @@ -110,7 +110,7 @@ void Adafruit_NeoPixel::updateType(neoPixelType t) {
}
}

#if defined(ESP8266)
#if defined(ESP8266)
// ESP8266 show() is external to enforce ICACHE_RAM_ATTR execution
extern "C" void ICACHE_RAM_ATTR espShow(
uint8_t pin, uint8_t *pixels, uint32_t numBytes, uint8_t type);
Expand Down Expand Up @@ -1207,12 +1207,12 @@ void Adafruit_NeoPixel::show(void) {
// [[[Begin of the Neopixel NRF52 EasyDMA implementation
// by the Hackerspace San Salvador]]]
// This technique uses the PWM peripheral on the NRF52. The PWM uses the
// EasyDMA feature included on the chip. This technique loads the duty
// cycle configuration for each cycle when the PWM is enabled. For this
// EasyDMA feature included on the chip. This technique loads the duty
// cycle configuration for each cycle when the PWM is enabled. For this
// to work we need to store a 16 bit configuration for each bit of the
// RGB(W) values in the pixel buffer.
// Comparator values for the PWM were hand picked and are guaranteed to
// be 100% organic to preserve freshness and high accuracy. Current
// be 100% organic to preserve freshness and high accuracy. Current
// parameters are:
// * PWM Clock: 16Mhz
// * Minimum step time: 62.5ns
Expand Down Expand Up @@ -1242,13 +1242,13 @@ void Adafruit_NeoPixel::show(void) {
#define CTOPVAL_400KHz 40UL // 2.5us

// ---------- END Constants for the EasyDMA implementation -------------
//
//
// If there is no device available an alternative cycle-counter
// implementation is tried.
// The nRF52832 runs with a fixed clock of 64Mhz. The alternative
// implementation is the same as the one used for the Teensy 3.0/1/2 but
// with the Nordic SDK HAL & registers syntax.
// The number of cycles was hand picked and is guaranteed to be 100%
// The number of cycles was hand picked and is guaranteed to be 100%
// organic to preserve freshness and high accuracy.
// ---------- BEGIN Constants for cycle counter implementation ---------
#define CYCLES_800_T0H 18 // ~0.36 uS
Expand Down Expand Up @@ -1289,7 +1289,7 @@ void Adafruit_NeoPixel::show(void) {
break;
}
}

// only malloc if there is PWM device available
if ( pwm != NULL ) {
#ifdef ARDUINO_FEATHER52 // use thread-safe malloc
Expand Down Expand Up @@ -1970,7 +1970,7 @@ void Adafruit_NeoPixel::show(void) {
}
}

#else
#else
#error Architecture not supported
#endif

Expand Down Expand Up @@ -2069,35 +2069,28 @@ void Adafruit_NeoPixel::setPixelColor(uint16_t n, uint32_t c) {
}
}

// Fills strip from given pixel to end. Arguments:
// Color, if unspecified, is zero (effectively a strip clear operation).
// First, if unspecified, is zero.
// Count, if unspecified, fills to end of strip.
void Adafruit_NeoPixel::fill(uint32_t c, uint16_t first, uint16_t count)
{
uint16_t i;
uint16_t last_pixel_index;
// Fills all or a given start+length of strip. Arguments:
// Packed RGB color (0 if unspecified, effectively a strip clear operation).
// Index if first pixel (0 if unspecified - beginning of strip).
// Pixel count (if unspecified, fills to end of strip).
void Adafruit_NeoPixel::fill(uint32_t c, uint16_t first, uint16_t count) {
uint16_t i, end;

if (first > (numLEDs - 1))
{
if(first >= numLEDs) {
return; // If first LED is past end of strip, nothing to do
}

// Calculate the index of the last pixel to fill
if (count == 0)
{
// Fill the strip to the end
last_pixel_index = numLEDs - 1;
}
else
{
// Calculate the index ONE AFTER the last pixel to fill
if(count == 0) {
// Fill to end of strip
end = numLEDs;
} else {
// Ensure that the loop won't go past the last pixel
last_pixel_index = first + count - 1;
last_pixel_index = min(last_pixel_index, numLEDs - 1);
end = first + count;
if(end > numLEDs) end = numLEDs;
}

for(i = first; i <= last_pixel_index; i++)
{
for(i = first; i < end; i++) {
this->setPixelColor(i, c);
}
}
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ Things I'd Like To Do But There's No Official Timeline So Please Don't Count On

* For the show() function (with all the delicate pixel timing stuff), break out each architecture into separate source files rather than the current unmaintainable tangle of #ifdef statements!
* Really the only reason I've never incorporated an HSV color function is that I haven't settled on a type and range for the hue element (mathematically an integer from 0 to 1529 yields a "most correct" approach but it's weird to use and would probably annoy people).
* Add a fill function with the arguments: (color, first, count). Count, if unspecified, fills to end of strip. First, if unspecified, is zero. Color, if unspecified, is zero (effectively a strip clear operation). Do NOT then implement fifty billion minor variations (such as first, last). No. This argument sequence was very specifically chosen because reasons, and equivalents to such variations are trivially made in one's call. Just one fill function, please.
* At such time that the prior two items are settled, revisit the DotStar library (and maybe even LPD8806 or anything else we've got) and add the same functions and behaviors so there's a good degree of sketch compatibility across different pixel types.
* At such time that the prior item is settled (along with the recently-added fill() function in Adafruit_NeoPixel), revisit the DotStar library (and maybe even LPD8806 or anything else we've got) and add the same functions and behaviors so there's a good degree of sketch compatibility across different pixel types.
* I wouldn't mind paring down strandtest a bit. More diagnostic, less Amiga demo.
* Please don't use updateLength() or updateType() in new code. They should not have been implemented this way (use the C++ 'new' operator with the regular constructor instead) and are only sticking around because of the Prime Directive. setPin() is OK for now though, it's a trick we can use to 'recycle' pixel memory across multiple strips.
* In the M0 and M4 code, use the hardware systick counter for bit timing rather than hand-tweaked NOPs (a temporary kludge at the time because I wasn't reading systick correctly).
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit NeoPixel
version=1.1.6
version=1.1.7
author=Adafruit
maintainer=Adafruit <[email protected]>
sentence=Arduino library for controlling single-wire-based LED pixels and strip.
Expand Down

0 comments on commit 9b10b8a

Please sign in to comment.