adafruit / Adafruit_CircuitPython_NeoKey

CircuitPython & Python library for NeoKey
MIT License
4 stars 5 forks source link

How to enable interrupts #9

Open gregorgebhardt opened 2 years ago

gregorgebhardt commented 2 years ago

Hi,

I would like to enable interrupts on a Adafruit NeoKey 1x4 board. The NeoKey board is connected to a Raspberry Pi, the INT pin of the NeyKey board is connected to pin 16 of the RPI. Is use the following code to register a callback for the interrupts:

GPIO.setmode(GPIO.BCM)
GPIO.setup(INTRRPT_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)

logger.info(f"registering interrupt detection on pin {INTRRPT_GPIO}")
GPIO.add_event_detect(INTRRPT_GPIO, GPIO.FALLING, callback=on_neokey_interrupt, bouncetime=100)

where the function on_neokey_interrupt just prints some output. This is working fine, if I connect pin 16 to ground.

Using the parameter in the constructor has no effect: https://github.com/adafruit/Adafruit_CircuitPython_NeoKey/blob/56d3cc2635a3604d9a4bd19a32d9ffc9f106ccfd/adafruit_neokey/neokey1x4.py#L58

This will only set the field interrupt_enabled since the property is only implemented in Keypad, not in Seesaw.

I tried the following, but also with no success:

neokeys = NeoKey1x4(board.I2C())
for k in range(4):
    neokeys.set_GPIO_interrupts(4 + k, True)

Any ideas what the problem could be?

gregorgebhardt commented 2 years ago

Sorry, found it out. It has to be a bit mask:

self.neokeys.set_GPIO_interrupts(0xf0, True)

Still, the parameter in the constructor has no effect.