Crate ev3dev_lang_rust[][src]

Expand description

Rust language bindings for ev3dev

extern crate ev3dev_lang_rust;

use ev3dev_lang_rust::Ev3Result;
use ev3dev_lang_rust::motors::{LargeMotor, MotorPort};
use ev3dev_lang_rust::sensors::ColorSensor;

fn main() -> Ev3Result<()> {

    // Get large motor on port outA.
    let large_motor = LargeMotor::get(MotorPort::OutA)?;

    // Set command "run-direct".
    large_motor.run_direct()?;

    // Run motor.
    large_motor.set_duty_cycle_sp(50)?;

    // Find color sensor. Always returns the first recognised one.
    let color_sensor = ColorSensor::find()?;

    // Switch to rgb mode.
    color_sensor.set_mode_rgb_raw()?;

    // Get current rgb color tuple.
    println!("Current rgb color: {:?}", color_sensor.get_rgb()?);

    Ok(())
}

Modules

Container module for motor types

Container module for sensor types

Sound-related functions. It can beep, play wav files, or convert text to speech.

Utility functions for cpu efficent wait commands. Uses the libc::epoll_wait that only works on linux systems.

Macros

The DcMotor provides a uniform interface for using regular DC motors with no fancy controls or feedback. This includes LEGO MINDSTORMS RCX motors and LEGO Power Functions motors.

Helper to create a new Device instance.

Add a sensor mode constant with getter and setter

The ServoMotor provides a uniform interface for using hobby type servo motors.

The TachoMotor provides a uniform interface for using motors with positional and directional feedback such as the EV3 and NXT motors. This feedback allows for precise control of the motors.

Structs

A wrapper to a attribute file in the /sys/class/ directory.

Helper struct that manages attributes. It creates an Attribute instance if it does not exists or uses a cached one.

Ev3 brick button handler. Opens the corresponding /dev/input file handlers.

The leds on top of the EV3 brick.

An interface to read data from the system’s power_supply class. Uses the built-in legoev3-battery if none is specified.

Enums

Custom error type for internal errors.

Traits

The ev3dev device base trait

EV3 ports

Type Definitions

Helper Result type for easy access.