Skip to content

Latest commit

Β 

History

History
65 lines (49 loc) Β· 1.98 KB

File metadata and controls

65 lines (49 loc) Β· 1.98 KB

STM32 I2C LCD Library

πŸ“‹ Overview A portable, efficient library for interfacing HD44780-compatible LCD displays (16x2, 20x4, etc.) via I2C backpack (PCF8574) with STM32 microcontrollers. Built on STM32 HAL for maximum compatibility across STM32 series (L4, F4, F1, etc.).

✨ Features Feature Description πŸš€ 4-Bit Mode Efficient I2C communication using 4-bit mode, minimizing pin usage πŸ–₯️ Multi-Display Support Compatible with 16x2, 20x4, and other HD44780 LCD modules πŸ”§ Simple API Intuitive functions for text display, cursor control, and display management πŸ”„ HAL Abstraction Clean abstraction layer using STM32 HAL I2C πŸ“± Cross-Platform Easily portable across STM32 series (L4, F4, F1, etc.) ⚑ Lightweight Minimal resource consumption, perfect for constrained environments πŸš€ Quick Start Prerequisites STM32CubeIDE / STM32CubeMX

Configured I2C peripheral (e.g., I2C1, I2C2)

I2C LCD backpack (PCF8574 typically at 0x27 or 0x3F)

Installation Steps Add Library Files to your STM32 project:

c // Copy these files to your project source folder: lcd_i2c_hal.c lcd_i2c_hal.h Include Header in your main application:

c #include "lcd_i2c_hal.h" Configure I2C using CubeMX:

Enable I2C peripheral

Configure appropriate pins

Set clock speed (typically 100kHz)

Initialize and Use:

c // External I2C handle (defined by CubeMX) extern I2C_HandleTypeDef hi2c1;

// LCD handle LCD_HandleTypeDef lcd;

// Initialize LCD (address 0x27, 16 columns, 2 rows) LCD_I2C_Init(&lcd, &hi2c1, 0x27, 16, 2);

// Display text LCD_I2C_Print(&lcd, "Hello, STM32!"); LCD_I2C_SetCursor(&lcd, 0, 1); LCD_I2C_Print(&lcd, "I2C LCD Demo");