Struct rust_rpi_4wd_car::Motors[][src]

pub struct Motors { /* fields omitted */ }

Proves a simpler interface for the robot’s motors.

Implementations

impl Motors[src]

pub fn new() -> Rr4cResult<Self>[src]

Constructor

pub fn brake(&mut self) -> Result[src]

Stop the robot motors.

pub fn enable(&mut self, v: bool)[src]

Used to enable/disable robot moving.

Arguments

  • v - Use true to enable robot moving else false to disable.

pub fn movement<L, R>(&mut self, left: L, right: R) -> Result where
    L: Into<Option<i8>>,
    R: Into<Option<i8>>, 
[src]

Sets direction and speed of motors.

NOTE: Motors must be enabled by calling enable(true) before this command cause robot to start moving.

Arguments

Both motors use a -100(%) to +100(%) integer speed range.

NOTE: Speeds below 20% in either direction may be glitchy and ones below 10% are likely to cause little or no movement of the robot.

  • left - Speed and direction for left motors.
  • right - Speed and direction for right motors.

Examples

use rust_rpi_4wd_car::{Motors, Result};

fn main() -> Result {
    let mut motors = Motors::new()?;
    motors.enable(true);
    motors.movement(-50, 50)
}

This will cause the robot to start spinning in place to the left. The left motors going backwards and the right motors forward. Both motors will be at ~50% speed.

pub fn speeds(&self) -> (i8, i8)[src]

Access the current speeds of the left and right motors.

NOTE: Speeds will be return even when motors are not actively being driven or enabled.

Trait Implementations

impl Debug for Motors[src]

Auto Trait Implementations

impl !RefUnwindSafe for Motors

impl Send for Motors

impl Sync for Motors

impl Unpin for Motors

impl !UnwindSafe for Motors

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.