LiquidTWI: High-performance LCD library for I2C Backpack Module, FalconFour writes –
I like fast things. And I like clean code. Often, the two go hand-in-hand 😉
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://hostfile.org/LiquidTWI.rar
i2c / SPI character LCD backpack. LCD backpacks reduce the number of pins needed to connect to an LCD. LCDs are a fun and easy way to have your microcontroller project talk back to you. Character LCDs are common, and easy to get, available in tons of colors and sizes. (or similar microcontroller) but find that the number of pins necessary to control the LCD can be restrictive, especially with ambitious projects. We wanted to make a ‘backpack’ (add-on circuit) that would reduce the number of pins without a lot of expense.
By using simple i2c and SPI input/output expanders we have reduced the number of pins (only 2 pins are needed for i2c) while still making it easy to interface with the LCD. For Arduino users, we provide a easy-to-use library that is backwards compatible with projects using the ‘6 pin’ wiring.
This backpack will work with any ‘standard’ character LCD, from 8×1 to 40×4 sizes! As long as they have a 16-pin single-line connection header at the top. We carry a few LCDs that work great.
For advanced users, this project can be used for general purpose I/O expansion, the MCP23008 has 8 i/o pins (7 are connected) with optional pull-ups, the SPI 74HC595 has 7 connected outputs.
In stock and shipping now from the Adafruit store!