AceSegmentWriter
0.5
Write decimal numbers, hex numbers, temperature, clock digits, characters, and strings to seven segment LED modules
|
The NumberWriter supports converting decimal and hexadecimal numbers to segment patterns expected by LedModule. More...
#include <NumberWriter.h>
Public Member Functions | |
NumberWriter (PatternWriter< T_LED_MODULE > &patternWriter) | |
Constructor. | |
T_LED_MODULE & | ledModule () |
Get the underlying LedModule. | |
PatternWriter< T_LED_MODULE > & | patternWriter () |
Get the underlying PatternWriter. | |
void | home () |
Reset cursor to home. | |
void | writeDigit (digit_t c) |
Write the digit c at position pos . More... | |
void | writeDigits (const digit_t s[], uint8_t len) |
Write the len hex characters given by s at LED pos . | |
void | writeDec2 (uint8_t d, uint8_t padPattern=kPattern0) |
Write a 2-digit decimal number at position digit, right justified with the given padPattern (default kPattern0). More... | |
void | writeDec4 (uint16_t dd, uint8_t padPattern=kPattern0) |
Write the 4 digit decimal number dd at pos, right justified, padded with a the padPattern (default kPattern0). More... | |
void | writeBcd (uint8_t bcd) |
Write a 2-digit BCD number at position, which involves just printing the number as a hexadecimal number. More... | |
void | writeHexByte (uint8_t b) |
Write the 2-digit (8-bit) hexadecimal byte 'b' at pos. | |
void | writeHexWord (uint16_t w) |
Write the 4 digit (16-bit) hexadecimal word at pos. | |
uint8_t | writeUnsignedDecimal (uint16_t num, int8_t boxSize=0) |
Write the 16-bit unsigned number num as a decimal number at pos. More... | |
uint8_t | writeSignedDecimal (int16_t num, int8_t boxSize=0) |
Same as writeUnsignedDecimal() but prepends a '-' sign if negative. | |
void | writeFloat (float x, uint8_t prec=2) |
Write a float using the same format as the Print class. More... | |
void | writeChar (char c) |
Write a limited set of ASCII characters, enough to support floating point numbers without scientific notation. More... | |
void | writeDecimalPoint (bool state=true) |
Write the decimal point at the digit before the current position. More... | |
void | clear () |
Clear the entire display. | |
void | clearToEnd () |
Clear the display from the current position to the end. More... | |
The NumberWriter supports converting decimal and hexadecimal numbers to segment patterns expected by LedModule.
The character set includes 0 to F, and a few other characters which should be self-explanatory: kDigitSpace and kDigitMinus.
T_LED_MODULE | the class of the underlying LED Module, often LedModule but other classes with the same generic public methods can be substituted |
Definition at line 72 of file NumberWriter.h.
|
inline |
Clear the display from the current position to the end.
Useful after calling writeSignedDecimal() and writeUnsignedDecimal() which prints a variable number of digits.
Definition at line 279 of file NumberWriter.h.
|
inline |
Write a 2-digit BCD number at position, which involves just printing the number as a hexadecimal number.
For example, 0x12 is printed as "12", but 0x1A is printed as "1 ".
Definition at line 159 of file NumberWriter.h.
|
inline |
Write a limited set of ASCII characters, enough to support floating point numbers without scientific notation.
Supports '0'-'9', '.', and '-'. Everything else is printed as a space ' ', including the space character itself. The period character '.' triggers a call to writeDecimalPoint() which is usually the desired behavior.
Definition at line 246 of file NumberWriter.h.
|
inline |
Write a 2-digit decimal number at position digit, right justified with the given padPattern
(default kPattern0).
If the number is greater than 100, then print " " (2 spaces). Useful for month, day, hour, minute, second.
d | decimal value to write |
padPattern | leading pattern, usually kPatternSpace or kPattern0 |
Definition at line 113 of file NumberWriter.h.
|
inline |
Write the 4 digit decimal number dd
at pos, right justified, padded with a the padPattern
(default kPattern0).
If the number is greater than 10000, print 4 spaces.
Definition at line 134 of file NumberWriter.h.
|
inline |
Write the decimal point at the digit before the current position.
If this is not sufficient, applications can call the lower level PatternWriter::setDecimalPointAt(pos, state) method for more control.
Definition at line 267 of file NumberWriter.h.
|
inline |
Write the digit c
at position pos
.
If c
falls outside the valid range of the kDigitPatterns set, a kDigitSpace
character is printed instead.
Definition at line 93 of file NumberWriter.h.
|
inline |
Write a float using the same format as the Print class.
Scientific notation (e.g. "1.3e8") is not supported, and the largest floating point number seems to be about 2^32 (but not exactly).
x | floating point number |
prec | number of digits after the decimal point, default 2 |
Definition at line 231 of file NumberWriter.h.
|
inline |
Write the 16-bit unsigned number num
as a decimal number at pos.
The lead padding character is always kPatternSpace.
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. The actual digits may spill over the recommended box size.
|
Definition at line 199 of file NumberWriter.h.