From b01d7a7279540133b712c1931477063a8dd1b648 Mon Sep 17 00:00:00 2001 From: LazyAssassin445 Date: Sat, 18 Mar 2017 23:52:09 +0000 Subject: [PATCH] Massive improvement on gpioshell --- .gitignore | 1 + testprograms/gpioshell | 54 ++++++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/testprograms/gpioshell b/testprograms/gpioshell index 1a6845a..14d3b12 100755 --- a/testprograms/gpioshell +++ b/testprograms/gpioshell @@ -8,24 +8,52 @@ GPIO.setmode(GPIO.BCM) GPIO.cleanup() GPIO.setmode(GPIO.BCM) +GPIO.setwarnings(False) def main(): - gpio = int(input("")) - onoff = int(input("")) + choice = str(input("")) - GPIO.setup(gpio, GPIO.OUT) + if choice == "on": + try: + which=input("") + except ValueError: + which=str(input("")) - GPIO.output(gpio, onoff) + if which != "all": + pin = int(which) + gpio = list() + gpio.append(pin) + GPIO.setup(gpio, GPIO.OUT) + GPIO.output(gpio, 1) + elif which == "all": + gpios = [23, 17, 18] + for i in gpios: + i = int(i) + GPIO.setup(i, GPIO.OUT) + GPIO.output(i, 1) - try: - main() - except KeyboardInterrupt: - GPIO.setmode(GPIO.BCM) - GPIO.setup(gpio, GPIO.OUT) - GPIO.cleanup() + if choice == "off": + try: + which=input("") + print(which) + except ValueError: + which=str(input("")) + print(which) - GPIO.setmode(GPIO.BCM) - GPIO.setup(gpio, GPIO.OUT) - + if which != "all": + pin = int(which) + gpio = list() + gpio.append(pin) + GPIO.setup(gpio, GPIO.OUT) + GPIO.output(gpio, 0) + elif which == "all": + gpios = [23, 17, 18] + for i in gpios: + i = int(i) + GPIO.setup(i, GPIO.OUT) + GPIO.output(i, 0) + + main() main() +