Giter Site home page Giter Site logo

Comments (8)

ladyada avatar ladyada commented on September 12, 2024

are you deleting the object? allocated memory is freed there
https://github.com/adafruit/Adafruit_ICM20X/blob/master/Adafruit_ICM20X.cpp#L54

from adafruit_icm20x.

caternuson avatar caternuson commented on September 12, 2024

see:
adafruit/Adafruit_MS8607#4 (comment)

from adafruit_icm20x.

gmanrc avatar gmanrc commented on September 12, 2024

@caternuson & @ladyada thanks for your help on that for the MS8607. Unfortunately, for the icm20948 does not appear to currently have an init() function for re-initializing the sensors. There is reset(); but calling begin() after reset; is still taking up the free memory.

from adafruit_icm20x.

caternuson avatar caternuson commented on September 12, 2024

calling begin() after reset; is still taking up the free memory.

Call begin only once, in setup. Call reset in the loop.

Nothing in reset should be eating memory:

void Adafruit_ICM20X::reset(void) {
_setBank(0);
Adafruit_BusIO_Register pwr_mgmt1 = Adafruit_BusIO_Register(
i2c_dev, spi_dev, ADDRBIT8_HIGH_TOREAD, ICM20X_B0_PWR_MGMT_1, 1);
Adafruit_BusIO_RegisterBits reset_bit =
Adafruit_BusIO_RegisterBits(&pwr_mgmt1, 1, 7);
reset_bit.write(1);
delay(20);
while (reset_bit.read()) {
delay(10);
};
delay(50);
}

from adafruit_icm20x.

gmanrc avatar gmanrc commented on September 12, 2024

calling begin() after reset; is still taking up the free memory.

Call begin only once, in setup. Call reset in the loop.

Nothing in reset should be eating memory:

void Adafruit_ICM20X::reset(void) {
_setBank(0);
Adafruit_BusIO_Register pwr_mgmt1 = Adafruit_BusIO_Register(
i2c_dev, spi_dev, ADDRBIT8_HIGH_TOREAD, ICM20X_B0_PWR_MGMT_1, 1);
Adafruit_BusIO_RegisterBits reset_bit =
Adafruit_BusIO_RegisterBits(&pwr_mgmt1, 1, 7);
reset_bit.write(1);
delay(20);
while (reset_bit.read()) {
delay(10);
};
delay(50);
}

Thanks for the quick reply @caternuson. Unfortunately, when I call reset() in the loop without begin(), the the data output of the sensors is only zeroes. Again, as with the other sensor, I am turning this sensor on and off each time to economize battery life.

from adafruit_icm20x.

gmanrc avatar gmanrc commented on September 12, 2024

I tried both the reset embedded with icm20x.h and the reset in icm20948.h. The first causes the device to hang. The latter causes the sensors to output zeroes.

from adafruit_icm20x.

caternuson avatar caternuson commented on September 12, 2024

The code in _init is likely needed to be called also, to re-establish the basic sensor config. But that's private, so not accessible in user sketch. It's also where the unchecked allocations are occurring:

temp_sensor = new Adafruit_ICM20X_Temp(this);
accel_sensor = new Adafruit_ICM20X_Accelerometer(this);
gyro_sensor = new Adafruit_ICM20X_Gyro(this);
mag_sensor = new Adafruit_ICM20X_Magnetometer(this);

So seems like like maybe this is not possible with the current state of the library.

from adafruit_icm20x.

gmanrc avatar gmanrc commented on September 12, 2024

Thanks for identifying this @caternuson. I'll monitor this space for updates to the library, as having this all in sensor is great.
But I will need to adjust my hardware for now to multiple sensors to capture the same data and be compliant with my battery saving measures.

from adafruit_icm20x.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.