25 #ifndef ACE_SEGMENT_WRITER_PATTERN_WRITER_H
26 #define ACE_SEGMENT_WRITER_PATTERN_WRITER_H
31 namespace ace_segment {
36 const uint8_t kPattern0 = 0b00111111;
39 const uint8_t kPattern1 = 0b00000110;
42 const uint8_t kPattern2 = 0b01011011;
45 const uint8_t kPattern3 = 0b01001111;
48 const uint8_t kPattern4 = 0b01100110;
51 const uint8_t kPattern5 = 0b01101101;
54 const uint8_t kPattern6 = 0b01111101;
57 const uint8_t kPattern7 = 0b00000111;
60 const uint8_t kPattern8 = 0b01111111;
63 const uint8_t kPattern9 = 0b01101111;
66 const uint8_t kPatternA = 0b01110111;
69 const uint8_t kPatternB = 0b01111100;
72 const uint8_t kPatternC = 0b00111001;
75 const uint8_t kPatternD = 0b01011110;
78 const uint8_t kPatternE = 0b01111001;
81 const uint8_t kPatternF = 0b01110001;
84 const uint8_t kPatternSpace = 0b00000000;
87 const uint8_t kPatternMinus = 0b01000000;
90 const uint8_t kPatternDeg = 0b01100011;
93 const uint8_t kPatternP = 0b01110011;
112 template <
typename T_LED_MODULE>
128 uint8_t
size()
const {
return mLedModule.size(); }
134 uint8_t
pos()
const {
return mPos; }
141 if (mPos >= mLedModule.size())
return;
142 mLedModule.setPatternAt(mPos, pattern);
148 for (uint8_t i = 0; i < len; i++) {
149 if (mPos >= mLedModule.size())
break;
150 mLedModule.setPatternAt(mPos, patterns[i]);
160 for (uint8_t i = 0; i < len; i++) {
161 if (mPos >= mLedModule.size())
break;
162 uint8_t pattern = pgm_read_byte(patterns + i);
163 mLedModule.setPatternAt(mPos, pattern);
175 if (mPos == 0)
return;
176 if (mPos > mLedModule.size())
return;
177 mLedModule.setDecimalPointAt(mPos - 1, state);
185 if (
pos >= mLedModule.size())
return;
186 mLedModule.setDecimalPointAt(
pos, state);
194 for (uint8_t i = mPos; i < mLedModule.size(); ++i) {
195 mLedModule.setPatternAt(i, 0);
206 T_LED_MODULE& mLedModule;
Write LED segment patterns to the underlying LedModule.
void writePatterns_P(const uint8_t patterns[], uint8_t len)
Write the array patterns[] of length len to the led module.
void setDecimalPointAt(uint8_t pos, bool state=true)
Write the decimal point for the pos.
void writeDecimalPoint(bool state=true)
Write a decimal point to the digit previous to the current position.
PatternWriter(T_LED_MODULE &ledModule)
Constructor.
uint8_t size() const
Return the number of digits supported by this display instance.
void home()
Set the cursor to the beginning.
void pos(uint8_t pos)
Set the current cursor position.
void writePattern(uint8_t pattern)
Write pattern at the current cursor.
void writePatterns(const uint8_t patterns[], uint8_t len)
Write the array patterns[] of length len to the led module.
void clear()
Clear the entire display, set the cursor to home().
uint8_t pos() const
Return the current cursor position.
T_LED_MODULE & ledModule() const
Return the underlying LedModule.
void clearToEnd()
Clear the display from pos to the end, set the cursor to home().