Crates.io | toio |
lib.rs | toio |
version | 0.1.4 |
source | src |
created_at | 2020-06-15 13:44:50.727074 |
updated_at | 2020-07-05 11:45:19.12722 |
description | toio driver in Rust |
homepage | https://github.com/yushiomote/toio-rs |
repository | https://github.com/yushiomote/toio-rs |
max_upload_size | |
id | 254237 |
size | 128,384 |
toio driver in Rust
use std::time::Duration;
use toio::Cube;
use tokio::time::delay_for;
#[tokio::main]
async fn main() {
// Search for the nearest cube
let mut cube = Cube::search().nearest().await.unwrap();
// Connect
cube.connect().await.unwrap();
// Move forward
cube.go(20, 20, None).await.unwrap();
delay_for(Duration::from_secs(3)).await;
// Move backward
cube.go(-15, -15, None).await.unwrap();
delay_for(Duration::from_secs(3)).await;
// Spin counterclockwise
cube.go(5, 50, None).await.unwrap();
delay_for(Duration::from_secs(3)).await;
// Spin clockwise
cube.go(50, 5, None).await.unwrap();
delay_for(Duration::from_secs(3)).await;
// Stop
cube.stop().await.unwrap();
}