Closed robyoung closed 3 years ago
Regarding the failing checks:
clippy:pedantic
.About
UnscaledMeasurement
/Measurement
I think it would be better to keepUnscaledMeasurement
as well so that the whole scaling operations can be avoided in scenarios where the scale is fixed. What do you think?
Yea, sounds good. What do you think about separate methods accel_data_unscaled
and mag_data_unscaled
?
_unscaled
methods sound good. That way the "default" method output is scaled, which would be great.
Could you also add an entry to the changelog?
Depends on #4
This change scales the accelerometer and magnetometer outputs. For the accelerometer this includes being able to set the scaling factor. I have renamed
UnscaledMeasurement
toMeasurement
to make it clear that these are now scaled.Scaling the accelerometer
Scaling the accelerometer data to milli-g is fairly well described in the datasheet. The only area of confusion is around the 16g scaling factor. The STMicroelectronics driver has this very confusing line which is also seen in others. I have chosen to go with the datasheet but I am not 100% sure that is correct.
Scaling the magnetometer
Scaling the magnetometer is a little more obscure. I have taken the 150 value from the here in the microbit-dal but there is very little context as to where that number comes from. The commit that introduced it does not shed any more light on the matter (although it does imply that the value has been determined empirically). I have seen similar scaling factors used in other LSM303 drivers but have not been able to find an explanation or any reference in the datasheet.