segment-display
Arduino library to drive a multiplexed segment display
|
Driver for a multiplexed segment display. More...
#include <segment_display.h>
Public Member Functions | |
Driver (std::initializer_list< uint8_t > digit_pins, std::initializer_list< uint8_t > segment_pins) | |
Create a new driver instance using the given pins. More... | |
void | setDigits (std::initializer_list< uint8_t > digits) |
Change the digits to the given ones. More... | |
void | setDigit (size_t num, uint8_t digit) |
Change the digit at index num to the given one. More... | |
void | setSegments (size_t num, uint8_t segments) |
Change the digit at index num to the given segments. More... | |
void | refresh (unsigned int light_time=0) |
Refresh on the display. More... | |
Static Public Attributes | |
static const size_t | EMPTY = 16 |
Turn all segments off. | |
static const size_t | DASH = 17 |
Only enable the segment in the middle (G ). | |
Driver for a multiplexed segment display.
NUM_DIGITS | Specifies the number of digits of the segment display. |
Definition at line 52 of file segment_display.h.
|
inline |
Create a new driver instance using the given pins.
digit_pins | Exactly NUM_DIGITS pins to use for the led cathodes of each digit. |
segment_pins | 7 or 8 pins to use for the segments (a to g/h). |
Definition at line 64 of file segment_display.h.
|
inline |
Refresh on the display.
Turns on the needed segments of all digits for a short amount of time. This must be called repeatedly in your main loops to trick the human brain into believing the display is constantly lit.
light_time | The amount of time each segment is lit up. The default of 0 is sufficient for most cases. |
Definition at line 126 of file segment_display.h.
|
inline |
Change the digit at index num to the given one.
All digits passed through the seven segment decoder, so you can pass decimal digits and the constants defined in this class.
num | The index of the digit to change |
digit | The new digit |
Definition at line 101 of file segment_display.h.
|
inline |
Change the digits to the given ones.
digits | A list of exactly NUM_DIGITS digits. |
Definition at line 87 of file segment_display.h.
|
inline |
Change the digit at index num to the given segments.
This functions bypasses the decimal decoder, so every segment can be enabled independently.
num | The index of the digit to change. |
segments | The new segments, where the LSB is segment a. |
Definition at line 113 of file segment_display.h.