Skip to content

Commit 3af50e3

Browse files
committed
Add begin() to example in doc #29
1 parent 7052651 commit 3af50e3

File tree

1 file changed

+49
-36
lines changed

1 file changed

+49
-36
lines changed

README.md

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
# TM1637 Tiny Display #
1+
# TM1637 Tiny Display
2+
23
[![arduino-library-badge](https://www.ardu-badge.com/badge/TM1637TinyDisplay.svg?)](https://www.ardu-badge.com/TM1637TinyDisplay)
34
[![Build Status](https://github.com/jasonacox/TM1637TinyDisplay/actions/workflows/sketch.yml/badge.svg)](https://github.com/jasonacox/TM1637TinyDisplay/actions/workflows/sketch.yml)
45

56
Arduino Library for the TM1637 Based LED Display Module
67

78
## Description
9+
810
This is an Arduino library for 4 and 6 digit 7-segment LED display modules based on the TM1637 chip.
911
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.
1012

11-
## Hardware
13+
## Hardware
14+
1215
![TM1637](examples/tm1637.png)
1316

1417
* 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,8 +20,9 @@ Connect the TM1637 display CLK and DIO pins to your Arduino GPIO pins, include t
1720
![TM1637](examples/tm1637back.png)
1821

1922
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
2226
* VCC - Power 5v
2327
* GND - Ground
2428

@@ -27,39 +31,13 @@ Power Note: Steady clean power is important for circuit stability. If you are se
2731
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.
2832

2933
## Installation
34+
3035
This library is available via the Arduino IDE. Install this library via `Tools`, `Manage Libraries`, search for "TM1637TinyDisplay" and click `Install`.
3136

3237
Alternatively, you can install this manually by cloning this repo into your Arduino library folder (e.g. `~/Documents/Arduino/libraries`).
3338

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.
54-
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
59-
60-
61-
6239
## Example Code
40+
6341
```cpp
6442
#include <Arduino.h>
6543
#include <TM1637TinyDisplay.h>
@@ -68,11 +46,13 @@ PROGMEM functions: Large string or animation data can be left in Flash instead o
6846
#define CLK 1
6947
#define DIO 2
7048

71-
// Initialize TM1637TinyDisplay
49+
// Instantiate TM1637TinyDisplay Class
7250
TM1637TinyDisplay display(CLK, DIO);
7351

7452
void setup() {
75-
display.setBrightness(0x0f);
53+
// Initialize Display
54+
display.begin();
55+
display.setBrightness(BRIGHT_HIGH);
7656
}
7757

7858
void loop() {
@@ -111,9 +91,8 @@ void loop() {
11191
}
11292
```
11393
114-
Refer to [TM1637TinyDisplay.h](TM1637TinyDisplay.h) for information on available functions. See also [Examples](examples) for more demonstration.
115-
11694
## Animation and Animator Tool
95+
11796
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.
11897
11998
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:
@@ -164,6 +143,7 @@ TM1637TinyDisplay6 display(CLK, DIO); // 6-Digit Display Class
164143

165144
void setup()
166145
{
146+
display.begin();
167147
display.setBrightness(BRIGHT_HIGH);
168148
display.clear();
169149
display.showString("digits");
@@ -175,11 +155,44 @@ void setup()
175155
}
176156
```
177157
158+
## Functions
159+
160+
The library provides a single class named TM1637TinyDisplay with the following functions:
161+
162+
* `begin()` - Initialize display memory and hardware (call in `setup()`)
163+
* `clear()` - Display an integer and floating point numbers (positive or negative)
164+
* `showNumber(..)` - Display a number
165+
* `showNumberDec(..)` - Display a number with ability to manually set decimal points or colon
166+
* `showNumberHex(..)` - Display a number in hexadecimal format and set decimal point or colon
167+
* `showString(..)` - Display a ASCII string of text with optional scrolling for long strings
168+
* `startStringScroll(..)` - Begins a non-blocking scrolling of a string message
169+
* `showLevel(..)` - Use display LEDs to simulate a level indicator (vertical or horizontal)
170+
* `showAnimation(..)` - Display a sequence of frames to render an animation
171+
* `startAnimation(..)` - Begins a non-blocking animation of a sequence of frames
172+
* `Animate()` - Worker routine to be called regularly which handles animations and scrolling in a non-blocking manner
173+
* `setSegments(..)` - Directly set the value of the LED segments in each digit
174+
* `setBrightness(..)` - Sets the brightness of the display
175+
* `setScrolldelay(..)` - Sets the speed for text scrolling
176+
* `flipDisplay(..)` - Sets/flips the orientation of the display
177+
* `isflipDisplay()` - Returns orientation of the display (True = flip)
178+
* `readBuffer(..)` - Returns current display segment values
179+
180+
PROGMEM functions: Large string or animation data can be left in Flash instead of being loaded in to SRAM to save memory.
181+
182+
* `showAnimation_P(..)` - Display a sequence of frames to render an animation (in PROGMEM)
183+
* `showString_P(..)` - Display a ASCII string of text with optional scrolling for long strings (in PROGMEM)
184+
* `startAnimation_P(..)` - Begins a non-blocking animation of a sequence of frames stored in PROGMEM
185+
* `startStringScroll_P(..)` - Begins a non-blocking scrolling of a string message stored in PROGMEM
186+
187+
Refer to [TM1637TinyDisplay.h](TM1637TinyDisplay.h) for information on available functions. See also [Examples](examples) for more demonstration.
188+
178189
## Arduino Library
190+
179191
* Library: https://www.arduinolibraries.info/libraries/tm1637-tiny-display
180192
* Scan Logs: http://downloads.arduino.cc/libraries/logs/github.com/jasonacox/TM1637TinyDisplay/
181193
182194
## References and Credit
195+
183196
* This library is based on the great work by Avishay Orpaz - https://github.com/avishorp/TM1637
184197
* SevenSegmentTM1637 Arduino Library by Bram Harmsen - https://github.com/bremme/arduino-tm1637
185198
* Arduino - https://playground.arduino.cc/Main/TM1637/

0 commit comments

Comments
 (0)