Skip to content
This repository was archived by the owner on Feb 25, 2021. It is now read-only.

Commit 9b8e65f

Browse files
author
Johannes Formann
committed
only write on I2C if something changed
1 parent ab3238f commit 9b8e65f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,11 @@ bool FXL6408_getDigitalInput(uint8_t port) {
158158
}
159159

160160
void FXL6408_setDigitalOutput(uint8_t port, bool state) {
161+
uint8_t old = fxl6408_outputRegister;
161162
fxl6408_outputRegister = FXL6408_setBit(fxl6408_outputRegister, port, state);
162-
FXL6408_setByteI2C(0x05, fxl6408_outputRegister);
163+
if (old != fxl6408_outputRegister) {
164+
FXL6408_setByteI2C(0x05, fxl6408_outputRegister);
165+
}
163166
};
164167

165168
uint8_t FXL6408_getByteI2C(int i2cregister) {

0 commit comments

Comments
 (0)