Crate ev3dev_lang_rust

Source
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 recognized 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 efficient 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.
ev3_button_functions
Helper macro to create all necessary functions for a button
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.
Buttonev3
Ev3 brick button handler. Opens the corresponding /dev/input file handlers.
Driver
Helper struct that manages attributes. It creates an Attribute instance if it does not exists or uses a cached one.
Ledev3
The led’s 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.
Screenscreen
Represents the device screen. Advanced drawing operations can be performed with the imageproc crate.

Enums§

Ev3Error
Custom error type for internal errors.

Traits§

Device
The ev3dev device base trait
Port
EV3 ports

Type Aliases§

Ev3Result
Helper Result type for easy access.