AceSegmentWriter  0.1.0
Write decimal numbers, hex numbers, temperature, clock digits, characters, and strings to seven segment LED modules
Public Member Functions | List of all members
ace_segment::NumberWriter< T_LED_MODULE > Class Template Reference

The NumberWriter supports converting decimal and hexadecimal numbers to segment patterns expected by LedModule. More...

#include <NumberWriter.h>

Public Member Functions

 NumberWriter (T_LED_MODULE &ledModule)
 Constructor.
 
T_LED_MODULE & ledModule ()
 Get the underlying LedModule.
 
PatternWriter< T_LED_MODULE > & patternWriter ()
 Get the underlying PatternWriter.
 
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 writeUnsignedDecimal2At (uint8_t pos, uint8_t num)
 Write the 2 digit decimal number at pos. More...
 
void writeDecimalPointAt (uint8_t pos, bool state=true)
 Write the decimal point for the pos. More...
 
void clear ()
 Clear the entire display.
 
void clearToEnd (uint8_t pos)
 Clear the display from pos to the end. More...
 

Detailed Description

template<typename T_LED_MODULE>
class ace_segment::NumberWriter< T_LED_MODULE >

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: kHexCharSpace and kHexCharMinus.

Template Parameters
T_LED_MODULEthe 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.

Member Function Documentation

◆ clearToEnd()

template<typename T_LED_MODULE >
void ace_segment::NumberWriter< T_LED_MODULE >::clearToEnd ( uint8_t  pos)
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 204 of file NumberWriter.h.

◆ writeDecimalPointAt()

template<typename T_LED_MODULE >
void ace_segment::NumberWriter< T_LED_MODULE >::writeDecimalPointAt ( uint8_t  pos,
bool  state = true 
)
inline

Write the decimal point for the pos.

Clock LED modules will attach the colon segment to one of the decimal points.

Definition at line 192 of file NumberWriter.h.

◆ writeHexCharAt()

template<typename T_LED_MODULE >
void ace_segment::NumberWriter< T_LED_MODULE >::writeHexCharAt ( uint8_t  pos,
hexchar_t  c 
)
inline

Write the hex character c at position pos.

If c falls outside the valid range of the kHexCharPatterns set, a kHexCharSpace character is printed instead.

Definition at line 90 of file NumberWriter.h.

◆ writeUnsignedDecimal2At()

template<typename T_LED_MODULE >
void ace_segment::NumberWriter< T_LED_MODULE >::writeUnsignedDecimal2At ( uint8_t  pos,
uint8_t  num 
)
inline

Write the 2 digit decimal number at pos.

This method always writes 2 characters. The padding is always a space, so 9 is printed as " 9" not "09". If num >= 100, then this prints "99".

This method is meant to be a lighter version of writeUnsignedDecimalAt() when only 2 digits are needed. Seems to save about 110 bytes of flash.

Definition at line 176 of file NumberWriter.h.

◆ writeUnsignedDecimalAt()

template<typename T_LED_MODULE >
uint8_t ace_segment::NumberWriter< T_LED_MODULE >::writeUnsignedDecimalAt ( uint8_t  pos,
uint16_t  num,
int8_t  boxSize = 0 
)
inline

Write the 16-bit unsigned number num as a decimal number at pos.

Parameters
posstart position of the number
numunsigned decimal number, 0-65535
boxSizesize of box. This is meant to be similar to the "%-5d" or "%5d" specifier to the printf() function
  • 0 means no boxing, printing from left
  • > 0 means right justified inside box
  • < 0 means left justified inside box
Returns
number of characters actually written, even if the characters bled over the end of the LED segments

Definition at line 134 of file NumberWriter.h.


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