Fix formatting and comments
This commit is contained in:
parent
6e8aaff050
commit
ed41f4cda5
@ -47,7 +47,7 @@ class BaseEncoder:
|
|||||||
new_state = (self.pin_a.get_value(), self.pin_b.get_value())
|
new_state = (self.pin_a.get_value(), self.pin_b.get_value())
|
||||||
|
|
||||||
if new_state != self._state:
|
if new_state != self._state:
|
||||||
# it moves !
|
# encoder moved
|
||||||
self._movement += 1
|
self._movement += 1
|
||||||
# false / false and true / true are common half steps
|
# false / false and true / true are common half steps
|
||||||
# looking on the step just before helps determining
|
# looking on the step just before helps determining
|
||||||
@ -60,8 +60,13 @@ class BaseEncoder:
|
|||||||
|
|
||||||
# when the encoder settles on a position (every 2 steps)
|
# when the encoder settles on a position (every 2 steps)
|
||||||
if new_state[0] == new_state[1]:
|
if new_state[0] == new_state[1]:
|
||||||
# an encoder returned to the previous position, cancel rotation
|
# an encoder returned to the previous
|
||||||
if self._start_state[0] == new_state[0] and self._start_state[1] == new_state[1] and self._movement <= 2:
|
# position halfway, cancel rotation
|
||||||
|
if (
|
||||||
|
self._start_state[0] == new_state[0]
|
||||||
|
and self._start_state[1] == new_state[1]
|
||||||
|
and self._movement <= 2
|
||||||
|
):
|
||||||
self._movement = 0
|
self._movement = 0
|
||||||
self._direction = 0
|
self._direction = 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user