AceSegment  0.7.0
A framework for rendering seven segment LED displays using the TM1637, MAX7219, HT16K33, or 74HC595 controller chips
Public Member Functions | Friends | List of all members
ace_segment::Ht16k33Module< T_WIREI, T_DIGITS > Class Template Reference

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

#include <Ht16k33Module.h>

Inheritance diagram for ace_segment::Ht16k33Module< T_WIREI, T_DIGITS >:
Inheritance graph
[legend]
Collaboration diagram for ace_segment::Ht16k33Module< T_WIREI, T_DIGITS >:
Collaboration graph
[legend]

Public Member Functions

 Ht16k33Module (T_WIREI &wire, bool enableColon=false)
 Constructor. More...
 
void begin ()
 
void end ()
 
void enableColon (bool enable)
 Set true to enable the colon segment on the module, which replaces the decimal point on digit 1 (second from left). More...
 
uint8_t getNumDigits () const
 Return the number of digits supported by this display instance.
 
void setPatternAt (uint8_t pos, uint8_t pattern) override
 Set the led digit pattern at position pos.
 
uint8_t getPatternAt (uint8_t pos) override
 Get the led digit pattern at position pos.
 
void setBrightness (uint8_t brightness) override
 Set global brightness of all digits. More...
 
void flush ()
 Send segment patterns of all digits. More...
 
- Public Member Functions inherited from ace_segment::LedModule
 LedModule (uint8_t numDigits)
 Constructor. More...
 
uint8_t getNumDigits () const
 Return the number of digits supported by this display instance. More...
 

Friends

class ::Ht16k33ModuleTest_patternForChipPos_colonDisabled
 
class ::Ht16k33ModuleTest_patternForChipPos_colonEnabled
 

Detailed Description

template<typename T_WIREI, uint8_t T_DIGITS>
class ace_segment::Ht16k33Module< T_WIREI, T_DIGITS >

An implementation of LedModule using the HT16K33 chip.

The chip uses I2C for communication.

This class is customized for the 4-digit LED module from Adafruit (https://www.adafruit.com/product/878) or one of its clones where the decimal point after digit 1 (second from left) and the colon between digits 1 and 2 can be controlled independently and turned on at the same time.

This class has the option of making the LED module behave like a normal 4-digit LED module (witout a colon), or a 4-digit LED clock module (with a colon). With the enableColon parameter set to false (default), the decimal point (bit 7) of digit 1 controls the decimal point to the right of digit 1. With enableColon set to true, the same bit controls the colon to the right of digit 1.

Although the hardware is capable of turning on the decimal point and colon at the same time, the AceSegment library does not support that mode. It does not seem like a combination that is useful. Fortunately, this class does allow the behavior of the colon segment to be changed at runtime using the enableColon() method. You can display the time of a clock (hh:mm), then display a normal number with a decimal point (xx.yy).

Template Parameters
T_WIREIthe class that wraps the I2C Wire interface, usually WireInterface
T_DIGITSnumber of logical digits in the module

Definition at line 65 of file Ht16k33Module.h.

Constructor & Destructor Documentation

◆ Ht16k33Module()

template<typename T_WIREI , uint8_t T_DIGITS>
ace_segment::Ht16k33Module< T_WIREI, T_DIGITS >::Ht16k33Module ( T_WIREI &  wire,
bool  enableColon = false 
)
inlineexplicit

Constructor.

Parameters
wireinstance of T_WIREI class
remapArray(optional, nullable) a mapping of the physical digit positions to their logical positions
enableColonenable the colon segment to behave like a 4-digit LED module for clocks (displaying a colon in hh:mm). The decimal point (bit 7) of digit 1 (second from left) becomes wired to the colon segment. (default: false)

Definition at line 77 of file Ht16k33Module.h.

Member Function Documentation

◆ enableColon()

template<typename T_WIREI , uint8_t T_DIGITS>
void ace_segment::Ht16k33Module< T_WIREI, T_DIGITS >::enableColon ( bool  enable)
inline

Set true to enable the colon segment on the module, which replaces the decimal point on digit 1 (second from left).

This has the same meaning as the enableColon parameter in the constructor.

You can enable the colon at runtime, just before the flush() method, to render a hh:mm clock display. Then you can call this method to disable the colon to enable the decimal point to render a xx.yy number.

Definition at line 108 of file Ht16k33Module.h.

◆ flush()

template<typename T_WIREI , uint8_t T_DIGITS>
void ace_segment::Ht16k33Module< T_WIREI, T_DIGITS >::flush ( )
inline

Send segment patterns of all digits.

Using the default 100kHz speed of Wire, this takes about 1.2 millis to send 4 digits.

On this particular LED module, the 4 logical LED digits are connected to 5 COM lines (COM0 to COM4), i.e. 5 physical digits. The mapping is:

  • digit 0 = COM0
  • digit 1 = COM1
  • colon = COM2 (bit 1)
  • digit 2 = COM3
  • digit 3 = COM4

Unlike some LED modules, it can display both the decimal point on digit 1 as well as the colon segment at the same time. However, various writers (e.g. ClockWriter) assumes that the most-significant-bit of digit 1 is connected to the colon. So if enableColon is set, make the logical mapping of that decimal point bit so the colon bit.

Definition at line 154 of file Ht16k33Module.h.

◆ setBrightness()

template<typename T_WIREI , uint8_t T_DIGITS>
void ace_segment::Ht16k33Module< T_WIREI, T_DIGITS >::setBrightness ( uint8_t  brightness)
inlineoverridevirtual

Set global brightness of all digits.

Different subclasses will interpret the brightness integer value differently.

Implements ace_segment::LedModule.

Definition at line 127 of file Ht16k33Module.h.


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