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_STRING_WRITER_H
26 #define ACE_SEGMENT_STRING_WRITER_H
29 #include <AceCommon.h>
30 #include "../LedModule.h"
31 #include "CharWriter.h"
33 class __FlashStringHelper;
35 namespace ace_segment {
66 return writeStringInternalAt<const char*>(pos, cs, numChar);
77 const __FlashStringHelper* fs,
80 return writeStringInternalAt<ace_common::FlashString>(
81 pos, ace_common::FlashString(fs), numChar);
106 template <
typename T>
107 uint8_t writeStringInternalAt(uint8_t pos, T s, uint8_t numChar) {
109 const uint8_t originalPos = pos;
110 bool charWasWritten =
false;
114 if (c ==
'\0')
break;
115 if (pos >= numDigits)
break;
119 if (charWasWritten) {
123 charWasWritten =
false;
128 charWasWritten =
true;
134 return pos - originalPos;
138 CharWriter& mCharWriter;
void writeDecimalPointAt(uint8_t pos, bool state=true)
Write the decimal point for the pos.
void clear()
Clear the entire display.
General interface that represents a generic seven-segment LED module with multiple digits.
The CharWriter supports mapping of an 8-bit character set to segment patterns supported by LedModule.
uint8_t writeStringAt(uint8_t pos, const char *cs, uint8_t numChar=255)
Write c-string cs at specified position pos up to numChar characters.
void clear()
Clear the entire display.
LedModule & ledModule() const
Get the underlying LedModule.
void clearToEnd(uint8_t pos)
Clear the display from pos to the end.
Class that writes out a string, collapsing '.
StringWriter(CharWriter &charWriter)
Constructor.
void writeCharAt(uint8_t pos, char c)
Write the character at the specified position.
LedModule & ledModule()
Get the underlying LedModule.
void clearToEnd(uint8_t pos)
Clear the display from pos to the end.
CharWriter & charWriter()
Get the underlying LedModule.
uint8_t getNumDigits() const
Return the number of digits supported by this display instance.
uint8_t writeStringAt(uint8_t pos, const __FlashStringHelper *fs, uint8_t numChar=255)
Write flash string fs at specified position pos up to numChar characters.