File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -39,14 +39,16 @@ class XL9555_IN : public I2cDevice {
3939
4040 void SetOutputState (uint8_t bit, uint8_t level) {
4141 uint16_t data;
42+ int index = bit;
43+
4244 if (bit < 8 ) {
4345 data = ReadReg (0x02 );
4446 } else {
4547 data = ReadReg (0x03 );
46- bit -= 8 ;
48+ index -= 8 ;
4749 }
4850
49- data = (data & ~(1 << bit )) | (level << bit );
51+ data = (data & ~(1 << index )) | (level << index );
5052
5153 if (bit < 8 ) {
5254 WriteReg (0x02 , data);
Original file line number Diff line number Diff line change @@ -28,14 +28,16 @@ class XL9555 : public I2cDevice {
2828
2929 void SetOutputState (uint8_t bit, uint8_t level) {
3030 uint16_t data;
31+ int index = bit;
32+
3133 if (bit < 8 ) {
3234 data = ReadReg (0x02 );
3335 } else {
3436 data = ReadReg (0x03 );
35- bit -= 8 ;
37+ index -= 8 ;
3638 }
3739
38- data = (data & ~(1 << bit )) | (level << bit );
40+ data = (data & ~(1 << index )) | (level << index );
3941
4042 if (bit < 8 ) {
4143 WriteReg (0x02 , data);
You can’t perform that action at this time.
0 commit comments