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;
107 template <
typename T_LED_MODULE>
123 uint8_t
size()
const {
return mLedModule.size(); }
129 uint8_t
pos()
const {
return mPos; }
136 if (mPos >= mLedModule.size())
return;
137 mLedModule.setPatternAt(mPos, pattern);
143 for (uint8_t i = 0; i < len; i++) {
144 if (mPos >= mLedModule.size())
break;
145 mLedModule.setPatternAt(mPos, patterns[i]);
155 for (uint8_t i = 0; i < len; i++) {
156 if (mPos >= mLedModule.size())
break;
157 uint8_t pattern = pgm_read_byte(patterns + i);
158 mLedModule.setPatternAt(mPos, pattern);
168 mLedModule.setDecimalPointAt(
pos, state);
176 for (uint8_t i = mPos; i < mLedModule.size(); ++i) {
177 mLedModule.setPatternAt(i, 0);
188 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.
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.
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.