Adafruit LED Backpack Library
Public Member Functions | List of all members
Adafruit_7segment Class Reference

Class for 7-segment numeric displays. More...

#include <Adafruit_LEDBackpack.h>

Inheritance diagram for Adafruit_7segment:
Adafruit_LEDBackpack

Public Member Functions

 Adafruit_7segment (void)
 Constructor for 7-segment numeric displays.
 
size_t write (char c)
 Issue single character to display. More...
 
size_t write (const char *buffer, size_t size)
 Write characters from buffer to display. More...
 
void print (char c)
 Print byte-size numeric value to 7-segment display. More...
 
void print (unsigned char b, int base=RAW_BITS)
 Print unsigned byte-size numeric value to 7-segment display. More...
 
void print (int n, int base=DEC)
 Print integer value to 7-segment display. More...
 
void print (unsigned int n, int base=DEC)
 Print unsigned integer value to 7-segment display. More...
 
void print (long n, int base=DEC)
 Print long integer value to 7-segment display. More...
 
void print (unsigned long n, int base=DEC)
 Print unsigned long integer value to 7-segment display. More...
 
void print (double n, int digits=2)
 Print double-precision float value to 7-segment display. More...
 
void print (const String &c)
 Print from a String object to 7-segment display. More...
 
void print (const char c[])
 Print from a C-style string array to 7-segment display. More...
 
void println (char c)
 Print byte-size numeric value w/newline to 7-segment display. More...
 
void println (unsigned char b, int base=RAW_BITS)
 Print unsigned byte-size numeric value w/newline to 7-segment display. More...
 
void println (int n, int base=DEC)
 Print integer value with newline to 7-segment display. More...
 
void println (unsigned int n, int base=DEC)
 Print unsigned integer value with newline to 7-segment display. More...
 
void println (long n, int base=DEC)
 Print long integer value with newline to 7-segment display. More...
 
void println (unsigned long n, int base=DEC)
 Print unsigned long integer value w/newline to 7-segment display. More...
 
void println (double n, int digits=2)
 Print double-precision float value to 7-segment display. More...
 
void println (const String &c)
 Print from a String object w/newline to 7-segment display. More...
 
void println (const char c[])
 Print from a C-style string array w/newline to 7-segment display. More...
 
void println (void)
 Print newline to 7-segment display (rewind position to start).
 
void writeDigitRaw (uint8_t x, uint8_t bitmask)
 Write raw segment bits into display buffer. More...
 
void writeDigitNum (uint8_t x, uint8_t num, bool dot=false)
 Set specific digit # to a numeric value. More...
 
void writeDigitAscii (uint8_t x, uint8_t c, bool dot=false)
 Set specific digit # to a character value. More...
 
void drawColon (bool state)
 Set or unset colon segment. More...
 
void printNumber (long n, uint8_t base=2)
 General integer-printing function used by some of the print() variants. More...
 
void printFloat (double n, uint8_t fracDigits=2, uint8_t base=DEC)
 General float-printing function used by some of the print() variants. More...
 
void printError (void)
 Light display segments in an error-indicating configuration.
 
void writeColon (void)
 Issue colon-on directly to display (bypass buffer).
 
- Public Member Functions inherited from Adafruit_LEDBackpack
 Adafruit_LEDBackpack (void)
 Constructor for HT16K33 devices.
 
bool begin (uint8_t _addr=0x70, TwoWire *theWire=&Wire)
 Start I2C and initialize display state (blink off, full brightness). More...
 
void setDisplayState (bool state)
 Turn display on or off. More...
 
void setBrightness (uint8_t b)
 Set display brightness. More...
 
void blinkRate (uint8_t b)
 Set display blink rate. More...
 
void writeDisplay (void)
 Issue buffered data in RAM to display.
 
void clear (void)
 Clear display.
 

Additional Inherited Members

- Public Attributes inherited from Adafruit_LEDBackpack
uint16_t displaybuffer [8]
 Raw display data.
 
- Protected Attributes inherited from Adafruit_LEDBackpack
Adafruit_I2CDevice * i2c_dev = NULL
 Pointer to I2C bus interface.
 

Detailed Description

Class for 7-segment numeric displays.

Member Function Documentation

◆ write() [1/2]

size_t Adafruit_7segment::write ( char  c)

Issue single character to display.

Parameters
cCharacter to write (ASCII character, not numeric).
Returns
1 if character written, else 0 (non-ASCII characters).

◆ write() [2/2]

size_t Adafruit_7segment::write ( const char *  buffer,
size_t  size 
)

Write characters from buffer to display.

Parameters
bufferCharacter array to write
sizeNumber of characters to write
Returns
Number of characters written

◆ print() [1/9]

void Adafruit_7segment::print ( char  c)

Print byte-size numeric value to 7-segment display.

Parameters
cNumeric value.

◆ print() [2/9]

void Adafruit_7segment::print ( unsigned char  b,
int  base = RAW_BITS 
)

Print unsigned byte-size numeric value to 7-segment display.

