Serial Wombat Arduino Library

Loading...
Searching...
No Matches
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:
[legend]
Collaboration diagram for SerialWombatTM1637:
[legend]

## Public Member Functions
| SerialWombatTM1637 (SerialWombatChip &serialWombat)
| Constructor for SerialWombatTM1637 class.
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.
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.
| SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
| Instantiates a Serial Wombat Pin.
uint16_t | readPublicData ()
| Read the 16 Bit public data associated with this pin.
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.
void | digitalWrite (uint8_t val)
| Set output pin High or Low.
int | digitalRead ()
| Reads the state of the Pin.
uint16_t | writePublicData (uint16_t value)
| Write a 16 bit value to this pin.
uint8_t | pin ()
| Returns the current SW pin number. Used primarily for virtual calls by derived classes.
uint8_t | swPinModeNumber ()
| Returns the Mode number. Used primarily by derived classes to populate packet data.
int16_t | initPacketNoResponse (uint8_t packetNumber, uint8_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55, uint8_t param4=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0, uint16_t param1, uint8_t param2=0x55)
int16_t | disable ()
| Disables the pin mode (if applicable)
int16_t | enablePullup (bool enabled)
| Enables the weak pull up on a pin. Implemented on SW18AB and SW8B only.
int16_t | enablePulldown (bool enabled)
| Enables the weak pull down on a pin. Implemented on SW18AB and SW8B only.
int16_t | enableOpenDrain (bool enabled)
| Enables open drain mode on a pin. Implemented on SW18AB and SW8B only.
int16_t | forceDMA (bool enabled)
| Forces use of DMA instead of hardware timing resources on SW18AB.

## 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

Definition at line 74 of file SerialWombatTM1637.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatTM1637()

SerialWombatTM1637::SerialWombatTM1637 | ( | SerialWombatChip & | serialWombat | ) |
| inline

Constructor for SerialWombatTM1637 class.

Parameters

  serialWombat | SerialWombatChip on which the PWM will run

Definition at line 81 of file SerialWombatTM1637.h.

## Member Function Documentation

## ◆ availableForWrite()

virtual int SerialWombatTM1637::availableForWrite | ( |  | ) |
| inline virtual

Definition at line 390 of file SerialWombatTM1637.h.

## ◆ 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

  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.

Definition at line 96 of file SerialWombatTM1637.h.

## ◆ suppressLeadingZeros()

int16_t SerialWombatTM1637::suppressLeadingZeros | ( | bool | suppress | ) |
| inline

Definition at line 277 of file SerialWombatTM1637.h.

## ◆ write() [1/2]

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

Definition at line 349 of file SerialWombatTM1637.h.

## ◆ write() [2/2]

size_t SerialWombatTM1637::write | ( | uint8_t | data | ) |
| inline

Definition at line 327 of file SerialWombatTM1637.h.

## ◆ writeAnimation()

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

Definition at line 258 of file SerialWombatTM1637.h.

## ◆ writeArray()

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

Definition at line 168 of file SerialWombatTM1637.h.

## ◆ writeBlinkBitmap()

int16_t SerialWombatTM1637::writeBlinkBitmap | ( | uint8_t | blinkBitmapLSBleftDigit | ) |
| inline

Definition at line 302 of file SerialWombatTM1637.h.

## ◆ writeBrightness()

int16_t SerialWombatTM1637::writeBrightness | ( | uint8_t | brightness0to7 | ) |
| inline

Definition at line 231 of file SerialWombatTM1637.h.

## ◆ writeDecimalBitmap()

int16_t SerialWombatTM1637::writeDecimalBitmap | ( | uint8_t | decimalBitmapLSBleftDigit | ) |
| inline

Definition at line 210 of file SerialWombatTM1637.h.

## ◆ writeDigitOrder()

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

Definition at line 130 of file SerialWombatTM1637.h.