Robot 7-segment Display, v1.0.0
Posted on

The library for controlling a 7-segment display.
Major version. Implementing controlling one display.
Features
- possibilities:
- controlling one display;
- structures:
- the
Characterstructure represents a character and keeps a set of specific segments that should be active for displaying this character; - the
Displaystructure represents one display and keeps mapping between segments and pins to which they are connected.
- the
Examples
A one-display stopwatch:
#include <Character.h>
#include <Display.h>
#include <PinForSegment.h>
using namespace irenica_ideas::robot_7_segment_display;
constexpr auto ONE_DIGIT_DELAY_IN_MS = 1000;
const Character digits[] = {
Character(0x7e), // digit 0
Character(0x30), // digit 1
Character(0x6d), // digit 2
Character(0x79), // digit 3
Character(0x33), // digit 4
Character(0x5b), // digit 5
Character(0x5f), // digit 6
Character(0x70), // digit 7
Character(0x7f), // digit 8
Character(0x7b) // digit 9
};
// TODO: specify your own pin for every segment.
auto display = Display(
PinForSegment<'a'>{2},
PinForSegment<'b'>{3},
PinForSegment<'c'>{5},
PinForSegment<'d'>{7},
PinForSegment<'e'>{11},
PinForSegment<'f'>{13},
PinForSegment<'g'>{17},
PinForSegment<'p'>{19}
);
void setup() {
display.initialize();
}
void loop() {
for (const auto& digit: digits) {
digit.show(display);
delay(ONE_DIGIT_DELAY_IN_MS);
}
}