[−][src]Trait embedded_hal::qei::Qei
Quadrature encoder interface
Examples
You can use this interface to measure the speed of a motor
extern crate embedded_hal as hal; #[macro_use(block)] extern crate nb; use hal::prelude::*; fn main() { let mut qei: Qei1 = { // .. }; let mut timer: Timer6 = { // .. }; let before = qei.try_count().unwrap(); timer.try_start(1.s()).unwrap(); block!(timer.try_wait()); let after = qei.try_count().unwrap(); let speed = after.wrapping_sub(before); println!("Speed: {} pulses per second", speed); }
Associated Types
Loading content...Required methods
fn try_count(&self) -> Result<Self::Count, Self::Error>
Returns the current pulse count of the encoder
fn try_direction(&self) -> Result<Direction, Self::Error>
Returns the count direction