Skip to content

Improve I2C LCD example #675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Windwoes
Copy link

This PR improve the I2C LCD example in the following ways:

  • Extracts driver code to a separate C file for code cleanliness
  • Supports creating multiple instances of the driver so that multiple displays can be driven
  • Improves performance by using better chosen delay values
  • Has functionality to simplify printed formatted strings to the display

The following article was used as a reference for timing: https://web.alfredstate.edu/faculty/weimandn/lcd/lcd_initialization/lcd_initialization_index.html

This code has been tested on real hardware with a Pi Pico.

Fixes #654
Fixes #597

void i2c_lcd_writeString(i2c_lcd_handle inst, char* string);
void i2c_lcd_writeStringf(i2c_lcd_handle inst, const char* __restrict format, ...) _ATTRIBUTE ((__format__ (__printf__, 2, 3)));
void i2c_lcd_writeChar(i2c_lcd_handle inst, char c);
void i2c_lcd_writeLines(i2c_lcd_handle inst, char* line1, char* line2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function-signature seems to be assuming that you're using a 16x2 LCD, and precludes the usage of a 20x4 LCD?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. The example name specifically says it's for 16x2. I also don't have 20x4 hardware to validate against.

@Windwoes Windwoes requested a review from lurch July 22, 2025 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hint for i2c Lcd 1602 example Fixes for several lcd_1602_i2c.c issues
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy