pub trait NineDof<'a> {
// Required method
fn set_client(&self, client: &'a dyn NineDofClient);
// Provided methods
fn read_accelerometer(&self) -> Result<(), ErrorCode> { ... }
fn read_magnetometer(&self) -> Result<(), ErrorCode> { ... }
fn read_gyroscope(&self) -> Result<(), ErrorCode> { ... }
}Expand description
A basic interface for a 9-DOF compatible chip.
This trait provides a standard interface for chips that implement some or all of a nine degrees of freedom (accelerometer, magnetometer, gyroscope) sensor. Any interface functions that a chip cannot implement can be ignored by the chip capsule and an error will automatically be returned.
Required Methods§
Sourcefn set_client(&self, client: &'a dyn NineDofClient)
fn set_client(&self, client: &'a dyn NineDofClient)
Set the client to be notified when the capsule has data ready or has finished some command. This is likely called in a board’s main.rs and is set to the virtual_ninedof.rs driver.
Provided Methods§
Sourcefn read_accelerometer(&self) -> Result<(), ErrorCode>
fn read_accelerometer(&self) -> Result<(), ErrorCode>
Get a single instantaneous reading of the acceleration in the X,Y,Z directions.
Sourcefn read_magnetometer(&self) -> Result<(), ErrorCode>
fn read_magnetometer(&self) -> Result<(), ErrorCode>
Get a single instantaneous reading from the magnetometer in all three directions.
Sourcefn read_gyroscope(&self) -> Result<(), ErrorCode>
fn read_gyroscope(&self) -> Result<(), ErrorCode>
Get a single instantaneous reading from the gyroscope of the rotation around all three axes.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".