Skip to content

This project demonstrates how to communicate with a 2.4" TFT LCD using the ILI9341 controller via SPI interface on the STM32F407 microcontroller. It's built for learning purposes, focusing on how SPI communication works and how to interface with graphical displays at a low level.

License

Notifications You must be signed in to change notification settings

dchithinh/stm32f407xx_pomodoro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ… STM32F407 Pomodoro Timer with ILI9341 LCD

A Pomodoro Timer application built for the STM32F407 microcontroller with a 2.4" ILI9341 TFT LCD display and LVGL graphics library. This project demonstrates embedded GUI development, SPI communication, and real-time timer functionality.

Project Demo

๐Ÿ“‹ Table of Contents


โœจ Features

  • ๐Ÿ… Full Pomodoro Timer functionality (25min work, 5min break cycles (Configurable) )
  • ๐Ÿ“ฑ Touch-enabled GUI with LVGL graphics library
  • ๐Ÿ–ฅ๏ธ 2.4" ILI9341 LCD display (240x320 resolution)
  • ๐Ÿ”ง Modular code structure with separated concerns
  • ๐Ÿ› UART debugging support with formatted logging
  • โšก Multiple clock configurations (16MHz HSI, 84MHz, 168MHz)
  • ๐ŸŽจ Beautiful UI with progress indicators and animations
  • ๐Ÿ”„ Touch cursor debugging for input validation
  • ๐Ÿ“Š Statistics tracking for completed sessions

๐ŸŽฏ Project Overview

This project was built for learning purposes, focusing on:

  • Embedded GUI development with LVGL
  • SPI communication with LCD displays
  • Real-time timer applications
  • STM32 HAL library usage and best practices
  • Modular embedded software architecture

The Pomodoro Technique is a time management method that uses 25-minute work intervals followed by short breaks, helping improve focus and productivity.


๐Ÿ–ฅ๏ธ Try Before You Build - Windows Simulator

Want to experience the Pomodoro app before building the hardware?

Check out MicroPomo - a Windows simulator that runs the exact same Pomodoro application with identical UI and functionality. This allows you to:

  • ๐ŸŽฎ Test the complete user interface and timer functionality
  • ๐Ÿ” Explore all features without any hardware setup
  • ๐Ÿ“ฑ Experience the touch interactions using mouse input
  • โšก Quick evaluation before investing in STM32 hardware
  • ๐ŸŽฏ Perfect for demonstrations and proof-of-concept

The simulator uses the same LVGL code base, providing an authentic preview of what you'll get on the actual STM32 hardware.

๐Ÿ‘‰ Try MicroPomo Simulator Now


๐Ÿ› ๏ธ Hardware Requirements

Component Specification Notes
Microcontroller STM32F407VGT6 ARM Cortex-M4, 168MHz
Display 2.4" ILI9341 LCD 240x320, SPI interface
Touch Controller XPT2046 SPI touch controller
Development Board STM32F4 Discovery Or compatible STM32F407 board
Power Supply 5V For LCD backlight
Debugger ST-Link/V2 For programming and debugging

๐Ÿ”Œ Hardware Connections

LCD Display Connections (SPI2)

LCD Pin STM32F407 Pin Function Notes
VCC 5V Power Supply External 5V required
GND GND Ground Common ground
CS PB9 Chip Select Active low
RESX PD10 Reset Active low
DCX PD9 Data/Command Data=1, Command=0
SDI/MOSI PB15 SPI MOSI SPI2 data out
SDO/MISO PC2 SPI MISO Optional for reading
SCK PB13 SPI Clock SPI2 clock
LED 5V Backlight Always on

Touch Controller Connections (SPI1)

Touch Pin STM32F407 Pin Function Notes
T_CLK PA5 Touch SPI Clock SPI1_SCK
T_CS PA15 Touch Chip Select Manual GPIO control
T_DIN PA7 Touch Data In SPI1_MOSI
T_DO PA6 Touch Data Out SPI1_MISO
T_IRQ PA8 Touch Interrupt GPIO input

Debug UART (USART2)

UART Pin STM32F407 Pin Function Notes
TX PA2 Debug output USART2_TX (AF7)
RX PA3 Debug input USART2_RX (AF7)

โš™๏ธ Software Requirements

  • STM32CubeIDE Version: 1.17.0
  • STM32CubeMX (for configuration)
  • STM32 HAL Library (included)
  • LVGL v9.4.0 (included as submodule)
  • Git (for cloning repository)

๐Ÿš€ Getting Started

Prerequisites

  1. Install STM32CubeIDE from STMicroelectronics website
  2. Install Git for version control
  3. Have your STM32F407 board and ILI9341 LCD ready

Installation

  1. Clone the repository:

    git clone https://github.com/dchithinh/stm32f407xx_pomodoro.git
    cd stm32f407xx_pomodoro
  2. Initialize LVGL submodule:

    git submodule update --init --recursive
  3. Open in STM32CubeIDE:

    • File โ†’ Import โ†’ Existing Projects into Workspace
    • Select the project folder

