Serial Wombat Arduino Library
Public Member Functions | List of all members
SerialWombatTM1637 Class Reference

A Class representing a TM1637 Seven-Segment Display connected to two Serial Wombat pins. More...

#include <SerialWombatTM1637.h>

Inheritance diagram for SerialWombatTM1637:
SerialWombatPin

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)
 
int16_t writeArray (uint8_t data[6])
 
int16_t writeDecimalBitmap (uint8_t decimalBitmapLSBleftDigit)
 
int16_t writeBrightness (uint8_t brightness0to7)
 
int16_t writeAnimation (uint16_t bufferIndex, uint16_t delay, uint8_t numberOfFrames, uint8_t data[][6])
 
int16_t suppressLeadingZeros (bool suppress)
 
int16_t writeBlinkBitmap (uint8_t blinkBitmapLSBleftDigit)
 
size_t write (uint8_t data)
 
size_t write (const uint8_t *buffer, size_t size)
 
virtual int availableForWrite ()
 
- Public Member Functions inherited from SerialWombatPin
 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, bool pullDown=false, bool openDrain=false)
 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

- Protected Attributes inherited from SerialWombatPin
uint8_t _pin = 255
 
SerialWombatChip_sw
 
uint8_t _pinMode = 0
 

Detailed Description

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: The Display shows the current value in Hex or decimal of a Pin's public data (including values written to the pin used to control the display) The Display shows an array of characters (as best they can be shown on a seven segment display) commanded by the host The Display shows raw 7-segment bitmaps commanded by the host The Display shows an animation downloaded to the Serial Wombat chip by the host.

See the available examples in the Arduino Library for usage.

Warning
Different TM1637 displays behave differently based on how the manufacturer routed the LED matrix pins to the TM1637 outputs on the PCB. This can cause digits to be displayed in the wrong order, or cause decimal points or clock colons to malfunction. This is a display issue, not an issue with this library or the Serial Wombat firmware. Display order issues can be corrected with the orderDigits() command.

A tutorial is available here:

https://youtu.be/AwW12n6o_T0

Constructor & Destructor Documentation

◆ SerialWombatTM1637()

SerialWombatTM1637::SerialWombatTM1637 ( SerialWombatChip serialWombat)
inline

Constructor for SerialWombatTM1637 class.

Parameters
serialWombatSerialWombatChip on which the PWM will run

Member Function Documentation

◆ availableForWrite()

virtual int SerialWombatTM1637::availableForWrite ( )
inlinevirtual

◆ begin()

int16_t SerialWombatTM1637::begin ( uint8_t  clkPin,
uint8_t  dioPin,
uint8_t  digits,
SWTM1637Mode  mode,
uint8_t  dataSourcePin,
uint8_t  brightness0to7 
)
inline

Initialize an instance of the TM1637 class.

Returns
Returns a negative error code if initialization failed.
Parameters
clkPinThe primary pin for this pin mode, the Serial Wombat pin connected to the clk pin of the TM1637
dioPinThe Serial Wombat pin connected to the DIO/data pin of the TM1637
digitsThe number of digits in the display. This is used to optimze displays shorter than 6 digits
modeThe mode (decimal, hex, char array, raw or animation) of the display driver
dataSourcePinif 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.

◆ suppressLeadingZeros()

int16_t SerialWombatTM1637::suppressLeadingZeros ( bool  suppress)
inline

◆ write() [1/2]

size_t SerialWombatTM1637::write ( const uint8_t *  buffer,
size_t  size 
)
inline

◆ write() [2/2]

size_t SerialWombatTM1637::write ( uint8_t  data)
inline

◆ writeAnimation()

int16_t SerialWombatTM1637::writeAnimation ( uint16_t  bufferIndex,
uint16_t  delay,
uint8_t  numberOfFrames,
uint8_t  data[][6] 
)
inline

◆ writeArray()

int16_t SerialWombatTM1637::writeArray ( uint8_t  data[6])
inline

◆ writeBlinkBitmap()

int16_t SerialWombatTM1637::writeBlinkBitmap ( uint8_t  blinkBitmapLSBleftDigit)
inline

◆ writeBrightness()

int16_t SerialWombatTM1637::writeBrightness ( uint8_t  brightness0to7)
inline

◆ writeDecimalBitmap()

int16_t SerialWombatTM1637::writeDecimalBitmap ( uint8_t  decimalBitmapLSBleftDigit)
inline

◆ writeDigitOrder()

int16_t SerialWombatTM1637::writeDigitOrder ( uint8_t  first,
uint8_t  second,
uint8_t  third,
uint8_t  fourth,
uint8_t  fifth,
uint8_t  sixth 
)
inline