AceSegment
0.8.0
A framework for rendering seven segment LED displays using the TM1637, MAX7219, HT16K33, or 74HC595 controller chips
|
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 elementOnPattern, uint8_t groupOnPattern) | |
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. | |
Protected Attributes | |
const uint8_t | mElementXorMask |
const uint8_t | mGroupXorMask |
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:
In most cases, the resistors will be on the segments to control the current on each segment, so the segments become 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 elementOnPattern and groupOnPattern are the bit patterns that activate the element and group. For example, a Common Cathode LED module places the negative end of the LED on the group pin and the element pins are positive. So elementOnPattern should be kActiveHighPattern and groupOnPattern should be kActiveLowPattern. 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 elementPattern and groupOnPattern 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 79 of file LedMatrixBase.h.
|
inline |
elementOnPattern | bit pattern that turns on the elements on group |
groupOnPattern | bit pattern that turns on the groups |
Definition at line 86 of file LedMatrixBase.h.