Massive improvement on gpioshell

This commit is contained in:
LazyAssassin445
2017-03-18 23:52:09 +00:00
parent 24c87c1b3f
commit b01d7a7279
2 changed files with 42 additions and 13 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
bin/

View File

@@ -8,24 +8,52 @@ GPIO.setmode(GPIO.BCM)
GPIO.cleanup() GPIO.cleanup()
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
def main(): def main():
gpio = int(input("")) choice = str(input(""))
onoff = int(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: if choice == "off":
main() try:
except KeyboardInterrupt: which=input("")
GPIO.setmode(GPIO.BCM) print(which)
GPIO.setup(gpio, GPIO.OUT) except ValueError:
GPIO.cleanup() which=str(input(""))
print(which)
GPIO.setmode(GPIO.BCM) if which != "all":
GPIO.setup(gpio, GPIO.OUT) 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() main()