@@ -71,18 +71,32 @@ void RGBled::setColor(RGBColors color)
7171 _red = 0x20 ;
7272 }
7373
74- setColor (_blue , _green, _red );
74+ setColor (_red , _green, _blue );
7575
7676}
7777
78- void RGBled::setColor (uint8_t blue, uint8_t green, uint8_t red)
78+ void RGBled::setColorBlue (uint8_t blue) {
79+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT1, blue >> scale_factor);
80+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_COLOR_UPDATE, 0xC5 );
81+ }
82+
83+ void RGBled::setColorRed (uint8_t red) {
84+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT3, red >> scale_factor);
85+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_COLOR_UPDATE, 0xC5 );
86+ }
87+
88+ void RGBled::setColorGreen (uint8_t green) {
89+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT2, green >> scale_factor);
90+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_COLOR_UPDATE, 0xC5 );
91+ }
92+
93+ void RGBled::setColor (uint8_t red, uint8_t green, uint8_t blue)
7994{
8095 // set rgb led current
81- writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT1, blue); // maximum current
82- writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT2, green);
83- writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT3, red);
96+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT1, blue >> scale_factor ); // maximum current
97+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT2, green >> scale_factor );
98+ writeByte (IS31FL3194_ADDRESS, IS31FL3194_OUT3, red >> scale_factor );
8499 writeByte (IS31FL3194_ADDRESS, IS31FL3194_COLOR_UPDATE, 0xC5 ); // write to color update register for changes to take effect
85-
86100}
87101
88102// Read the Chip ID register, this is a good test of communication
@@ -141,7 +155,7 @@ void RGBled::writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
141155uint8_t RGBled::readByte (uint8_t address, uint8_t subAddress)
142156{
143157 nicla::i2c_mutex.lock ();
144- char response = 0xFF ;
158+ // char response = 0xFF;
145159 Wire1.beginTransmission (address);
146160 Wire1.write (subAddress);
147161 Wire1.endTransmission (false );
0 commit comments