Funziona anche repeat

This commit is contained in:
2020-11-30 14:44:43 +00:00
parent 4c9723561a
commit 13bc0d16da

View File

@@ -21,8 +21,9 @@ client = None
debounce = 0.25 debounce = 0.25
def on_message(client, userdata, msg): def on_message(client, userdata, msg):
print(f"{msg.topic} -> {str(msg.payload)}") global isRunning
if "STOP" in str(msg.payload): print(f"{msg.topic} -> {str(msg.payload.decode('ascii'))}")
if "STOP" in msg.payload.decode('ascii'):
isRunning = False isRunning = False
pass pass
@@ -69,7 +70,7 @@ def main():
client.connect('localhost',1883) client.connect('localhost',1883)
client.subscribe(MQTT_RECEIVE) client.subscribe(MQTT_RECEIVE)
client.on_message = on_message client.on_message = on_message
#evento premuto #evento premuto
btn_su.when_pressed = send_SU btn_su.when_pressed = send_SU
btn_giu.when_pressed = send_GIU btn_giu.when_pressed = send_GIU
btn_sx.when_pressed = send_SX btn_sx.when_pressed = send_SX
@@ -83,7 +84,6 @@ def main():
btn_dx.when_held = send_DX btn_dx.when_held = send_DX
btn_ok.when_held = send_OK btn_ok.when_held = send_OK
btn_can.when_held = send_CAN btn_can.when_held = send_CAN
while isRunning: while isRunning:
client.loop(timeout=1) client.loop(timeout=1)
time.sleep(1) time.sleep(1)
@@ -93,7 +93,7 @@ def main():
client=None client=None
pass pass
pass pass
if __name__=="__main__": if __name__=="__main__":
sys.exit(main()) sys.exit(main())