Adafruit-MCP23017-Arduino-Library icon indicating copy to clipboard operation
Adafruit-MCP23017-Arduino-Library copied to clipboard

If the I2C-Bus is not available for any reason 32 Bytes of free heap gets consumed each cycle..

Open eXtr3me26 opened this issue 9 months ago • 0 comments

This method needs to be changed:

bool Adafruit_MCP23XXX::begin_I2C(uint8_t i2c_addr, TwoWire *wire) { i2c_dev = new Adafruit_I2CDevice(i2c_addr, wire); return i2c_dev->begin(); }

into:

bool Adafruit_MCP23XXX::begin_I2C(uint8_t i2c_addr, TwoWire *wire) { if (i2c_dev != nullptr) { delete i2c_dev; i2c_dev = nullptr; } i2c_dev = new Adafruit_I2CDevice(i2c_addr, wire); return i2c_dev->begin(); }

Also, this seems to be a general problem of this library.. only a successful run seems to avoid free heap problems..

eXtr3me26 avatar Feb 22 '25 14:02 eXtr3me26