Struct linkbot::Linkbot [] [src]

pub struct Linkbot { /* fields omitted */ }

An object representing a Linkbot.

Methods

impl Linkbot
[src]

Try to connect to a Linkbot.

If there is an error, None is returned and an error message is printed to stderr.

Get a Linkbot's current joint angles.

Returns a tuple containing the three joint angles in degrees and a timestamp representing the number of milliseconds the robot has been powered on.

Move a Linkbot's motors. The mask specifies which motors to move. For instance, a mask value of 5 (0b101) indicates that motors 1 and 3 should be moved. A mask of 4 (0b100) indicates that only motor 3 should be moved.

The units of movement are in degrees.

Move a Linkbot's motors to absolute positions.

See move_motors for a description of the mask argument.

Wait until a Linkbot's motors have stopped moving.

This function blocks execution in the current thread until the Linkbot's motors have stopped moving. The motors to wait for are specified by the mask argument. For instance, to wait for all motors, specify a mask of 0x07 (0b111). Or, to only wait for motor 3, specify a mask of 0x04 (0b100).

Set a callback for when a Linkbot button is pressed

The callback will be called whenever a button is depressed or released. The third argument of the callback function is a timestamp indicating the number of milleseconds the robot has been powered on.

Examples

extern crate linkbot;
use linkbot::Linkbot;

fn main() {
    let mut l = Linkbot::new("ZRG6").unwrap();
    l.set_button_handler( |button, state, timestamp| {
        // Do something. This closure will be called when any button is depressed or
        // released.
    });
}

Remove the Linkbot button handler

If there was a button handler previously set with set_button_handler(), this function removes it and restores the default Linkbot button functionality.

Set the buzzer frequency

Set the buzzer frequency to a value specified in Hertz (Hz). Set the buzzer frequency to 0 to stop the buzzer.