I2C interface to LCD display

Does anyone have sample code to show how to use an LCD panel in Java? We have a 4 line display that we’d like to get working.
I’ve seen the edu.wpi.first.wpilibj.I2C class. It seems to be a lot lowerlevel than what I’ve done before – just pushing bytes to addresses (we’d like to be able to send a string to display on line 2).

I tried searching for code, but only found people using the DriverStationLCD or interfacing to an Arduino.

Thanks.

I’ve never done any work with I2C in FIRST before, but I’ve used it a bit for other projects. A brief overview of how I2C works:
I2C allows you to connect a single master device to one or more slave devices. Each slave device has an address (built into its hardware, although sometimes configurable), which is how the master device specifies what it is talking to (this also means that if you try to connect to two slave devices with the same built in address on the same I2C bus, you will run into problems). Each slave device has a set of registers, each assigned a number. The master device is able to send read and write commands to read the value from a register on a slave or to write a value to a register on a slave. Physically, an I2C bus has two wires, which connect all the devices together, one clock (SCL) that alternates high and low to keep all the devices going at the same speed and one data (SDL) used to transmit data. Because there is only one data line, the slave devices are not allowed to ‘say’ anything unless they are first ‘spoken to’ by the master device in order to prevent multiple devices signaling at the same time.

You will probably have to use the I2C class, unless you can find another team who has used the same display before and can give you their code. Most I2C displays will have different interfaces from each other, so it is unlikely that there is already a class for this display.

The first step will be to look up the datasheet for your display; if you bought it online wherever you got it from should have it available for download, otherwise you should be able to find one by looking up its part number. The datasheet should say what the address of the device is and what to put into which registers to get it to display text (you’ll probably end up converting whatever string you want to write into bytes and and writing it into a register/splitting it between a few registers).

If you post a link to the datasheet I or someone else can give you more specific help on how to write to it. Some one with prior experience using I2C in wpilib could give you more specific code help, but if necessary I can read through the docs on it.

This is the one that we have. It already has all of the I2C hardware attached at the back

http://ecx.images-amazon.com/images/I/51oyuj2JGcL.jpg

I’ve gotten it working in Python with the Raspberry Pi no problem.

Thanks for your help. We’ll probably just mess around with it. I was hoping to find source code in Java for it.

Check the pi4J project - I wrote an I2C lcd implementation for that I believe. I know thats for use on the raspberry pi but really you would just take the code and adapt it to the wpi i2c class.