{"id":13613292,"url":"https://github.com/mcauser/micropython-tm1637","last_synced_at":"2025-04-05T19:13:30.165Z","repository":{"id":41153133,"uuid":"76649937","full_name":"mcauser/micropython-tm1637","owner":"mcauser","description":"MicroPython driver for TM1637 quad 7-segment LED modules","archived":false,"fork":false,"pushed_at":"2023-07-04T20:38:00.000Z","size":2097,"stargazers_count":205,"open_issues_count":6,"forks_count":87,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T18:08:56.842Z","etag":null,"topics":["7-segment","esp8266","grove","micropython","tm1637","wemos-d1-mini"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcauser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-12-16T11:50:54.000Z","updated_at":"2025-03-20T11:25:11.000Z","dependencies_parsed_at":"2024-01-29T19:30:28.023Z","dependency_job_id":"dd014713-4d3b-4a70-85e0-28384b5115a5","html_url":"https://github.com/mcauser/micropython-tm1637","commit_stats":{"total_commits":23,"total_committers":3,"mean_commits":7.666666666666667,"dds":"0.21739130434782605","last_synced_commit":"0ef0fc04829f6b3d12215a1479d60e2023f3465f"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-tm1637","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-tm1637/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-tm1637/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-tm1637/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcauser","download_url":"https://codeload.github.com/mcauser/micropython-tm1637/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386265,"owners_count":20930619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["7-segment","esp8266","grove","micropython","tm1637","wemos-d1-mini"],"created_at":"2024-08-01T20:00:43.561Z","updated_at":"2025-04-05T19:13:30.135Z","avatar_url":"https://github.com/mcauser.png","language":"Python","readme":"# MicroPython TM1637\n\nA MicroPython library for quad 7-segment LED display modules using the TM1637 LED driver.\n\n![demo](docs/demo.jpg)\n\n### Installation\n\nUsing mip via mpremote:\n\n```bash\n$ mpremote mip install github:mcauser/micropython-tm1637\n```\n\nUsing mip directly on a WiFi capable board:\n\n```python\n\u003e\u003e\u003e import mip\n\u003e\u003e\u003e mip.install(\"github:mcauser/micropython-tm1637\")\n```\n\nManual installation:\n\nCopy `tm1637.py` to the root directory of your device.\n\n## Examples\n\n**Basic usage**\n\n```python\nimport tm1637\nfrom machine import Pin\ntm = tm1637.TM1637(clk=Pin(5), dio=Pin(4))\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 [tm1637_test.py](tm1637_test.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## Modules\n\n* [Grove 4 Digit Display](https://www.seeedstudio.com/Grove-4-Digit-Display.html)\n* [RobotDyn 4-digit LED Display Tube](https://www.aliexpress.com/item/32795908218.html)\n* [RobotDyn 6-digit LED Display Tube](https://www.aliexpress.com/item/32800127265.html)\n* [Generic TM1637 LED Display Module](https://www.aliexpress.com/item/32657932650.html)\n\nFor example, the [Grove - 4 Digit Display module](http://wiki.seeed.cc/Grove-4-Digit_Display/)\n\n## Connections\n\n`CLK` and `DIO` are bit-banged. You can use any GPIO.\n\n4 Digit Display | TinyPICO | Pi Pico | WeMos D1 Mini\n--------------- | ---------| ------- | -------------\nCLK             | IO18     | IO27    | D1 (GPIO5)\nDIO             | IO23     | IO26    | D2 (GPIO4)\nVCC             | 3V3      | 3V3     | 3V3/5V\nGND             | GND      | GND     | G\n\n## Links\n\n* [micropython.org](http://micropython.org)\n* [TM1637 datasheet](http://www.titanmec.com/index.php/en/project/download/id/302.html)\n* [Titan Micro TM1637 product page](http://www.titanmec.com/index.php/en/project/view/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","funding_links":[],"categories":["精选驱动库","Libraries","Python"],"sub_categories":["显示类","Display"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-tm1637","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcauser%2Fmicropython-tm1637","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-tm1637/lists"}