Parameters
bNumeric value.
baseNumber base (default = RAW_BITS = raw bits)

◆ print() [3/9]

void Adafruit_7segment::print ( int  n,
int  base = DEC 
)

Print integer value to 7-segment display.

Parameters
nNumeric value.
baseNumber base (default = DEC = base 10)

◆ print() [4/9]

void Adafruit_7segment::print ( unsigned int  n,
int  base = DEC 
)

Print unsigned integer value to 7-segment display.

Parameters
nNumeric value.
baseNumber base (default = DEC = base 10)

◆ print() [5/9]

void Adafruit_7segment::print ( long  n,
int  base = DEC 
)

Print long integer value to 7-segment display.

Parameters
nNumeric value.
baseNumber base (default = DEC = base 10)

◆ print() [6/9]

void Adafruit_7segment::print ( unsigned long  n,
int  base = DEC 
)

Print unsigned long integer value to 7-segment display.

Parameters
nNumeric value.
baseNumber base (default = DEC = base 10)

◆ print() [7/9]

void Adafruit_7segment::print ( double  n,
int  digits = 2 
)

Print double-precision float value to 7-segment display.

Parameters
nNumeric value.
digitsFractional-part digits.

◆ print() [8/9]

void Adafruit_7segment::print ( const String &  c)

Print from a String object to 7-segment display.

Parameters
cString object, passed by reference.

◆ print() [9/9]

void Adafruit_7segment::print ( const char  c[])

Print from a C-style string array to 7-segment display.

Parameters
cArray of characters.

◆ println() [1/9]

void Adafruit_7segment::println ( char  c)

Print byte-size numeric value w/newline to 7-segment display.

Parameters
cNumeric value.

◆ println() [2/9]

void Adafruit_7segment::println ( unsigned char  b,
int  base = RAW_BITS 
)

Print unsigned byte-size numeric value w/newline to 7-segment display.

Parameters
bNumeric value.
baseNumber base (default = RAW_BITS = raw bits)

◆ println() [3/9]

void Adafruit_7segment::println ( int  n,
int  base = DEC 
)

Print integer value with newline to 7-segment display.

Parameters
nNumeric value.
baseNumber base (default = DEC = base 10)

◆ println() [4/9]

void Adafruit_7segment::println ( unsigned int  n,
int  base = DEC 
)

Print unsigned integer value with newline to 7-segment display.

Parameters
nNumeric value.
baseNumber base (default = DEC = base 10)

◆ println() [5/9]

void Adafruit_7segment::println ( long  n,
int  base = DEC 
)

Print long integer value with newline to 7-segment display.

Parameters
nNumeric value.
baseNumber base (default = DEC = base 10)

◆ println() [6/9]

void Adafruit_7segment::println ( unsigned long  n,
int  base = DEC 
)

Print unsigned long integer value w/newline to 7-segment display.

Parameters
nNumeric value.
baseNumber base (default = DEC = base 10)

◆ println() [7/9]

void Adafruit_7segment::println ( double  n,
int  digits = 2 
)

Print double-precision float value to 7-segment display.

Parameters
nNumeric value.
digitsFractional-part digits.

◆ println() [8/9]

void Adafruit_7segment::println ( const String &  c)

Print from a String object w/newline to 7-segment display.

Parameters
cString object, passed by reference.

◆ println() [9/9]

void Adafruit_7segment::println ( const char  c[])

Print from a C-style string array w/newline to 7-segment display.

Parameters
cArray of characters.

◆ writeDigitRaw()

void Adafruit_7segment::writeDigitRaw ( uint8_t  x,
uint8_t  bitmask 
)

Write raw segment bits into display buffer.

Parameters
xCharacter position (0-3).
bitmaskSegment bits.

◆ writeDigitNum()

void Adafruit_7segment::writeDigitNum ( uint8_t  x,
uint8_t  num,
bool  dot = false 
)

Set specific digit # to a numeric value.

Parameters
xCharacter position.
numNumeric (not ASCII) value.
dotIf true, light corresponding decimal.

◆ writeDigitAscii()

void Adafruit_7segment::writeDigitAscii ( uint8_t  x,
uint8_t  c,
bool  dot = false 
)

Set specific digit # to a character value.

Parameters
xCharacter position.
cCharacter (ASCII).
dotIf true, light corresponding decimal.

◆ drawColon()

void Adafruit_7segment::drawColon ( bool  state)

Set or unset colon segment.

Parameters
state'true' to enable colon, 'false' for off.

◆ printNumber()

void Adafruit_7segment::printNumber ( long  n,
uint8_t  base = 2 
)

General integer-printing function used by some of the print() variants.

Parameters
nNumeric value.
baseBase (2 = binary).

◆ printFloat()

void Adafruit_7segment::printFloat ( double  n,
uint8_t  fracDigits = 2,
uint8_t  base = DEC 
)

General float-printing function used by some of the print() variants.

Parameters
nNumeric value.
fracDigitsFractional-part digits.
baseBase (default DEC = base 10).

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