Update GPIO output and setup for PTT pin 20

Refactor GPIO handling to use RPi.GPIO library for pin 20.
master-b-p-s
Alan Johnston 1 month ago committed by GitHub
parent ffa0fcdc2d
commit 9518ba870e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,7 +1,7 @@
#!/usr/bin/env python
#import RPi.GPIO as GPIO
#from RPi.GPIO import output
import RPi.GPIO as GPIO
from RPi.GPIO import output
#import subprocess
import time
from time import sleep
@ -15,9 +15,12 @@ import random
import subprocess
def output(pin, value):
command = "gpio -g write " + str(pin) + " " + str(value)
system(command)
print(command)
if (pin != 20):
command = "gpio -g write " + str(pin) + " " + str(value)
system(command)
print(command)
else: # ptt pin
GPIO.output(pin, value)
def input(pin):
# command = "gpio -g read " + str(pin)
@ -37,9 +40,17 @@ def input(pin):
def setup(pin, config):
if config == "in" or config == "out" or config == "up" or config == "down":
command = "gpio -g mode " + str(pin) + " " + config
system(command)
print(command)
if (pin != 20):
command = "gpio -g mode " + str(pin) + " " + config
system(command)
print(command)
else: # ptt pin
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
if config == "out:
GPIO.setup(27, GPIO.OUT)
else:
GPIO.setup(27, GPIO.IN)
else:
print(f"Unknown GPIO setup configuration: {config}")

Loading…
Cancel
Save

Powered by TurnKey Linux.