LCD Library

mellis: great to hear.

Hi,

I'm planning to include a LiquidCrystal library in Arduino 0012. The API mirrors the Wiring one

I would suggest to add another command that allows switching the cursor to
Off - 0x0C
On - 0x0E
Blinking - 0x0F

Is it useful to be able to switch the display off completely? (0x08)
Then it could be wrapped into a single function:
displayMode(boolean displayOnOrOff, boolean cursorOnOrOff, boolean cursorBlinkOrStatic);

That would make the Lib complete...
Eberhard

Me again,
I looked at the code and it supports only 1-line displays?
Most displays are 2 and 4 lines I think. There should be a way initialize the display for that.

Eberhard

I'm planning to include a LiquidCrystal library in Arduino 0012. It will support both 4 and 8 bit modes (though is there any reason you'd want to use the 8-bit one?). The API mirrors the Wiring one (http://wiring.org.co/learning/libraries/LiquidCrystal/index.html) - using the same print() and println() functions as the Serial class. The code is at: Arduino Starter Kit kaufen [verschiedene Ausführungen]

The interface for the wiring lcd library is not as friendly as I would hope for the arduino. The init routine doesn't allow for fine enough control of the location of the data pins, and it does not have any way to set the number of lines on the display. Also it doesn't have any way to send arbitrary control codes (or any high level interface to the functions on the LCD)

I would think that the interface could look somewhat like this:

class LCD {
LCD(int numLines, int ePin, int rwPin, int rsPin, int d4Pin, int d5Pin, int d6Pin, int d7Pin);
LCD(int numLines, int ePin, int rwPin, int rsPin, int d0Pin, int d1Pin, int d2Pin, int d3Pin, int d4Pin, int d5Pin, int d6Pin, int d7Pin);
init();
clear();
enable();
disable()
cursorMode(int mode);
cursorTo(int row, int column);
commandWrite(int value);

// print() and println() functions as in serial

}

notice that which constructor you use will set either 4bit or 8bit mode

Another thing that we could do would be to make Serial, SoftwareSerial and LCD all inherit from a common base class. That way all the number printing routines and such would only have to be implemented once. This might cost space if only one of the 3 was used, but we might wave space when using 2 or more.

I've been doing multiline support the way that wiring does: not explicitly configuring it that way, but allowing you to move the cursor to any line you want. I can write to all the lines on the 2 and 4 line displays I have.

gradbert: The constructor for the LiquidCrystal library on Arduino will be basically what you suggest. The rest of the API will mirror Wiring's, although we could certainly add some functions (either now or later).

Ok, I figured code speaks louder than words, so I took the LCD4bit library and combined it with the code from SoftwareSerial. The constructor it the interface described previously. It has the most of the same print() and println() functions as SoftwareSerial. The print(uint8_t) is replaced with rprint(uint8_t). something with the casting was giving me grief. All the printing functions have been moved to a class called Printable. the LCDnew class only has to implement rprint(). I don't have the carrage return/line feed handling implemented in the LCD class yet.

check it out at http://www.gradbert.org/ldcnew.zip

I still need to do some work on this but I figure some early feedback would be good

hi gradbert, I am looking forward to trying your LCD library but your site is not responding.

gradbert: cool. I actually did something similar (see: Arduino Starter Kit kaufen [verschiedene Ausführungen]), but you've got some nice improvements. I like the name Printable better than Print, which is what I used. Also, did you get this to work on the Arduino? I had trouble getting virtual functions to compile, so I hacked together my own version.

hi gradbert, I am looking forward to trying your LCD library but your site is not responding.

I should be more careful posting late at night. The correct url is http://www.gradbert.org/lcdnew.zip

gradbert: cool. I actually did something similar (see: Arduino Starter Kit kaufen [verschiedene Ausführungen]), but you've got some nice improvements. I like the name Printable better than Print, which is what I used. Also, did you get this to work on the Arduino? I had trouble getting virtual functions to compile, so I hacked together my own version.

I did get it working. In the zip file is an example program that will compile, download, and display on an lcd. The only thing that was really giving me a problem was that the build doesn't seem to be very happy with a library including another library, so in my sketch I have to explicitly include <Printable.h>.

Now because the pin assignments are local to the instance of the object, I should be able to hook up two lcd displays at once. If I have some time this week, I will make a second lcd cable and try it.

Here is a pic of an arduino driving two lcd's at once using the lcd library i have been playing with

(the small circuit board on the protoboard is a 3 axis accelerometer, for another project)

I have the println() methods working now. The new version is at http://www.gradbert.org/lcdnew.zip

will this work with serial-enabled LCDs?

no, this is for paralele interfaced LCD's with the hitachi chipset.

will this work with serial-enabled LCDs?

I have a library for an LCD driven by Software Serial. The command codes are for a PH Anderon controller chip, but they would be trivially easy to edit.

http://www.wulfden.org/downloads/code/arduino/SWSerialLCDPHA_Lib.zip

cheers ... BBR

It will support both 4 and 8 bit modes (though is there any reason you'd want to use the 8-bit one?).

Isn't there some non-trivial speed difference between the two methods? (From memory, not personal experience.)

--Phil.

I have a library for an LCD driven by Software Serial. The command codes are for a PH Anderon controller chip, but they would be trivially easy to edit.

http://www.wulfden.org/downloads/code/arduino/SWSerialLCDPHA_Lib.zip

cheers ... BBR

I must thank everyone so far for their efforts for a unified 8 and 4-bit library, but wouldn't it be prudent to also support a serial version of this new library? I was thinking of just an undertaking...but many wonderful people here have already started and I wouldn't dream of encroaching upon their work :slight_smile:

As far as I know, different serial LCDs have different protocols, which makes it hard to write a single library to talk to them. But if anyone wants to take a shot at creating a nice system for supporting multiple protocols and selecting between them, that would be cool.

What's the process for the code getting merged into the other 4/8bit hitachi and/or serial LCD librar(ies)?

Also.. Please provide a clear hookup diagram for your version.. I've seen a half dozen different hookup configs.. none of which are compatible with each other.

Tweeks

Good point on the diagram.

The LiquidCrystal library in Arduino 0012 will support both 4 and 8 bit. For the moment, there's no serial support, since I guess every Serial LCD has a different interface. The playground is publicly editable, but you should probably coordinate with whoever posted the version you want to modify / improve.