Nunchuk

Struct Nunchuk 

Source
pub struct Nunchuk<I2C, Delay> { /* private fields */ }

Implementations§

Source§

impl<I2C, Delay> Nunchuk<I2C, Delay>
where I2C: I2c, Delay: DelayNs,

Source

pub fn new(i2cdev: I2C, delay: Delay) -> Self

Create a new Wii Nunchuck

Source

pub fn destroy(self) -> (I2C, Delay)

Destroy this driver, recovering the i2c bus and delay used to create it

Source

pub async fn update_calibration(&mut self) -> Result<(), AsyncImplError>

Update the stored calibration for this controller

Since each device will have different tolerances, we take a snapshot of some analog data to use as the “baseline” center.

Source

pub async fn init(&mut self) -> Result<(), AsyncImplError>

Send the init sequence to the controller and calibrate it

Source

pub async fn read(&mut self) -> Result<NunchukReadingCalibrated, AsyncImplError>

Do a read, and report axis values relative to calibration

Source

pub async fn identify_controller( &mut self, ) -> Result<Option<ControllerType>, AsyncImplError>

Determine the controller type based on the type ID of the extension controller

Auto Trait Implementations§

§

impl<I2C, Delay> Freeze for Nunchuk<I2C, Delay>
where I2C: Freeze, Delay: Freeze,

§

impl<I2C, Delay> RefUnwindSafe for Nunchuk<I2C, Delay>
where I2C: RefUnwindSafe, Delay: RefUnwindSafe,

§

impl<I2C, Delay> Send for Nunchuk<I2C, Delay>
where I2C: Send, Delay: Send,

§

impl<I2C, Delay> Sync for Nunchuk<I2C, Delay>
where I2C: Sync, Delay: Sync,

§

impl<I2C, Delay> Unpin for Nunchuk<I2C, Delay>
where I2C: Unpin, Delay: Unpin,

§

impl<I2C, Delay> UnwindSafe for Nunchuk<I2C, Delay>
where I2C: UnwindSafe, Delay: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.