-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
92 lines (82 loc) · 2.54 KB
/
config.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
import board
from microcontroller import Pin
from adafruit_hid.consumer_control_code import ConsumerControlCode
# USB HID usage for CC Power
CC_POWER_CODE = 0x30
"""
Holding 'Start' button for this period will send a Power Off command
"""
START_BUTTON_HOLD_FOR_SHUTDOWN_SECS = 3
# Configure the board with available analog/digital inputs:
"""
All available analog inputs on the board.
Keys can be anything you like except core commands, [btn{N}, x, y, z, r_z, v, hold, pre, post]
Keys are referenced by serial command interface.
Be sure to update default_joystick_pins below to match if you change them
"""
analog_ins: dict[str, Pin ] = {
'a0' : board.A0,
'a1' : board.A1,
'a2' : board.A2,
'a3' : board.A3,
}
"""
All available digital inputs on the board
Keys can be anything you like
Keys are referenced by serial command interface.
Be sure to update default_button_pins below to match if you change them
"""
digital_ins: dict[str, Pin] = {
'd0' : board.GP0,
'd1' : board.GP1,
'd2' : board.GP2,
'd3' : board.GP3,
'd4' : board.GP4,
'd5' : board.GP5,
'd6' : board.GP6,
'd7' : board.GP7,
}
# Enumerate all our digital io inputs as HID button IDs (0-15)
BUTTON_WEST_Y = 0
BUTTON_SOUTH_B = 1
BUTTON_EAST_A = 2
BUTTON_NORTH_X = 3
BUTTON_SHOULDER_L = 4
BUTTON_SHOULDER_R = 5
BUTTON_TRIGGER_L = 6
BUTTON_TRIGGER_R = 7
BUTTON_SELECT = 8
BUTTON_START = 9
BUTTON_THUMB_L = 10
BUTTON_THUMB_R = 11
BUTTON_HAT_UP = 12
BUTTON_HAT_DOWN = 13
BUTTON_HAT_LEFT = 14
BUTTON_HAT_RIGHT = 15
# CC Volume handled by buttons outside gamepad button range
BUTTON_VOL_UP = ConsumerControlCode.VOLUME_INCREMENT
BUTTON_VOL_DOWN = ConsumerControlCode.VOLUME_DECREMENT
BUTTON_VOL_MUTE = ConsumerControlCode.MUTE
BUTTON_POWER = CC_POWER_CODE
# These are the default mappings of buttons to digital inputs
default_button_pins: dict[int, str] = {
BUTTON_VOL_UP : 'd0',
BUTTON_VOL_DOWN : 'd1',
BUTTON_START : 'd2',
BUTTON_SELECT : 'd3',
BUTTON_SOUTH_B : 'd4',
BUTTON_WEST_Y : 'd5',
BUTTON_EAST_A : 'd6',
BUTTON_NORTH_X : 'd7',
}
# These are the default mappings of analog axes for joysticks:
default_joystick_pins: dict[str, str] = {
'x' : 'a0',
'y' : 'a1',
'z' : 'a2',
'r_z' : 'a3',
}
# These are the default rotary-encoder mappings:
default_rotary_encoder_pins: dict[str: (str, str, int, int)] = {
# 'rot_vol': ('d0', 'd1', BUTTON_VOL_DOWN, BUTTON_VOL_UP),
}