{"id":19856565,"url":"https://github.com/gavinlyonsrepo/tm1638plus","last_synced_at":"2025-04-06T06:12:58.378Z","repository":{"id":34926628,"uuid":"190821724","full_name":"gavinlyonsrepo/TM1638plus","owner":"gavinlyonsrepo","description":"An Arduino library to drive  TM1638 seven segment modules. ","archived":false,"fork":false,"pushed_at":"2024-11-02T18:09:45.000Z","size":590,"stargazers_count":80,"open_issues_count":0,"forks_count":25,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-30T05:07:58.942Z","etag":null,"topics":["1638","arduino","arduino-library","arduino-project","ascii-fonts","attiny85","decimal-points","esp32","esp8266","libraries","library","lkm1638","microcontroller","module","segment","seven-segment","seven-segments-display","stm32f103c8t6","tm-1638","tm1638"],"latest_commit_sha":null,"homepage":"https://gavinlyonsrepo.github.io/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gavinlyonsrepo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"publiccode":null,"codemeta":null}},"created_at":"2019-06-07T23:05:27.000Z","updated_at":"2025-03-29T13:15:38.000Z","dependencies_parsed_at":"2022-08-08T03:00:32.426Z","dependency_job_id":"9ead2eb6-108b-4465-ba1d-d305b62144c1","html_url":"https://github.com/gavinlyonsrepo/TM1638plus","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FTM1638plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FTM1638plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FTM1638plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FTM1638plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gavinlyonsrepo","download_url":"https://codeload.github.com/gavinlyonsrepo/TM1638plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441060,"owners_count":20939239,"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":["1638","arduino","arduino-library","arduino-project","ascii-fonts","attiny85","decimal-points","esp32","esp8266","libraries","library","lkm1638","microcontroller","module","segment","seven-segment","seven-segments-display","stm32f103c8t6","tm-1638","tm1638"],"created_at":"2024-11-12T14:15:59.395Z","updated_at":"2025-04-06T06:12:58.357Z","avatar_url":"https://github.com/gavinlyonsrepo.png","language":"C++","readme":"[![Website](https://img.shields.io/badge/Website-Link-blue.svg)](https://gavinlyonsrepo.github.io/)  [![Rss](https://img.shields.io/badge/Subscribe-RSS-yellow.svg)](https://gavinlyonsrepo.github.io//feed.xml)  [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/whitelight976)\n\n\n# TM1638plus \n\n## Table of contents\n\n  * [Overview](#overview)\n  * [Installation](#installation)\n  * [Software](#software)\n  * [Connections](#connections)\n  * [Model Types](#model-types)\n     * [Model One](#model-one)\n     * [Model Two](#model-two)\n     * [Model Three](#model-three)\n  * [Tested](#tested)\n  * [Notes](#notes)\n     * [Swapped data nibbles](#swapped-data-nibbles)\n     * [Read buttons anomaly](#read-buttons-anomaly)\n     * [Multiple displays](#multiple-displays)\n     * [Multiple buttons pressed together](#multiple-buttons-pressed-together)\n \n## Overview\n\n* Name: TM1638plus\n* Description: \n\nAn Arduino library to display data on a 8-digit TM1638 seven segment module's.\nThis library supports all 3 of the known models on market. see Model type section below\n\n* Main Author: Gavin Lyons.\n\n## Installation\n\nThe library is included in the official Arduino library manger and the optimum way to install it \nis using the library manager which can be opened by the *manage libraries* option in Arduino IDE. \nSearch \"tm1638\" in search bar of library manager to find it.\n\nSee link below for instruction for this and for the other methods too.\n\n[Installing Additional Arduino Libraries guide](https://www.arduino.cc/en/Guide/Libraries)\n\n## Software \n\nThe API (application programming interface)  html documentation is at link. Hosted on github pages and generated by Doxygen software. Here the user will find lots of information on files, functions \u0026 data types. \n\n[Software API Url Link](https://gavinlyonsrepo.github.io/misc/software_docs/TM1638plus/index.html)\n\n\n## Connections\n\nConnections to MCU: \n\n\t* GPIO = STB = Strobe\n\t* GPIO  = CLK  = Clock\n\t* GPIO = DIO = Data input / output\n\t* GND\n\t* VCC \n\n## Model Types\n\nThis library supports three variants of the TM1638, which for purposes of this documentation, \nwill be named Model 1 ,Model 2 and Model 3.  Pictured left to right. \n\n![ module pics ](https://github.com/gavinlyonsrepo/TM1638plus/blob/master/extra/images/tm16383.jpg)\n\n| Model Name | PCB Labels | LEDs | Push buttons | \n| ------ | ------ |  ------ | ------ |\n| Model 1 | TM1638 LED \u0026 KEY | 8 red only | 8 |\n| Model 2 | TM1638 KEYS, QYF  | 0 | 16 |\n| Model 3 | TM1638 V1.3 or LKM1638  | 8 bi color,  red or green  | 8 |\n\n\n### Model One\n\nTM1638 Module 8 Push buttons 8 LEDS (LED \u0026 KEY)\n\n![ module ](https://github.com/gavinlyonsrepo/pic_16F18446_projects/blob/master/images/TM1638.jpg)\n\n![ sch ](https://github.com/gavinlyonsrepo/pic_16F18446_projects/blob/master/images/TM1638_2.jpg)\n \nThis variant consist of an 8-digit seven segment display with decimal points,\n8 Leds and 8 Push buttons. Two 4 digit 3461AS-1 (.34 inch, 4 digit ,common Cathode,  decimal point, RED) are used in this module giving a total of 8 digits. A TM1638 controller chip drives the unit.\nThe unit is marked (LED \u0026 KEY).\n\nThe library support ASCII ,text ,Hex and allows for setting individual segments,\nand the decimal point of segment. User may have to \"debounce\" the button read  method depending on application.\ndebouncing left out to minimise library size. Example files show some methods to do this.\nUser can Adjust brightness of module. Support 8 degree brightness adjustment.\nIt is possible to manually set segments to create custom patterns without reference to the ASCII font.\n\n### Model Two\n\nTM1638 Module 16 Push buttons (16 KEY) (QYF).\n\n![ module ](https://github.com/gavinlyonsrepo/TM1638plus/blob/master/extra/images/tm16381.jpg)\n\n![ sch ](https://github.com/gavinlyonsrepo/TM1638plus/blob/master/extra/images/tm16382.jpg)\n\nThey consist of an 8-digit seven segment display with decimal points,\nand 16 Push buttons.Two 4 digit 3461BS-1 (.34 inch, 4 digit ,common Anode,  decimal point, RED)are used in this module giving a total of 8 digits. A TM1638 controller chip drives the unit.\nNB :  If your display shows \"56781234\" for \"12345678\" see Notes section. Note 1.\n\nUser may want to \"debounce\" button's read method depending on application.\nSee TM1638plus_ADC_TEST_Model2.ino for debounce button example. \nTwo different functions to read buttons. \nRaw ASCII data can be printed without reference to font file.\n\n### Model Three\n\n\nThere are different PCB's of these modules on market, \nThis library was tested on no 3 below. I think this software will work for all of them \nand the differences in PCB are related to connectors, layout and component placement. \nThis module is a variant of Model 1. The differences are the LEDs are bigger and bi-color\nboth red and green, The seven segment display is larger and extra connectors are added for Daisy chaining. \nTwo 4 digit KYX-5461AS-7.3 (.54 inch, 4 digit ,common cathode,  decimal point, RED)are used in this module\ngiving a total of 8 digits. \n\n1. LKM1638 v1.1\n2. LKM1638 v1.2\n3. TM1638 V1.3 \n\n![ module ](https://github.com/gavinlyonsrepo/TM1638plus/blob/master/extra/images/tm16384.jpg)\n\n*Model 3 LED Functions*\n\nThe code is the same as model 1 and there is one unique model 3 example file. \nsetLED and setLEDs functions behaviour is the only difference in code base between 1 and 3.\nSetLED: The difference is when you call the setLED function you pass the following to get LEDs to change colour. For more detailed information on functions see commented headers in header file(.h).\n\n| Model | setLED Value | result | \n|    ----   |    ----   |    ----   |\n|    1 \u0026 3  |    0   |    LED off   |\n|    3   |    1   |    Led green on  |\n|    3   |    2   |    LED red on  |\n|    1   |    1   |    LED on   |\n\nSetLEDs: When you pass call the setLEDs function you can pass a word pattern where upper byte is turns LEDs green on and lower byte turns LEDs red on . Model one ignores lower byte, Set to 0x00 always. \n\n1. Model 3 setLEDs(word) = 0xGGRR\n3. Model 1 setLEDs(word) = 0xRR00\n\n## Tested\n\n\n* Tested on following MCU  \u0026 Development platforms.\n* Examples files are set up for Arduino UNO \u0026 NANO v3.\n* File GPIO_OTHER_MCUs.txt in extra folder gives pins  tested  for other MCU.\n\n1. Arduino UNO \u0026 NANO v3 .\n2. ATtiny85 .\n3. ESP32.\n4. STM32 STM32F103C8T6 \"the blue pill\".\n5. ESP8266.\n6. Teensy 4.0. (may not work at highest frequency see  note #2 in notes section)\n\n## Notes\n\n### Swapped data nibbles\n \nModel 2 only.\nFor Some users using this library the nibbles in information display byte \nwhere swapped around. This is because there are different versions of modules on market with different wiring.  See issue #3 on github called Swapped display :: \"12345678\" becomes \"56781234\". \nIf you test library and you see this issue, in order to fix this when you declare the \nObject, set the fourth parameter \"swap_nibbles\" to True, The default is false.\n\n| PCB Model noted Label | Operation | Object constructor 4th parameter |\n| ------ | ------ | ------ | \n| QYF-TM1638 | default operation | false | \n| QYF-TM1638 -Ver 1.0 | Swapped display Fix |  true  | \n\n### Read buttons anomaly\n\nRead buttons anomaly on High frequency micro-controllers.\nThis library uses a software SPI-like protocol and may not work fully on \nmicro-controllers running at a very high frequency, without some adjustments to timing.\nIt is a SPI-like interface with a single bidirectional data wire DIO.\nThe TM1638 is basically a slow SPI device (\u003c 500kHz) in DIO mode. The clock uses the equivalent of SPI mode 3 (normally high, clocks data on the rising edge). The problem is that the native Arduino shiftIn()/shiftOut() wire functions are simply too fast for this device (technically the clock signalling for the TM1638 is inverted but as it triggers on a rising edge still it is tolerant of that).\nTo make this work with fast devices, the shift clocking is slowed with a small delay (on the order of a microsecond).  \n\nHighFreqshiftin  function:\n \nAs of version 1.6 a new parameter *(_HIGH_FREQ)* has been introduced to constructor it is false by default. Set to true for high frequency MCU ~\u003e 100Mhz.  This should fix the issue of HF MCU not reading buttons correctly(ESP-Xs). The High_Freq parameter causes a custom shift-in function to be used. The delay in this function is fixed at 1 uS, it can be changed manually by adjusted  the defines in common header file.\n\nThe  Teensy results have been sent in by email, I don't have these MCU's them at time of writing. \n\n| IC |  frequency | Status | \n| ------ | ------ | ------ | \n| ATtiny85 | 1Mhz internal | Working | \n| Arduino UNO  |  16 MHz  | Working | \n| Arduino Nano  | 16 MHz  | Working |\n| STM32 \"blue pill\" STM32F103C8T6 | 72Mhz | Working |\n| ESP8266 | 160Mhz | Working |\n| ESP 32  |   240 MHz  | Working, with high_freq set to  true | \n| Teensy 4.0| 150Mhz | Working model 1,  no Data rest of models |\n| Teensy 4.0| 396Mhz | Not working on  m1 pre v1.6, no data after,  no Data rest of models |\n\n### Multiple displays\n\nDriving multiple displays.\nIt is possible to drive multiple modules. Share the DIO and CLK lines and use a unique\nSTB line for each device. see issue number 10 at github for example code.\n\n\n### Multiple buttons pressed together\n\nDetecting multiple buttons pressed together.\n\nModel 1 and Model 3 CAN detect multiple buttons pressed.\n\nModel 2 has two different functions:\n\n1. ReadKey16 returns a byte with decimal value 1-16 this function cannot \ndetect multiple buttons pressed.\n\n2. ReadKey16Two returns a 16 bit integer where each bit corresponds to the 16 switch's.\nHowever due to the wiring  of the module, see SG-X lines  on schematic,\nPressing Certain combinations of buttons will cause the  data on Seven Segments to \nchange. So the simultaneous use of multiple key presses and the seven segments display \nis problematic. See issue 12 on github for more details.\n","funding_links":["https://www.paypal.com/paypalme/whitelight976"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinlyonsrepo%2Ftm1638plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgavinlyonsrepo%2Ftm1638plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinlyonsrepo%2Ftm1638plus/lists"}