Crate ev3dev_lang_rust[][src]

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

motors

Container module for motor types

sensors

Container module for sensor types

sound

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

wait

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

Macros

dc_motor

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.

findable

Helper to create a new Device instance.

sensor_mode

Add a sensor mode constant with getter and setter

servo_motor

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

tacho_motor

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

Attribute

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

Driver

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

Ev3Button

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

Led

The leds on top of the EV3 brick.

PowerSupply

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

Enums

Ev3Error

Custom error type for internal errors.

Traits

Device

The ev3dev device base trait

Port

EV3 ports

Type Definitions

Ev3Result

Helper Result type for easy access.