![]() |
LED7Seg
1.00
LED 7-segment library
|
LED 7-Segment library. More...
#include <LED7Seg.h>
Public Member Functions | |
SevSeg () | |
Constructor. More... | |
void | begin (enum led_config conf, uint8_t digits, const uint8_t *pin) |
void | setSegments (enum led_seg mask) |
void | setDigits (enum led_dig mask) |
void | refreshDigits (void) |
void | refreshSegments (void) |
void | showHex (unsigned long num) |
void | showNumber (unsigned long num, uint8_t dp, enum led_seg fill=SEG_NONE) |
void | showDecimal (signed long i, uint8_t dp) |
void | showText (const char *str) |
void | showRaw (const enum led_seg *buf) |
Protected Attributes | |
uint8_t | m_config |
Config byte: bit 0=SEG_INVERT, bit 1=DIG_INVERT. | |
uint8_t | m_digits |
Number of digits (e.g. sizeof(m_digitPin) | |
uint8_t | m_index |
Index of digit to multiplex. | |
unsigned long | m_last |
Timestamp of last refresh/update. | |
enum led_seg | m_buf [MAX_DIGITS] |
Buffer of segments to display. | |
const uint8_t * | m_pins |
Digit pin array. | |
LED 7-Segment Display Driver library for Arduino
--A-- F | | B --G-- E | | C --D--
CAUTION: use series resistors in series with the segment pins to limit the current to the LED. Using the output pin voltage, LED forward current calculate the value for the resistor using the following website:
http://led.linear1.org/1led.wiz
Typical values for series resistor for 5V outputs are: 330 ohms = 10mA, 220 ohms = 15 mA, 150 ohms = 20 mA.
If the total current exceeds the maximum source or sink current of any pin (approx 100mA see datasheet for details) use a PNP or NPN transistor to prevent damage to the ATMega microprocessor.
SevSeg::SevSeg | ( | ) |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
void SevSeg::begin | ( | enum led_config | conf, |
uint8_t | digits, | ||
const uint8_t * | pins | ||
) |
Initialization function
conf | Bit mask (Bit0, Bit1..Bit m_digits) |
digits | Number of digits (typically 1-4) |
pins | Output pin array |
void SevSeg::refreshDigits | ( | void | ) |
Refresh/multiplex all the digits on the LED Display. Use this method when the current limiting resistors are in series with the segment pins.
void SevSeg::refreshSegments | ( | void | ) |
Refresh/multiplex all the segments on the LED Display. Use this method when the current limiting resistors are in series with the digit pins.
void SevSeg::setDigits | ( | enum led_dig | mask | ) |
Set LED Digit pins based on mask.
mask | Bit mask (DIG_0..DIG_n-1) |
void SevSeg::setSegments | ( | enum led_seg | mask | ) |
Set all LED segment pins based on mask
mask | Bit mask (SEG_A,SEG_B,SEG_C,SEG_D,SEG_E,SEG_F,SEG_G,SEG_DP) |
void SevSeg::showDecimal | ( | signed long | num, |
uint8_t | dp | ||
) |
Show number as signed decimal with [optional] decimal point right justified on the LED display.
num | Number to display |
dp | Decimal Places (-1 if no decimal point) |
void SevSeg::showHex | ( | unsigned long | num | ) |
Show number as hexadecimal right justified on the LED display
num | Number to display |
Show number as unsigned decimal with [optional] decimal point right justified on the LED display.
num | Number to display |
dp | Number of decimal places (-1 if no decimal point) |
fill | Fill char (' ', '-' or '+') |
void SevSeg::showRaw | ( | const enum led_seg * | buf | ) |
Show raw segments (A-F + decimal point) left justified on the LED display. Useful for displaying graphics and other special symbols.
buf | Buffer of segment masks |
void SevSeg::showText | ( | const char * | str | ) |
Show text string as ASCII characters with [optional] decimal point left justified on the LED display.
str | Text string to display |