# TM1637
# GPIOD Python 3 TM1637
A Python 3 port from MicroPython library for the quad 7-segment LED display modules based on the TM1637 LED driver, implemented using Linux GPIOD.
## Installation
This project is available through [pip](https://www.w3schools.com/python/python_pip.asp). Make sure that you are using Python 3.
```
$ pip3 install gpiod-tm1637
```
## Examples
**Basic usage**
```python
import tm1637
tm = tm1637.TM1637("/dev/gpiochip0", clk=3, dio=2)
# 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 [demo.py](./demo.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.
```python
brightness(val=None)
```
Write one or more segments at a given offset.
```python
write(segments, pos=0)
```
Convert a single hex digit (0x00-0x0f) to a segment.
```python
encode_digit(digit)
```
Convert a string to a list of segments.
```python
encode_string(string)
```
Convert a single character to a segment.
```python
encode_char(char)
```
Display a number in hexadecimal format 0000 through FFFF.
```python
hex(val)
```
Display a number -999 through 9999, right aligned.
```python
number(num)
```
Display 2 independent numbers on either side of the (optional) colon, with leading zeros.
```python
numbers(num1, num2, colon=True)
```
Display a temperature -9 through 99 followed by degrees C.
```python
temperature(num)
```
Show a string on the display.
Shorthand for `write(encode_string())`.
Limited to first 4 characters.
```python
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.
```python
scroll(string, delay=250)
```
## Parts
* [Grove 4 Digit Display](https://www.seeedstudio.com/grove-4digital-display-p-1198.html) $5.90 USD
* [Grove Male Jumper Cable](https://www.seeedstudio.com/Grove-4-pin-Male-Jumper-to-Grove-4-pin-Conversion-Cable-%285-PCs-per-Pack%29-p-1565.html) $2.90 USD
## Connections
Raspberry Pi | 4 Digit Display
------------- | ---------------
GPIO3 | CLK
GPIO2 | DIO
3V3 (or 5V) | VCC
GND | GND
## Links
* [TM1637 datasheet](http://www.titanmec.com/index.php/en/project/download/id/302.html)
* [Nokia 5110 version](https://github.com/mcauser/MicroPython-ESP8266-Nokia-5110-Quad-7-segment)
* [BBC micro:bit version](https://github.com/mcauser/microbit-tm1637)
## License
Licensed under the [MIT License](http://opensource.org/licenses/MIT).
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/matsievskiysv/gpiod-tm1637",
"name": "gpiod-tm1637",
"maintainer": "Sergey Matsievskiy",
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": "matsievskiysv@gmail.com",
"keywords": "tm1637 armbian seven segment led python",
"author": "Mike Causer",
"author_email": "mcauser@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/73/ca/49c9a384781f4006bb565b24b0dc0bfe06b7d560efdef1e829f9935124d7/gpiod-tm1637-1.3.7.tar.gz",
"platform": null,
"description": "# TM1637\n# GPIOD Python 3 TM1637\n\nA Python 3 port from MicroPython library for the quad 7-segment LED display modules based on the TM1637 LED driver, implemented using Linux GPIOD.\n\n## Installation\n\nThis project is available through [pip](https://www.w3schools.com/python/python_pip.asp). Make sure that you are using Python 3.\n\n```\n$ pip3 install gpiod-tm1637\n```\n\n## Examples\n\n**Basic usage**\n\n```python\nimport tm1637\ntm = tm1637.TM1637(\"/dev/gpiochip0\", clk=3, dio=2)\n\n# all LEDS on \"88:88\"\ntm.write([127, 255, 127, 127])\n\n# all LEDS off\ntm.write([0, 0, 0, 0])\n\n# show \"0123\"\ntm.write([63, 6, 91, 79])\n\n# show \"COOL\"\ntm.write([0b00111001, 0b00111111, 0b00111111, 0b00111000])\n\n# show \"HELP\"\ntm.show('help')\n\n# display \"dEAd\", \"bEEF\"\ntm.hex(0xdead)\ntm.hex(0xbeef)\n\n# show \"12:59\"\ntm.numbers(12, 59)\n\n# show \"-123\"\ntm.number(-123)\n\n# show temperature '24*C'\ntm.temperature(24)\n```\n\nFor more detailed examples, see [demo.py](./demo.py)\n\n# Seven Segment Font\n\nThey are called 7-segment displays as there are 7 LEDs for each digit (segment).\nOne byte (7 lower bits) for each segment. The 8th bit (MSB) is for the colon and only on the 2nd segment.\n\n```\n A\n ---\n F | | B *\n -G- H (on 2nd segment)\n E | | C *\n ---\n D\n\n HGFEDCBA\n0b01101101 = 0x6D = 109 = show \"5\"\n```\n\nDisplay | Bin | Hex | Dec\n------- | ---------- | ---- | ---\n0 | 0b00111111 | 0x3F | 63\n1 | 0b00000110 | 0x06 | 6\n2 | 0b01011011 | 0x5B | 91\n3 | 0b01001111 | 0x4F | 79\n4 | 0b01100110 | 0x66 | 102\n5 | 0b01101101 | 0x6D | 109\n6 | 0b01111101 | 0x7D | 125\n7 | 0b00000111 | 0x07 | 7\n8 | 0b01111111 | 0x7F | 127\n9 | 0b01101111 | 0x6F | 111\nA | 0b01110111 | 0x77 | 119\nb | 0b01111100 | 0x7C | 124\nC | 0b00111001 | 0x39 | 57\nd | 0b01011110 | 0x5E | 94\nE | 0b01111001 | 0x79 | 121\nF | 0b01110001 | 0x71 | 113\nG | 0b00111101 | 0x3D | 61\nH | 0b01110110 | 0x76 | 118\nI | 0b00000110 | 0x06 | 6\nJ | 0b00011110 | 0x1E | 30\nK | 0b01110110 | 0x76 | 118\nL | 0b00111000 | 0x38 | 56\nM | 0b01010101 | 0x55 | 85\nn | 0b01010100 | 0x54 | 84\nO | 0b00111111 | 0x3F | 63\nP | 0b01110011 | 0x73 | 115\nq | 0b01100111 | 0x67 | 103\nr | 0b01010000 | 0x50 | 80\nS | 0b01101101 | 0x6D | 109\nt | 0b01111000 | 0x78 | 120\nU | 0b00111110 | 0x3E | 62\nv | 0b00011100 | 0x1C | 28\nW | 0b00101010 | 0x2A | 42\nX | 0b01110110 | 0x76 | 118\ny | 0b01101110 | 0x6E | 110\nZ | 0b01011011 | 0x5B | 91\nblank | 0b00000000 | 0x00 | 0\n\\- | 0b01000000 | 0x40 | 64\n\\* | 0b01100011 | 0x63 | 99\n\n# Methods\n\nGet or set brightness.\n```python\nbrightness(val=None)\n```\n\nWrite one or more segments at a given offset.\n```python\nwrite(segments, pos=0)\n```\n\nConvert a single hex digit (0x00-0x0f) to a segment.\n```python\nencode_digit(digit)\n```\n\nConvert a string to a list of segments.\n```python\nencode_string(string)\n```\n\nConvert a single character to a segment.\n```python\nencode_char(char)\n```\n\nDisplay a number in hexadecimal format 0000 through FFFF.\n```python\nhex(val)\n```\n\nDisplay a number -999 through 9999, right aligned.\n```python\nnumber(num)\n```\n\nDisplay 2 independent numbers on either side of the (optional) colon, with leading zeros.\n```python\nnumbers(num1, num2, colon=True)\n```\n\nDisplay a temperature -9 through 99 followed by degrees C.\n```python\ntemperature(num)\n```\n\nShow a string on the display.\nShorthand for `write(encode_string())`.\nLimited to first 4 characters.\n```python\nshow(string, colon=False)\n```\n\nDisplay a string on the display, scrolling from the right to left, speed adjustable.\nString starts off-screen and scrolls until off-screen at 4 FPS by default.\n```python\nscroll(string, delay=250)\n```\n\n## Parts\n\n* [Grove 4 Digit Display](https://www.seeedstudio.com/grove-4digital-display-p-1198.html) $5.90 USD\n* [Grove Male Jumper Cable](https://www.seeedstudio.com/Grove-4-pin-Male-Jumper-to-Grove-4-pin-Conversion-Cable-%285-PCs-per-Pack%29-p-1565.html) $2.90 USD\n\n## Connections\n\nRaspberry Pi | 4 Digit Display\n------------- | ---------------\nGPIO3 | CLK\nGPIO2 | DIO\n3V3 (or 5V) | VCC\nGND | GND\n\n## Links\n\n* [TM1637 datasheet](http://www.titanmec.com/index.php/en/project/download/id/302.html)\n* [Nokia 5110 version](https://github.com/mcauser/MicroPython-ESP8266-Nokia-5110-Quad-7-segment)\n* [BBC micro:bit version](https://github.com/mcauser/microbit-tm1637)\n\n## License\n\nLicensed under the [MIT License](http://opensource.org/licenses/MIT).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "GPIOD port from Raspberry Pi Python port from MicroPython library for TM1637 LED driver.",
"version": "1.3.7",
"project_urls": {
"Homepage": "https://gitlab.com/matsievskiysv/gpiod-tm1637"
},
"split_keywords": [
"tm1637",
"armbian",
"seven",
"segment",
"led",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "187b0c5370e097ead3cd9304ca9af3a494ffb1c6387d487a6946d82c5b20b264",
"md5": "de3f7c535a48ead6f357a4fd41690cb7",
"sha256": "e62eaeefd01bc4847220e800b1e50fa598a341bc37608b90c506f801b9c0290d"
},
"downloads": -1,
"filename": "gpiod_tm1637-1.3.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "de3f7c535a48ead6f357a4fd41690cb7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 7329,
"upload_time": "2024-02-02T17:17:07",
"upload_time_iso_8601": "2024-02-02T17:17:07.543305Z",
"url": "https://files.pythonhosted.org/packages/18/7b/0c5370e097ead3cd9304ca9af3a494ffb1c6387d487a6946d82c5b20b264/gpiod_tm1637-1.3.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "73ca49c9a384781f4006bb565b24b0dc0bfe06b7d560efdef1e829f9935124d7",
"md5": "1c66e1781028c05225861bc909554671",
"sha256": "15d233de7e51cd8fb0f9d6baff7b8ad6a4e84a91ebefc2f70dee80ce04569e51"
},
"downloads": -1,
"filename": "gpiod-tm1637-1.3.7.tar.gz",
"has_sig": false,
"md5_digest": "1c66e1781028c05225861bc909554671",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 7086,
"upload_time": "2024-02-02T17:17:09",
"upload_time_iso_8601": "2024-02-02T17:17:09.582939Z",
"url": "https://files.pythonhosted.org/packages/73/ca/49c9a384781f4006bb565b24b0dc0bfe06b7d560efdef1e829f9935124d7/gpiod-tm1637-1.3.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-02 17:17:09",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "matsievskiysv",
"gitlab_project": "gpiod-tm1637",
"lcname": "gpiod-tm1637"
}