When I create a class and define a callback, it results in a segmentation fault:
class xx():
def hwtrig(self,channel):
pass
def __init__(self):
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD) ## Pin Numbers
GPIO.PIN = 16
GPIO.setup(GPIO.PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## Pin 16 (GPIO.22)
GPIO.add_event_detect(GPIO.PIN, GPIO.FALLING, callback=self.hwtrig, bouncetime=100)
GPIO.LCD = 7 #GPIO.4
GPIO.setup(GPIO.LCD, GPIO.OUT)
self.BL = GPIO.PWM(GPIO.LCD,2000) ## PIN.7, GPIO.4 @ 2khz
self.BL.start(99)
if I comment out the following line then the fault goes away:
GPIO.add_event_detect(GPIO.PIN, GPIO.FALLING, callback=self.hwtrig, bouncetime=100)