-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpress_button.py
93 lines (66 loc) · 1.67 KB
/
press_button.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from pystages import Vector, CNCRouter
import time
from enum import Enum, auto
cnc = CNCRouter("/dev/ttyUSB0")
# cnc.move_to(Vector(15, -45, -3))
cnc.set_origin()
# Offset of 5 milimeters
z_offset = Vector(0, 0, 3)
waiting_time_up = 3
waiting_time_down = 0.75
class MODEL(Enum):
IPHONE = auto
PIXEL = auto
model = MODEL.IPHONE
x_sep = 33.5 / 2 if model == MODEL.IPHONE else 15.0
y_sep = 50 / 3 if model == MODEL.IPHONE else 15.0
up = Vector(0, y_sep, 0)
right = Vector(x_sep, 0, 0)
zero = Vector(0, 0, 0)
eight = zero + up
seven = eight - right
nine = eight + right
five = eight + up
four = five - right
six = five + right
two = five + up
one = two - right
three = two + right
def move_relative(axe, direction):
delta = [Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 0.5)][axe] * direction
cnc.position += delta
cnc.wait_move_finished()
def move_above(position):
cnc.move_to(position + (0, 0, 3))
def tap(position):
move_above(position)
cnc.position = position
move_above(position)
def unlock():
tap(zero)
cnc.move_to(zero)
cnc.position = zero + (0, 80, 2)
def tap_loop():
while True:
# Go down
cnc.position -= z_offset
# Go up
time.sleep(waiting_time_down)
cnc.position += z_offset
time.sleep(waiting_time_up)
if __name__ == "__main__":
tap(zero)
unlock()
target_digit = zero
cnc.move_to(target_digit + z_offset)
cnc.wait_move_finished()
tap_loop()
"""
while True:
# Go down
cnc.position -= z_offset
# Go up
time.sleep(waiting_time_down)
cnc.position += z_offset
time.sleep(waiting_time_up)
"""