MaixPy-v1_scripts icon indicating copy to clipboard operation
MaixPy-v1_scripts copied to clipboard

GPIO IRQ sample error

Open kartben opened this issue 4 years ago • 0 comments

GPIO IRQ sample (https://github.com/sipeed/MaixPy_scripts/blob/master/hardware/demo_gpio_intr.py) has a wrong signature for the IRQ handler, at least for MaixPy 5

def test_irq(GPIO, pin_num):
    print("key", pin_num)

Gives an error as callback is expected to have one argument only, the GPIO object. Replacing with:

def test_irq(gpio):
    print("key", gpio)

works. However, GPIO module doesn't expose a reader for pin number so one has to compare gpio against the gpio objects. Mabye not ideal in an IRQ handler?

kartben avatar Feb 25 '20 17:02 kartben