Currently this project is not compatible with the BrickPi platform.
```rust extern crate ev3devlangrust;
use std::io::Result; use ev3devlangrust::tachomotor::{LargeMotor, TachoMotor}; use ev3devlangrust::core::MotorPort; use ev3devlangrust::colorsensor::ColorSensor;
fn main() -> Result<()> {
// Get large motor on port outA.
let mut large_motor = LargeMotor::new(MotorPort::OutA).unwrap();
// 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 mut color_sensor = ColorSensor::find().unwrap();
// Switch to rgb mode.
color_sensor.set_mode_rgb_raw()?;
// Get current rgb color tuple.
println!("Current rgb color: {:?}", color_sensor.get_rgb()?);
Ok(())
} ```
Create Dockerfile ```dockerfile FROM ubuntu:18.04
RUN apt update
RUN apt --yes install curl g++ g++-arm-linux-gnueabi
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH "$PATH:/root/.cargo/bin"
RUN rustup target add armv5te-unknown-linux-gnueabi ```
Build docker image
bash
docker build . -t pixix4/ev3dev-rust-cross
Start docker image
bash
docker run -it --rm -v $PWD:/build/ -w /build pixix4/ev3dev-rust-cross
Build binary for ev3dev
bash
cargo build --release --target armv5te-unknown-linux-gnueabi
The --release
flag is optional. However, it can speedup the execution time by a factor of 30.
The target binary is now in target/armv5te-unknown-linux-gnueabi/release/libev3dev_lang_rust.rlib