AceSegment
0.7.0
A framework for rendering seven segment LED displays using the TM1637, MAX7219, HT16K33, or 74HC595 controller chips
|
Class that knows how to communicate with a TM1637 chip. More...
#include <SoftTmiInterface.h>
Public Member Functions | |
SoftTmiInterface (uint8_t dioPin, uint8_t clkPin, uint8_t delayMicros) | |
Constructor. More... | |
void | begin () const |
Initialize the dio and clk pins. | |
void | end () const |
Set dio and clk pins to INPUT mode. | |
void | startCondition () const |
Generate the I2C start condition. | |
void | stopCondition () const |
Generate the I2C stop condition. | |
uint8_t | sendByte (uint8_t data) const |
Send the data byte on the data bus, with LSB first instead of the usual MSB first for I2C. More... | |
Class that knows how to communicate with a TM1637 chip.
It uses a 2-wire (Clock and a bidirectional DIO) protocol that is similar to I2C electrically. Both the Clock and Data pins are open-drain which means a single transitor on either the master or slave can pull the line LOW, but a pull-up resisotr is required to set the line HIGH. Because these are open-drain, we must make sure that the microcontroller does not actively drive these lines HIGH, otherwise, the output pin of the MCU at 5V (HIGH) becomes directly connected to the 0V (LOW) of the transistor on the device pulling it LOW, with no current limiting resistor. Either of MCU or the device can become damaged. To set the line HIGH or LOW, we set the output level to LOW, then use the pinMode() function to either INPUT (to get a HIGH value) or OUTPUT (to get a LOW value).
The logical protocol of the TM1637 is similar to I2C in the following ways:
The difference is:
Since the protocol does not match I2C, we cannot use the hardware I2C capabilities of the microcontroller, so we have to implement a software version of this protocol.
This class is stateless. It is thread-safe.
Definition at line 65 of file SoftTmiInterface.h.
|
inlineexplicit |
Constructor.
dioPin | pin attached to the LED module data line |
clkPin | pin attached to the LED module clock line |
delayMicros | delay after each bit transition (full cycle is 2 * delayMicros) |
Definition at line 74 of file SoftTmiInterface.h.
|
inline |
Send the data byte on the data bus, with LSB first instead of the usual MSB first for I2C.
Definition at line 127 of file SoftTmiInterface.h.