Skip to content

Commit 410488d

Browse files
Fixed issue due to change in how Adafruit Neopixel library was initliased post compile time.
1 parent 6a7d9db commit 410488d

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Neo7Segment
2-
version=1.0.0
2+
version=1.0.1
33
author=UnexpectedMaker
44
maintainer=UnexpectedMaker
55
sentence=A library to display numbers and letters on Neo7Segment displays.

src/Neo7Segment.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ Neo7Segment::Neo7Segment( uint8_t displayCount, uint8_t dPin )
163163
{
164164
dispCount = displayCount;
165165
dispPin = dPin;
166-
pixels = Adafruit_NeoPixel ( ( dispCount * NUM_PIXELS_PER_BOARD ), dispPin, NEO_GRB + NEO_KHZ800 );
166+
pixels = Adafruit_NeoPixel ();
167+
pixels.updateType( NEO_GRB + NEO_KHZ800 );
168+
pixels.updateLength( dispCount * NUM_PIXELS_PER_BOARD );
169+
pixels.setPin(dispPin);
167170
isReady = false;
168171
}
169172

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

180183
void Neo7Segment::Begin( uint8_t brightness )
181184
{
185+
182186
pixels.begin(); // This initializes the NeoPixel library.
183-
pixels.clear();
184-
pixels.setBrightness( brightness );
187+
pixels.show();
188+
pixels.setBrightness( brightness );
185189

186190
cachedString = "";
187191
cachedBytes = (byte *) malloc(dispCount * sizeof(byte));
@@ -240,23 +244,32 @@ void Neo7Segment::CheckToCacheBytes( String str )
240244
int index = 0;
241245
for ( int s = 0; s < str.length(); s++ )
242246
{
247+
#ifdef DEBUG
243248
Serial.print( (String)str.charAt(s) );
244249
Serial.print( " .. " );
250+
#endif
251+
245252
if ( (String)str.charAt(s) != "." )
246253
{
247254
cachedBytes[index] = FindByteForCharater( (String)str.charAt(s) );
255+
#ifdef DEBUG
248256
Serial.println( "1" );
257+
#endif
249258
index++;
250259
}
251260
else if ( s > 0 && bitRead( cachedBytes[index-1], 7 ) != 1 )
252261
{
253262
cachedBytes[index-1] = cachedBytes[index-1] | 0b10000000;
263+
#ifdef DEBUG
254264
Serial.println( "2" );
265+
#endif
255266
}
256267
else
257268
{
258269
cachedBytes[index] = 0b10000000;
270+
#ifdef DEBUG
259271
Serial.println( "3" );
272+
#endif
260273
index++;
261274
}
262275
}

src/Neo7Segment.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ---------------------------------------------------------------------------
2-
// Neo7Segment Library - v1.0 - 28/01/2018
2+
// Neo7Segment Library - v1.0.1 - 25/04/2018
33
//
44
// AUTHOR/LICENSE:
55
// Created by Seon Rozenblum - [email protected]
@@ -25,6 +25,7 @@
2525
// HISTORY:
2626

2727
//
28+
// 25/04/2018 v1.0.1 - Fixed bug due to change in Adafruit Neopixel library initialisation
2829
// 28/01/2018 v1.0 - Initial release.
2930
//
3031
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)