GitHunt

๐Ÿ’ก TM1637 7-Segment Display Driver for STM32

A lightweight and efficient TM1637 display driver written in C for STM32 (HAL-based).

This library provides an easy way to interface STM32 MCUs with the TM1637 7-segment LED display driver โ€” commonly used in digital clocks, voltmeters, and similar projects.
It supports 1โ€“6 digits, brightness control, and formatted string display.


โœจ Features

  • ๐Ÿ”น Supports 1 to 6 digits (configurable)
  • ๐Ÿ”น Adjustable brightness levels (0โ€“8)
  • ๐Ÿ”น Displays numbers, characters, and strings
  • ๐Ÿ”น Supports formatted printing (printf)
  • ๐Ÿ”น Full STM32 HAL compatibility
  • ๐Ÿ”น Simple and portable API design
  • ๐Ÿ”น Example and video tutorial included

โš™๏ธ Installation

You can install in two ways:

1. Copy files directly

Add these files to your STM32 project:

  • tm1637.h
  • tm1637.c
  • tm1637_config.h

Available in the official pack repo:
๐Ÿ‘‰ STM32-PACK


๐Ÿ›  CubeMX Setup

  1. CLK (Clock) Pin โ€“ Configure as Output Open-Drain
  2. DIO (Data I/O) Pin โ€“ Configure as Output Open-Drain
  3. No timer or interrupt configuration is needed

Pin Connections

Display Segment TM1637 Pin
A SEG1
B SEG2
C SEG3
D SEG4
E SEG5
F SEG6
G SEG7
. (Dot) SEG8

๐Ÿš€ Quick Start

Adjust delay

To ensure latency in 'tm1637_config.h', set it to a large value and then adjust it for faster response.

TM1637_DELAY     10

Define and Initialize a Display

#include "tm1637.h"

tm1637_t seg = 
{
    .seg_cnt  = 4,             // Number of digits
    .gpio_clk = GPIOA,         // CLK pin port
    .gpio_dat = GPIOA,         // DIO pin port
    .pin_clk  = GPIO_PIN_1,    // CLK pin number
    .pin_data = GPIO_PIN_2,    // DIO pin number
};

tm1637_init(&seg);
tm1637_str(&seg, "1234");

๐Ÿงฐ API Overview

Function Description
tm1637_init() Initializes the TM1637 display driver
tm1637_brightness() Sets brightness level (0โ€“8)
tm1637_seg() Configures number of active 7-segment digits
tm1637_raw() Displays raw segment data buffer
tm1637_str() Displays a string on the display
tm1637_printf() Displays formatted text using printf style
tm1637_clear() Clears all digits (turns off all segments)

๐ŸŽฅ Example & Demo Video ( Previous Version )


๐Ÿ’– Support

If you find this project useful, please โญ the repo and consider supporting me:

  • GitHub
  • YouTube
  • Instagram
  • LinkedIn
  • Email
  • Ko-fi

๐Ÿ“œ License

Licensed under the terms in the LICENSE.

nimaltd/tm1637 | GitHunt