embedded-hal
embedded-hal copied to clipboard
Quadrature encoder trait
Signed count
It's unclear from the documentation whether the intended use is an unsigned result from count()
, with direction()
indicating which way the system has moved from its zero point, or whether count()
may return a signed value and direction()
indicates the sign of the last change in location.
From an ergonomic standpoint, I strongly prefer the use of a signed count()
-- perhaps enforced on the Count
type? The hidden lines in the example seem to suggest an unsigned value being the intended use, however.
This would probably be clarified by a reference implementation.
Count reset
Should the Qei
trait have a reset_count(&mut self)
method?
Users of a quadrature encoder might want the ability to make the current position "zero". Some hardware implementations will support this by default, or it can be done in software by subtracting an offset.