Skip to content

Commit

Permalink
Make getters const (#56)
Browse files Browse the repository at this point in the history
* add const for a getter
* make getAddress() const and inline
* move getAddress() to header file
  • Loading branch information
hasenradball authored Dec 4, 2024
1 parent 9dac937 commit 8bde2f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
8 changes: 0 additions & 8 deletions PCF8574.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,12 @@ bool PCF8574::isConnected()
return ( _wire->endTransmission() == 0);
}


bool PCF8574::setAddress(const uint8_t deviceAddress)
{
_address = deviceAddress;
return isConnected();
}


uint8_t PCF8574::getAddress()
{
return _address;
}


// removed _wire->beginTransmission(_address);
// with @100 KHz -> 265 micros()
// without @100 KHz -> 132 micros()
Expand Down
5 changes: 2 additions & 3 deletions PCF8574.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class PCF8574
// note: setting the address corrupt internal buffer values
// a read8() / write8() call updates them.
bool setAddress(const uint8_t deviceAddress);
uint8_t getAddress();

uint8_t getAddress() const { return _address; }

uint8_t read8();
uint8_t read(const uint8_t pin);
Expand All @@ -54,7 +53,7 @@ class PCF8574
uint8_t readButton8(const uint8_t mask);
uint8_t readButton(const uint8_t pin);
void setButtonMask(const uint8_t mask) { _buttonMask = mask; };
uint8_t getButtonMask() { return _buttonMask; };
uint8_t getButtonMask() const { return _buttonMask; };


// rotate, shift, toggle, reverse expect all lines are output
Expand Down

0 comments on commit 8bde2f0

Please sign in to comment.