• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MicroPython driver for TM1637 quad 7-segment LED modules

MicroPython TM1637

A MicroPython library for quad 7-segment LED display modules using the TM1637 LED driver.

For example, the Grove - 4 Digit Display module

demo

Examples

Copy the file to your device, using ampy, webrepl or compiling and deploying. eg.

$ ampy put tm1637.py

Basic usage

import tm1637
from machine import Pin
tm = tm1637.TM1637(clk=Pin(5), dio=Pin(4))

# all LEDS on "88:88"
tm.write([127, 255, 127, 127])

# all LEDS off
tm.write([0, 0, 0, 0])

# show "0123"
tm.write([63, 6, 91, 79])

# show "COOL"
tm.write([0b00111001, 0b00111111, 0b00111111, 0b00111000])

# show "HELP"
tm.show('help')

# display "dEAd", "bEEF"
tm.hex(0xdead)
tm.hex(0xbeef)

# show "12:59"
tm.numbers(12, 59)

# show "-123"
tm.number(-123)

# show temperature '24*C'
tm.temperature(24)

For more detailed examples, see tm1637_test.py

Seven Segment Font

They are called 7-segment displays as there are 7 LEDs for each digit (segment). One byte (7 lower bits) for each segment. The 8th bit (MSB) is for the colon and only on the 2nd segment.

      A
     ---
  F |   | B   *
     -G-      H (on 2nd segment)
  E |   | C   *
     ---
      D

  HGFEDCBA
0b01101101 = 0x6D = 109 = show "5"
Display Bin Hex Dec
0 0b00111111 0x3F 63
1 0b00000110 0x06 6
2 0b01011011 0x5B 91
3 0b01001111 0x4F 79
4 0b01100110 0x66 102
5 0b01101101 0x6D 109
6 0b01111101 0x7D 125
7 0b00000111 0x07 7
8 0b01111111 0x7F 127
9 0b01101111 0x6F 111
A 0b01110111 0x77 119
b 0b01111100 0x7C 124
C 0b00111001 0x39 57
d 0b01011110 0x5E 94
E 0b01111001 0x79 121
F 0b01110001 0x71 113
G 0b00111101 0x3D 61
H 0b01110110 0x76 118
I 0b00000110 0x06 6
J 0b00011110 0x1E 30
K 0b01110110 0x76 118
L 0b00111000 0x38 56
M 0b01010101 0x55 85
n 0b01010100 0x54 84
O 0b00111111 0x3F 63
P 0b01110011 0x73 115
q 0b01100111 0x67 103
r 0b01010000 0x50 80
S 0b01101101 0x6D 109
t 0b01111000 0x78 120
U 0b00111110 0x3E 62
v 0b00011100 0x1C 28
W 0b00101010 0x2A 42
X 0b01110110 0x76 118
y 0b01101110 0x6E 110
Z 0b01011011 0x5B 91
blank 0b00000000 0x00 0
- 0b01000000 0x40 64
* 0b01100011 0x63 99

Methods

Get or set brightness.

brightness(val=None)

Write one or more segments at a given offset.

write(segments, pos=0)

Convert a single hex digit (0x00-0x0f) to a segment.

encode_digit(digit)

Convert a string to a list of segments.

encode_string(string)

Convert a single character to a segment.

encode_char(char)

Display a number in hexadecimal format 0000 through FFFF.

hex(val)

Display a number -999 through 9999, right aligned.

number(num)

Display 2 independent numbers on either side of the (optional) colon, with leading zeros.

numbers(num1, num2, colon=True)

Display a temperature -9 through 99 followed by degrees C.

temperature(num)

Show a string on the display. Shorthand for write(encode_string()). Limited to first 4 characters.

show(string, colon=False)

Display a string on the display, scrolling from the right to left, speed adjustable. String starts off-screen and scrolls until off-screen at 4 FPS by default.

scroll(string, delay=250)

Parts

Connections

WeMos D1 Mini 4 Digit Display
D1 (GPIO5) CLK
D2 (GPIO4) DIO
3V3 (or 5V) VCC
G GND

Links

License

Licensed under the MIT License.

More Repositories

1

awesome-micropython

A curated list of awesome MicroPython libraries, frameworks, software and resources.
HTML
913
star
2

