AceSegment
0.4.0
An adjustable, configurable, and extensible framework for rendering seven segment LED displays.
|
The NumberWriter supports converting decimal and hexadecimal numbers to segment patterns expected by LedDisplay. More...
#include <NumberWriter.h>
Public Types | |
typedef uint8_t | hexchar_t |
The type of the character set supported by many methods in this class, usually containing the string "HexChar" in its name. More... | |
Public Member Functions | |
NumberWriter (LedDisplay &ledDisplay) | |
Constructor. | |
LedDisplay & | display () const |
Get the underlying LedDisplay. | |
void | writeHexCharAt (uint8_t pos, hexchar_t c) |
Write the hex character c at position pos . More... | |
void | writeHexCharsAt (uint8_t pos, const hexchar_t s[], uint8_t len) |
Write the len hex characters given by s starting at pos . | |
void | writeHexByteAt (uint8_t pos, uint8_t b) |
Write the 2-digit (8-bit) hexadecimal byte 'b' at pos. | |
void | writeHexWordAt (uint8_t pos, uint16_t w) |
Write the 4 digit (16-bit) hexadecimal word at pos. | |
uint8_t | writeUnsignedDecimalAt (uint8_t pos, uint16_t num, int8_t boxSize=0) |
Write the 16-bit unsigned number num as a decimal number at pos. More... | |
uint8_t | writeSignedDecimalAt (uint8_t pos, int16_t num, int8_t boxSize=0) |
Same as writeUnsignedDecimalAt() but prepends a '-' sign if negative. | |
void | clearToEnd (uint8_t pos) |
Clear the display from pos to the end. More... | |
Static Public Attributes | |
static const uint8_t | kNumHexChars = 18 |
Total number of characters in the HexCharacter set. | |
static const hexchar_t | kCharSpace = 0x10 |
A space character. | |
static const hexchar_t | kCharMinus = 0x11 |
A minus character. | |
The NumberWriter supports converting decimal and hexadecimal numbers to segment patterns expected by LedDisplay.
The character set includes 0 to F, and a few other characters which should be self-explanatory: kCharSpace and kCharMinus.
Definition at line 39 of file NumberWriter.h.
typedef uint8_t ace_segment::NumberWriter::hexchar_t |
The type of the character set supported by many methods in this class, usually containing the string "HexChar" in its name.
This custom character set is not ASCII to save flash memory. It is a restricted set that starts with 0 and goes up to 0xF to support hexadecimal digits. In addition, the character set adds few more characters for convenience:
The hexchar_t
typedef is an alias for uint8_t
and unfortunately, C++ will not prevent mixing a normal char
or uint8_t
with a hexchar_t
. However, it does make the documentation of the various methods more self-explanatory.
Definition at line 56 of file NumberWriter.h.
|
inline |
Clear the display from pos
to the end.
Useful after calling writeSignedDecimalAt() and writeUnsignedDecimalAt() which prints a variable number of digits.
Definition at line 142 of file NumberWriter.h.
|
inline |
Write the hex character c
at position pos
.
If c
falls outside the valid range of the kHexCharPatterns set, a kCharSpace
character is printed instead.
Definition at line 82 of file NumberWriter.h.
uint8_t ace_segment::NumberWriter::writeUnsignedDecimalAt | ( | uint8_t | pos, |
uint16_t | num, | ||
int8_t | boxSize = 0 |
||
) |
Write the 16-bit unsigned number num
as a decimal number at pos.
pos | start position of the number |
num | unsigned decimal number, 0-65535 |
boxSize | size of box. This is meant to be similar to the "%-5d" or "%5d" specifier to the printf() function)
|
Definition at line 71 of file NumberWriter.cpp.