]>
fbox.kageds.com Git - richie-water-pump.git/blob - sevseg.h
3 Copyright 2017 Dean Reading
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
17 This library allows an Arduino to easily display numbers in decimal format on
18 a 7-segment display without a separate 7-segment display controller.
20 Direct any questions or suggestions to deanreading@hotmail.com
21 See the included readme for instructions.
25 #define MAXNUMDIGITS 8 // Can be increased, but the max number is 2^31
31 #if defined(ARDUINO) && ARDUINO >= 100
34 typedef unsigned char byte
;
37 // Use defines to link the hardware configurations to the correct numbers
38 #define COMMON_CATHODE 0
39 #define COMMON_ANODE 1
40 #define N_TRANSISTORS 2
41 #define P_TRANSISTORS 3
42 #define NP_COMMON_CATHODE 1
43 #define NP_COMMON_ANODE 0
51 void refreshDisplay();
52 void begin(byte hardwareConfig
, byte numDigitsIn
, byte digitPinsIn
[],
53 byte segmentPinsIn
[], bool resOnSegmentsIn
=0,
54 bool updateWithDelaysIn
=0, bool leadingZerosIn
=0);
55 void setBrightness(int brightnessIn
); // A number from 0..100
57 void setNumber(long numToShow
, char decPlaces
=-1, bool hex
=0);
58 void setNumber(unsigned long numToShow
, char decPlaces
=-1, bool hex
=0);
59 void setNumber(int numToShow
, char decPlaces
=-1, bool hex
=0);
60 void setNumber(unsigned int numToShow
, char decPlaces
=-1, bool hex
=0);
61 void setNumber(char numToShow
, char decPlaces
=-1, bool hex
=0);
62 void setNumber(byte numToShow
, char decPlaces
=-1, bool hex
=0);
63 void setNumber(float numToShow
, char decPlaces
=-1, bool hex
=0);
65 void setSegments(byte segs
[]);
66 void setChars(char str
[]);
70 void setNewNum(long numToShow
, char decPlaces
, bool hex
=0);
71 void findDigits(long numToShow
, char decPlaces
, bool hex
, byte digits
[]);
72 void setDigitCodes(byte nums
[], char decPlaces
);
74 bool digitOn
,digitOff
,segmentOn
,segmentOff
;
75 bool resOnSegments
, updateWithDelays
, leadingZeros
;
76 byte digitPins
[MAXNUMDIGITS
];
80 byte digitCodes
[MAXNUMDIGITS
];
82 unsigned long prevUpdateTime
;