work pls
This commit is contained in:
parent
815221a3d2
commit
0c35597360
24
main.py
24
main.py
@ -2,7 +2,7 @@
|
||||
import pigpio
|
||||
import time
|
||||
import datetime
|
||||
from multiprocessing import Process
|
||||
import asyncio
|
||||
|
||||
def run_in_parallel(*fns):
|
||||
proc = []
|
||||
@ -20,18 +20,18 @@ pi = pigpio.pi()
|
||||
# button pin
|
||||
pi.set_mode(10, pigpio.INPUT)
|
||||
|
||||
def button_press(gpio:int, level) -> bool:
|
||||
while True:
|
||||
if(pi.read(gpio)!=0):
|
||||
PTT_IS_ON = 1
|
||||
if(pi.read(gpio)==0):
|
||||
PTT_IS_ON = 0
|
||||
time.sleep(.5)
|
||||
async def button_check(gpio:int, level):
|
||||
if(pi.read(gpio)!=0):
|
||||
return True
|
||||
if(pi.read(gpio)==0):
|
||||
return False
|
||||
|
||||
def ptt():
|
||||
async def ptt():
|
||||
while True:
|
||||
if PTT_IS_ON == 1:
|
||||
if await button_check(10, pigpio.EITHER_EDGE):
|
||||
print("HEEEEEE")
|
||||
time.sleep(.5)
|
||||
asyncio.sleep(.5)
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_in_parallel(button_press(10, pigpio.EITHER_EDGE), ptt())
|
||||
# button_press(10, pigpio.EITHER_EDGE)
|
||||
asyncio.run(ptt))
|
Loading…
x
Reference in New Issue
Block a user