Working with uasyncio
Closed this issue · 0 comments
maveric commented
I was able to get this library working with uasyncio using the inputs as buttons with a very simple addition.
Adding:
def __call__(self):
return self.value()
to the VirtualPin class allows extremely simple addition of inputs / buttons with asyncio - example:
from primitives import Pushbutton
import uasyncio as asyncio
import mcp23017
BLUE_INPUT_PIN = 0
...
mcp.pin(BLUE_INPUT_PIN, mode=1, pullup=1, polarity=1)
blue_button = Pushbutton(self.mcp[BLUE_INPUT_PIN])
blue_button.press_func(None)
asyncio.create_task(self.buttonPressed(self.blue_button.press, 'blue'))
I'm a github noob and don't know how to offer a pull request.