Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
lcd.c File Reference

LCD driver for 20x4 I2C display. Adapted from SunFounder example. More...

#include "lcd.h"

Macros

#define LCD_BACKLIGHT   0x08
#define LCD_ENABLE   0x04
#define LCD_RW   0x00
#define LCD_RS   0x01

Functions

void lcd_send_command (uint8_t cmd)
 Sends a command byte to the LCD.
void lcd_send_data (uint8_t data)
 Sends a data byte (character) to the LCD.
void lcd_force_backlight_on (void)
 Forces the LCD backlight to turn on.
void lcd_init (void)
 Initializes the LCD in 4-bit mode.
void lcd_clear (void)
 Clears the LCD display.
void lcd_set_cursor (uint8_t row, uint8_t col)
 Sets the LCD cursor to the specified position.
void lcd_print (char *str)
 Prints a string to the LCD display.

Detailed Description

LCD driver for 20x4 I2C display. Adapted from SunFounder example.

Date
May 22, 2025
Author
Andrew Carr and Kai De La Cruz
Note
Modified for STM32 HAL and tailored for 20x4 LCD output.

Function Documentation

◆ lcd_force_backlight_on()

void lcd_force_backlight_on ( void )

Forces the LCD backlight to turn on.

Forces the LCD backlight to remain on.

◆ lcd_init()

void lcd_init ( void )

Initializes the LCD in 4-bit mode.

Initializes the LCD in 4-bit I2C mode.

◆ lcd_print()

void lcd_print ( char * str)

Prints a string to the LCD display.

Prints a null-terminated string to the LCD.

Parameters
strNull-terminated character string

◆ lcd_send_command()

void lcd_send_command ( uint8_t cmd)

Sends a command byte to the LCD.

Parameters
cmdCommand byte

◆ lcd_send_data()

void lcd_send_data ( uint8_t data)

Sends a data byte (character) to the LCD.

Parameters
dataData byte

◆ lcd_set_cursor()

void lcd_set_cursor ( uint8_t row,
uint8_t col )

Sets the LCD cursor to the specified position.

Sets the LCD cursor to a specific row and column.

Parameters
rowRow index (0–3)
colColumn index (0–19)