aboutsummaryrefslogtreecommitdiff
path: root/install.sh
diff options
context:
space:
mode:
authorhesicong <derekhe@april1985.com>2016-04-19 22:08:50 +0800
committerhesicong <derekhe@april1985.com>2016-04-19 22:08:50 +0800
commit31b91ea7ca2274e60f089499e2c8337eae47bff2 (patch)
tree3d5fefa22c6918ba53b595fa3735f72d2d15c13b /install.sh
parentcdd8ebaefe28e2068f87b66c5ebd73ef08efcdac (diff)
parent046a24dbf4fcd45e4b8123c82c46e89394191f13 (diff)
downloadwaveshare-7inch-touchscreen-driver-31b91ea7ca2274e60f089499e2c8337eae47bff2.tar.xz
waveshare-7inch-touchscreen-driver-31b91ea7ca2274e60f089499e2c8337eae47bff2.zip
Merge pull request #17 from noisysoil/master
Added support for async driver for systems with Python 3.4 and above.
Diffstat (limited to 'install.sh')
-rw-r--r--install.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/install.sh b/install.sh
index 9af1910..f5cbd0a 100644
--- a/install.sh
+++ b/install.sh
@@ -1,5 +1,12 @@
#!/bin/bash
+
+# For checking version numbers greater than or equal.
+check_ver_lte() {
+ [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
+}
+
+
chmod +x *.sh *.py
sudo patch -b /boot/config.txt 7inch.patch
sudo apt-get install -y python3-pip libudev-dev
@@ -7,7 +14,13 @@ sudo pip-3.2 install python-uinput pyudev
#if pip-3.2 can't be found, please use pip3
#sudo pip3 install python-uinput pyudev
-sudo cp touch.py /usr/bin/
+PYTHON_VERSION=`python3 -c 'import sys; print(".".join(map(str, sys.version_info[:3])))'`
+if check_ver_lte "3.4" $PYTHON_VERSION; then
+ echo "Python $PYTHON_VERSION detected - using async driver."
+ sudo cp touch_async.py /usr/bin/touch.py
+else
+ sudo cp touch.py /usr/bin/
+fi
sudo cp touch.sh /etc/init.d/
sudo chmod +x /usr/bin/touch.py