cleanup
This commit is contained in:
parent
7f15aa81da
commit
8e6c23ae03
21
main.py
21
main.py
@ -4,7 +4,6 @@ import time
|
|||||||
import datetime
|
import datetime
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
PTT_IS_ON = 0
|
PTT_IS_ON = 0
|
||||||
|
|
||||||
# init GPIO
|
# init GPIO
|
||||||
@ -12,18 +11,20 @@ pi = pigpio.pi()
|
|||||||
# button pin
|
# button pin
|
||||||
pi.set_mode(10, pigpio.INPUT)
|
pi.set_mode(10, pigpio.INPUT)
|
||||||
|
|
||||||
async def button_check(gpio:int, level):
|
async def button_press(gpio:int, level) -> bool:
|
||||||
if(pi.read(gpio)!=0):
|
while True:
|
||||||
return True
|
print("a")
|
||||||
if(pi.read(gpio)==0):
|
if(pi.read(gpio)!=0):
|
||||||
return False
|
PTT_IS_ON = 1
|
||||||
|
if(pi.read(gpio)==0):
|
||||||
|
PTT_IS_ON = 0
|
||||||
|
asyncio.sleep(.5)
|
||||||
|
|
||||||
async def ptt():
|
async def ptt():
|
||||||
|
await asyncio.create_task(button_press(10, pigpio.EITHER_EDGE))
|
||||||
while True:
|
while True:
|
||||||
if await button_check(10, pigpio.EITHER_EDGE):
|
if PTT_IS_ON == 1:
|
||||||
print("HEEEEEE")
|
print("HEEEEEE")
|
||||||
asyncio.sleep(.5)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# button_press(10, pigpio.EITHER_EDGE)
|
asyncio.run(ptt())
|
||||||
asyncio.run(ptt)
|
|
Loading…
x
Reference in New Issue
Block a user