diff options
Diffstat (limited to 'peripheral/libmraa/examples/python/hello_isr.py')
-rw-r--r-- | peripheral/libmraa/examples/python/hello_isr.py | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/peripheral/libmraa/examples/python/hello_isr.py b/peripheral/libmraa/examples/python/hello_isr.py index 7cdd276..cb02488 100644 --- a/peripheral/libmraa/examples/python/hello_isr.py +++ b/peripheral/libmraa/examples/python/hello_isr.py @@ -24,31 +24,20 @@ import mraa import time -import sys class Counter: count = 0 c = Counter() -# inside a python interrupt you cannot use 'basic' types so you'll need to use +# inside a python interupt you cannot use 'basic' types so you'll need to use # objects -def test(gpio): - print("pin " + repr(gpio.getPin(True)) + " = " + repr(gpio.read())) +def test(args): + print("wooo") c.count+=1 -pin = 6; -if (len(sys.argv) == 2): - try: - pin = int(sys.argv[1], 10) - except ValueError: - printf("Invalid pin " + sys.argv[1]) -try: - x = mraa.Gpio(pin) - print("Starting ISR for pin " + repr(pin)) - x.dir(mraa.DIR_IN) - x.isr(mraa.EDGE_BOTH, test, x) - var = raw_input("Press ENTER to stop") - x.isrExit() -except ValueError as e: - print(e) +x = mraa.Gpio(6) +x.dir(mraa.DIR_IN) +x.isr(mraa.EDGE_BOTH, test, test) + +time.sleep(500) |