← Back to ratslair.com
aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorEdvin <[email protected]>2025-05-15 11:01:45 +0200
committerEdvin <[email protected]>2025-05-15 11:01:45 +0200
commita9eef22ca75317f86dbaa44d9b5d5794b7ff7016 (patch)
treed173b810aa9b8a77b63c627f3318a2679bd8dfe0 /main.py
parent28f7162043ed6f36c913695b9ef1b92324be7a7c (diff)
Improved direction status when going backwards
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py16
1 files 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