python-tm1637 is a library for interfacing with TM1637-based 4-digit 7-segment LED display modules, using the Linux GPIO character device interface (gpiod).
Features
- Hardware-agnostic implementation using the modern Linux GPIO character device interface
- Automatic detection of the available GPIO chip device for the given clock and data GPIO lines
- Uses the official
libgpiodPython bindings:gpiod v2+ - Text display
- Scrolling text
- Hexadecimal display (0x0000 to 0xffff)
- Number display (-999 to 9999 or two -9 to 99)
- Temperature display (-9 to 99 with degree Celsius or -9.9 to 99.9 with degree)
- Support for decimal point displays through
TM1637Decimalclass
Installation
pip install python-tm1637
Getting Started
import time
import tm1637
# Initialize display connected to GPIO 23 & 24 at /dev/gpiochip4
display = tm1637.TM1637(clk=23, dio=24, chip_path="/dev/gpiochip4")
# Write segments directly
display.write([127, 127, 127, 127]) # 8888
time.sleep(1)
# Turn off all LEDs
display.write([0, 0, 0, 0])
time.sleep(1)
# Display text
display.show("HIYA")
time.sleep(1)
# Display a number
display.number(8888)
time.sleep(1)
API Reference
TM1637 Class
Constructor
TM1637(clk, dio, *, chip_path="/dev/gpiochip*", brightness=7)
clk: GPIO pin number for the clock linedio: GPIO pin number for the data I/O linebrightness: Initial brightness level (0-7, default: 7)chip_path: Path to the GPIO chip device (defaults to auto-detection)
Properties
brightness: Get or set the display brightnesschip_path: Get the path to GPIO chip device in useclk: Get the GPIO pin number of the clock line passed to constructordio: Get the GPIO pin number of the data I/O line passed to constructor
Methods
write(segments, pos=0): Write raw segmentsshow(string, sep=False, fill=" "): Display a stringscroll(string, delay=0.25): Scroll a string across the displayhex(val): Display a hexadecimal value (0x0000 to 0xffff)number(num, zero_pad=True): Display an integer value (-999 to 9999)numbers(num1, num2, sep=True, zero_pad=True): Display two integers values (-9 to 99)temperature(num): Display a temperature integer valuetemperature_decimal(num): Display a temperature decimal value
Static Methods
encode_char(char): Convert a character to its segment representationencode_digit(digit): Convert a digit to its segment representationencode_string(string): Convert a string to an array of segments
TM1637Decimal Class
Extends the TM1637 class to enable support for display modules having a decimal point after each digit.
Permissions
To access the GPIO chip device without root permissions, the user must be in the gpio group. To add the current user to the gpio group:
sudo usermod -aG gpio $USER
sudo reboot
Hardware Connections
| TM1637 | Pin |
|---|---|
| CLK | GPIO X |
| DIO | GPIO Y |
| VCC | 3.3V or 5V |
| GND | Ground |
where
TM1637(clk=X, dio=Y)
Examples
Clock Display
import time
import tm1637
display = tm1637.TM1637(clk=23, dio=24)
colon = True
while True:
time.sleep(1 - time.time()%1)
lt = time.localtime()
display.numbers(lt.tm_hour, lt.tm_min, sep=colon)
colon = not colon
Temperature Display
import tm1637
display = tm1637.TM1637(clk=23, dio=24)
display.temperature(23) # 23*C
display.temperature_decimal(23.5) # 23:5*
Scrolling Text
import tm1637
display = tm1637.TM1637(clk=23, dio=24)
display.scroll("HELLO WORLD", delay=0.1)
Sources
Metadata
Release files for python-tm1637 1.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| python_tm1637-1.1.5.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_tm1637-1.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 kB
Release files / python_tm1637-1.1.5.tar.gz
| Download URL | python_tm1637-1.1.5.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be42d4572da6d897188374306a31dde2865d5e93b6fabdaab94625c87d4f6ffc
|
|
BLAKE2b-256 checksum How to use checksums |
f7b4f8f71c2cfa9c77c65651e61f9d7f5d7e104c8c1a8fee0c0c7cbf9fe86206
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / python_tm1637-1.1.5-py3-none-any.whl
| Download URL | python_tm1637-1.1.5-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1433612702b6e7dc11a534e75ff6bff3ace60f47d7c531f99d35e2f67f284901
|
|
BLAKE2b-256 checksum How to use checksums |
c399eba4508706f5c0bedd4b3e6b6ef912896ee5d877377418758ffc2b06048e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for python-tm1637 1.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.