Skip to content

Commit

Permalink
Fixed issue due to change in how Adafruit Neopixel library was initli…
Browse files Browse the repository at this point in the history
…ased post compile time.
  • Loading branch information
Seon Rozenblum committed Apr 25, 2018
1 parent 6a7d9db commit 410488d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Neo7Segment
version=1.0.0
version=1.0.1
author=UnexpectedMaker
maintainer=UnexpectedMaker
sentence=A library to display numbers and letters on Neo7Segment displays.
Expand Down
19 changes: 16 additions & 3 deletions src/Neo7Segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ Neo7Segment::Neo7Segment( uint8_t displayCount, uint8_t dPin )
{
dispCount = displayCount;
dispPin = dPin;
pixels = Adafruit_NeoPixel ( ( dispCount * NUM_PIXELS_PER_BOARD ), dispPin, NEO_GRB + NEO_KHZ800 );
pixels = Adafruit_NeoPixel ();
pixels.updateType( NEO_GRB + NEO_KHZ800 );
pixels.updateLength( dispCount * NUM_PIXELS_PER_BOARD );
pixels.setPin(dispPin);
isReady = false;
}

Expand All @@ -179,9 +182,10 @@ bool Neo7Segment::IsReady()

void Neo7Segment::Begin( uint8_t brightness )
{

pixels.begin(); // This initializes the NeoPixel library.
pixels.clear();
pixels.setBrightness( brightness );
pixels.show();
pixels.setBrightness( brightness );

cachedString = "";
cachedBytes = (byte *) malloc(dispCount * sizeof(byte));
Expand Down Expand Up @@ -240,23 +244,32 @@ void Neo7Segment::CheckToCacheBytes( String str )
int index = 0;
for ( int s = 0; s < str.length(); s++ )
{
#ifdef DEBUG
Serial.print( (String)str.charAt(s) );
Serial.print( " .. " );
#endif

if ( (String)str.charAt(s) != "." )
{
cachedBytes[index] = FindByteForCharater( (String)str.charAt(s) );
#ifdef DEBUG
Serial.println( "1" );
#endif
index++;
}
else if ( s > 0 && bitRead( cachedBytes[index-1], 7 ) != 1 )
{
cachedBytes[index-1] = cachedBytes[index-1] | 0b10000000;
#ifdef DEBUG
Serial.println( "2" );
#endif
}
else
{
cachedBytes[index] = 0b10000000;
#ifdef DEBUG
Serial.println( "3" );
#endif
index++;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Neo7Segment.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ---------------------------------------------------------------------------
// Neo7Segment Library - v1.0 - 28/01/2018
// Neo7Segment Library - v1.0.1 - 25/04/2018
//
// AUTHOR/LICENSE:
// Created by Seon Rozenblum - [email protected]
Expand All @@ -25,6 +25,7 @@
// HISTORY:

//
// 25/04/2018 v1.0.1 - Fixed bug due to change in Adafruit Neopixel library initialisation
// 28/01/2018 v1.0 - Initial release.
//
// ---------------------------------------------------------------------------
Expand Down

0 comments on commit 410488d

Please sign in to comment.