adafruit / Adafruit_LSM6DS

Arduino library for LSM6DS
Other
47 stars 39 forks source link

Read selector #34

Open eringerli opened 2 years ago

eringerli commented 2 years ago

With a selector (which defaults to the behaviour as before this commit), the calling code can specify which kind data to transfer from the IMU.

All the data transfer code is centralized in _read() now, the various getEvent() methods call it with a selector. As only the data needed is transfered, this should result in a small performance gain.

I removed some hard coded conversions, all reads should now respect the set ranges. I also added a method to read out the accelerometer and gyroscope at the same time.

As all the errors bubble up, this solves issue #26 and makes PR #27 obsolete.

Beware, this PR is based on PR #33: Screenshot_20220429_004110

eringerli commented 2 years ago

@caternuson Did you have the time to read through this PR?

caternuson commented 2 years ago

This needs #33, so looking at that one first.

f-peri commented 1 year ago

@eringerli and @caternuson thanks for your efforts to update this library. I tested your pull and found that the readAcceleration and readGyro members were not working. I investigated a bit and believe I found the typo in the following:

constexpr uint8_t registersAndNum[] = { LSM6DS_OUT_TEMP_L, 14, LSM6DS_OUTX_L_G, 12, LSM6DS_OUTX_L_G, 6, LSM6DS_OUTX_L_A, 6, LSM6DS_OUT_TEMP_L, 2}; seems like the wrong registers were referenced. If I change to the following: constexpr uint8_t registersAndNum[] = { LSM6DS_OUT_TEMP_L, 14, LSM6DS_OUTX_L_G, 12, LSM6DS_OUTX_L_A, 6, LSM6DS_OUTX_L_G, 6, LSM6DS_OUT_TEMP_L, 2}; the functions appear to work as designed. I am in no way a pro at this, so I don't presume to know if there are other bits of code that should be checked.

thanks again.

eringerli commented 1 year ago

You're right, @f-peri. I want to rebase this commit anyway, so I have a look at it soon.