#![no_std]
#![no_main]
use core::time::Duration;
use pros::prelude::*;
pub struct Robot {
encoder: AdiEncoder,
}
impl Robot {
fn new(peripherals: Peripherals) -> Self {
let expander = AdiExpander::new(peripherals.port_1);
Self {
encoder: AdiEncoder::new((expander.adi_a, expander.adi_b), false).unwrap(),
}
}
}
impl AsyncRobot for Robot {
async fn opcontrol(&mut self) -> Result {
loop {
println!("Encoder position: {}", self.encoder.position()?);
delay(Duration::from_secs(1));
}
}
}
async_robot!(Robot, Robot::new(Peripherals::take().unwrap()));