|
1 | | -# TM1637 |
2 | 1 | # MicroPython TM1637 |
3 | 2 |
|
4 | | -A MicroPython library for the quad 7-segment LED display modules based on the TM1637 LED driver. |
| 3 | +A MicroPython library for quad 7-segment LED display modules using the TM1637 LED driver. |
5 | 4 |
|
6 | 5 | For example, the [Grove - 4 Digit Display module](http://wiki.seeed.cc/Grove-4-Digit_Display/) |
7 | 6 |
|
8 | 7 |  |
9 | 8 |
|
| 9 | +## Examples |
| 10 | + |
| 11 | +Copy the file to your device, using ampy, webrepl or compiling and deploying. eg. |
| 12 | + |
| 13 | +``` |
| 14 | +$ ampy put tm1637.py |
| 15 | +``` |
| 16 | + |
| 17 | +**Basic usage** |
| 18 | + |
| 19 | +``` |
| 20 | +import tm1637 |
| 21 | +from machine import Pin |
| 22 | +tm = tm1637.TM1637(clk=Pin(5), dio=Pin(4)) |
| 23 | +
|
| 24 | +# all LEDS on "88:88" |
| 25 | +tm.write([127, 255, 127, 127]) |
| 26 | +
|
| 27 | +# all LEDS off |
| 28 | +tm.write([0, 0, 0, 0]) |
| 29 | +
|
| 30 | +# display "0123" |
| 31 | +tm.write([63, 6, 91, 79]) |
| 32 | +
|
| 33 | +# show "COOL" |
| 34 | +tm.write([0b00111001, 0b00111111, 0b00111111, 0b00111000]) |
| 35 | +
|
| 36 | +# display "dEAd", "bEEF" |
| 37 | +tm.hex(0xdead) |
| 38 | +tm.hex(0xbeef) |
| 39 | +
|
| 40 | +# show "12:59" |
| 41 | +tm.numbers(12,59) |
| 42 | +
|
| 43 | +# show "-123" |
| 44 | +tm.number(-123) |
| 45 | +
|
| 46 | +# show temperature '24*C' |
| 47 | +tm.temperature(24) |
| 48 | +``` |
| 49 | + |
| 50 | +For more detailed examples, see  |
| 51 | + |
10 | 52 | They are called 7-segment displays as there are 7 LEDs for each digit (segment). |
11 | 53 | One byte (7 lower bits) for each segment. The 8th bit (MSB) is for the colon and only on the 2nd segment. |
12 | 54 |
|
@@ -63,4 +105,7 @@ G | GND |
63 | 105 |
|
64 | 106 | * [WeMos D1 Mini](http://www.wemos.cc/Products/d1_mini.html) |
65 | 107 | * [micropython.org](http://micropython.org) |
| 108 | +* [TM1637 datasheet](http://www.titanmec.com/index.php/en/project/download/id/302.html) |
| 109 | +* [Titan Micro TM1637 product page](http://www.titanmec.com/index.php/en/project/view/id/302.html) |
66 | 110 | * [Nokia 5110 version](https://github.com/mcauser/MicroPython-ESP8266-Nokia-5110-Quad-7-segment) |
| 111 | +* [Adafruit Ampy](https://learn.adafruit.com/micropython-basics-load-files-and-run-code/install-ampy) |
0 commit comments