Skip to content

Commit

Permalink
added support for non-default pins for i2c on esp32 (#107)
Browse files Browse the repository at this point in the history
* added support for non-default pins for i2c

* corrected incorect symbol
  • Loading branch information
haberturdeur authored and Makuna committed Dec 27, 2019
1 parent fa93baf commit 54433ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/RtcDS1302.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ template<class T_WIRE_METHOD> class RtcDS1302
_wire.begin();
}


void Begin(int sda, int scl)
{
_wire.begin(sda, scl);
}

bool GetIsWriteProtected()
{
uint8_t wp = getReg(DS1302_REG_WP);
Expand Down
4 changes: 4 additions & 0 deletions src/RtcDS1307.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ template<class T_WIRE_METHOD> class RtcDS1307
{
_wire.begin();
}
void Begin(int sda, int scl)
{
_wire.begin(sda, scl);
}

uint8_t LastError()
{
Expand Down
9 changes: 7 additions & 2 deletions src/RtcDS3231.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ template<class T_WIRE_METHOD> class RtcDS3231
_wire.begin();
}

void Begin(int sda, int scl)
{
_wire.begin(sda, scl);
}

uint8_t LastError()
{
return _lastError;
Expand Down Expand Up @@ -344,7 +349,7 @@ template<class T_WIRE_METHOD> class RtcDS3231
}

// Temperature is represented as a 10-bit code with a resolution
// of 1/4th °C and is accessable as a signed 16-bit integer at
// of 1/4th °C and is accessable as a signed 16-bit integer at
// locations 11h and 12h.
//
// | r11h | DP | r12h |
Expand All @@ -354,7 +359,7 @@ template<class T_WIRE_METHOD> class RtcDS3231
// As it takes (8) right-shifts to register the decimal point (DP) to
// the right of the 0th bit, the overall word scaling equals 256.
//
// For example, at +/- 25.25°C, concatenated registers <r11h:r12h> =
// For example, at +/- 25.25°C, concatenated registers <r11h:r12h> =
// 256 * (+/- 25+(1/4)) = +/- 6464, or 1940h / E6C0h.

_wire.requestFrom(DS3231_ADDRESS, DS3231_REG_TEMP_SIZE);
Expand Down

0 comments on commit 54433ff

Please sign in to comment.