From 880d379dd17693dac00bd74abbe636303fc48510 Mon Sep 17 00:00:00 2001 From: Boyan Date: Wed, 20 Jul 2022 17:36:29 +0300 Subject: [PATCH] this might work --- main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 1cc39d5..8fe3a35 100644 --- a/main.py +++ b/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))) \ No newline at end of file + asyncio.run(button_press(10, pigpio.EITHER_EDGE)) + while True: + if PTT_IS_ON == 1: + print("WE'RE LIVE")