AceSegment
0.11.0
A library for rendering seven segment LED displays using the TM1637, TM1638, MAX7219, HT16K33, or 74HC595 controller chips
|
An implementation of LedModule using the HT16K33 chip. More...
#include <Ht16k33Module.h>
Public Member Functions | |
Ht16k33Module (T_WIREI &wireInterface, uint8_t addr, 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... | |
bool | isFlushRequired () const |
Return true if flushing required. | |
void | flush () |
Send segment patterns of all digits. More... | |
![]() | |
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 | ::Ht16k33ModuleTest_patternForChipPos_colonDisabled |
class | ::Ht16k33ModuleTest_patternForChipPos_colonEnabled |
Additional Inherited Members | |
![]() | |
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. | |
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.
Unfortunately, the AceSegment library does not support controlling both the decimal point and the colon at the same time. Instead, this class provides the option of enabling one or the other, 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.
The behavior of the colon segment to be changed at runtime as well 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
).
T_WIREI | the class that wraps the I2C Wire interface (one of TwoWireInterface, SimpleWireInterface of SimpleWireFastInterface) |
T_DIGITS | number of logical digits in the module. Currently this should always be set to 4 because it is designed to support the 4-digit LED modules found on Adafruit, Amazon or eBay. |
Definition at line 66 of file Ht16k33Module.h.
|
inlineexplicit |
Constructor.
wireInterface | instance of T_WIREI class |
addr | the 7-bit I2C addr |
enableColon | enable 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.
|
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 116 of file Ht16k33Module.h.
|
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:
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, map the decimal point bit to the colon bit.
The isFlushRequired() method can be used to optimize the number of calls to flush(), but often it is not necessary.
Definition at line 151 of file Ht16k33Module.h.