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