From 10b37f066b9153def8e43038297e73e51708dd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Sun, 20 Mar 2022 23:22:36 +0100 Subject: [PATCH] fix: repaired the rotate function I broke --- src/garage.py | 11 +++++------ src/main.py | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/garage.py b/src/garage.py index 2b847e1..0f7ad11 100644 --- a/src/garage.py +++ b/src/garage.py @@ -1,5 +1,6 @@ import itertools import logging +from curses.ascii import DEL from subprocess import call from time import sleep @@ -18,7 +19,6 @@ BACK_BTN = (50, 50) COLOR_MIN = 375 COLOR_MAX = 715 -COLOR_CENTER = (COLOR_MIN + COLOR_MAX) // 2 COLOR_DIST = COLOR_MAX - COLOR_MIN TEAM_OFFSET = 250 PRIMARY_COLOR_SLIDER = (290, 290 + TEAM_OFFSET) @@ -33,7 +33,7 @@ NB_WHEELS = 19 NB_HATS = 22 NB_TEAMS = 2 -DELAY = 0.08 +DELAY = 0.15 NB_PRIMARY_COLORS = 5 NB_SECONDARY_COLORS = 5 @@ -70,23 +70,20 @@ def setColor(team: int, primary_color: float, secondary_color: float): # set primary color, if necessary if primary_color != old_primary_color: motion((COLOR_MIN + old_primary_color * COLOR_DIST, PRIMARY_COLOR_SLIDER[team]), "DOWN") - motion((COLOR_MIN + old_primary_color * COLOR_DIST, PRIMARY_COLOR_SLIDER[team]), "MOVE") motion((COLOR_MIN + primary_color * COLOR_DIST, PRIMARY_COLOR_SLIDER[team]), "MOVE") motion((COLOR_MIN + primary_color * COLOR_DIST, PRIMARY_COLOR_SLIDER[team]), "UP") # set secondary color, if necessary if secondary_color != old_secondary_color: motion((COLOR_MIN + old_secondary_color * COLOR_DIST, SECONDARY_COLOR_SLIDER[team]), "DOWN") - motion((COLOR_MIN + old_secondary_color * COLOR_DIST, SECONDARY_COLOR_SLIDER[team]), "MOVE") motion((COLOR_MIN + secondary_color * COLOR_DIST, SECONDARY_COLOR_SLIDER[team]), "MOVE") motion((COLOR_MIN + secondary_color * COLOR_DIST, SECONDARY_COLOR_SLIDER[team]), "UP") def rotate(x, y): - sleep(2) motion(CENTER, "DOWN") - motion(CENTER, "MOVE") motion(np.array(CENTER) + np.array((x, y)), "MOVE") + sleep(DELAY) motion(np.array(CENTER) + np.array((x, y)), "UP") @@ -131,6 +128,8 @@ def newCar(wheel: int, hat: int, team: int, primary_color: float, secondary_colo global old_secondary_color global old_team + sleep(0.5) + # goto garage menu tap(GARAGE_BTN) sleep(DELAY) diff --git a/src/main.py b/src/main.py index 88716a7..e94d967 100644 --- a/src/main.py +++ b/src/main.py @@ -26,14 +26,15 @@ if __name__ == "__main__": set_notifications(device, False) loadouts = generate_loadouts() - rotations = generate_rotations() + NB_ROTATIONS = 20 while detect_focus(device): for (wheel, hat, team, primary_color, secondary_color) in loadouts: logging.debug(f"next loadout: {(wheel, hat, team, primary_color, secondary_color)}") newCar(wheel, hat, team, primary_color, secondary_color) - # for (horizontal_rotation, vertical_rotation) in rotations: - # rotate(horizontal_rotation, vertical_rotation) + sleep(0.5) + for _ in range(NB_ROTATIONS): + rotate(130, 0) set_notifications(device, True)