http://www.youtube.com/watch?v=IpwqGJwn1FY
After looking through the modified LiquidCrystal library for use with the i2c backpack and darn near crying when I saw all the faux digitalRead() and pinMode() being done on each transfer, I was bound and determined to never let that happen to another friendly Arduino user again. I first made a proof of concept modification to the library to "burst" all the "LiquidCrystal::send" bits instead of digitalWrite()'ing them out one at a time (read I2C, modify, write... read, modify, write... read, modify, write... read, modify, write - over 16 I2C commands for each single character). It worked great. I could do animation on the screen once again, and it was smooth.
OK, so the next step... package it up into something usable. I kept running into issues where Wire.h needed to be part of every program I use LiquidCrystal with. It just had to be "forked" to its own library. I'm sure C++ will allow a typedef alias for any libraries/sketches that have LiquidCrystal hard-coded into them... I just haven't had a need yet. I fully gutted LiquidCrystal of all functions relating to digitalRead/digitalWrite, and made it 100% pure i2c. What a sleek beauty... just watch the video.
Of course, next on my to-do list is a proper animation library for character LCDs.
LiquidTWI library is attached to this post, also mirrored here: http://dl.dropbox.com/u/35284720/postfi ... uidTWI.rar
Hope it helps!
Changelog:
- 1.1 / 6-17-2011:
Oops... initial bugchecking was done on one program (performance test). LCD_DISPLAYCONTROL functions were sending bit 7 (backlight) to the LCD as part of the command, invalidating most commands and setting the cursor to address 0 instead of doing their function. That also screwed up the initialization routine something fierce. A miracle this slipped by testing. - 1.0 / 6-12-2011:
Initial release
Distributed with as free-will a license as is available given this code's long associative chain of licenses (LiquidCrystal -> Arduino -> Wiring -> ...?). Use it in any way you feel fit, profit or free, provided it fits in the licenses of its associated works.
Usage:
- Code: Select all
Attach CLK pin to ANALOG 5 pin (remember: analog pins double as digital!),
Attach DAT pin to ANALOG 4 pin,
Give it 5V using 5V pin,
Then, GND it with GND pin, and you're all set!
LiquidTWI lcd(0);
void setup() { lcd.begin(16,2); }
void loop() { lcd.print("Happy!"); delay(500); lcd.clear(); delay(500); }
If you changed the i2c address of the board (multiple LCDs? I dig it!), set "lcd(0)" to your new 3-bit address. If you have more than a 16x2 LCD, change "lcd.begin(16,2)" to reflect the columns and rows of your LCD.

