From ca876dbe1fee7a25984ec6d6d1899b6a159ebe1e Mon Sep 17 00:00:00 2001 From: Tilman Date: Fri, 28 May 2021 16:52:55 +0200 Subject: [PATCH] trigger gate first, then message to mower (takes seconds) --- garage/garage.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/garage/garage.py b/garage/garage.py index 106617f..5dfa31a 100644 --- a/garage/garage.py +++ b/garage/garage.py @@ -52,7 +52,6 @@ def logpush(message): logger.info(message) Thread(target=pushover,args=[message]).start() - # move robomower into safe zone def mower_safety(): try: @@ -108,16 +107,21 @@ def garage_button(channel): def gate_button(channel): time.sleep(0.01) if channel == 0 or GPIO.input(PIN_GATE_BUTTON) == GPIO.LOW: + toSafety = False if GPIO.input(PIN_SENSOR_GATE) == 0: - mower_safety() - else: - mower_auto() + toSafety = True + logger.info("trigger gate") GPIO.output(PIN_GATE, GPIO.HIGH) GPIO.output(PIN_LED, GPIO.HIGH) time.sleep(0.4) GPIO.output(PIN_GATE, GPIO.LOW) GPIO.output(PIN_LED, GPIO.LOW) + + if toSafety == True: + mower_safety() + else: + mower_auto() else: logger.info("flare (gate button)")