{"id":13897194,"url":"https://github.com/mcauser/microbit-tm1637","last_synced_at":"2025-07-28T05:32:44.495Z","repository":{"id":150620615,"uuid":"116643887","full_name":"mcauser/microbit-tm1637","owner":"mcauser","description":"MicroPython for micro:bit library for quad 7-segment LED modules using TM1637 LED driver","archived":false,"fork":false,"pushed_at":"2019-01-23T12:33:46.000Z","size":1798,"stargazers_count":11,"open_issues_count":2,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-01T08:46:31.095Z","etag":null,"topics":["7-segment","grove","microbit","microbit-scripts","micropython","tm1637"],"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}},"created_at":"2018-01-08T07:25:45.000Z","updated_at":"2025-02-24T17:07:56.000Z","dependencies_parsed_at":"2023-05-06T09:33:11.435Z","dependency_job_id":null,"html_url":"https://github.com/mcauser/microbit-tm1637","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mcauser/microbit-tm1637","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-tm1637","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-tm1637/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-tm1637/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-tm1637/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcauser","download_url":"https://codeload.github.com/mcauser/microbit-tm1637/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-tm1637/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267468371,"owners_count":24092330,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","grove","microbit","microbit-scripts","micropython","tm1637"],"created_at":"2024-08-06T18:03:24.841Z","updated_at":"2025-07-28T05:32:43.931Z","avatar_url":"https://github.com/mcauser.png","language":"Python","readme":"# BBC micro:bit MicroPython TM1637\n\nA micro:bit MicroPython library for quad 7-segment LED display modules using the TM1637 LED driver.\n\nFor example, the [Grove - 4 Digit Display module](http://wiki.seeed.cc/Grove-4-Digit_Display/)\n\n![demo](docs/demo.jpg)\n\n## Installation\n\n* Install MicroPython for micro:bit by either compiling from [source](https://github.com/bbcmicrobit/micropython) or using one of the included [precompiled firmwares](/firmware)\n* Install [ufs](https://github.com/ntoll/microfs) to upload .py scripts\n* Copy `tm1637.py` and one of the example `main.py` scripts to the micro:bit\n* Reset to run `main.py` on boot.\n\n# Examples\n\nThere are multiple methods which can produce the same result. Here are a few examples to get you started.\n\n```python\nfrom microbit import *\nfrom tm1637 import TM1637\ntm = TM1637(clk=pin1, dio=pin2)\n\n# all LEDS on \"88:88\"\ntm.write([127, 255, 127, 127])\ntm.show('8888', True)\ntm.numbers(88, 88)\n\n# all LEDS off\ntm.write([0, 0, 0, 0])\ntm.show('    ')\n\n# write to the 2nd and 3rd segments only\ntm.write([119, 124], 1)\ntm.write([124], 2)\ntm.write([119], 1)\n\n# display \"0123\"\ntm.show('1234')\ntm.number(1234)\ntm.numbers(12, 34)\n\n# show \"COOL\"\ntm.write([0b00111001, 0b00111111, 0b00111111, 0b00111000])\ntm.write([0x39, 0x3F, 0x3F, 0x38])\ntm.write([57, 63, 63, 56])\ntm.show('cool')\ntm.show('COOL')\n\n# display \"dEAd\", \"bEEF\"\ntm.hex(0xdead)\ntm.hex(0xbeef)\ntm.show('dead')\ntm.show('Beef')\n\n# show \"12:59\"\ntm.numbers(12,59)\ntm.number(1259, True)\ntm.show('1259', True)\n\n# show \"-123\"\ntm.number(-123)\ntm.show('-123')\n\n# show temperature '24*C'\ntm.temperature(24)\ntm.show('24*C')\n\n# get current brightness\ntm.brightness()\n\n# reduce brightness\ntm.brightness(3)\n```\n\nFor more detailed examples, see /examples.\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```\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```\nbrightness(val=None)\n```\n\nWrite one or more segments at a given offset.\n```\nwrite(segments, pos=0)\n```\n\nConvert a string to a list of segments.\n```\nencode_string(string)\n```\n\nConvert a single character to a segment.\n```\nencode_char(char)\n```\n\nDisplay a number in hexadecimal format 0000 through FFFF.\n```\nhex(val)\n```\n\nDisplay a number -999 through 9999, right aligned.\n```\nnumber(num)\n```\n\nDisplay 2 independent numbers on either side of the (optional) colon, with leading zeros.\n```\nnumbers(num1, num2, colon=True)\n```\n\nDisplay a temperature -9 through 99 followed by degrees C.\n```\ntemperature(num)\n```\n\nShow a string on the display.\nShorthand for write(encode_string()).\nLimited to first 4 characters.\n```\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```\nscroll(string, delay=250)\n```\n\n## Parts\n\n* [BBC micro:bit](https://tronixlabs.com.au/bbc-micro-bit/bbc-micro-bit-board-only-retail-pack-australia/) $24.95 AUD\n* [Edge Connector Breakout Board](https://tronixlabs.com.au/bbc-micro-bit/edge-connector-breakout-board-for-bbc-micro-bit-australia/) $11.95 AUD\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\nmicro:bit | Grove 4 Digit Display\n--------- | ---------------\nPin 1     | CLK (yellow)\nPin 2     | DIO (white)\n3V3       | VCC (red)\nGND       | GND (black)\n\nAn edge connector breakout board comes in handy here.\n\nYou're welcome to change the data and clock pins to something else - just update `TM1637(clk=pin1, dio=pin2)` in your `main.py`\n\n## Links\n\n* [BBC micro:bit](http://microbit.org/)\n* [MicroPython for the BBC micro:bit](https://github.com/bbcmicrobit/micropython)\n* [Kitronik Edge Connector Breakout Board](https://www.https://www.kitronik.co.uk/5601b-edge-connector-breakout-board-for-bbc-microbit-pre-built.html.co.uk/5601b-edge-connector-breakout-board-for-bbc-microbit-pre-built.html)\n* [Grove 4 Digit Display Wiki Page](http://wiki.seeed.cc/Grove-4-Digit_Display/)\n* [micropython.org](http://micropython.org)\n* [micro:bit on the MicroPython forum](https://forum.micropython.org/viewforum.php?f=17)\n* [microfs](https://github.com/ntoll/microfs)\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* [MicroPython TM1637](https://github.com/mcauser/micropython-tm1637)\n\n# Troubleshooting\n\nIf you upload a new `.hex` file, all changes are overwritten and you will need to `ufs put` both the `tm1637.py` and `main.py` scripts again.\n\nIf you edit one of the example precompiled `.hex` files in one of the [online editors](https://python.microbit.org/v/1), it may swap the MicroPython runtime to an older version and introduce bugs.\nBest to flash one of the stock MicroPython firmwares and upload your own `tm1637.py` and `main.py` scripts.\n\nIf you flash a `.hex` file from an online editor, it may block `main.py` from running as the editor combines the MicroPython runtime with your script.\nYour script is executed like the main script, however, you can't `ufs get` and `ufs put` changes.\n\nIf you board is throwing MemoryErrors and you are unable to continue, start fresh by copying one of the MicroPython firmware `.hex` files to the MICROBIT mounted filesystem.\n\n## License\n\nLicensed under the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Python","🐍 Python"],"sub_categories":["🐍 MicroPython Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicrobit-tm1637","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcauser%2Fmicrobit-tm1637","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicrobit-tm1637/lists"}