Once your code is working lets add a method to init our RGB controller, also we will need a method to set the color of the Display :
void setRGBColor(I2CCONTEXT *rgb, int r, int g, int b)
{
writeByteRegister(rgb->file, REG_RED, r);
writeByteRegister(rgb->file, REG_GREEN, g);
writeByteRegister(rgb->file, REG_BLUE, b);
}
void initRGB(I2CCONTEXT *rgb)
{
// backlight init
writeByteRegister(rgb->file, REG_MODE1, 0);
// set LEDs controllable by both PWM and GRPPWM registers
writeByteRegister(rgb->file, REG_OUTPUT, 0xFF);
// set MODE2 values
writeByteRegister(rgb->file, REG_MODE2, 0x20);
// set the baklight Color to white :)
setRGBColor(rgb, 0xFF, 0xFF, 0xFF);
}
Add another method to turn off the light upon program exit: