Closed tarcieri closed 4 years ago
I second this idea. It's hard to write portable drivers if the data isn't normalized.
An alternative to the a normalized vector and a sensitivity value is having a single normalized vector. Simply return a vector of floats representing acceleration in G's.
{0.0, 5.2, 0.0} - 5.2 G's of acceleration in the y axis
Yeah, that’s a good idea. I think that’s what I meant to propose with accel_norm
but re-reading what I wrote it’s a bit unclear.
Also happy to accept a PR for this
How would I go about selecting the appropriate f32 vector size?
Should just be F32x2 or F32x3?
Resolved by #53
Right now the
Accelerometer::acceleration
method returns a raw device-specific acceleration vector.It'd be nice to also add a method for computing an acceleration vector normalized to the device's current sensitivity, e.g. an
f32
G value normalized between0.0..0.1
.Suggested API change:
Accelerometer::acceleration
=>Accelerometer::accel_raw
(device-specific raw acceleration vector)Accelerometer::accel_norm
(acceleration normalized per above)Related: API for obtaining the current sensitivity? e.g. this example enum from the
adxl343
crate