Skip to content

Commit

Permalink
add public function canShow() to be able to determine if show() would…
Browse files Browse the repository at this point in the history
… block

In order to be able to minimize blocking this function is provided.
  • Loading branch information
sjaeckel committed Jul 7, 2014
1 parent 0571cca commit 09b8f4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Adafruit_NeoPixel.cpp
Expand Up @@ -79,7 +79,7 @@ void Adafruit_NeoPixel::show(void) {
// subsequent round of data until the latch time has elapsed. This
// allows the mainline code to start generating the next frame of data
// rather than stalling for the latch.
while((micros() - endTime) < 50L);
while(!canShow());
// endTime is a private member (rather than global var) so that mutliple
// instances on different pins can be quickly issued in succession (each
// instance doesn't delay the next).
Expand Down
2 changes: 2 additions & 0 deletions Adafruit_NeoPixel.h
Expand Up @@ -64,6 +64,8 @@ class Adafruit_NeoPixel {
Color(uint8_t r, uint8_t g, uint8_t b);
uint32_t
getPixelColor(uint16_t n) const;
inline bool
canShow(void) { return (micros() - endTime) >= 50L; }

private:

Expand Down

0 comments on commit 09b8f4d

Please sign in to comment.