From a9eef22ca75317f86dbaa44d9b5d5794b7ff7016 Mon Sep 17 00:00:00 2001 From: Edvin Date: Thu, 15 May 2025 11:01:45 +0200 Subject: Improved direction status when going backwards --- main.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 02fb728..8762366 100755 --- a/main.py +++ b/main.py @@ -45,14 +45,15 @@ def adjustAngle(adiff, f, b): print("Going backward") if adiff < 0: adiff += 180 - print(f"Adjusting to the right {adiff}") - NANO.write(b"Right\n") + print(f"Adjusting to the left {adiff}") + NANO.write(b"Left\n") sleep(abs(adiff) / 90) NANO.write(b"Stop\n") + elif adiff > 0: adiff -= 180 - print(f"Adjusting to the left {adiff}") - NANO.write(b"Left\n") + print(f"Adjusting to the right {adiff}") + NANO.write(b"Right\n") sleep(abs(adiff) / 90) NANO.write(b"Stop\n") @@ -324,7 +325,12 @@ if bto.find("Connected") != -1: xstatus = str(x).zfill(4) ystatus = str(y).zfill(4) - dirstatus = str(int(curDir)).zfill(3) + dirstatus = int(curDir) + if backward: + dirstatus -= 180 + if dirstatus < 0: + dirstatus += 360 + dirstatus = str(dirstatus).zfill(3) if iteration > delay: NANO.write(f"Current status {xstatus} {ystatus} {dirstatus}\n".encode()) iteration = 0 -- cgit v1.2.3