LED7Seg  1.00
LED 7-segment library
Public Member Functions | Protected Attributes | List of all members
SevSeg Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

void SevSeg::begin ( enum led_config  conf,
uint8_t  digits,
const uint8_t *  pins 
)

Initialization function

Parameters
confBit mask (Bit0, Bit1..Bit m_digits)
digitsNumber of digits (typically 1-4)
pinsOutput 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.

Parameters
maskBit mask (DIG_0..DIG_n-1)
void SevSeg::setSegments ( enum led_seg  mask)

Set all LED segment pins based on mask

Parameters
maskBit 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.

Parameters
numNumber to display
dpDecimal Places (-1 if no decimal point)
void SevSeg::showHex ( unsigned long  num)

Show number as hexadecimal right justified on the LED display

Parameters
numNumber to display
void SevSeg::showNumber ( unsigned long  num,
uint8_t  dp,
enum led_seg  fill = SEG_NONE 
)

Show number as unsigned decimal with [optional] decimal point right justified on the LED display.

Parameters
numNumber to display
dpNumber of decimal places (-1 if no decimal point)
fillFill 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.

Parameters
bufBuffer 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.

Parameters
strText string to display

The documentation for this class was generated from the following files: