From 59ddd7a90c27dba91ba672aa917cfcfdcd000677 Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Fri, 8 Oct 2021 02:57:53 +0300 Subject: [PATCH] Encoders: Rename x_callback to a_callback and y_callback to b_callback Oops! --- encoders/ENCODERS.md | 4 ++-- encoders/encoder.py | 4 ++-- encoders/encoder_portable.py | 4 ++-- encoders/encoder_timed.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/encoders/ENCODERS.md b/encoders/ENCODERS.md index b9bf49e..f16e13a 100644 --- a/encoders/ENCODERS.md +++ b/encoders/ENCODERS.md @@ -51,11 +51,11 @@ class Encoder: 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, pin): + def a_callback(self, pin): self.forward = pin() ^ self.pin_b() self._pos += 1 if self.forward else -1 - def y_callback(self, pin): + def b_callback(self, pin): self.forward = self.pin_a() ^ pin() ^ 1 self._pos += 1 if self.forward else -1 diff --git a/encoders/encoder.py b/encoders/encoder.py index c01bea7..c12e211 100644 --- a/encoders/encoder.py +++ b/encoders/encoder.py @@ -17,11 +17,11 @@ class Encoder: self.a_interrupt = pyb.ExtInt(pin_a, pyb.ExtInt.IRQ_RISING_FALLING, pyb.Pin.PULL_NONE, self.a_callback) self.b_interrupt = pyb.ExtInt(pin_b, pyb.ExtInt.IRQ_RISING_FALLING, pyb.Pin.PULL_NONE, self.b_callback) - def x_callback(self, line): + def a_callback(self, line): self.forward = self.pin_a.value() ^ self.pin_b.value() ^ self.reverse self._pos += 1 if self.forward else -1 - def y_callback(self, line): + def b_callback(self, line): self.forward = self.pin_a.value() ^ self.pin_b.value() ^ self.reverse ^ 1 self._pos += 1 if self.forward else -1 diff --git a/encoders/encoder_portable.py b/encoders/encoder_portable.py index fdb3302..b28e3e6 100644 --- a/encoders/encoder_portable.py +++ b/encoders/encoder_portable.py @@ -22,10 +22,10 @@ class Encoder: 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, pin): + def a_callback(self, pin): self._pos += 1 if (pin() ^ self.pin_b()) else -1 - def y_callback(self, pin): + def b_callback(self, pin): self._pos += 1 if (self.pin_a() ^ pin() ^ 1) else -1 def position(self, value=None): diff --git a/encoders/encoder_timed.py b/encoders/encoder_timed.py index 97cbebd..0a3d601 100644 --- a/encoders/encoder_timed.py +++ b/encoders/encoder_timed.py @@ -23,13 +23,13 @@ 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, pin): + def a_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, pin): + def b_callback(self, pin): self.forward = self.pin_a() ^ pin() ^ 1 self._pos += 1 if self.forward else -1 self.tprev = self.tlast