This value could easily be cached in the object using a tiny amount of memory on the reasonable assumption that this object is the only thing changing the range. This would reduce the amount of i2c traffic benefitting the performance of the magnetometer reads.
The
read()
member function which is also used bygetEvent()
callsgetRange()
which reads the value over the i2c bus:https://github.com/adafruit/Adafruit_LIS3MDL/blob/d162c5759bfab9ed707fa89b92098169a04e01ac/Adafruit_LIS3MDL.cpp#L172
https://github.com/adafruit/Adafruit_LIS3MDL/blob/d162c5759bfab9ed707fa89b92098169a04e01ac/Adafruit_LIS3MDL.cpp#L380-L387
This value could easily be cached in the object using a tiny amount of memory on the reasonable assumption that this object is the only thing changing the range. This would reduce the amount of i2c traffic benefitting the performance of the magnetometer reads.