[Dprglist] Encoder decoding, 2nd attempt
Murray Altheim
murray18 at altheim.com
Wed Feb 10 00:29:44 PST 2021
Oops. I accidentally included the older, now-unused "_pulse()" function
from my old way of doing things, where I was having that function's code
perform the logic of figuring out which GPIO pin was calling it. This
turned out to be unnecessary, as I could just set up the callbacks to
call two different methods, which is what I'm doing now.
I've removed the unused function below, which makes it easier to understand.
Sorry for any confusion.
On 10/02/21 8:00 pm, Murray Altheim via DPRGlist wrote:
> Here's the relevant snippet from the Decoder class:
>
> class Decoder(object):
> def __init__(self, pi, orientation, gpio_a, gpio_b, callback, level):
> # ...
> self.cbA = self._pi.callback(self._gpio_a, _edge, self._pulse_a)
> self.cbB = self._pi.callback(self._gpio_b, _edge, self._pulse_b)
>
> def _pulse_a(self, gpio, level, tick):
> self._level_a = level
> if level == 1 and self._level_b == 1:
> self.callback(1)
>
> def _pulse_b(self, gpio, level, tick):
> self._level_b = level;
> if level == 1 and self._level_a == 1:
> self.callback(-1)
>
> source: https://github.com/ifurusato/ros/blob/master/lib/decoder.py
...........................................................................
Murray Altheim <murray18 at altheim dot com> = = ===
http://www.altheim.com/murray/ === ===
= = ===
In the evening
The rice leaves in the garden
Rustle in the autumn wind
That blows through my reed hut.
-- Minamoto no Tsunenobu
More information about the DPRGlist
mailing list