AceSegment  0.12.0
A library for rendering seven segment LED displays using the TM1637, TM1638, MAX7219, HT16K33, or 74HC595 controller chips
Public Member Functions | Friends | List of all members
ace_segment::LedMatrixDualHc595< T_SPII > Class Template Reference

An LedMatrix that whose group pins are attached to one 74HC595 shift register and the element pins are attached to another 74HC595 shift register. More...

#include <LedMatrixDualHc595.h>

Inheritance diagram for ace_segment::LedMatrixDualHc595< T_SPII >:
Inheritance graph
[legend]
Collaboration diagram for ace_segment::LedMatrixDualHc595< T_SPII >:
Collaboration graph
[legend]

Public Member Functions

 LedMatrixDualHc595 (const T_SPII &spiInterface, uint8_t elementOnPattern, uint8_t groupOnPattern, uint8_t byteOrder, const uint8_t *remapArrayInverted=nullptr)
 Constructor. More...
 
void begin () const
 
void end () const
 
void draw (uint8_t group, uint8_t elementPattern) const
 Write out the group and element patterns in a single 16-bit stream. More...
 
void enableGroup (uint8_t group) const
 Turn on the given group, using the previous segment pattern. More...
 
void disableGroup (uint8_t group) const
 Turn off the given group. More...
 
void clear () const
 Clear the entire display.
 
- Public Member Functions inherited from ace_segment::LedMatrixBase
 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.
 

Friends

class ::LedMatrixDualHc595Test_draw
 
class ::LedMatrixDualHc595Test_enableGroup
 
class ::LedMatrixDualHc595Test_disableGroup
 

Additional Inherited Members

- Protected Attributes inherited from ace_segment::LedMatrixBase
const uint8_t mElementXorMask
 
const uint8_t mGroupXorMask
 

Detailed Description

template<typename T_SPII>
class ace_segment::LedMatrixDualHc595< T_SPII >

An LedMatrix that whose group pins are attached to one 74HC595 shift register and the element pins are attached to another 74HC595 shift register.

The 2 shift registers are daisy chained so that they can be accessed in a serial transfer of 16-bits using hardware or software SPI.

The group pins are assumed to be connected to the most significant byte. The element pins are connected to the least signficiant byte.

Template Parameters
T_SPIIclass that implements the SPI interface, usually one of the classes in the AceSPI library: SimpleSpiInterface, SimpleSpiFastInterface, HardSpiInterface, HardSpiFastInterface.

Definition at line 56 of file LedMatrixDualHc595.h.

Constructor & Destructor Documentation

◆ LedMatrixDualHc595()

template<typename T_SPII >
ace_segment::LedMatrixDualHc595< T_SPII >::LedMatrixDualHc595 ( const T_SPII &  spiInterface,
uint8_t  elementOnPattern,
uint8_t  groupOnPattern,
uint8_t  byteOrder,
const uint8_t *  remapArrayInverted = nullptr 
)
inline

Constructor.

Parameters
spiInterfaceobject that knows how to send SPI packets
elementOnPatternbit pattern that turns on the elements
groupOnpatternbit pattern that turns on the groups
byteOrderdetermine order of group and element bytes
remapArrayInverted(optional, nullable) a map of the physical positions to their logical positions, which is the inverse of the remapArray used by Tm1637Module and Max7219Module

Definition at line 68 of file LedMatrixDualHc595.h.

Member Function Documentation

◆ disableGroup()

template<typename T_SPII >
void ace_segment::LedMatrixDualHc595< T_SPII >::disableGroup ( uint8_t  group) const
inline

Turn off the given group.

Useful for blinking a group.

Definition at line 128 of file LedMatrixDualHc595.h.

◆ draw()

template<typename T_SPII >
void ace_segment::LedMatrixDualHc595< T_SPII >::draw ( uint8_t  group,
uint8_t  elementPattern 
) const
inline

Write out the group and element patterns in a single 16-bit stream.

The byteOrder parameter determines whether the group bits are in the high byte and element bits in the low byte, or flipped around.

The group is the desired physical location of elementPattern. We need to send that pattern to the logical position which will cause it to appear in the correct physical position. That turns out to be a mapping of the physical-to-logical address, which is the inverse of the remapping operation performed in Tm1637Module and Max7219Module. In those classes, we have random access to all the logical segment/element patterns. In this class, we are given just a single digit, but we don't have random access to the other digit patterns, so the remapArray must go the other way. The direction of the remapArray conversion is quite subtle, and it took me 2-3 attempts to get this right. In many (most?) cases, the remapArray and the remapArrayInverted are identical because the digit reordering is caused by pair-wise swapping of the LED modules pins to the controller chip pins. But in the general case, this class needs the inverted mapping.

Parameters
groupthe desired physical position of the elementPattern
elementPatternthe element (i.e. segment) pattern

Definition at line 109 of file LedMatrixDualHc595.h.

◆ enableGroup()

template<typename T_SPII >
void ace_segment::LedMatrixDualHc595< T_SPII >::enableGroup ( uint8_t  group) const
inline

Turn on the given group, using the previous segment pattern.

Useful for blinking a group (e.g. a digit of an LED segment module).

Definition at line 123 of file LedMatrixDualHc595.h.


The documentation for this class was generated from the following file: