this might work

This commit is contained in:
Boyan 2022-07-20 17:36:29 +03:00
parent f1c0cbf8ad
commit 880d379dd1

11
main.py
View File

@ -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")