![]() |
Serial Wombat Arduino Library
|
A Class representing a TM1637 Seven-Segment Display connected to two Serial Wombat pins. More...
#include <SerialWombatTM1637.h>
Public Member Functions | |
SerialWombatTM1637 (SerialWombatChip &serialWombat) | |
Constructor for SerialWombatTM1637 class. More... | |
int16_t | begin (uint8_t clkPin, uint8_t dioPin, uint8_t digits, SWTM1637Mode mode, uint8_t dataSourcePin, uint8_t brightness0to7) |
Initialize an instance of the TM1637 class. More... | |
int16_t | writeDigitOrder (uint8_t first, uint8_t second, uint8_t third, uint8_t fourth, uint8_t fifth, uint8_t sixth) |
Used to reorder the digits of the display to match display hardware. More... | |
int16_t | writeArray (uint8_t data[6]) |
Used to send data to the data array of the driver. More... | |
int16_t | writeDecimalBitmap (uint8_t decimalBitmapLSBleftDigit) |
Set a bitmap of the MSB of each digit to control decimal points. More... | |
int16_t | writeBrightness (uint8_t brightness0to7) |
Changes the brightness of the display. More... | |
int16_t | writeAnimation (uint16_t bufferIndex, uint16_t delay, uint8_t numberOfFrames, uint8_t data[][6]) |
Loads an animation to the Serial Wombat user buffer area and initializes the animation. More... | |
int16_t | suppressLeadingZeros (bool suppress) |
Whether or not to suppress leading zeros in decimal mode. More... | |
int16_t | writeBlinkBitmap (uint8_t blinkBitmapLSBleftDigit) |
Set a bitmap of the digits that should blink at 2Hz with 7/8 duty cycle. More... | |
virtual size_t | write (uint8_t data) |
Write a byte to String mode, shifting other characters. More... | |
virtual size_t | write (const uint8_t *buffer, size_t size) |
virtual int | availableForWrite () |
![]() | |
SerialWombatPin (SerialWombatChip &serialWombatChip) | |
Instantiates a Serial Wombat Pin. More... | |
SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin) | |
Instantiates a Serial Wombat Pin. More... | |
uint16_t | readPublicData () |
Read the 16 Bit public data associated with this pin. More... | |
void | pinMode (uint8_t mode) |
Set pin to INPUT or OUTPUT. More... | |
void | pinMode (uint8_t mode, bool pullDown, bool openDrain) |
Set pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings. More... | |
void | digitalWrite (uint8_t val) |
Set output pin High or Low. More... | |
int | digitalRead () |
Reads the state of the Pin. More... | |
uint16_t | writePublicData (uint16_t value) |
Write a 16 bit value to this pin. More... | |
uint8_t | pin () |
Returns the current SW pin number. Used primarily for virtual calls by derived classes. More... | |
uint8_t | swPinModeNumber () |
Returns the Mode number. Used primarily by derived classes to populate packet data. More... | |
Additional Inherited Members | |
![]() | |
uint8_t | _pin = 255 |
SerialWombatChip & | _sw |
uint8_t | _pinMode = 0 |
A Class representing a TM1637 Seven-Segment Display connected to two Serial Wombat pins.
This class is only supported on the Serial Wombat SW18AB chip. It is not supported on the Serial Wombat 4X line.
This class controls a State Machine driven driver for a TM1637 Seven Segment LED Display.
Each instance of this class uses an average of approximately 5% of the SW18's processing time. This varies by configuration options and usage.
The Serial Wombat TM1637 driver can be configured in a number of ways:
See the available examples in the Arduino Library for usage.
A tutorial is available here:
/// ///
SerialWombatTM1637::SerialWombatTM1637 | ( | SerialWombatChip & | serialWombat | ) |
Constructor for SerialWombatTM1637 class.
serialWombat | SerialWombatChip on which the PWM will run |
|
inlinevirtual |
int16_t SerialWombatTM1637::begin | ( | uint8_t | clkPin, |
uint8_t | dioPin, | ||
uint8_t | digits, | ||
SWTM1637Mode | mode, | ||
uint8_t | dataSourcePin, | ||
uint8_t | brightness0to7 | ||
) |
Initialize an instance of the TM1637 class.
clkPin | The primary pin for this pin mode, the Serial Wombat pin connected to the clk pin of the TM1637 |
dioPin | The Serial Wombat pin connected to the DIO/data pin of the TM1637 |
digits | The number of digits in the display. This is used to optimze displays shorter than 6 digits |
mode | The mode (decimal, hex, char array, raw or animation) of the display driver |
dataSourcePin | if in decimal or hex mode, the pin from which the 16 bit data will be read. Set this to the clkPin setting if you want to be able to write 16 bit (5 digit) numbers using the SerialWombat.writePublicData() function. Numbers larger than 65535 must be written as strings using the Character Mode |
Brightness | - a value from 0 (dimmest) to 7 (brightest) based on the TM1637 hardware. This scale is not linear. |
int16_t SerialWombatTM1637::suppressLeadingZeros | ( | bool | suppress | ) |
Whether or not to suppress leading zeros in decimal mode.
supress | true: suppress leading zeros false: Do not suppress leading zeros |
|
virtual |
|
virtual |
Write a byte to String mode, shifting other characters.
This function allows the TM1637 mode to use Arduino Print statements.
data | Byte to be written to display |
int16_t SerialWombatTM1637::writeAnimation | ( | uint16_t | bufferIndex, |
uint16_t | delay, | ||
uint8_t | numberOfFrames, | ||
uint8_t | data[][6] | ||
) |
Loads an animation to the Serial Wombat user buffer area and initializes the animation.
The pin should have previously been initialized with the begin() command an animation mode prior to this call.
bufferIndex | The index into the User Buffer where the data for the animation should be stored |
delay | How long the animation display driver should wait between loading new data |
Number | of Frames to be displayed before returning to the first frame. This should be the number of lines in data |
data | A 2 dimensional array of width 6 and arbitrary length. |
int16_t SerialWombatTM1637::writeArray | ( | uint8_t | data[6] | ) |
Used to send data to the data array of the driver.
data | A 6 byte array that is sent to the display driver |
The meaning of this data varies based on mode. See examples.
int16_t SerialWombatTM1637::writeBlinkBitmap | ( | uint8_t | blinkBitmapLSBleftDigit | ) |
Set a bitmap of the digits that should blink at 2Hz with 7/8 duty cycle.
This function is useful for creating user interfaces where the user increments or decrements one digit of a number at a time. The blinking digit indicates the digit that will change.
blinkBitmap | A bitmap indicating if the decimal for each digit should be lit. LSB is first digit Valid values are 0 - 0x3F. 1 = blink |
int16_t SerialWombatTM1637::writeBrightness | ( | uint8_t | brightness0to7 | ) |
Changes the brightness of the display.
Brightness | - a value from 0 (dimmest) to 7 (brightest) based on the TM1637 hardware. This scale is not linear. |
int16_t SerialWombatTM1637::writeDecimalBitmap | ( | uint8_t | decimalBitmapLSBleftDigit | ) |
Set a bitmap of the MSB of each digit to control decimal points.
Note that TM1637 decimal point implementation varies greatly depending on the display manufacturer. Setting bits may or may not cause decimal points to display, the clock colon to display, or other undefined behavior. Unexpected behavior is likely the result of display pcb implementation, not an issue with this library or the Serial Wombat firmware.
decimalBitmapLSBleftDigit | A bitmap indicating if the decimal for each digit should be lit. LSB is first digit Valid values are 0 - 0x3F |
int16_t SerialWombatTM1637::writeDigitOrder | ( | uint8_t | first, |
uint8_t | second, | ||
uint8_t | third, | ||
uint8_t | fourth, | ||
uint8_t | fifth, | ||
uint8_t | sixth | ||
) |
Used to reorder the digits of the display to match display hardware.
TM1637 displays do not have a standardized wiring of LED module to the TM1637 driver pins. This can cause numbers to appear in the wrong order. This can be fixed by displaying the string "012345" on the display. If it appears out of order, then issue this command with the parameters matching what is displayed on the screen.
For instance, if a Six digit display showed 210543 when commanded to show "012345", calling
after begin() would cause the driver to reorder the output to make the display appear in the desired order.