WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

Devantech/LCD03.h

Adds support for the Devantech LCD03 display using I2C.
To use the I2C interface you will need to remove the jumper that selects either serial or I2C. Do this with the power turned off.
LCD03.jpg
The default I2C address for this device is 0xC6. If this clashes with another I2C device then read the LCD03 manual as you can change the address for the device. How to do this is out of the scope of this manual as its not something you should do on the fly. Alternatively: think about using a dedicated software I2C bus to avoid such conflicts - as described in the I2C section of this manual.
Step 1 - Create the device
Lets create an instance of this display called 'lcd03' at the default I2C address. In order to do this we need to reference a 'Writer' which we will define later - so we can forward define it.
MAKE_WRITER(lcd03_put_char); // We will define it later
LCD03_I2C lcd03 = MAKE_LCD03_I2C_At(0xC6,&lcd03_put_char);
Step 2 - Create a Writer
Now we will create the body of the writer and all it does is forward the data to the display:-
MAKE_WRITER(lcd03_put_char){
    return displaySendByte(&lcd03,byte);
}
Step 3 - Create the i2cBus
Now we need to create a list of devices on the I2C bus. If you're already using other I2C devices then you will already be doing this - in which case just add the 'lcd03' to the list.
I2C_DEVICE_LIST PROGMEM i2cMaster_list[] = {
    &lcd03.i2cInfo
};
Given a list we can now create a bus to drive the devices:-
I2C_HARDWARE_BUS i2cMaster = MAKE_I2C_HARDWARE_BUS(i2cMaster_list);
Step 4 - In your code
Once defined you should call displayInit(&lcd03) from appInitHardware and then you can use other display commands as listed in _display_common.h
If that sounds complex then try using Project Designer as it does it all for you!

Valid XHTML 1.0 Transitional