Encoders/encoder_timed.py: Make callbacks according to encoder_portable.py

pull/23/head
IhorNehrutsa 2021-10-08 02:32:46 +03:00
rodzic f33c824047
commit 097d664d53
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -22,14 +22,14 @@ class EncoderTimed:
self.a_interrupt = pin_a.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=self.a_callback)
self.b_interrupt = pin_b.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=self.b_callback)
def x_callback(self, line):
self.forward = self.pin_a.value() ^ self.pin_b.value()
def x_callback(self, pin):
self.forward = pin() ^ self.pin_b()
self._pos += 1 if self.forward else -1
self.tprev = self.tlast
self.tlast = utime.ticks_us()
def y_callback(self, line):
self.forward = self.pin_a.value() ^ self.pin_b.value() ^ 1
def y_callback(self, pin):
self.forward = self.pin_a() ^ pin() ^ 1
self._pos += 1 if self.forward else -1
self.tprev = self.tlast
self.tlast = utime.ticks_us()