AceSegment
0.4.0
An adjustable, configurable, and extensible framework for rendering seven segment LED displays.
|
Class that represents the abstraction of a particular LED display wiring, and knows how to turn off and turn on a specific group of LEDs with a specific pattern. More...
#include <LedMatrixBase.h>
Public Member Functions | |
LedMatrixBase (uint8_t groupOnPattern, uint8_t elementOnPattern) | |
void | begin () const |
Configure the pins for the given LED wiring. | |
void | end () const |
Turn off the pins by doing the opposite of begin(). | |
void | draw (uint8_t, uint8_t) const |
Write element patterns for the given group. | |
void | disableGroup (uint8_t) const |
Disable the elements of given group. | |
void | enableGroup (uint8_t) const |
Enable the elements of given group. | |
void | clear () const |
Clear everything. | |
Static Public Attributes | |
static constexpr uint8_t | kActiveHighPattern = 0xFF |
Bit pattern to indicate that logical 1 activates group or element. | |
static constexpr uint8_t | kActiveLowPattern = 0x00 |
Bit pattern to indicate that logical 0 activates group or element. | |
Protected Attributes | |
const uint8_t | mGroupXorMask |
const uint8_t | mElementXorMask |
Class that represents the abstraction of a particular LED display wiring, and knows how to turn off and turn on a specific group of LEDs with a specific pattern.
This class is conceptually stateless. The API exposes a class that does not remember the LED element patterns that is currently being displayed. (However, an implementation class may need to cache a small bit of information to implement this API abstraction.)
I have provided 3 wiring implementations:
If the resistors are on the segments, then the segments become the Elements and the digits become the Groups.
If the resistors are on the digits, then the digits become the Elements and the segments become the Groups. This configuration is not very useful and has not been tested very much.
The groupOnPattern and elementOnPattern is the bit pattern that activates the group or element. For example, a Common Cathode places the negative end of the LED on the group pin and the element pins are positive. So groupOnPattern should be kActiveLowPattern and elementOnPattern should be kActiveHighPattern. However, if a driver transitor is placed on the group pins to handle the higher current, then it inverts the logic on the group pins, so groupOnPattern must be set to kActiveHighPattern.
The groupOnPattern and elementPattern are compile-time constants so these parameters could be moved into the template parameters. When I did that, the flash size when down by only ~20 bytes on AVR, and ~40 bytes on an STM32. I decided to leave them as instance variables, because the decrease in readability of the code didn't seem worth 20 bytes.
Definition at line 72 of file LedMatrixBase.h.
|
inline |
groupOnPattern | bit pattern that turns on the groups |
elementOnPattern | bit pattern that turns on the elements on group |
Definition at line 85 of file LedMatrixBase.h.