25 #ifndef ACE_SEGMENT_WRITER_STRING_WRITER_H
26 #define ACE_SEGMENT_WRITER_STRING_WRITER_H
29 #include <AceCommon.h>
30 #include "CharWriter.h"
32 class __FlashStringHelper;
34 namespace ace_segment {
44 template <
typename T_LED_MODULE>
53 T_LED_MODULE&
ledModule() {
return mCharWriter.ledModule(); }
57 return mCharWriter.patternWriter();
64 void home() { mCharWriter.home(); }
73 return writeStringInternal<const char*>(cs, numChar);
82 uint8_t
writeString(
const __FlashStringHelper* fs, uint8_t numChar = 255) {
83 return writeStringInternal<ace_common::FlashString>(
84 ace_common::FlashString(fs), numChar);
88 void clear() { mCharWriter.clear(); }
109 template <
typename T>
110 uint8_t writeStringInternal(T s, uint8_t numChar) {
111 const uint8_t numDigits = mCharWriter.size();
112 bool charWasWritten =
false;
113 uint8_t numWritten = 0;
117 if (c ==
'\0')
break;
119 if (pos >= numDigits)
break;
123 if (charWasWritten) {
124 mCharWriter.setDecimalPointAt(pos - 1);
126 mCharWriter.writeChar(
'.');
127 charWasWritten =
false;
131 mCharWriter.writeChar(c);
132 charWasWritten =
true;
142 CharWriter<T_LED_MODULE>& mCharWriter;
The CharWriter supports mapping of an 8-bit character set to segment patterns supported by LedModule.
Write LED segment patterns to the underlying LedModule.
Class that writes out a string, collapsing '.
void home()
Set the cursor to the beginning.
StringWriter(CharWriter< T_LED_MODULE > &charWriter)
Constructor.
T_LED_MODULE & ledModule()
Get the underlying LedModule.
void clearToEnd()
Clear the display from pos to the end.
void clear()
Clear the entire display.
uint8_t writeString(const __FlashStringHelper *fs, uint8_t numChar=255)
Write flash string fs at specified position pos up to numChar characters.
uint8_t writeString(const char *cs, uint8_t numChar=255)
Write c-string cs at specified position pos up to numChar characters.
PatternWriter< T_LED_MODULE > & patternWriter()
Get the underlying PatternWriter.
CharWriter< T_LED_MODULE > & charWriter()
Get the underlying CharWriter.