-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hello and thanks for this library.
I am trying to setup the standard mode decoder but it is only detecting every second indent of the encoder as a rotation. I am wondering if I am using the API wrong?
This is the pulses from the encoder, the red lines are the indents.

If I translate this to a simple test code this is the result. As you can see every second indent returns Direction::None.
let mut encoder = StandardMode::new();
encoder.update(true, false);
encoder.update(true, true); // Returns Direction::None
encoder.update(false, true);
encoder.update(false, false); // Returns Direction::Clockwise
encoder.update(true, false);
encoder.update(true, true); // Returns Direction::None
encoder.update(false, true);
encoder.update(false, false); // Returns Direction::ClockwiseAm I using the library wrong or is the algoritm missing this?
If I change the update code like this it works:
if a == PIN_EDGE && b == 0x00 {
dir = Direction::Anticlockwise;
} else if b == PIN_EDGE && a == 0x00 {
dir = Direction::Clockwise;
} else if b == 1 && a == 0x3 { // This is new
dir = Direction::Clockwise;
} else if a == 1 && b == 0x3 { // This is new
dir = Direction::Anticlockwise;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels