Serial Wombat Arduino Library
SerialWombatTM1637.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 Copyright 2021 Broadwell Consulting Inc.
4 
5 Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11 
12 The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14 
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22 */
23 
24 #include <stdint.h>
25 #include "SerialWombat.h"
26 
33 };
34 
69 class SerialWombatTM1637:public Print, public SerialWombatPin
70 {
71 public:
74  SerialWombatTM1637(SerialWombatChip& serialWombat);
75 
85  int16_t begin(uint8_t clkPin, uint8_t dioPin, uint8_t digits, SWTM1637Mode mode, uint8_t dataSourcePin, uint8_t brightness0to7);
86 
87 
103  int16_t writeDigitOrder(uint8_t first, uint8_t second, uint8_t third, uint8_t fourth, uint8_t fifth, uint8_t sixth );
104 
111  int16_t writeArray(uint8_t data[6]);
122  int16_t writeDecimalBitmap(uint8_t decimalBitmapLSBleftDigit);
127  int16_t writeBrightness(uint8_t brightness0to7);
128 
139  int16_t writeAnimation(uint16_t bufferIndex, uint16_t delay, uint8_t numberOfFrames, uint8_t data[][6]);
140 
145  int16_t suppressLeadingZeros(bool suppress);
146 
155  int16_t writeBlinkBitmap(uint8_t blinkBitmapLSBleftDigit);
156 
164  virtual size_t write(uint8_t data);
165 
166  virtual size_t write(const uint8_t* buffer, size_t size);
167 
168  virtual int availableForWrite() { return 100; } // We will throw out everthing but the last 6.
169  using Print::write;
170 
171 private:
172 
173  uint8_t _dioPin = 255;
174 };
175 
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition: SerialWombat.h:267
SerialWombatTM1637::write
virtual size_t write(uint8_t data)
Write a byte to String mode, shifting other characters.
Definition: SerialWombatTM1637.cpp:180
SerialWombatTM1637::begin
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.
Definition: SerialWombatTM1637.cpp:30
tm1637RawArray
@ tm1637RawArray
Display raw LED segments sent by the host.
Definition: SerialWombatTM1637.h:31
SerialWombatTM1637::writeDecimalBitmap
int16_t writeDecimalBitmap(uint8_t decimalBitmapLSBleftDigit)
Set a bitmap of the MSB of each digit to control decimal points.
Definition: SerialWombatTM1637.cpp:107
tm1637Animation
@ tm1637Animation
Definition: SerialWombatTM1637.h:32
SerialWombatTM1637::writeArray
int16_t writeArray(uint8_t data[6])
Used to send data to the data array of the driver.
Definition: SerialWombatTM1637.cpp:77
SerialWombatTM1637::writeDigitOrder
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.
Definition: SerialWombatTM1637.cpp:47
SerialWombatTM1637::SerialWombatTM1637
SerialWombatTM1637(SerialWombatChip &serialWombat)
Constructor for SerialWombatTM1637 class.
Definition: SerialWombatTM1637.cpp:26
SerialWombatTM1637::writeAnimation
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.
Definition: SerialWombatTM1637.cpp:137
SerialWombatTM1637::writeBlinkBitmap
int16_t writeBlinkBitmap(uint8_t blinkBitmapLSBleftDigit)
Set a bitmap of the digits that should blink at 2Hz with 7/8 duty cycle.
Definition: SerialWombatTM1637.cpp:165
SerialWombat.h
SerialWombatTM1637::suppressLeadingZeros
int16_t suppressLeadingZeros(bool suppress)
Whether or not to suppress leading zeros in decimal mode.
Definition: SerialWombatTM1637.cpp:150
SerialWombatTM1637
A Class representing a TM1637 Seven-Segment Display connected to two Serial Wombat pins.
Definition: SerialWombatTM1637.h:69
tm1637CharArray
@ tm1637CharArray
Display a string sent by the host.
Definition: SerialWombatTM1637.h:30
SerialWombatPin
Describes a Serial Wombat Pin. Is base class for other pin modes.
Definition: SerialWombat.h:727
tm1637Decimal16
@ tm1637Decimal16
Get the number to display from a pin or data source and display in decimal.
Definition: SerialWombatTM1637.h:28
SerialWombatTM1637::writeBrightness
int16_t writeBrightness(uint8_t brightness0to7)
Changes the brightness of the display.
Definition: SerialWombatTM1637.cpp:122
SerialWombatTM1637::availableForWrite
virtual int availableForWrite()
Definition: SerialWombatTM1637.h:168
SWTM1637Mode
SWTM1637Mode
Definition: SerialWombatTM1637.h:27
tm1637Hex16
@ tm1637Hex16
Get the number to display from a pin or data source and display in hex.
Definition: SerialWombatTM1637.h:29