fix: repaired the rotate function I broke

This commit is contained in:
Laureηt 2022-03-20 23:22:36 +01:00
parent 8e5fa969a7
commit 10b37f066b
No known key found for this signature in database
GPG key ID: D88C6B294FD40994
2 changed files with 9 additions and 9 deletions

View file

@ -1,5 +1,6 @@
import itertools import itertools
import logging import logging
from curses.ascii import DEL
from subprocess import call from subprocess import call
from time import sleep from time import sleep
@ -18,7 +19,6 @@ BACK_BTN = (50, 50)
COLOR_MIN = 375 COLOR_MIN = 375
COLOR_MAX = 715 COLOR_MAX = 715
COLOR_CENTER = (COLOR_MIN + COLOR_MAX) // 2
COLOR_DIST = COLOR_MAX - COLOR_MIN COLOR_DIST = COLOR_MAX - COLOR_MIN
TEAM_OFFSET = 250 TEAM_OFFSET = 250
PRIMARY_COLOR_SLIDER = (290, 290 + TEAM_OFFSET) PRIMARY_COLOR_SLIDER = (290, 290 + TEAM_OFFSET)
@ -33,7 +33,7 @@ NB_WHEELS = 19
NB_HATS = 22 NB_HATS = 22
NB_TEAMS = 2 NB_TEAMS = 2
DELAY = 0.08 DELAY = 0.15
NB_PRIMARY_COLORS = 5 NB_PRIMARY_COLORS = 5
NB_SECONDARY_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 # set primary color, if necessary
if primary_color != old_primary_color: 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]), "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]), "MOVE")
motion((COLOR_MIN + primary_color * COLOR_DIST, PRIMARY_COLOR_SLIDER[team]), "UP") motion((COLOR_MIN + primary_color * COLOR_DIST, PRIMARY_COLOR_SLIDER[team]), "UP")
# set secondary color, if necessary # set secondary color, if necessary
if secondary_color != old_secondary_color: 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]), "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]), "MOVE")
motion((COLOR_MIN + secondary_color * COLOR_DIST, SECONDARY_COLOR_SLIDER[team]), "UP") motion((COLOR_MIN + secondary_color * COLOR_DIST, SECONDARY_COLOR_SLIDER[team]), "UP")
def rotate(x, y): def rotate(x, y):
sleep(2)
motion(CENTER, "DOWN") motion(CENTER, "DOWN")
motion(CENTER, "MOVE")
motion(np.array(CENTER) + np.array((x, y)), "MOVE") motion(np.array(CENTER) + np.array((x, y)), "MOVE")
sleep(DELAY)
motion(np.array(CENTER) + np.array((x, y)), "UP") 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_secondary_color
global old_team global old_team
sleep(0.5)
# goto garage menu # goto garage menu
tap(GARAGE_BTN) tap(GARAGE_BTN)
sleep(DELAY) sleep(DELAY)

View file

@ -26,14 +26,15 @@ if __name__ == "__main__":
set_notifications(device, False) set_notifications(device, False)
loadouts = generate_loadouts() loadouts = generate_loadouts()
rotations = generate_rotations() NB_ROTATIONS = 20
while detect_focus(device): while detect_focus(device):
for (wheel, hat, team, primary_color, secondary_color) in loadouts: for (wheel, hat, team, primary_color, secondary_color) in loadouts:
logging.debug(f"next loadout: {(wheel, hat, team, primary_color, secondary_color)}") logging.debug(f"next loadout: {(wheel, hat, team, primary_color, secondary_color)}")
newCar(wheel, hat, team, primary_color, secondary_color) newCar(wheel, hat, team, primary_color, secondary_color)
# for (horizontal_rotation, vertical_rotation) in rotations: sleep(0.5)
# rotate(horizontal_rotation, vertical_rotation) for _ in range(NB_ROTATIONS):
rotate(130, 0)
set_notifications(device, True) set_notifications(device, True)