summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgpioedge.py19
-rwxr-xr-xgpiotest.py22
-rwxr-xr-xgpiotest.sh20
3 files changed, 61 insertions, 0 deletions
diff --git a/gpioedge.py b/gpioedge.py
new file mode 100755
index 0000000..097b690
--- /dev/null
+++ b/gpioedge.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python2
+import turris_gpio as gpio
+
+gpio.setmode(gpio.BCM)
+
+gpio.setup(18, gpio.IN)
+
+channel = gpio.wait_for_edge(18, gpio.BOTH, timeout=5000)
+print("both " + str(channel))
+channel = gpio.wait_for_edge(18, gpio.RISING)
+print("rising " + str(channel))
+channel = gpio.wait_for_edge(18, gpio.FALLING)
+print("falling " + str(channel))
+channel = gpio.wait_for_edge(18, gpio.BOTH)
+print("both " + str(channel))
+channel = gpio.wait_for_edge(18, gpio.BOTH)
+print("both " + str(channel))
+
+gpio.cleanup()
diff --git a/gpiotest.py b/gpiotest.py
new file mode 100755
index 0000000..130c03d
--- /dev/null
+++ b/gpiotest.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+import turris_gpio as gpio
+
+gpio.setmode(gpio.BCM)
+
+gpio.setup(33, gpio.OUT)
+gpio.setup(18, gpio.IN)
+
+gpio.output(33, 0)
+if not gpio.input(18):
+ print("0 fine")
+else:
+ print("0 failed")
+
+
+gpio.output(33, 1)
+if gpio.input(18):
+ print("1 fine")
+else:
+ print("1 failed")
+
+gpio.cleanup()
diff --git a/gpiotest.sh b/gpiotest.sh
new file mode 100755
index 0000000..00e7eb2
--- /dev/null
+++ b/gpiotest.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+G1=18
+G2=33
+
+SYS=/sys/class/gpio
+
+[ -d $SYS/gpio$G1 ] || echo $G1 > $SYS/export
+[ -d $SYS/gpio$G2 ] || echo $G2 > $SYS/export
+
+echo in > $SYS/gpio$G1/direction
+echo out > $SYS/gpio$G2/direction
+
+echo 1 > $SYS/gpio$G2/value
+[ "$(cat $SYS/gpio$G1/value)" = "1" ] || echo "1 failed"
+
+echo 0 > $SYS/gpio$G2/value
+[ "$(cat $SYS/gpio$G1/value)" = "0" ] || echo "0 failed"
+
+echo $G1 > $SYS/unexport
+echo $G2 > $SYS/unexport