Skip to content

Commit 3a0425e

Browse files
Brent WilkinsBrent Wilkins
authored andcommitted
Changed type of characterToDisplay to unsigned since it's used to index an array
1 parent 9d7a9b7 commit 3a0425e

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/SevSeg.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
/*
2-
This library allows an Arduino to easily display numbers and characters on a 4 digit 7-segment
2+
This library allows an Arduino to easily display numbers and characters on a 4 digit 7-segment
33
display without a separate 7-segment display controller.
44
55
If you have feature suggestions or need support please use the github support page: https://github.com/sparkfun/SevSeg
66
77
Original Library by Dean Reading (deanreading@hotmail.com: http://arduino.cc/playground/Main/SevenSegmentLibrary), 2012
88
Improvements by Nathan Seidle, 2012
99
10-
Now works for any digital pin arrangement, common anode and common cathode displays.
10+
Now works for any digital pin arrangement, common anode and common cathode displays.
1111
Added character support including letters A-F and many symbols.
1212
13-
Hardware Setup: 4 digit 7 segment displays use 12 digital pins. You may need more pins if your display has colons or
13+
Hardware Setup: 4 digit 7 segment displays use 12 digital pins. You may need more pins if your display has colons or
1414
apostrophes.
1515
16-
There are 4 digit pins and 8 segment pins. Digit pins are connected to the cathodes for common cathode displays, or anodes
17-
for common anode displays. 8 pins control the individual segments (seven segments plus the decimal point).
16+
There are 4 digit pins and 8 segment pins. Digit pins are connected to the cathodes for common cathode displays, or anodes
17+
for common anode displays. 8 pins control the individual segments (seven segments plus the decimal point).
1818
19-
Connect the four digit pins with four limiting resistors in series to any digital or analog pins. Connect the eight segment
19+
Connect the four digit pins with four limiting resistors in series to any digital or analog pins. Connect the eight segment
2020
pins to any digital or analog pins (no limiting resistors needed). See the SevSeg example for more connection information.
21-
21+
2222
SparkFun has a large, 1" 7-segment display that has four digits.
2323
https://www.sparkfun.com/products/11408
24-
Looking at the display like this: 8.8.8.8. pin 1 is on the lower row, starting from the left.
24+
Looking at the display like this: 8.8.8.8. pin 1 is on the lower row, starting from the left.
2525
Pin 12 is the top row, upper left pin.
26-
26+
2727
Pinout:
2828
1: Segment E
2929
2: Segment D
@@ -40,23 +40,23 @@
4040
4141
4242
Software:
43-
Call SevSeg.Begin in setup.
43+
Call SevSeg.Begin in setup.
4444
The first argument (boolean) tells whether the display is common cathode (0) or common
4545
anode (1).
4646
The next four arguments (bytes) tell the library which arduino pins are connected to
4747
the digit pins of the seven segment display. Put them in order from left to right.
4848
The next eight arguments (bytes) tell the library which arduino pins are connected to
4949
the segment pins of the seven segment display. Put them in order a to g then the dp.
50-
50+
5151
In summary, Begin(type, digit pins 1-4, segment pins a-g, dp)
52-
52+
5353
The calling program must run the DisplayString() function repeatedly to get the number displayed.
54-
Any number between -999 and 9999 can be displayed.
54+
Any number between -999 and 9999 can be displayed.
5555
To move the decimal place one digit to the left, use '1' as the second
56-
argument. For example, if you wanted to display '3.141' you would call
56+
argument. For example, if you wanted to display '3.141' you would call
5757
myDisplay.DisplayString("3141", 1);
5858
59-
59+
6060
*/
6161

6262
#include "SevSeg.h"
@@ -67,11 +67,11 @@ SevSeg::SevSeg()
6767
DecAposColon = 0; //This variable tracks the decimal place, apostrophe, and colon (if the display has support)
6868

