Close

IIC Communications

A project log for RGB LCD Backpack Addon

Additional IIC backpack for the IIC LCD backpack

smartroadsmartroad 09/01/2019 at 17:460 Comments

I have added the current firmware for the backpack. It uses the FastLED library to enable some features. Due to a small mistake on my PCB design I forgot to add in the solder jumpers to enable the device to change it's IIC address, which is currently hard coded to 0x30. Of course this can be changed in code if it is a problem, however jumpers would enable an easier change should it conflict.

The current code enables turning the backlight off and 4 other modes to set the colour. These modes are:

Here is a chart for the command structure:

As indicated when setting hue, saturation, brightness, red, green or blue values they can be anything in the range of 0-255, allowing a full 16 million colour palette.

When sending a command standard IIC commands need to be sent, first the address, then the command and finally up to 3 bytes of data (depending on the command).

Using Arduino to tell the board to show red you could do:
  Wire.beginTransmission(0x30); // device address
  Wire.write(4);                // RGB command
  Wire.write(255);              // sends red byte
  Wire.write(0);                // sends green byte
  Wire.write(0);                // sends blue byte
  Wire.endTransmission();       // stop transmitting

Given FastLED starts it's hue spectrum at red (https://github.com/FastLED/FastLED/wiki/Pixel-reference) you could send:

  Wire.beginTransmission(0x30); // device address
  Wire.write(1);                // RGB command
  Wire.write(0);                // sends hue byte
  Wire.endTransmission();       // stop transmitting 

One other feature of the code is that the unit stores the last colour settings in EEPROM (there is a 5 second delay after the last change to reduce wear on the EEPROM). So when the board powers up it will recall the last colour it was set on. That way it could be used to setup the colour you want but also be used on something that doesn't have the ability to interface with the board.

Discussions