diff options
author | Mihai Serban <mihai.serban@intel.com> | 2016-07-01 14:55:25 +0300 |
---|---|---|
committer | Mihai Serban <mihai.serban@intel.com> | 2016-07-04 15:49:56 +0300 |
commit | b33fe8d1c1c2ce22c58b02160eeda61b80eb1d26 (patch) | |
tree | efa2da1c44a8ebe8a3425291bd4f54c7fac299e8 /peripheral/libmraa/examples/python/hello_isr.py | |
parent | 180fd6f2baf51cc437c8ba84b053b2b9ed2cca11 (diff) | |
download | intel-b33fe8d1c1c2ce22c58b02160eeda61b80eb1d26.tar.gz |
libmraa: sync with upstream (SHA1: d336e9f)
URL: https://github.com/intel-iot-devkit/mraa
Branch: master
SHA1: d336e9f8d69a85b6ed1aeb5b324910234031d4a8
BUG=None
Change-Id: I0f49f13c5deccd1a42936b5934b6baf74eb8d03b
Signed-off-by: Mihai Serban <mihai.serban@intel.com>
Diffstat (limited to 'peripheral/libmraa/examples/python/hello_isr.py')
-rw-r--r-- | peripheral/libmraa/examples/python/hello_isr.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/peripheral/libmraa/examples/python/hello_isr.py b/peripheral/libmraa/examples/python/hello_isr.py index cb02488..7cdd276 100644 --- a/peripheral/libmraa/examples/python/hello_isr.py +++ b/peripheral/libmraa/examples/python/hello_isr.py @@ -24,20 +24,31 @@ import mraa import time +import sys class Counter: count = 0 c = Counter() -# inside a python interupt you cannot use 'basic' types so you'll need to use +# inside a python interrupt you cannot use 'basic' types so you'll need to use # objects -def test(args): - print("wooo") +def test(gpio): + print("pin " + repr(gpio.getPin(True)) + " = " + repr(gpio.read())) c.count+=1 -x = mraa.Gpio(6) -x.dir(mraa.DIR_IN) -x.isr(mraa.EDGE_BOTH, test, test) - -time.sleep(500) +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) |