Remove a few temporary variables from sx1509_library.cpp

pull/18/head
Jesse Vincent 10 years ago
parent 80c403aa17
commit 6666ec7f24

@ -468,9 +468,8 @@ byte sx1509Class::readByte(byte registerAddress)
if (timeout == 0) if (timeout == 0)
return 0; return 0;
readValue = Wire.read(); return Wire.read();
return readValue;
} }
// readWord(byte registerAddress) // readWord(byte registerAddress)
@ -480,8 +479,6 @@ byte sx1509Class::readByte(byte registerAddress)
// - The lsb of the return value will contain the value read from registerAddress + 1 // - The lsb of the return value will contain the value read from registerAddress + 1
unsigned int sx1509Class::readWord(byte registerAddress) unsigned int sx1509Class::readWord(byte registerAddress)
{ {
unsigned int readValue;
unsigned int msb, lsb;
unsigned int timeout = RECEIVE_TIMEOUT_VALUE * 2; unsigned int timeout = RECEIVE_TIMEOUT_VALUE * 2;
Wire.beginTransmission(deviceAddress); Wire.beginTransmission(deviceAddress);
@ -495,11 +492,7 @@ unsigned int sx1509Class::readWord(byte registerAddress)
if (timeout == 0) if (timeout == 0)
return 0; return 0;
msb = (Wire.read() & 0x00FF) << 8; return ((Wire.read() & 0x00FF) << 8 | (Wire.read() & 0x00FF));
lsb = (Wire.read() & 0x00FF);
readValue = msb | lsb;
return readValue;
} }
// readBytes(byte firstRegisterAddress, byte * destination, byte length) // readBytes(byte firstRegisterAddress, byte * destination, byte length)

Loading…
Cancel
Save