Crate rcx

source ·
Expand description

§rcx

Crates.io Version docs.rs GitHub Actions Workflow Status

Interface library for communicating with the LEGO Mindstorms RCX brick

§Example

use rcx::{tower::usb::UsbTower, MotorSelection, Rcx};

const DEVICE: &str = "/dev/usb/legousbtower0";

fn main() -> color_eyre::Result<()> {
    color_eyre::install()?;
    let rcx = UsbTower::open(DEVICE)?;

    let mut rcx = Rcx::new(rcx);

    rcx.set_motor_direction(MotorSelection::A, rcx::MotorDirection::Forward)?;
    rcx.set_motor_power(MotorSelection::A, 5)?;
    rcx.set_motor_on_off(MotorSelection::A, rcx::MotorPowerState::On)?;
    std::thread::sleep(std::time::Duration::from_secs(2));
    rcx.set_motor_on_off(MotorSelection::A, rcx::MotorPowerState::Float)?;

    Ok(())
}

Modules§

Structs§

  • Motor state is encoded as a single byte. Bits 0-2 contain the motor power, 0..7. The remaining bits are used as follows:

Enums§

  • Set the slope and mode of sensor number sensor to the value specified by mode, and clear that sensor’s value. The bits of mode are split into two portions. Bits 0-4 contain a slope value in 0..31, while bits 5-7 contain the mode, 0..7. The eight modes, which control the value returned by the sensor, are:
  • There are six avaiable sound types:
  • This section describes the available sources and arguments.
  • Set the transmitter range. 0 indicates short range, 1 indicates long range. Other values are ignored.

Type Aliases§