AceSegment
0.8.2
A framework for rendering seven segment LED displays using the TM1637, MAX7219, HT16K33, or 74HC595 controller chips
|
25 #ifndef ACE_SEGMENT_CLOCK_WRITER_H
26 #define ACE_SEGMENT_CLOCK_WRITER_H
29 #include "NumberWriter.h"
31 namespace ace_segment {
34 const uint8_t kPatternA = 0b01110111;
37 const uint8_t kPatternP = 0b01110011;
43 template <
typename T_LED_MODULE>
57 uint8_t colonDigit = 1
60 mColonDigit(colonDigit)
64 T_LED_MODULE&
ledModule() {
return mNumberWriter.ledModule(); }
68 return mNumberWriter.patternWriter();
76 mNumberWriter.writeHexCharAt(pos, c);
95 uint8_t high = (bcd & 0xF0) >> 4;
96 uint8_t low = (bcd & 0x0F);
97 if (high > 9) high = kHexCharSpace;
98 if (low > 9) low = kHexCharSpace;
111 uint8_t bcd = ace_common::decToBcd(d);
121 uint8_t high = dd / 100;
122 uint8_t low = dd - high * 100;
143 mNumberWriter.writeDecimalPointAt(mColonDigit, state);
147 void clear() { mNumberWriter.clear(); }
150 void clearToEnd(uint8_t pos) { mNumberWriter.clearToEnd(pos); }
158 uint8_t
const mColonDigit;
void writeDec4At(uint8_t pos, uint16_t dd)
Write the 4 digit decimal number at pos, right justified, padded with a '0' character.
void writeColon(bool state=true)
Write the colon symbol between 'hh' and 'mm'.
void writeCharAt(uint8_t pos, hexchar_t c)
Write the hexchar_t 'c' at 'pos'.
void writeHourMinute(uint8_t hh, uint8_t mm)
Write the hour and minutes, and the colon in one-shot, assuming the LED module is a 4-digit clock mod...
void clearToEnd(uint8_t pos)
Clear the display from pos to the end.
void writeDec2At(uint8_t pos, uint8_t d)
Write a 2-digit decimal number at position digit, right justified.
void writeBcd2At(uint8_t pos, uint8_t bcd)
Write a 2-digit BCD number at position, which involves just printing the number as a hexadecimal numb...
NumberWriter< T_LED_MODULE > & numberWriter()
Get the underlying NumberWriter.
void clear()
Clear the entire display.
The NumberWriter supports converting decimal and hexadecimal numbers to segment patterns expected by ...
PatternWriter< T_LED_MODULE > & patternWriter()
Get the underlying PatternWriter.
ClockWriter(T_LED_MODULE &ledModule, uint8_t colonDigit=1)
Constructor.
T_LED_MODULE & ledModule()
Get the underlying LedModule.
Write LED segment patterns to the underlying LedModule.
The ClockWriter writes "hh:mm" and "yyyy" to the LedModule.
void writeChars2At(uint8_t pos, hexchar_t c0, hexchar_t c1)
Write the 2 hexchar_t 'c0' and 'c1' at 'pos' and 'pos+1'.