Public Member Functions | Public Attributes | Private Member Functions
rotary_encoder.decoder Class Reference

List of all members.

Public Member Functions

def __init__
def cancel

Public Attributes

 callback
 cbA
 cbB
 gpioA
 gpioB
 lastGpio
 levA
 levB
 pi

Private Member Functions

def _pulse

Detailed Description

Class to decode mechanical rotary encoder pulses.

Definition at line 5 of file rotary_encoder.py.


Constructor & Destructor Documentation

def rotary_encoder.decoder.__init__ (   self,
  pi,
  gpioA,
  gpioB,
  callback 
)
Instantiate the class with the pi and gpios connected to
rotary encoder contacts A and B.  The common contact
should be connected to ground.  The callback is
called when the rotary encoder is turned.  It takes
one parameter which is +1 for clockwise and -1 for
counterclockwise.

EXAMPLE

import time
import pigpio

import rotary_encoder

pos = 0

def callback(way):

   global pos

   pos += way

   print("pos={}".format(pos))

pi = pigpio.pi()

decoder = rotary_encoder.decoder(pi, 7, 8, callback)

time.sleep(300)

decoder.cancel()

pi.stop()

Definition at line 9 of file rotary_encoder.py.


Member Function Documentation

def rotary_encoder.decoder._pulse (   self,
  gpio,
  level,
  tick 
) [private]
Decode the rotary encoder pulse.

       +---------+         +---------+      0
       |         |         |         |
   A         |         |         |         |
       |         |         |         |
   +---------+         +---------+         +----- 1

 +---------+         +---------+            0
 |         |         |         |
   B   |         |         |         |
 |         |         |         |
   ----+         +---------+         +---------+  1

Definition at line 67 of file rotary_encoder.py.

Cancel the rotary encoder decoder.

Definition at line 100 of file rotary_encoder.py.


Member Data Documentation

Definition at line 44 of file rotary_encoder.py.

Definition at line 44 of file rotary_encoder.py.

Definition at line 44 of file rotary_encoder.py.

Definition at line 44 of file rotary_encoder.py.

Definition at line 44 of file rotary_encoder.py.

Definition at line 44 of file rotary_encoder.py.

Definition at line 44 of file rotary_encoder.py.

Definition at line 44 of file rotary_encoder.py.

Definition at line 44 of file rotary_encoder.py.


The documentation for this class was generated from the following file:


cob_hand_bridge
Author(s): Mathias L├╝dtke
autogenerated on Thu Jun 6 2019 20:43:57