58 lines
808 B
Python
58 lines
808 B
Python
from gpiozero import Button
|
|
from paho.mqtt import client as mqtt
|
|
from signal import pause
|
|
import sys
|
|
|
|
#numero pin GPIO secondo lo schema BCM
|
|
SU =1
|
|
GIU =2
|
|
SX =3
|
|
DX =4
|
|
OK =5
|
|
CAN =6
|
|
|
|
#variabili globali
|
|
isRunning = True
|
|
|
|
def send_SU():
|
|
pass
|
|
|
|
def send_GIU():
|
|
pass
|
|
|
|
def send_SX():
|
|
pass
|
|
|
|
def send_DX():
|
|
pass
|
|
|
|
def send_OK():
|
|
pass
|
|
|
|
def send_CAN():
|
|
pass
|
|
|
|
|
|
def main():
|
|
btn_su = Button(SU)
|
|
btn_giu = Button(GIU)
|
|
btn_sx = Button(SX)
|
|
btn_dx = Button(DX)
|
|
btn_ok = Button(OK)
|
|
btn_can = Button(CAN)
|
|
|
|
while isRunning:
|
|
try:
|
|
client = mqtt.Client()
|
|
client.connect('localhost',1883)
|
|
|
|
except Exception as e:
|
|
print(f"Exception: {e}")
|
|
pass
|
|
pass
|
|
|
|
|
|
if __name__=="__main__":
|
|
sys.exit(main())
|
|
|