ex_lcd icon indicating copy to clipboard operation
ex_lcd copied to clipboard

Using an I2C controller with ex_lcd

Open juhalehtonen opened this issue 8 years ago • 5 comments

Currently the ex_lcd docs only show an example for using through GPIO, and the config requires many GPIO pins to be configured although an I2C controller would not require as many pins to be used. How would one go about interacting with an LCD screen through an I2C controller using the ex_lcd library, or is that even considered / possible?

Apologies if the issue is outside of scope or otherwise silly. I'm far from familiar when it comes to hardware, but love the ex_lcd library already.

juhalehtonen avatar Dec 03 '17 10:12 juhalehtonen

Hey there, I am also interested in using I2C to control an LCD display - specifically the 1602 backpack.

I've found a python implementation of a driver here which will serve as a good reference for implementing it.

I can have a stab at creating it today/tomorrow - let's see how well I do :)

astutecat avatar Mar 22 '18 13:03 astutecat

Thanks for the update and for the link to the driver @astutecat ! I also had the 1602 in mind when I created this issue. If you happen to advance on this front over the coming days (or whenever you find the time), I'll be more than happy to test things out and help out any way I can :)

juhalehtonen avatar Mar 22 '18 19:03 juhalehtonen

I made some progress, mainly figuring my way around how the LCD receives commands. This is also a useful reference, it includes a C++ implementation of the driver which appears to be a bit more comprehensive - http://www.geeetech.com/wiki/index.php/Serial_I2C_1602_16%C3%972_Character_LCD_Module

more to follow, hoping to get some actual coding done this weekend

astutecat avatar Mar 23 '18 15:03 astutecat

Hey @astutecat , a belated thanks for the follow-up. Have you happened to make any further progress on this in the past months?

juhalehtonen avatar Jun 03 '18 08:06 juhalehtonen

I also invested some time into this and I think I have a working piece of code. In the end I decided its not really worth the time and abandoned the I2C interface. Essentially, I2C is doing the same thing as the normal 4-bit mode of the LCD module. The only difference is that one has to write a full byte to the I2C "port". The first 4 bits are the 4 bits to be sent to the device, the last 4 bits are flags for EN, RS and so on. So when sending data, you wouldn't first set high on the RS GPIO port, but simply set the relevant RS bit when sending the data. pulse_en also works slightly different.

As I said, I didn't test my code… it compiles and when comparing it to the Python implementation, it looks like it should work.

If anyone wants to invest more time, here is what I have so far: https://gist.github.com/Strayer/c2b6c39f6939b4d14b7f66d25e5807eb

strayer avatar Sep 19 '18 11:09 strayer