Saved some 50K flash memory by modifying the singleton implementation
This commit is contained in:
parent
b46b7461f4
commit
4ad4de080f
|
@ -492,14 +492,20 @@ TwoWire& Wire1 = TwoWire::getInstance1(); //SCL: D1 SDA: D0
|
||||||
// Static methods //////////////////////////////////////////////////////////////
|
// Static methods //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TwoWire& TwoWire::getInstance(){
|
TwoWire& TwoWire::getInstance(){
|
||||||
static TwoWire instance(I2C1);
|
static TwoWire* instance = nullptr;
|
||||||
return instance;
|
if (!instance) {
|
||||||
|
instance = new TwoWire(I2C1);
|
||||||
|
}
|
||||||
|
return *instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WIRE_INTERFACES_COUNT > 1
|
#if WIRE_INTERFACES_COUNT > 1
|
||||||
TwoWire& TwoWire::getInstance1(){
|
TwoWire& TwoWire::getInstance1(){
|
||||||
static TwoWire instance(I2C2);
|
static TwoWire* instance = nullptr;
|
||||||
return instance;
|
if (!instance) {
|
||||||
|
instance = new TwoWire(I2C2);
|
||||||
|
}
|
||||||
|
return *instance;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue