|
54 | 54 | Any number between -999 and 9999 can be displayed.
|
55 | 55 | To move the decimal place one digit to the left, use '1' as the second
|
56 | 56 | argument. For example, if you wanted to display '3.141' you would call
|
57 |
| - myDisplay.DisplayNumber(3141, 1); |
| 57 | + myDisplay.DisplayString("3141", 1, 250); |
| 58 | + The last argument (250) is the amount of time the display will be on in microseconds. |
| 59 | + Used in conjunction with |
58 | 60 |
|
59 | 61 | */
|
60 | 62 |
|
@@ -144,7 +146,8 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits,
|
144 | 146 | //Given a string such as "-A32", we display -A32
|
145 | 147 | //Each digit is displayed for ~2000us, and cycles through the 4 digits
|
146 | 148 | //After running through the 4 numbers, the display is turned off
|
147 |
| -void SevSeg::DisplayString(char* toDisplay, byte DecPlace){ |
| 149 | +//Will turn the display on for a given amount of time - this helps control brightness |
| 150 | +void SevSeg::DisplayString(char* toDisplay, byte DecPlace, unsigned int brightnessLevel){ |
148 | 151 |
|
149 | 152 | //For the purpose of this code, digit = 1 is the left most digit, digit = 4 is the right most digit
|
150 | 153 |
|
@@ -183,8 +186,9 @@ void SevSeg::DisplayString(char* toDisplay, byte DecPlace){
|
183 | 186 |
|
184 | 187 | //Service the decimal point
|
185 | 188 | if(DecPlace == digit) digitalWrite(segmentDP, SegOn);
|
186 |
| - |
187 |
| - delayMicroseconds(2000); //Display this digit for a fraction of a second (between 1us and 5000us, 500-2000 is pretty good) |
| 189 | + |
| 190 | + delayMicroseconds(brightnessLevel + 1); //Display this digit for a fraction of a second (between 1us and 5000us, 500-2000 is pretty good) |
| 191 | + //The + 1 is a bit of a hack but it removes the possible zero display (0 causes display to become bright and flickery) |
188 | 192 | //If you set this too long, the display will start to flicker. Set it to 25000 for some fun.
|
189 | 193 |
|
190 | 194 | //Turn off all segments
|
@@ -215,6 +219,10 @@ void SevSeg::DisplayString(char* toDisplay, byte DecPlace){
|
215 | 219 |
|
216 | 220 | //This only currently works for 4 digits
|
217 | 221 | }
|
| 222 | + |
| 223 | + // The display is on for microSeconds(brightnessLevel + 1), now turn off for the remainder of the framePeriod |
| 224 | + delayMicroseconds(FRAMEPERIOD - brightnessLevel + 1); //the +1 is a hack so that we can never have a delayMicroseconds(0), causes display to flicker |
| 225 | + |
218 | 226 | }
|
219 | 227 |
|
220 | 228 | }
|
0 commit comments