Skip to content

Commit ff041e9

Browse files
committed
I2C parameter setActive
1 parent 061dd4d commit ff041e9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/DriverPins.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,14 @@ PinsSPI ESP32PinsSD{PinFunction::SD, 14, 2, 15, 13, SPI};
151151
struct PinsI2C {
152152
PinsI2C() = default;
153153
PinsI2C(PinFunction function, GpioPin scl, GpioPin sda, int port = -1,
154-
uint32_t frequency = 100000, TwoWire &wire = Wire) {
154+
uint32_t frequency = 100000, TwoWire &wire = Wire, bool active=true) {
155155
this->function = function;
156156
this->scl = scl;
157157
this->sda = sda;
158158
this->port = port;
159159
this->frequency = frequency;
160160
this->p_wire = &wire;
161+
this->set_active = active;
161162
}
162163

163164
PinFunction function;
@@ -272,8 +273,14 @@ class DriverPins {
272273
}
273274

274275
bool addI2C(PinFunction function, GpioPin scl, GpioPin sda, int port = -1,
275-
uint32_t frequency = 100000, TwoWire &wire = Wire) {
276-
PinsI2C pin(function, scl, sda, port, frequency, wire);
276+
uint32_t frequency = 100000, TwoWire &wire = Wire, bool active = true) {
277+
PinsI2C pin(function, scl, sda, port, frequency, wire, active);
278+
return addI2C(pin);
279+
}
280+
281+
/// Just define your initialzed wire object
282+
bool addI2C(PinFunction function, TwoWire &wire, bool setActive = false) {
283+
PinsI2C pin(function, -1, -1, -1, -1, wire, setActive);
277284
return addI2C(pin);
278285
}
279286

0 commit comments

Comments
 (0)