6969
}
70-
void SevSeg::Begin(boolean mode_in, byte numOfDigits,
71-
byte dig1, byte dig2, byte dig3, byte dig4,
70+
void SevSeg::Begin(boolean mode_in, byte numOfDigits,
71+
byte dig1, byte dig2, byte dig3, byte dig4,
7272
byte digitCol, byte digitApos,
73-
byte segA, byte segB, byte segC, byte segD, byte segE, byte segF, byte segG,
74-
byte segDP,
73+
byte segA, byte segB, byte segC, byte segD, byte segE, byte segF, byte segG,
74+
byte segDP,
7575
byte segCol, byte segApos)
7676
{
7777
//Bring all the variables in from the caller
@@ -92,7 +92,7 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits,
9292
segmentDP = segDP;
9393
segmentApostrophe = segApos;
9494
segmentColon = segCol;
95-
95+
9696
//Assign input values to variables
9797
//mode is what the digit pins must be set at for it to be turned on. 0 for common cathode, 1 for common anode
9898
mode = mode_in;
@@ -103,7 +103,7 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits,
103103
SegOn = LOW;
104104
SegOff = HIGH;
105105
}
106-
else
106+
else
107107
{
108108
DigitOn = LOW;
109109
DigitOff = HIGH;
@@ -126,13 +126,13 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits,
126126

127127
//Turn everything Off before setting pin as output
128128
//Set all digit pins off. Low for common anode, high for common cathode
129-
for (byte digit = 0 ; digit < numberOfDigits ; digit++)
129+
for (byte digit = 0 ; digit < numberOfDigits ; digit++)
130130
{
131131
digitalWrite(DigitPins[digit], DigitOff);
132132
pinMode(DigitPins[digit], OUTPUT);
133133
}
134134
//Set all segment pins off. High for common anode, low for common cathode
135-
for (byte seg = 0 ; seg < 8 ; seg++)
135+
for (byte seg = 0 ; seg < 8 ; seg++)
136136
{
137137
digitalWrite(SegmentPins[seg], SegOff);
138138
pinMode(SegmentPins[seg], OUTPUT);
@@ -159,9 +159,9 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits,
159159
//Set pin modes and turns all displays off
160160
//This second begin is used when the display does not support a colon and apostrophe
161161
//The digitApostrophe, segmentApostrophe, and dig/segColon are set to 255 and the normal .Begin is called
162-
void SevSeg::Begin(boolean mode_in, byte numOfDigits,
163-
byte dig1, byte dig2, byte dig3, byte dig4,
164-
byte segA, byte segB, byte segC, byte segD, byte segE, byte segF, byte segG,
162+
void SevSeg::Begin(boolean mode_in, byte numOfDigits,
163+
byte dig1, byte dig2, byte dig3, byte dig4,
164+
byte segA, byte segB, byte segC, byte segD, byte segE, byte segF, byte segG,
165165
byte segDP)
166166
{
167167
Begin(mode_in, numOfDigits, dig1, dig2, dig3, dig4, 255, 255, segA, segB, segC,
@@ -189,9 +189,9 @@ void SevSeg::SetBrightness(byte percentBright)
189189
void SevSeg::DisplayString(char* toDisplay, byte DecAposColon)
190190
{
191191
//For the purpose of this code, digit = 1 is the left most digit, digit = 4 is the right most digit
192-
for(byte digit = 1 ; digit < (numberOfDigits+1) ; digit++)
192+
for(byte digit = 1 ; digit < (numberOfDigits+1) ; digit++)
193193
{
194-
switch(digit)
194+
switch(digit)
195195
{
196196
case 1:
197197
digitalWrite(digit1, DigitOn);
@@ -212,7 +212,7 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon)
212212
//This could be cleaned up a bit but it works
213213
//displayCharacter(toDisplay[digit-1]); //Now display this digit
214214
// displayArray (defined in SevSeg.h) decides which segments are turned on for each number or symbol
215-
char characterToDisplay = toDisplay[digit-1];
215+
unsigned char characterToDisplay = toDisplay[digit-1];
216216
if (characterToDisplay & 0x80) // bit 7 enables bit-per-segment control
217217
{ // Each bit of characterToDisplay turns on a single segment (from A-to-G)
218218
if (characterToDisplay & 0x01) digitalWrite(segmentA, SegOn);
@@ -237,7 +237,7 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon)
237237
//Service the decimal point, apostrophe and colon
238238
if ((DecAposColon & (1<<(digit-1))) && (digit < 5)) //Test DecAposColon to see if we need to turn on a decimal point
239239
digitalWrite(segmentDP, SegOn);
240-
240+
241241
delayMicroseconds(brightnessDelay + 1); //Display this digit for a fraction of a second (between 1us and 5000us, 500-2000 is pretty good)
242242
//The + 1 is a bit of a hack but it removes the possible zero display (0 causes display to become bright and flickery)
243243
//If you set this too long, the display will start to flicker. Set it to 25000 for some fun.
@@ -253,7 +253,7 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon)
253253
digitalWrite(segmentDP, SegOff);
254254

255255
//Turn off this digit
256-
switch(digit)
256+
switch(digit)
257257
{
258258
case 1:
259259
digitalWrite(digit1, DigitOff);
@@ -270,11 +270,11 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon)
270270
//This only currently works for 4 digits
271271
}
272272
// The display is on for microSeconds(brightnessLevel + 1), now turn off for the remainder of the framePeriod
273-
delayMicroseconds(FRAMEPERIOD - brightnessDelay + 1); //the +1 is a hack so that we can never have a delayMicroseconds(0), causes display to flicker
273+
delayMicroseconds(FRAMEPERIOD - brightnessDelay + 1); //the +1 is a hack so that we can never have a delayMicroseconds(0), causes display to flicker
274274
}
275275

276276
//After we've gone through the digits, we control the colon and apostrophe (if the display supports it)
277-
277+
278278
//Turn on the colon and/or apostrophe
279279
if ((digitColon != 255) || (digitApostrophe != 255))
280280
{
@@ -294,8 +294,8 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon)
294294
digitalWrite(digitColon, DigitOff);
295295
digitalWrite(segmentColon, SegOff);
296296
digitalWrite(digitApostrophe, DigitOff);
297-
digitalWrite(segmentApostrophe, SegOff);
297+
digitalWrite(segmentApostrophe, SegOff);
298298
delayMicroseconds(FRAMEPERIOD - brightnessDelay + 1); //the +1 is a hack so that we can never have a delayMicroseconds(0), causes display to flicker
299299
}
300-
300+
301301
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy