Skip to content

nimaltd/tm1637

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💡 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

2. STM32Cube Pack Installer (Recommended)

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.