style: renamed some variables

This commit is contained in:
Laureηt 2022-03-20 18:00:44 +01:00
parent 4554bad0a5
commit a162e69458
No known key found for this signature in database
GPG key ID: D88C6B294FD40994

View file

@ -1,28 +1,28 @@
import logging import logging
from subprocess import call
from time import sleep from time import sleep
import numpy as np import numpy as np
from ppadb.client import Client as AdbClient
center = (1000, 500) CENTER = (1000, 500)
garage = (340, 980) GARAGE = (340, 980)
edit = (1950, 850) EDIT_LOADOUT_BTN = (1950, 850)
select = (1950, 980) SELECT_CAR_BTN = (1950, 980)
back = (70, 60) BACK_BTN = (70, 60)
itemX = (200, 450, 700) itemX = (200, 450, 700)
itemY = (300, 580, 860) itemY = (300, 580, 860)
sticker = (220, 60) STICKER_MENU_BTN = (220, 60)
wheel = (330, 60) WHEEL_MENU_BTN = (330, 60)
hat = (440, 60) HAT_MENU_BTN = (440, 60)
color = (660, 60) COLOR_MENU_BTN = (660, 60)
principale = (290, 542) PRIMARY_COLOR_SLIDER = (290, 542)
accent = (380, 632) SECONDARY_COLOR_SLIDER = (380, 632)
color_min = 366 color_min = 366
color_max = 708 color_max = 708
@ -30,10 +30,10 @@ color_center = (color_min + color_max) / 2
color_dist = color_max - color_min color_dist = color_max - color_min
Nsticker = [2, 2] # [3, 3, 8, 9] Nsticker = [2, 2] # [3, 3, 8, 9]
Nwheel = 2 # 19 Nwheel = 19
Nhat = 2 # 22 Nhat = 22
delay = 0.08 DELAY = 0.5
Ncolor_p = 1 # 3 Ncolor_p = 1 # 3
Ncolor_a = 1 # 3 Ncolor_a = 1 # 3
@ -44,6 +44,7 @@ Nrot_v = 1 # 3
def tap(pos): def tap(pos):
call(["adb", "shell", "input", "tap", str(pos[0]), str(pos[1])]) call(["adb", "shell", "input", "tap", str(pos[0]), str(pos[1])])
# device.shell(f"input tap {pos[0]} {pos[1]}")
def motion(pos, type): def motion(pos, type):
@ -51,31 +52,32 @@ def motion(pos, type):
def setColor(c: int, p: float, a: float): def setColor(c: int, p: float, a: float):
tap(color) tap(COLOR_MENU_BTN)
# set principal color # set principal color
motion((color_center, principale[c]), "DOWN") motion((color_center, PRIMARY_COLOR_SLIDER[c]), "DOWN")
motion((color_min + 100, principale[c]), "MOVE") motion((color_min + 100, PRIMARY_COLOR_SLIDER[c]), "MOVE")
motion((color_min + p * color_dist, principale[c]), "MOVE") motion((color_min + p * color_dist, PRIMARY_COLOR_SLIDER[c]), "MOVE")
motion((color_min + p * color_dist, principale[c]), "UP") motion((color_min + p * color_dist, PRIMARY_COLOR_SLIDER[c]), "UP")
# set accent color # set accent color
motion((color_center, accent[c]), "DOWN") motion((color_center, SECONDARY_COLOR_SLIDER[c]), "DOWN")
motion((color_min + 100, accent[c]), "MOVE") motion((color_min + 100, SECONDARY_COLOR_SLIDER[c]), "MOVE")
motion((color_min + a * color_dist, accent[c]), "MOVE") motion((color_min + a * color_dist, SECONDARY_COLOR_SLIDER[c]), "MOVE")
motion((color_min + a * color_dist, accent[c]), "UP") motion((color_min + a * color_dist, SECONDARY_COLOR_SLIDER[c]), "UP")
def rotate(x, y): def rotate(x, y):
motion(center, "DOWN") sleep(2)
motion(center, "MOVE") motion(CENTER, "DOWN")
motion(np.array(center) + np.array((x, y)), "MOVE") motion(CENTER, "MOVE")
motion(np.array(center) + np.array((x, y)), "UP") motion(np.array(CENTER) + np.array((x, y)), "MOVE")
motion(np.array(CENTER) + np.array((x, y)), "UP")
def selectItem(kind, i): def selectItem(kind, i):
tap(kind) tap(kind)
sleep(delay) sleep(DELAY)
col = i % 3 col = i % 3
row = i // 3 row = i // 3
@ -96,45 +98,45 @@ def selectItem(kind, i):
def nextModel(n): def nextModel(n):
motion(center, "DOWN") motion(CENTER, "DOWN")
motion(center, "MOVE") motion(CENTER, "MOVE")
motion(np.array(center) + np.array((n * -1700, 0)), "MOVE") motion(np.array(CENTER) + np.array((n * -1700, 0)), "MOVE")
motion(np.array(center) + np.array((n * -1700, 0)), "UP") motion(np.array(CENTER) + np.array((n * -1700, 0)), "UP")
tap(select) tap(SELECT_CAR_BTN)
def newCar(s: int, w: int, h: int, c: int, p: float, a: float, n: int): def newCar(s=-1, w=-1, h=-1, c=-1, p=-1.0, a=-1.0, n=-1):
tap(garage) tap(GARAGE)
sleep(delay) sleep(DELAY)
if n != 0: if n != 0:
nextModel(n) nextModel(n)
sleep(delay) sleep(DELAY)
tap(edit) tap(EDIT_LOADOUT_BTN)
sleep(delay) sleep(DELAY)
if s >= 0: if s >= 0:
selectItem(sticker, s) selectItem(STICKER_MENU_BTN, s)
sleep(delay) sleep(DELAY)
if w >= 0: if w >= 0:
selectItem(wheel, w) selectItem(WHEEL_MENU_BTN, w)
sleep(delay) sleep(DELAY)
if h >= 0: if h >= 0:
selectItem(hat, h) selectItem(HAT_MENU_BTN, h)
sleep(delay) sleep(DELAY)
if c >= 0: if c >= 0:
setColor(c, p, a) setColor(c, p, a)
sleep(delay) sleep(DELAY)
tap(back) tap(BACK_BTN)
sleep(delay) sleep(DELAY)
tap(back) tap(BACK_BTN)
sleep(delay) sleep(DELAY)
# principal color dicho # principal color dicho
@ -156,24 +158,29 @@ for ip in range(3):
# model # model
for nm, ns in enumerate(Nsticker): for nm, ns in enumerate(Nsticker):
logging.debug("model")
newCar(-1, -1, -1, c, p, a, 0) newCar(-1, -1, -1, c, p, a, 0)
# sticker # sticker
for s in range(ns): for s in range(ns):
logging.debug("sticker")
newCar(s, -1, -1, -1, 0.0, 0.0, 0) newCar(s, -1, -1, -1, 0.0, 0.0, 0)
# wheel # wheel
for w in range(Nwheel): for w in range(Nwheel):
logging.debug("wheel")
newCar(-1, w, -1, -1, 0.0, 0.0, 0) newCar(-1, w, -1, -1, 0.0, 0.0, 0)
# hat # hat
for h in range(Nhat): for h in range(Nhat):
logging.debug("hat")
newCar(-1, -1, h, -1, 0.0, 0.0, 0) newCar(-1, -1, h, -1, 0.0, 0.0, 0)
# rotate # rotate
for i in range(Nrot_v): for i in range(Nrot_v):
for j in range(Nrot_h): for j in range(Nrot_h):
rotate(1200, 0) rotate(1200, 0)
logging.debug("rotation")
rotate(0, 100) rotate(0, 100)
# next model # next model
newCar( newCar(