Building the Project

  1. Configure build:

    • Right-click project โ†’ Properties โ†’ C/C++ Build
    • Select your preferred configuration (Debug/Release)
  2. Build the project:

    • Press Ctrl+B or use Project โ†’ Build Project

Flashing to MCU

  1. Connect ST-Link debugger to your STM32F407 board
  2. Flash the firmware:
    • Right-click project โ†’ Run As โ†’ STM32 C/C++ Application
    • Or use the debug configuration for development

๐Ÿ“– Usage

  1. Power on the system
  2. Touch the screen to interact with the Pomodoro timer
  3. Start a session by tapping the start button
  4. Monitor progress through the circular progress indicator
  5. Take breaks when prompted between work sessions
  6. View statistics to track your productivity

Debug Output

Connect a USB-to-TTL adapter to UART2 pins (PA2/PA3) to see debug output:

  • Baud rate: 115200
  • Data bits: 8
  • Stop bits: 1
  • Parity: None

๐Ÿ—๏ธ Project Structure

stm32f407xx_pomodoro/
โ”œโ”€โ”€ ๐Ÿ“ Core/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Inc/           # Header files
โ”‚   โ”‚   โ”œโ”€โ”€ main.h
โ”‚   โ”‚   โ”œโ”€โ”€ clock_config.h
โ”‚   โ”‚   โ””โ”€โ”€ debug_utils.h
โ”‚   โ””โ”€โ”€ ๐Ÿ“ Src/           # Source files
โ”‚       โ”œโ”€โ”€ main.c
โ”‚       โ”œโ”€โ”€ clock_config.c
โ”‚       โ””โ”€โ”€ debug_utils.c
โ”œโ”€โ”€ ๐Ÿ“ bsp/              # Board Support Package
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ lcd/          # LCD driver
โ”‚   โ””โ”€โ”€ ๐Ÿ“ lvgl/         # LVGL port
โ”œโ”€โ”€ ๐Ÿ“ lvgl/             # LVGL library (submodule)
โ”œโ”€โ”€ ๐Ÿ“ Drivers/          # STM32 HAL drivers
โ”œโ”€โ”€ ๐Ÿ“ Doc/              # Documentation and images
โ””โ”€โ”€ ๐Ÿ“„ README.md         # This file

๐Ÿ”ง Configuration

Clock Configuration

The project supports multiple clock configurations in clock_config.h:

// Uncomment one of the following:
// #define USE_HSI_16MHZ    1    // 16MHz HSI
// #define USE_HSI_84MHZ    1    // 84MHz PLL
// Default: 168MHz HSE PLL

Display Configuration

Display settings are configured in bsp/lcd/config.h:

  • Resolution: 240x320
  • Color depth: 16-bit RGB565
  • Orientation: Portrait/Landscape

Debug Configuration

Debug features can be enabled/disabled in debug_utils.h:

  • UART logging: Enable/disable debug output
  • Touch cursor: Visual touch point indicator

๐Ÿ“š Technical Notes

SPI Communication

The project uses SPI2 for LCD communication with the following settings:

  • Mode: Full-duplex master
  • Clock polarity: Low (CPOL=0)
  • Clock phase: 1st edge (CPHA=0)
  • Data size: 8-bit
  • MSB first

LVGL Integration

  • Version: LVGL v9.4.0
  • Color depth: 16-bit (RGB565)
  • Memory: Static allocation
  • Input: Touch controller integration

Known Issues

  1. SPI Read Operations: Unable to read LCD ID/status registers reliably
  2. 16-bit HAL SPI: Issues with 16-bit transfers using HAL API
  3. Touch Input Lag: On first touch at a new position, the system may respond to the previous touch location. A second touch is required to register the correct position.
  4. System Stability at 168MHz: When using 168MHz system clock configuration, the system occasionally hangs or generates hard faults. Consider using 84MHz configuration for more stable operation.

๐Ÿค Contributing

๐Ÿ’ก Fun Fact

I'm an embedded developer, not a UI/UX designer - so the UI in this app may not be that great! ๐Ÿ˜… Feel free to improve the user interface and make it more beautiful. The original purpose of this project was to learn LVGL, STM32 HAL, and SPI communication - and I'm always excited to see how the community can enhance it further!


Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Contribution Guidelines

  • Follow the existing code style
  • Add comments for complex functions
  • Test your changes thoroughly
  • Update documentation as needed

๐Ÿ™ Acknowledgments


๐Ÿ“ฌ Contact


โญ Star this repository if you found it helpful!

About

This project demonstrates how to communicate with a 2.4" TFT LCD using the ILI9341 controller via SPI interface on the STM32F407 microcontroller. It's built for learning purposes, focusing on how SPI communication works and how to interface with graphical displays at a low level.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published