View Single Post
  #14   Spotlight this post!  
Unread 25-04-2009, 10:57
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: anyone else use the I2C bus?

We used the I2C bus for our LCD menu system. Our display was purchased from New Haven Display. This was the only device we attempted to use.

Quote:
Originally Posted by Dave Flowerday View Post
1) The I2C driver in WPIlib forces you to use a certain I2C "protocol" where the register address is always sent and then you can read or write up to 4 bytes. I would have preferred if it didn't impose this register address protocol on us (there's no reason in our application that we couldn't have issued a read without first writing a register address). This wouldn't impact you though since the Devantech sensors appear to use this fairly-standard protocol.
We had a rather difficult time with this as well. From what I noticed, we could only send a register address and one byte of data. The LCD we used doesn't follow this scheme, but we were lucky in that every command starts with a 0xFE byte followed by another byte to identify the command. We just used 0xFE as the register address, so it looked like this:

Code:
...
	static const UINT8 kCommandPrefix = 0xFE;
...

/**
 * Send a command (without any parameters) to the LCD.
 * 
 * @param command The command to send.
 */
void LCD::SendCommand(UINT8 command)
{
	m_i2c->Write(kCommandPrefix, command);
}

From there on, we could only send a limited amount of commands (only those that did not require any parameters). Rather than asking the LCD to move the cursor to a specific location we had to keep sending move right/left commands. Also, text could only be written 2 characters at a time.

In the end, it did work, but it's kind of sloppy. I'm hoping that the I2C driver will become a little more flexible in the future.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award