micropython-waveshare-epaper

MicroPython drivers for Waveshare e-paper modules
Python
253
star
3

micropython-max7219

MicroPython driver for MAX7219 8x8 LED matrix modules, cascadable and with framebuf
Python
146
star
4

WEACT_F411CEU6

MicroPython board definition for the WeAct STM32F411CEU6 board
C
108
star
5

BLACK_F407VE

MicroPython board definition for the MCUDev Black STM32F407VET6 board
C
100
star
6

Fritzing-Part-WeMos-D1-Mini

Fritzing Part: WeMos D1 Mini
Shell
77
star
7

micropython-tinyrtc-i2c

MicroPython driver for TinyRTC I2C modules with DS1307 RTC and AT24C32N EEPROM
Python
59
star
8

micropython-pcd8544

MicroPython driver for Nokia 5110 PCD8544 84x48 LCD modules
Python
55
star
9

MCUDEV_DEVEBOX_F407VGT6

MicroPython board definition for the MCUDev DevEBox STM32F407VGT6 board
C
53
star
10

MCUDEV_DEVEBOX_H7XX_M

MicroPython board definition for the MCUDev DevEBox STM32H7XX_M boards
C
52
star
11

MicroPython-ESP8266-DHT-Nokia-5110

MicroPython example using a DHT12, AM2320 and a Nokia 5110 with an ESP8266
Python
43
star
12

BLUE_PILL_F103C8

MicroPython board definition for the Blue Pill STM32F103C8T6 board
C
41
star
13

micropython-mcp23017

MicroPython driver for MCP23017 16-bit I/O Expander
Python
39
star
14

Fritzing-Part-WeMos-D1-mini-Shields

Fritzing Part: WeMos D1 Mini Shields
Shell
34
star
15

MicroPython-ESP8266-Nokia-5110-Conways-Game-of-Life

Conway's Game of Life on a Nokia 5110 with WeMos D1 mini running MicroPython ESP8266
Python
29
star
16

YX8018-solar-led-driver

YX8018 LED driver in Bunnings Lytworx solar garden LED lights
29
star
17

micropython-mlx90614

MicroPython driver for the MLX90614 IR temperature sensor
Python
27
star
18

BLACK_F407ZE

MicroPython board definition for the MCUDev Black STM32F407ZET6 board
C
26
star
19

i2cdetect

Arduino library for scanning I2C bus for devices
C++
24
star
20

micropython-pcf8574

MicroPython driver for PCF8574 8-Bit I2C I/O Expander with Interrupt
Python
24
star
21

BLACK_F407ZG

MicroPython board definition for the MCUDev Black STM32F407ZGT6 board
C
24
star
22

WeMos-D1-mini-Nokia-5110-PCD8544

Arduino examples
24
star
23

micropython-ssd1327

MicroPython driver for SSD1327 128x128 4-bit greyscale OLED displays
Python
23
star
24

micropython-am2320

MicroPython driver for the Aosong AM2320 temperature and humidity sensor
Python
23
star
25

ESP8266-WiFi-Signal-Strength-Graph-Nokia-5110

Arduino
23
star
26

micropython-tm1638

MicroPython driver for TM1638 dual quad 7-segment LED modules with switches
Python
22
star
27

Raspberry-Pi-ITead-Studio-GPS-NEO-6M

Experiments with my ITead Studio RPI GPS Add On
22
star
28

micropython-74hc595

MicroPython driver for 74HC595 shift registers
Python
21
star
29

micropython-ys-irtm

MicroPython examples for YS-IRTM 5V NEC Infrared UART transceivers
20
star
30

Fritzing-Part-WiFi-Witty-Gizwits-ESP-12F

Fritzing Part: WiFi Witty Gizwits ESP-12F
Shell
20
star
31

VCC_GND_F407VE

MicroPython board definition for the VCC GND STM32F407VET6 mini board
C
18
star
32

MCUDEV_DEVEBOX_F407VET6

MicroPython board definition for the MCUDev DevEBox STM32F407VET6 board
C
16
star
33

micropython-dht12

MicroPython driver for the Aosong DHT12 temperature and humidity sensor
Python
15
star
34

Grove-Eagle

Eagle source files for Grove modules
Eagle
13
star
35

BLUE_BUTTON_F103RET6

