AceSegment
0.7.0
A framework for rendering seven segment LED displays using the TM1637, MAX7219, HT16K33, or 74HC595 controller chips
|
25 #ifndef ACE_SEGMENT_NUMBER_WRITER_H
26 #define ACE_SEGMENT_NUMBER_WRITER_H
29 #include "PatternWriter.h"
31 namespace ace_segment {
84 writeInternalHexCharAt(
90 for (uint8_t i = 0; i < len; ++i) {
97 uint8_t low = (b & 0x0F);
99 uint8_t high = (b & 0x0F);
101 writeInternalHexCharAt(pos++, high);
102 writeInternalHexCharAt(pos++, low);
107 uint8_t low = (w & 0xFF);
108 uint8_t high = (w >> 8) & 0xFF;
172 void writeInternalHexCharAt(uint8_t pos,
hexchar_t c);
175 void writeInternalHexCharsAt(uint8_t pos,
const hexchar_t s[],
177 for (uint8_t i = 0; i < len; ++i) {
178 writeInternalHexCharAt(pos++, s[i]);
188 uint8_t writeHexCharsInsideBoxAt(
207 uint8_t toDecimal(uint16_t num,
hexchar_t buf[], uint8_t bufSize) {
208 uint8_t pos = bufSize;
214 uint16_t quot = num / 10;
215 buf[--pos] = num - quot * 10;
225 PatternWriter mPatternWriter;
void writeHexCharAt(uint8_t pos, hexchar_t c)
Write the hex character c at position 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.
LedModule & ledModule() const
Return the underlying LedModule.
void clearToEnd(uint8_t pos)
Clear the display from pos to the end.
NumberWriter(LedModule &ledModule)
Constructor.
General interface that represents a generic seven-segment LED module with multiple digits.
static const uint8_t kNumHexChars
Total number of characters in the HexCharacter set.
uint8_t writeSignedDecimalAt(uint8_t pos, int16_t num, int8_t boxSize=0)
Same as writeUnsignedDecimalAt() but prepends a '-' sign if negative.
void writeHexWordAt(uint8_t pos, uint16_t w)
Write the 4 digit (16-bit) hexadecimal word at pos.
void clear()
Clear the entire display.
void writeDecimalPointAt(uint8_t pos, bool state=true)
Write the decimal point for the pos.
PatternWriter & patternWriter()
Get the underlying LedModule.
uint8_t hexchar_t
The type of the character set supported by many methods in this class, usually containing the string ...
static const hexchar_t kCharMinus
A minus character.
void clearToEnd(uint8_t pos)
Clear the display from pos to the end.
void writeHexCharsAt(uint8_t pos, const hexchar_t s[], uint8_t len)
Write the len hex characters given by s starting at pos.
The NumberWriter supports converting decimal and hexadecimal numbers to segment patterns expected by ...
static const hexchar_t kCharSpace
A space character.
void writeDecimalPointAt(uint8_t pos, bool state=true)
Write the decimal point for the pos.
Write LED segment patterns to the underlying LedModule.
LedModule & ledModule()
Get the underlying LedModule.
void writeHexByteAt(uint8_t pos, uint8_t b)
Write the 2-digit (8-bit) hexadecimal byte 'b' at pos.
void writeUnsignedDecimal2At(uint8_t pos, uint8_t num)
Write the 2 digit decimal number at pos.