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 :
voidsetRGBColor(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); }voidinitRGB(I2CCONTEXT *rgb){// backlight initwriteByteRegister(rgb->file, REG_MODE1,0);// set LEDs controllable by both PWM and GRPPWM registerswriteByteRegister(rgb->file, REG_OUTPUT,0xFF);// set MODE2 valueswriteByteRegister(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: