-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unpredictable behavior in a specific case of unused decimal point pins caused by an array out of bounds condition #109
Comments
That makes sense. With this setup, SevSeg reads in 8 pin numbers, where the 8th pin number is not defined. |
Many thanks for looking at this so quickly. There are, unfortunately, code samples circulating which are misleading, for example this implying that all works when only seven segment pins are defined and without reference to a disableDecPoint parameter : https://forum.arduino.cc/t/how-to-use-a-2-digit-7-segment-display-with-sevseg-h-library/644014. I'll deal with that one specifically by requesting that the tread is reopened and adding a comment. If you wish you can mark this as closed. |
Yep that's exactly right. Your idea of maintaining the old begin function for backwards compatibility is a great one.
I think that it needs a new begin function that takes in a 'struct SevSegSettings'. This would allow more flexibility for input arguments.
|
Unpredictable behavior occurs if only seven segments pins (that is no decimal point pins) are defined in the array
segmentPins[]
in the call to the begin() method but the parameterdisableDecPoint
is omitted.This could be the case when the decimal point pins of the seven segment displays are not used.
The problem is that the default value of
disableDecPoint
is false. This leads to the library treating the number of elements insegmentPins[]
as 8 even though only 7 elements are present. When the array is later scanned an attempt is made to read the non-existent element number 8 leading to this unpredictable behavior [array out of bounds].In the specific case recorded at https://forum.arduino.cc/t/2-digit-display-with-sevseg-library-a-segment-staying-on/1230896 the effect of this error was that an unwanted segment on a display remained lit.
The text was updated successfully, but these errors were encountered: