Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions OneWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ OneWire::OneWire(uint8_t address)
Wire.begin();
}

OneWire::OneWire(uint8_t sdaPin, uint8_t sclPin)
{
// sdaPin and sclPin can override the default SCL and SDA
// pins on some hardware
// Address is determined by two pins on the DS2482 AD1/AD0
// Pass 0b00, 0b01, 0b10 or 0b11
mAddress = 0x18;
mError = 0;
Wire.begin(sdaPin, sclPin);
}

OneWire::OneWire(uint8_t sdaPin, uint8_t sclPin, uint8_t address)
{
// sdaPin and sclPin can override the default SCL and SDA
// pins on some hardware
// Address is determined by two pins on the DS2482 AD1/AD0
// Pass 0b00, 0b01, 0b10 or 0b11
mAddress = 0x18 | address;
mError = 0;
Wire.begin(sdaPin, sclPin);
}

uint8_t OneWire::getAddress()
{
return mAddress;
Expand Down
2 changes: 2 additions & 0 deletions OneWire.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class OneWire
public:
OneWire();
OneWire(uint8_t address);
OneWire(uint8_t sdaPin, uint8_t sclPin);
OneWire(uint8_t sdaPin, uint8_t sclPin, uint8_t address);

uint8_t getAddress();
uint8_t getError();
Expand Down