stm32duino / LSM6DSR

Arduino library to support the LSM6DSR 3D accelerometer and 3D gyroscope
7 stars 7 forks source link

Get x axes output as float #9

Closed nuenen313 closed 3 months ago

nuenen313 commented 4 months ago

Summary

LSM6DSR has a relatively high sensitivity of the accelerometer readings per the datasheet (0.061 mg/LSB at ±2 g FS). I think it would be useful for the output of the Get_X_Axes function to be a float (currently int32_t), so that it can be printed with more decimal points more easily.

This PR fixes/implements the following:

Motivation for making the change

It would be especially convenient for use cases where high accuracy of the output is needed (i.e. machine monitoring systems), as well as for determining the actual sensitivity of the accelerometer in real life conditions.

Validation

The changes have been validated using the example arduino sketches and an ESP32 (LOLIN D32 PRO in particular) with the LSM6DSR accelerometer.

cparata commented 4 months ago

Hi @nuenen313 , thanks a lot for this PR. Because in C++ we have the possibility of function overloading, I prefer to add a new dedicated function with the float array parameter, keeping also the function with int32_t array parameter. In this way we have a library that is backward compatible with the previous versions. Could you update the PR in this way? Thanks again for your contribution. Best Regards, Carlo

nuenen313 commented 4 months ago

Hi @cparata, thanks for the reply! I updated the PR to use overloading and reverted the changes in the Arduino examples, only adding a comment that float accelerometer [3] can also be used. Let me know if that's an acceptable approach. Best regards, Marta

cparata commented 3 months ago

Hello @nuenen313 , thanks a lot! Now the PR is fine for me. I would ask you to squash all the 3 commits in just 1 commit to avoid useless commits. Thanks in advance, Carlo

nuenen313 commented 3 months ago

Hi @cparata, all done! Thank you for your help. Best regards, Marta

cparata commented 3 months ago

PR integrated! Thanks a lot for your contribution. Best Regards, Carlo