MicroPython board definition for the Blue Button STM32F103RET6 board
C
13
star
36

esp8266-useless-throwie

ESP8266 Useless Throwie
HTML
13
star
37

micropython-mpr121

MicroPython driver for MPR121 capacitive touch keypads and breakout boards
Python
13
star
38

micropython-tm1640

MicroPython driver for TM1740 8x8 LED matrix modules
Python
12
star
39

micropython-pcf8575

MicroPython driver for PCF8575 16-Bit I2C I/O Expander with Interrupt
Python
11
star
40

micropython-tca9548a

MicroPython examples using TCA9548A I2C multiplexer
11
star
41

MicroPython-ESP8266-Nokia-5110-Bitcoin

MicroPython library for displaying bitcoin price index on a Nokia 5110 display with PCD8544 driver
Python
10
star
42

microbit-tm1637

MicroPython for micro:bit library for quad 7-segment LED modules using TM1637 LED driver
Python
9
star
43

micropython-ys-rf34t

MicroPython examples using YS-RF34T 433MHz ASK/OOK UART transceivers
7
star
44

Fritzing-Part-Micro-Python-pyboard

Fritzing part: MicroPython pyboard
Shell
7
star
45

WeMos-D1-mini-OLED-Shield-64x48-SSD1306

C
7
star
46

micropython-ttp223

MicroPython examples using TTP223 capacitive touch module
6
star
47

micropython-my9221

MicroPython driver for MY9221 10-segment LED bar graph modules
Python
6
star
48

micropython-hx1230

MicroPython library for HX1230 96x68 LCD modules
Python
5
star
49

XL7105-SY-B-Breakout

Breakout board for the XL7105-SY-B 2.4GHz RF transceiver module
5
star
50

micropython-p9813

MicroPython driver for P9813 chainable RGB LEDs
Python
4
star
51

Fritzing-Part-DFRobot-DFPlayer-Mini

Fritzing Part: DFRobot DFPlayer Mini
Shell
4
star
52

MicroPython-ESP8266-Nokia-5110-Quad-7-segment

MicroPython library for emulating quad 7-segment LED displays on a Nokia 5110 with PCD8544 driver
Python
3
star
53

RadioHead

Mirror of Mike McCauley's RadioHead library
C++
3
star
54

deshipu-micropython-oled

Python
3
star
55

micropython-sht31

MicroPython driver for the SHT31 Temperature and Humidity Sensor
2
star
56

micropython-lm75a

MicroPython driver for the LM75A digital temperature sensor
Python
2
star
57

VCC_GND_F407ZG

MicroPython board definition for the VCC GND STM32F407ZGT6 mini board
C
2
star
58

micropython-tinypico-lol-rgb-shield

A MicroPython library for the TinyPICO LOL RGB Shield
Python
2
star
59

microbit-dht12

MicroPython for micro:bit library for the Aosong DHT12 temperature and humidity sensor
Python
2
star
60

deshipu-micropython-pca9685

Python
2
star
61

micropython-hz1050

MicroPython driver for HZ-1050 UART and Wiegand 125Khz RFID Reader
2
star
62

A7139-Breakout

Breakout board for the A7139 433MHz RF transceiver module
2
star
63

deshipu-micropython-bno055

Python
2
star
64

14-segment-led-alphanumeric

1
star
65

deshipu-micropython-ht16k33

Python
1
star
66

micropython-nrf905

MicroPython driver for Nordic nRF905 Sub-1GHz RF transceiver modules
1
star
67

coldfusion-munin

Munin plugins for ColdFusion
ColdFusion
1
star
68

deshipu-micropython-max31855

Python
1
star
69

circuitpython-feathers2neo-rgb-matrix

CircuitPython library for FeatherS2 Neo RGB Matrix
Python
1
star
70

deshipu-micropython-sdcard

Python
1
star
71

LC12S-Breakout

Breakout board for the LC12S 2.4GHz UART transceiver module
1
star
72

micropython-rda5807m

MicroPython driver for RDA5807M stereo FM radio modules
1
star
73

micropython-max44009

MicroPython driver for the MAX44009 ambient light sensor
Python
1
star
74

micropython-pcd8544-c

C
1
star
75

deshipu-micropython-ili9341

Python
1
star