quadrature_encoder/mode/
rotary.rs1use quadrature_decoder::Change;
4
5use crate::mode::OperationMode;
6
7use super::Movement;
8
9#[repr(i8)]
11#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
12pub enum RotaryMovement {
13 Clockwise = 1,
15 CounterClockwise = -1,
17}
18
19impl From<Change> for RotaryMovement {
20 fn from(change: Change) -> Self {
25 match change {
26 Change::Positive => Self::Clockwise,
27 Change::Negative => Self::CounterClockwise,
28 }
29 }
30}
31
32impl Movement for RotaryMovement {
33 fn flipped(self) -> Self {
34 match self {
35 Self::Clockwise => Self::CounterClockwise,
36 Self::CounterClockwise => Self::Clockwise,
37 }
38 }
39}
40
41pub struct Rotary;
43
44impl OperationMode for Rotary {
45 type Movement = RotaryMovement;
46}