/
ui_map.py
57 lines (43 loc) · 1.72 KB
/
ui_map.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
#
# TO MAKE A NEW CONTROL MAP JUST:
#
# 1. SOMEWHERE BELOW CREATE A CLASS THAT EXTENDS map_interface.
# PERHAPS COPY AND MODIFY toggle_map.
#
# 2. ADD AN INSTANCE OF YOUR NEW CLASS TO map_list AT THE BOTTOM
# OF THIS FILE
#
import global_data
import mctransmitter
class map_interface:
description = "Default map description"
def update(self, button, val):
raise NotImplementedError()
class basic_map(map_interface):
description = """Basic control map:
X -> Hold for Motor 1
Y -> Hold for Motor 2
A -> Toggle Motor 1
B -> Toggle Motor 2
L2 -> Wavelength
R2 -> Frequency"""
def update(self, button_type, button_index, button_value):
if (button_type == global_data.TYPE_BUTTON):
if (button_index == global_data.BUTTON_X):
mctransmitter.tx_digital(0, button_value)
elif (button_index == global_data.BUTTON_Y):
mctransmitter.tx_digital(1, button_value)
elif ((button_index == global_data.BUTTON_A) and button_value):
mctransmitter.tx_digital(0, not global_data.digital_0_sent)
elif ((button_index == global_data.BUTTON_B) and button_value):
mctransmitter.tx_digital(1, not global_data.digital_1_sent)
elif (button_type == global_data.TYPE_AXIS):
if (button_index == global_data.AXIS_LEFT_TRIGGER):
tx_value = 127 - (button_value / 2)
mctransmitter.tx_analog(0, tx_value)
if (button_index == global_data.AXIS_RIGHT_TRIGGER):
tx_value = 127
if (button_value > 0.0):
tx_value = 128 + (button_value / 2)
mctransmitter.tx_analog(0, tx_value)
map_list = [basic_map()]