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