Go to Post Did our Jaguar swallow a chipmunk, or is something else going on? - Tom Line [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-12-2014, 07:29
RaiderRobotics RaiderRobotics is offline
Registered User
FRC #5024
 
Join Date: Nov 2014
Location: London, Ontario
Posts: 9
RaiderRobotics is an unknown quantity at this point
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.
  #2   Spotlight this post!  
Unread 10-12-2014, 09:15
Nyle's Avatar
Nyle Nyle is offline
Registered User
FRC #0422 (The Mech Tech Dragons)
Team Role: Leadership
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Richmond, Virginia
Posts: 28
Nyle is just really niceNyle is just really niceNyle is just really niceNyle is just really nice
Re: I2C interface to LCD display

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.
  #3   Spotlight this post!  
Unread 10-12-2014, 12:31
RaiderRobotics RaiderRobotics is offline
Registered User
FRC #5024
 
Join Date: Nov 2014
Location: London, Ontario
Posts: 9
RaiderRobotics is an unknown quantity at this point
Re: I2C interface to LCD display

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.
  #4   Spotlight this post!  
Unread 10-12-2014, 16:07
riftware riftware is offline
Parent Mentor
AKA: Andrew Chandler
FRC #0031
Team Role: Mentor
 
Join Date: Dec 2013
Rookie Year: 2011
Location: Tulsa
Posts: 27
riftware is an unknown quantity at this point
Re: I2C interface to LCD display

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.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi