You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arduino Library for the TM1637 Based LED Display Module
6
7
7
8
## Description
9
+
8
10
This is an Arduino library for 4 and 6 digit 7-segment LED display modules based on the TM1637 chip.
9
-
Connect the TM1637 display CLK and DIO pins to your Arduino GPIO pins, include this library, initialize TM1637TinyDisplay and call easy to use functions like showNumber(), showString(), showLevel() and showAnimation(). Display will scroll text for larger strings. Functions support screen splitting for easy number + text formatting. Library also runs well on tiny controllers including the ATtiny85.
11
+
Connect the TM1637 display CLK and DIO pins to your Arduino GPIO pins, include this library, initialize TM1637TinyDisplay and call easy to use functions like `showNumber()`, `showString()`, `showLevel()` and `showAnimation()`. Display will scroll text for larger strings. Functions support screen splitting for easy number + text formatting. Library also runs well on tiny controllers including the ATtiny85.
12
+
13
+
## Hardware
10
14
11
-
## Hardware
12
15

13
16
14
17
* 4-Digit Display modules based on the TM1637 chip are available from [HiLetgo](https://www.amazon.com/gp/product/B01DKISMXK/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1), [DX](https://dx.com/p/0-36-led-4-digit-display-module-for-arduino-black-blue-works-with-official-arduino-boards-254978) and [SeeedStudio](https://www.digikey.com/products/en?keywords=tm1637).
@@ -17,62 +20,43 @@ Connect the TM1637 display CLK and DIO pins to your Arduino GPIO pins, include t
17
20

18
21
19
22
The display has four connectors:
20
-
* CLK - Clock - attach to any GPIO output
21
-
* DIO - Data - attach to any GPIO output
23
+
24
+
* CLK - Clock - attach to any GPIO output
25
+
* DIO - Data - attach to any GPIO output
22
26
* VCC - Power 5v
23
27
* GND - Ground
24
28
25
-
Power Note: Steady clean power is important for circuit stability. If you are seeing display artifacts during high frequency updates or animation sequences, you may be experiencing power fluctuations that are impacting signal timing and communication with the TM1637. This is especially true with standalone microprocessor applications that lack any power conditioning (e.g. ATtiny85). A polarized 100uF electrolytic capacitor inserted across VCC and GND can help smooth out the spikes.
29
+
**Power Note:** Steady clean power is important for circuit stability. If you are seeing display artifacts during high frequency updates or animation sequences, you may be experiencing power fluctuations that are impacting signal timing and communication with the TM1637. This is especially true with standalone microprocessor applications that lack any power conditioning (e.g. ATtiny85). A polarized 100uF electrolytic capacitor inserted across VCC and GND can help smooth out the spikes.
26
30
27
-
Decimals and Colons: Some TM1637 displays come equipped with a middle colon LED (as shown above) as used in digital clocks but with no decimal points. Some displays come with decimal point LEDS for each digit. Some come with both but often the decimal point LEDs are not connected. These extra LEDs are activated by setting the upper bit (0x80) for the digit next to the dot. This library will handle setting that for you via the showNumber() function when you specify floating point numbers or via the showNumberDec() function where you can set the decimal point manually.
31
+
**Decimals and Colons:** Some TM1637 displays come equipped with a middle colon LED (like above) as used in digital clocks but with no decimal points. Some displays come with decimal point LEDS for each digit. Some come with both but often the decimal point LEDs are not connected. These extra LEDs are activated by setting the upper eighth bit (0x80) for the digit to the left of the dot. This library will handle setting that for you via the `showNumber()` function when you specify floating point numbers, or you can do it manually via the `showNumberDec()` function where you can set the decimal points/colon yourself.
28
32
29
33
## Installation
30
-
This library is available via the Arduino IDE. Install this library via `Tools`, `Manage Libraries`, search for "TM1637TinyDisplay" and click `Install`.
31
-
32
-
Alternatively, you can install this manually by cloning this repo into your Arduino library folder (e.g. `~/Documents/Arduino/libraries`).
33
34
34
-
## Usage
35
-
The library provides a single class named TM1637TinyDisplay with the following functions:
36
-
37
-
*`showNumber` - Display an integer and floating point numbers (positive or negative)
38
-
*`showNumberDec` - Display a number with ability to manually set decimal points or colon
39
-
*`showNumberHex` - Display a number in hexadecimal format and set decimal point or colon
40
-
*`showString` - Display a ASCII string of text with optional scrolling for long strings
41
-
*`showLevel` - Use display LEDs to simulate a level indicator (vertical or horizontal)
42
-
*`showAnimation` - Display a sequence of frames to render an animation
43
-
*`startAnimation` - Begins a non-blocking animation of a sequence of frames
44
-
*`startStringScroll` - Begins a non-blocking scrolling of a string message
45
-
*`Animate` - Worker routine to be called regularly which handles animations and scrolling in a non-blocking manner
46
-
*`setSegments` - Directly set the value of the LED segments in each digit
47
-
*`setBrightness` - Sets the brightness of the display
48
-
*`setScrolldelay` - Sets the speed for text scrolling
49
-
*`flipDisplay` - Sets/flips the orientation of the display
50
-
*`isflipDisplay` - Returns orientation of the display (True = flip)
51
-
*`readBuffer` - Returns current display segment values
52
-
53
-
PROGMEM functions: Large string or animation data can be left in Flash instead of being loaded in to SRAM to save memory.
35
+
This library is available via the Arduino IDE. Install this library via `Tools`, `Manage Libraries`, search for "TM1637TinyDisplay" and click `Install`.
54
36
55
-
*`showAnimation_P` - Display a sequence of frames to render an animation (in PROGMEM)
56
-
*`showString_P` - Display a ASCII string of text with optional scrolling for long strings (in PROGMEM)
57
-
*`startAnimation_P` - Begins a non-blocking animation of a sequence of frames stored in PROGMEM
58
-
*`startStringScroll_P` - Begins a non-blocking scrolling of a string message stored in PROGMEM
37
+
Alternatively, you can install this manually by cloning this repo into your Arduino library folder (e.g. `~/Documents/Arduino/libraries`).
Basic connection schematic done with <ahref="https://fritzing.org">Fritzing</a>
44
+
</p>
61
45
62
-
## Example Code
63
46
```cpp
64
47
#include<Arduino.h>
65
48
#include<TM1637TinyDisplay.h>
66
49
67
50
// Define Digital Pins
68
-
#defineCLK1
69
-
#define DIO 2
51
+
#defineCLK2
52
+
#define DIO 3
70
53
71
-
//Initialize TM1637TinyDisplay
54
+
//Instantiate TM1637TinyDisplay Class
72
55
TM1637TinyDisplay display(CLK, DIO);
73
56
74
57
void setup() {
75
-
display.setBrightness(0x0f);
58
+
// Initialize Display
59
+
display.begin();
76
60
}
77
61
78
62
void loop() {
@@ -111,12 +95,11 @@ void loop() {
111
95
}
112
96
```
113
97
114
-
Refer to [TM1637TinyDisplay.h](TM1637TinyDisplay.h) for information on available functions. See also [Examples](examples) for more demonstration.
115
-
116
98
## Animation and Animator Tool
117
-
The showAnimation() function projects a sequence of frames (patterns) onto the display. This works by defining the animation sequence through a multi-dimensional array of patterns.
118
99
119
-
You can use the included javascript based interactive [7-Segment LED Animator Tool](https://jasonacox.github.io/TM1637TinyDisplay/examples/7-segment-animator.html) to help build your animation. The source code is in the [Examples](examples) folder. This tool will let you set up the LED sequences you want, save each frame and copy the final code (a static array) directly into your sketch to use for the `showAnimation(data, frames, timing)` function. Here is an example:
100
+
The `showAnimation()` function projects a sequence of frames (patterns) onto the display. This works by defining the animation sequence through a multi-dimensional array of patterns.
101
+
102
+
You can use the included javascript based interactive [7-Segment LED Animator Tool](https://jasonacox.github.io/TM1637TinyDisplay/examples/7-segment-animator.html) to help build your animation. The source code is in the [Examples](examples) folder. This tool will let you set up the LED sequences you want, save each frame and copy the final code (a static array) directly into your sketch to use for the `showAnimation(data, frames, timing)` function. Here is an example:
This library now supports the 6-digit display as well as the 4-digit display. The 6-digit display requires additional handling. Specifically, the display digits are not sequential (requires a map) and the 7-segment LED data must be uploaded in reverse order.
133
+
This library now supports the 6-digit display as well as the 4-digit display. The 6-digit display requires additional handling. Specifically, the display digits are not sequential (requires a map) and the 7-segment LED data must be uploaded in reverse order.
151
134
152
135
TM1637TinyDisplay6 handles this for you but you must initialize the display using the TM1637TinyDisplay6 class:
153
136
@@ -157,15 +140,14 @@ TM1637TinyDisplay6 handles this for you but you must initialize the display usin
157
140
#include<TM1637TinyDisplay6.h>// Include 6-Digit Display Class Header
158
141
159
142
// Define Digital Pins
160
-
#defineCLK1
161
-
#define DIO 2
143
+
#defineCLK2
144
+
#define DIO 3
162
145
163
146
TM1637TinyDisplay6 display(CLK, DIO); // 6-Digit Display Class
164
147
165
148
void setup()
166
149
{
167
-
display.setBrightness(BRIGHT_HIGH);
168
-
display.clear();
150
+
display.begin();
169
151
display.showString("digits");
170
152
delay(1000);
171
153
display.showNumber(123456);
@@ -175,13 +157,46 @@ void setup()
175
157
}
176
158
```
177
159
160
+
## Functions
161
+
162
+
The library provides a single class named TM1637TinyDisplay with the following functions:
163
+
164
+
* `begin()` - Initialize display memory and hardware (call in `setup()`)
165
+
* `clear()` - Display an integer and floating point numbers (positive or negative)
166
+
* `showNumber(..)` - Display a number
167
+
* `showNumberDec(..)` - Display a number with ability to manually set decimal points or colon
168
+
* `showNumberHex(..)` - Display a number in hexadecimal format and set decimal point or colon
169
+
* `showString(..)` - Display a ASCII string of text with optional scrolling for long strings
170
+
* `startStringScroll(..)` - Begins a non-blocking scrolling of a string message
171
+
* `showLevel(..)` - Use display LEDs to simulate a level indicator (vertical or horizontal)
172
+
* `showAnimation(..)` - Display a sequence of frames to render an animation
173
+
* `startAnimation(..)` - Begins a non-blocking animation of a sequence of frames
174
+
* `Animate()` - Worker routine to be called regularly which handles animations and scrolling in a non-blocking manner
175
+
* `setSegments(..)` - Directly set the value of the LED segments in each digit
176
+
* `setBrightness(..)` - Sets the brightness of the display
177
+
* `setScrolldelay(..)` - Sets the speed for text scrolling
178
+
* `flipDisplay(..)` - Sets/flips the orientation of the display
179
+
* `isflipDisplay()` - Returns orientation of the display (True = flip)
180
+
* `readBuffer(..)` - Returns current display segment values
181
+
182
+
PROGMEM functions: Large string or animation data can be left in Flash instead of being loaded in to SRAM to save memory.
183
+
184
+
* `showAnimation_P(..)` - Display a sequence of frames to render an animation (in PROGMEM)
185
+
* `showString_P(..)` - Display a ASCII string of text with optional scrolling for long strings (in PROGMEM)
186
+
* `startAnimation_P(..)` - Begins a non-blocking animation of a sequence of frames stored in PROGMEM
187
+
* `startStringScroll_P(..)` - Begins a non-blocking scrolling of a string message stored in PROGMEM
188
+
189
+
Refer to [TM1637TinyDisplay.h](TM1637TinyDisplay.h) for information on available functions. See also [Examples](examples) for more demonstration.
* MCI Electronics Datasheet for TM1637 - https://www.mcielectronics.cl/website_MCI/static/documents/Datasheet_TM1637.pdf
187
-
* TM16xx - Library for entire TM16xx chip family include maxint-rd's own [display-modules](https://github.com/maxint-rd/arduino-modules#display-modules) - https://github.com/maxint-rd/TM16xx
202
+
* TM16xx - Library for entire TM16xx chip family include maxint-rd's own [display-modules](https://github.com/maxint-rd/arduino-modules#display-modules) - https://github.com/maxint-rd/TM16xx
Copy file name to clipboardExpand all lines: RELEASE.md
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,18 @@
1
1
# Release Notes for TM1637TinyDisplay
2
2
3
+
## v1.8.1 - Add Default Brightness
4
+
5
+
* Updated the `begin()` method to set a non zero default brightness for the display, as reported in https://github.com/jasonacox/TM1637TinyDisplay/pull/29#issuecomment-1446362105 and submitted by @mgesteiro in https://github.com/jasonacox/TM1637TinyDisplay/pull/30
6
+
7
+
## v1.8.0 - Updated Library Operation with New begin() Method
8
+
9
+
* Updated library operation to include an initializing method `begin()` to move outside the constructor hardware related calls, as reported in https://github.com/jasonacox/TM1637TinyDisplay/issues/28
10
+
11
+
## v1.7.1 - Fix Compile Errors for ESP8266
12
+
13
+
* Fix compile errors and warnings on ESP8266 cores (type casts and erroneous defaults in functions) as reported in https://github.com/jasonacox/TM1637TinyDisplay/issues/26
14
+
* Fix function names for async animation/scroll in keywords.txt by @hackerceo in https://github.com/jasonacox/TM1637TinyDisplay/pull/25
15
+
3
16
## v1.7.0 - Add Non-Blocking Animation for 4-Digit
4
17
5
18
* Add non-blocking animation and string scrolling to 4-digit display by @hackerceo in https://github.com/jasonacox/TM1637TinyDisplay/pull/24
0 commit comments