Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1246

Python • Some trouble with pigpio callback

$
0
0
Hi,

I have an application that uses the following class:

Code:

class inout:#            #Input Numbers#             rc = 16#             ro = 17#             lc = 6#             lo = 19#             lid = 20#            #output numbers#             d1dir = 4#             d2dir = 18#             d1pul = 12#             d2pul = 13    def __init__(self, *args, **kwargs):        self.pio = pigpio.pi()        if not self.pio.connected:            print("GPIO Connection Error :inout")            exit()        self.pio.callback(rc,pigpio.EITHER_EDGE,inout.RightAct)        self.pio.callback(ro,pigpio.EITHER_EDGE,inout.RightAct)        self.pio.callback(lc,pigpio.EITHER_EDGE,inout.LeftAct)         self.pio.callback(lo,pigpio.EITHER_EDGE,inout.LeftAct)         self.pio.callback(lid,pigpio.EITHER_EDGE,inout.LidAct)            def LeftAct(self,gpio,level,tick):        if gpio == lc:            if level == 0:                hmi.LedState(0,1)            else:                hmi.LedState(0,0)        if gpio == lo:            if level == 0:                hmi.LedState(1,1)            else:                hmi.LedState(1,0)                    def RightAct(self,gpio,level,tick):        if gpio == rc:            if level == 0:                hmi.LedState(2,1)            else:                hmi.LedState(2,0)        if gpio == ro:            if level == 0:                hmi.LedState(2,1)            else:                hmi.LedState(2,0)                    def LidAct(self,gpio,level,tick):            if level == 0:                hmi.LedState(3,1)            else:                hmi.LedState(3,0)        
I can instantiate this, and all seems well until I wiggle one of the I/O associated with one of the callbacks, then I get the following:

Code:

Exception in thread Thread-1:Traceback (most recent call last):  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner    self.run()  File "/home/eng/pythonvenv/lib/python3.11/site-packages/pigpio.py", line 1213, in run    cb.func(cb.gpio, newLevel, tick)TypeError: inout.RightAct() missing 1 required positional argument: 'tick'
I do seem to have all the arguments... What am I missing?

Thanks!

Statistics: Posted by rallenbaggett — Wed Feb 26, 2025 8:10 pm



Viewing all articles
Browse latest Browse all 1246

Trending Articles