RaspiQRP/main.py

30 lines
588 B
Python
Raw Normal View History

2022-07-20 17:22:05 +03:00
#!/usr/bin/env python
import pigpio
import time
import datetime
2022-07-20 19:28:27 +03:00
import asyncio
2022-07-20 19:22:13 +03:00
2022-07-20 17:36:29 +03:00
PTT_IS_ON = 0
2022-07-20 17:29:35 +03:00
# init GPIO
pi = pigpio.pi()
# button pin
pi.set_mode(10, pigpio.INPUT)
2022-07-20 17:02:17 +03:00
2022-07-20 19:31:34 +03:00
async def button_press(gpio:int, level) -> bool:
while True:
print("a")
if(pi.read(gpio)!=0):
PTT_IS_ON = 1
if(pi.read(gpio)==0):
PTT_IS_ON = 0
asyncio.sleep(.5)
2022-07-20 15:41:07 +01:00
2022-07-20 19:28:27 +03:00
async def ptt():
2022-07-20 19:32:26 +03:00
asyncio.create_task(button_press(10, pigpio.EITHER_EDGE))
2022-07-20 19:18:34 +03:00
while True:
2022-07-20 19:31:34 +03:00
if PTT_IS_ON == 1:
2022-07-20 19:18:34 +03:00
print("HEEEEEE")
2022-07-20 19:28:27 +03:00
2022-07-20 17:29:35 +03:00
if __name__ == "__main__":
2022-07-20 19:31:34 +03:00
asyncio.run(ptt())