diff options
| author | Edvin <[email protected]> | 2025-05-15 11:01:45 +0200 |
|---|---|---|
| committer | Edvin <[email protected]> | 2025-05-15 11:01:45 +0200 |
| commit | a9eef22ca75317f86dbaa44d9b5d5794b7ff7016 (patch) | |
| tree | d173b810aa9b8a77b63c627f3318a2679bd8dfe0 /main.py | |
| parent | 28f7162043ed6f36c913695b9ef1b92324be7a7c (diff) | |
Improved direction status when going backwards
Diffstat (limited to 'main.py')
| -rwxr-xr-x | main.py | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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 |
