-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.py
53 lines (41 loc) · 1.35 KB
/
actions.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
import time
from globals import DISPLAY
from utils import empty_queue
"""
Action Ideas,
Reaction tests in different levels
Jokes to read - set read speed?
"""
class Action1:
def __init__(self, action_queue, display=DISPLAY):
self.action_queue = action_queue
empty_queue(self.action_queue)
self.running = True
self.display = display
def run(self):
while self.running:
if not self.action_queue.empty():
button_press = self.action_queue.get()
self.display.show_text(button_press["combination"])
time.sleep(0.02)
def stop(self):
self.running = False
self.display.stop()
class Action2:
def __init__(self, action_queue, display=DISPLAY):
self.action_queue = action_queue
empty_queue(self.action_queue)
self.running = True
self.display = display
def run(self):
while self.running:
if not self.action_queue.empty():
button_press = self.action_queue.get()
self.display.stop_text_in_loop()
time.sleep(0.01)
self.display.start_text_in_loop(button_press["combination"], color_cycles=5)
time.sleep(0.02)
def stop(self):
self.running = False
self.display.stop_text_in_loop()
time.sleep(0.05)