NeoBirth / accelerometer.rs

Generic Rust accelerometer support, including traits and types for taking readings from 2 or 3-axis accelerometers
Apache License 2.0
26 stars 10 forks source link

Split `Accelerometer` and `RawAccelerometer` #54

Closed tarcieri closed 4 years ago

tarcieri commented 4 years ago

Some accelerometers (e.g. ADXL343) support reading raw acceleration in e.g. both integer and floating point format, and for this reason it may make sense to impl the raw acceleration trait repeatedly for different vector types (which the adxl343 crate presently does).

However, for normalized acceleration, this doesn't make sense and the impls could potentially conflict as the type system has no generic parameters to resolve which trait impl to use.

This commit splits the Accelerometer trait into a separate RawAccelerometer trait providing something closer to the previous API which can be impl'd many times for different types of raw readings.