I'm curious, is there a way I could use touchio to set up a touch input and pass that through keypad as a key?
To use the "Handling Interrupts with keypad" guide as a reference, could I do something like this?
Code: Select all
import asyncio
import board
import keypad
touch_A1 = touchio.TouchIn(board.A1) # Set up the touch input
async def catch_pin_transitions(pin):
"""Print a message when pin goes low and when it goes high."""
with keypad.Keys((pin,), value_when_pressed=False) as keys:
while True:
event = keys.events.get()
if event:
if event.pressed:
print("pin went low")
elif event.released:
print("pin went high")
await asyncio.sleep(0)
async def main():
interrupt_task = asyncio.create_task(catch_pin_transitions(touch_A1)) # pass that pin as in input for kaypad, or maybe it could remain as board.A1
await asyncio.gather(interrupt_task)
asyncio.run(main())