import tm1637
The tm1637 module drives common two-wire TM1637 LED display boards, usually 4-digit clock or counter displays. Use ``tm1637.Display(...)`` to create an independent display object. Each object owns one native display slot, so two or more TM1637 displays can run at the same time without channel bookkeeping.
Quick example
import tm1637
import system
counter = tm1637.Display(clk=18, dio=19)
clock = tm1637.Display(clk=22, dio=23, brightness=3)
counter.show_number(1234)
def tick():
clock.show_clock(12, 34, colon=True)
system.schedule("clock", 1000, 1000, -1, tick)
import tm1637
display = tm1637.Display(clk=18, dio=19, digits=4, brightness=3)
display.show_text("done")
display.set_brightness(7)
importtm1637
TM1637 7-segment display module.
The tm1637 module drives common two-wire TM1637 LED display boards, usually 4-digit clock or counter displays. Use ``tm1637.Display(...)`` to create an independent display object. Each object owns one native display slot, so two or more TM1637 displays can run at the same time without channel bookkeeping.
tm1637.Display(clk: int, dio: int, digits: any = None, brightness: int = None, delay_us: int = None) -> tm1637_display
tm1637.Display(clk: int, dio: int, digits: any = None, brightness: int = None, delay_us: int = None) -> tm1637_displayCreate an independent TM1637 display object.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
clk |
int |
positional or keyword | Yes | GPIO output pin connected to CLK. |
dio |
int |
positional or keyword | Yes | GPIO output pin connected to DIO. |
digits |
any |
positional or keyword | No | Optional number of display digits. Defaults to 4. Supported values are 1 through 6. |
brightness |
int |
positional or keyword | No | Optional brightness from 0 through 7. Defaults to 7. |
delay_us |
int |
positional or keyword | No | Optional bit-bang delay in microseconds. Defaults to 3. |
tm1637_display tm1637_display object.
tm1637.Display().show_number(value, colon=False, leading_zero=False) -> bool
tm1637.Display().show_number(value, colon=False, leading_zero=False) -> boolDisplay an integer.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
value |
any |
positional or keyword | Yes | Required value. |
colon |
bool |
positional or keyword | No | Optional value. Defaults to False. |
leading_zero |
bool |
positional or keyword | No | Optional value. Defaults to False. |
tm1637.Display().show_text(text, colon=False, position=0) -> bool
tm1637.Display().show_text(text, colon=False, position=0) -> boolDisplay simple 7-segment text.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
text |
str |
positional or keyword | Yes | Required value. |
colon |
bool |
positional or keyword | No | Optional value. Defaults to False. |
position |
int |
positional or keyword | No | Optional value. Defaults to 0. |
tm1637.Display().show_clock(hour, minute, colon=True, leading_zero=True) -> bool
tm1637.Display().show_clock(hour, minute, colon=True, leading_zero=True) -> boolDisplay HHMM time.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
hour |
any |
positional or keyword | Yes | Required value. |
minute |
any |
positional or keyword | Yes | Required value. |
colon |
bool |
positional or keyword | No | Optional value. Defaults to True. |
leading_zero |
bool |
positional or keyword | No | Optional value. Defaults to True. |
tm1637.Display().set_digit(position, value, dot=False) -> bool
tm1637.Display().set_digit(position, value, dot=False) -> boolSet one hex digit.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
position |
int |
positional or keyword | Yes | Required value. |
value |
any |
positional or keyword | Yes | Required value. |
dot |
bool |
positional or keyword | No | Optional value. Defaults to False. |
tm1637.Display().show_segments(segments, position=0) -> bool
tm1637.Display().show_segments(segments, position=0) -> boolWrite raw segment byte or bytes.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
segments |
any |
positional or keyword | Yes | Required value. |
position |
int |
positional or keyword | No | Optional value. Defaults to 0. |
tm1637.Display().set_brightness(value, enabled=True) -> bool
tm1637.Display().set_brightness(value, enabled=True) -> boolSet brightness and visibility.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
value |
any |
positional or keyword | Yes | Required value. |
enabled |
bool |
positional or keyword | No | Optional value. Defaults to True. |
tm1637.Display().clear() -> bool
tm1637.Display().clear() -> boolBlank this display.
tm1637.Display().info() -> dict
tm1637.Display().info() -> dictReturn this display's configuration.
tm1637.Display().close() -> bool
tm1637.Display().close() -> boolRelease this display slot and reset its pins.
tm1637.begin(clk: int, dio: int, digits: any = None, brightness: int = None, channel: int = None, delay_us: int = None) -> bool
tm1637.begin(clk: int, dio: int, digits: any = None, brightness: int = None, channel: int = None, delay_us: int = None) -> boolLegacy: initialize one module-level TM1637 display channel.
Prefer ``display = tm1637.Display(...)`` for new code. The legacy default API remains for older scripts that manage displays through ``channel``.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
clk |
int |
positional or keyword | Yes | GPIO output pin connected to CLK. |
dio |
int |
positional or keyword | Yes | GPIO output pin connected to DIO. |
digits |
any |
positional or keyword | No | Optional number of display digits. Defaults to 4. Supported values are 1 through 6. |
brightness |
int |
positional or keyword | No | Optional brightness from 0 through 7. Defaults to 7. |
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. Supported channels are 0 through 3. |
delay_us |
int |
positional or keyword | No | Optional bit-bang delay in microseconds. Defaults to 3. |
bool True when the GPIO pins are configured and the display accepts a frame.
tm1637.show_number(value: any, colon: bool = None, leading_zero: bool = None, channel: int = None) -> bool
tm1637.show_number(value: any, colon: bool = None, leading_zero: bool = None, channel: int = None) -> boolDisplay an integer.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
value |
any |
positional or keyword | Yes | Integer value to show. Long values are clipped from the left. |
colon |
bool |
positional or keyword | No | Optional colon/dot marker on the middle digit. Defaults to False. |
leading_zero |
bool |
positional or keyword | No | Optional zero padding. Defaults to False. |
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
bool True when the frame was transmitted.
tm1637.show_text(text: str, colon: bool = None, position: int = None, channel: int = None) -> bool
tm1637.show_text(text: str, colon: bool = None, position: int = None, channel: int = None) -> boolDisplay simple 7-segment text.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
text |
str |
positional or keyword | Yes | Text to display. Supported characters include digits, common 7-segment letters, dash, underscore, space, and decimal points. |
colon |
bool |
positional or keyword | No | Optional colon/dot marker on the middle digit. Defaults to False. |
position |
int |
positional or keyword | No | Optional starting digit. Defaults to 0. |
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
bool True when the frame was transmitted.
tm1637.show_clock(hour: any, minute: any, colon: bool = None, leading_zero: bool = None, channel: int = None) -> bool
tm1637.show_clock(hour: any, minute: any, colon: bool = None, leading_zero: bool = None, channel: int = None) -> boolDisplay hour and minute in HHMM form.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
hour |
any |
positional or keyword | Yes | Hour value. |
minute |
any |
positional or keyword | Yes | Minute value. |
colon |
bool |
positional or keyword | No | Optional colon marker. Defaults to True. |
leading_zero |
bool |
positional or keyword | No | Optional zero padding for the hour. Defaults to True. |
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
bool True when the clock frame was transmitted.
tm1637.set_digit(position: int, value: any, dot: bool = None, channel: int = None) -> bool
tm1637.set_digit(position: int, value: any, dot: bool = None, channel: int = None) -> boolSet one digit and write the display.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
position |
int |
positional or keyword | Yes | Zero-based digit position. |
value |
any |
positional or keyword | Yes | Hex digit value from 0 through 15. |
dot |
bool |
positional or keyword | No | Optional decimal point on this digit. Defaults to False. |
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
bool True when the frame was transmitted.
tm1637.show_segments(segments: list, position: int = None, channel: int = None) -> bool
tm1637.show_segments(segments: list, position: int = None, channel: int = None) -> boolWrite raw TM1637 segment bytes.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
segments |
list |
positional or keyword | Yes | One integer segment byte or a list of segment bytes. |
position |
int |
positional or keyword | No | Optional starting digit. Defaults to 0. |
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
bool True when at least one segment byte was written and transmitted.
tm1637.set_brightness(value: any, enabled: bool = None, channel: int = None) -> bool
tm1637.set_brightness(value: any, enabled: bool = None, channel: int = None) -> boolSet brightness and display enabled state.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
value |
any |
positional or keyword | Yes | Brightness from 0 through 7. |
enabled |
bool |
positional or keyword | No | Optional visible display state. Defaults to True. |
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
bool True when the brightness command was transmitted.
tm1637.clear(channel: int = None) -> bool
tm1637.clear(channel: int = None) -> boolBlank the display.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
bool True when the blank frame was transmitted.
tm1637.encode(value: any, dot: bool = None) -> int
tm1637.encode(value: any, dot: bool = None) -> intReturn a raw 7-segment byte for a character.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
value |
any |
positional or keyword | Yes | Character or digit to encode. |
dot |
bool |
positional or keyword | No | Optional decimal point bit. Defaults to False. |
int Integer segment byte.
tm1637.info(channel: int = None) -> dict
tm1637.info(channel: int = None) -> dictReturn display configuration.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
dict Dict with initialized, channel, clk, dio, digits, brightness, enabled, and delay_us fields.
tm1637.deinit(channel: int = None) -> bool
tm1637.deinit(channel: int = None) -> boolRelease a display channel and reset its pins.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
channel |
int |
positional or keyword | No | Optional display channel. Defaults to 0. |
bool True when an initialized display was released.