JohnDoneth / hd44780-driver

Implementation of the embedded-hal traits for the HD44780.
MIT License
37 stars 40 forks source link

Add I2C support #12

Closed nils-van-zuijlen closed 4 years ago

nils-van-zuijlen commented 4 years ago

I2C backpacks are available for HD44780 LCDs. They are mostly found in projects where the micro-controller does not have many pins or where an I2C bus is already in use.

A schematic for these backpacks can be found at https://www.electroschematics.com/arduino-i2c-lcd-backpack-introductory-tutorial/

It could be implemented by using a FourBitBus over I2C and by adding other controls for the RS, RW, E and BT (backlight) bits.

An Arduino library for driving LCD modules using these backpacks is available at https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library for reference

JohnDoneth commented 4 years ago

Closed by #13

mpbraendli commented 4 years ago

Very happy to have discovered this! The fact that the i2c backpacks are supported is however not mentioned in the README, and it took me some searching to find out. Looking forward to trying out your library, many thanks!

JohnDoneth commented 4 years ago

@mpbraendli Thanks for the feedback! I'll put that in the README for future users.

mpbraendli commented 4 years ago

I found out that I had a different i2c backpack, with an MCP23008 expander (adafruit sells those). I've added support here and I feel I'm close but not quite there yet:

mcp23008

This is supposed to show the customary "hello world"...

Would you perchance have an idea that could help me further? Did you ever see similar behaviour with your screens?

One thing I noticed:

In [1]: bin(ord('d'))                                                                                                                                                                                                                                                   
Out[1]: '0b1100100'

In [2]: bin(ord('l'))                                                                                                                                                                                                                                                   
Out[2]: '0b1101100'
JohnDoneth commented 4 years ago

@mpbraendli Interesting! I would try playing with the timing and seeing if that fixes it.

mpbraendli commented 4 years ago

There was an issue with my wiring that led to this half-working/half-broken state. It works fine now.

I've also improved documentation a bit, if you wish to take these modifications you can pull them from https://github.com/mpbraendli/hd44780-driver

Thanks again!

piegamesde commented 4 years ago

Please make a new release so that the i2c support actually shows up in the docs on crates.io

JohnDoneth commented 4 years ago

@piegamesde Thanks for the reminder, you can watch this issue #25 for the release.

piegamesde commented 4 years ago

Thx