this might work
This commit is contained in:
parent
f1c0cbf8ad
commit
880d379dd1
11
main.py
11
main.py
@ -5,6 +5,7 @@ import datetime
|
||||
import asyncio
|
||||
from functools import wraps, partial
|
||||
|
||||
PTT_IS_ON = 0
|
||||
def async_wrap(func):
|
||||
@wraps(func)
|
||||
async def run(*args, loop=None, executor=None, **kwargs):
|
||||
@ -22,9 +23,13 @@ pi.set_mode(10, pigpio.INPUT)
|
||||
@async_wrap
|
||||
def button_press(gpio:int, level) -> bool:
|
||||
while True:
|
||||
if(pi.read(gpio)!=0):
|
||||
PTT_IS_ON = 1
|
||||
if(pi.read(gpio)==0):
|
||||
return True
|
||||
|
||||
PTT_IS_ON = 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(asyncio.run(button_press(10, pigpio.EITHER_EDGE)))
|
||||
asyncio.run(button_press(10, pigpio.EITHER_EDGE))
|
||||
while True:
|
||||
if PTT_IS_ON == 1:
|
||||
print("WE'RE LIVE")
|
||||
|
Loading…
x
Reference in New Issue
Block a user