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::Tm1638AnodeModule< T_TMII, T_DIGITS > Class Template Reference

An implementation of LedModule using the TM1638 chip. More...

#include <Tm1638AnodeModule.h>

Inheritance diagram for ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >:
Inheritance graph
[legend]
Collaboration diagram for ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >:
Collaboration graph
[legend]

Public Member Functions

 Tm1638AnodeModule (const T_TMII &tmiInterface)
 Constructor. More...
 
void begin ()
 Initialize the module. More...
 
void end ()
 Signal end of usage. More...
 
void setDisplayOn (bool on=true)
 Turn off the entire display. More...
 
bool isFlushRequired () const
 Return true if flushing required.
 
void flush ()
 Send segment patterns of all digits plus the brightness to the display. More...
 
uint32_t readButtons () const
 Read the 4 bytes with key information. More...
 
- Public Member Functions inherited from ace_segment::LedModule
 LedModule (uint8_t *patterns, uint8_t numDigits)
 Constructor. More...
 
uint8_t getNumDigits () const
 Return the number of digits supported by this display instance.
 
void setPatternAt (uint8_t pos, uint8_t pattern)
 Set the led digit pattern at position pos.
 
uint8_t getPatternAt (uint8_t pos) const
 Get the led digit pattern at position pos.
 
void setBrightness (uint8_t brightness)
 Set global brightness of all digits. More...
 
uint8_t getBrightness () const
 Get the current brightness.
 

Friends

class ::Tm1638ModuleTest_flush
 

Additional Inherited Members

- Protected Member Functions inherited from ace_segment::LedModule
void begin ()
 Subclasses should call this from its own begin().
 
void end ()
 Subclasses should call this from its own end(). More...
 
void setDigitDirty (uint8_t pos)
 Set the dirty bit of digit pos.
 
void clearDigitDirty (uint8_t pos)
 Clear the dirty bit of digit pos.
 
bool isDigitDirty (uint8_t pos) const
 Check the dirty bit of digit pos.
 
void clearDigitsDirty ()
 Clear dirty bits of all digits.
 
bool isAnyDigitDirty () const
 Return true if any digits are dirty.
 
bool isBrightnessDirty () const
 Check if the brightness level is dirty.
 
void setBrightnessDirty ()
 Mark the brightness as dirty.
 
void clearBrightnessDirty ()
 Clear the dirty bit for brightness.
 

Detailed Description

template<typename T_TMII, uint8_t T_DIGITS>
class ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >

An implementation of LedModule using the TM1638 chip.

The chip communicates using a protocol that is electrically similar to SPI.

Template Parameters
T_TMIIclass that implements the three wire SPI-like protocol interface for TM1638, usually one of the classes from the AceTMI library: SimpleTmi1638Interface or SimpleTmi1638FastInterface.
T_DIGITSnumber of digits in the LED module (usually 8)

Definition at line 48 of file Tm1638AnodeModule.h.

Constructor & Destructor Documentation

◆ Tm1638AnodeModule()

template<typename T_TMII , uint8_t T_DIGITS>
ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >::Tm1638AnodeModule ( const T_TMII &  tmiInterface)
inlineexplicit

Constructor.

Parameters
tmiInterfaceinstance of TM1638 interface class
remapArray(optional, nullable) a mapping of the logical digit positions to their physical positions, useful for 8-digt LED modules whose digits are wired out of order

Definition at line 58 of file Tm1638AnodeModule.h.

Member Function Documentation

◆ begin()

template<typename T_TMII , uint8_t T_DIGITS>
void ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >::begin ( )
inline

Initialize the module.

The SimpleTmi1638Interface or SimpleTmi1638FastInterface object must be initialized separately.

Definition at line 73 of file Tm1638AnodeModule.h.

◆ end()

template<typename T_TMII , uint8_t T_DIGITS>
void ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >::end ( )
inline

Signal end of usage.

Currently does nothing.

Definition at line 81 of file Tm1638AnodeModule.h.

◆ flush()

template<typename T_TMII , uint8_t T_DIGITS>
void ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >::flush ( )
inline

Send segment patterns of all digits plus the brightness to the display.

Performance, for sending 8 digits (total of 1+1+16+1 = 19 bytes), using a 1 microsecond delay, on an SparkFun Pro Micro (AVR):

  • SimpleTm1638Interface, using digitalWrite()
    • flush() takes 2.6 ms
    • effective speed of 58 kbps
  • SimpleTm1638FastInterface, using digitalWriteFast()
    • flush() takes 0.3 ms
    • effective speed of 500 kbps

The isFlushRequired() method can be used to optimize the number of calls to flush(), but often it is not necessary.

Definition at line 123 of file Tm1638AnodeModule.h.

◆ readButtons()

template<typename T_TMII , uint8_t T_DIGITS>
uint32_t ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >::readButtons ( ) const
inline

Read the 4 bytes with key information.

Use little-endian ordering since the bits in each byte come out of the device in LSBFIRST order. In other words, first byte is the least signficant byte of the 32-bit result, and bit0 of the first byte is the first bit that streamed out of the device.

Definition at line 179 of file Tm1638AnodeModule.h.

◆ setDisplayOn()

template<typename T_TMII , uint8_t T_DIGITS>
void ace_segment::Tm1638AnodeModule< T_TMII, T_DIGITS >::setDisplayOn ( bool  on = true)
inline

Turn off the entire display.

The brightness is not affected so when it is turned back on, the previous brightness will be used.

Definition at line 93 of file Tm1638AnodeModule.h.


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