change from push and release operation to just push
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import os
|
import os
|
||||||
os.environ['RPI_LGPIO_REVISION'] = "800012"
|
os.environ['RPI_LGPIO_REVISION'] = "800012"
|
||||||
|
import time
|
||||||
import requests
|
import requests
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
|
||||||
@@ -49,25 +49,14 @@ BenBusyRRCSdataFalling = '''<?xml version="1.0"?>
|
|||||||
def button_callback(channel):
|
def button_callback(channel):
|
||||||
if GPIO.input(channel):
|
if GPIO.input(channel):
|
||||||
print(f"{RED}Button pressed{RESET}")
|
print(f"{RED}Button pressed{RESET}")
|
||||||
r = requests.post(
|
r = requests.post('http://10.75.120.229:8193',headers={'content-type': 'text/xml'},data=BenBusyRRCSdataRising)
|
||||||
'http://10.75.120.229:8193',
|
time.sleep(0.05)
|
||||||
headers={'content-type': 'text/xml'},
|
|
||||||
data=BenBusyRRCSdataRising
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
print(f"{GREEN}Button released{RESET}")
|
print(f"{GREEN}Button released{RESET}")
|
||||||
r = requests.post(
|
r = requests.post('http://10.75.120.229:8193',headers={'content-type': 'text/xml'},data=BenBusyRRCSdataFalling)
|
||||||
'http://10.75.120.229:8193',
|
|
||||||
headers={'content-type': 'text/xml'},
|
|
||||||
data=BenBusyRRCSdataFalling
|
|
||||||
)
|
|
||||||
print(r.text)
|
|
||||||
|
|
||||||
GPIO.setwarnings(False)
|
GPIO.setwarnings(False)
|
||||||
GPIO.setmode(GPIO.BOARD)
|
GPIO.setmode(GPIO.BOARD)
|
||||||
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||||
|
|
||||||
# One event detector, both edges:
|
|
||||||
GPIO.add_event_detect(12, GPIO.BOTH, callback=button_callback, bouncetime=200)
|
GPIO.add_event_detect(12, GPIO.BOTH, callback=button_callback, bouncetime=200)
|
||||||
|
|
||||||
input("Press enter to quit\n\n")
|
input("Press enter to quit\n\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user