Skip to content

Commit 13d08de

Browse files
committed
implementing change_layer action on shortcuts
1 parent e277bd0 commit 13d08de

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

CircuitPython_Touch_Deck/code.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
MEDIA,
2424
KEY_PRESS,
2525
KEY_RELEASE,
26+
CHANGE_LAYER,
2627
)
2728

28-
2929
# seems to help the touchscreen not get stuck with chip not found
3030
time.sleep(3)
3131

@@ -40,7 +40,7 @@
4040
cc = ConsumerControl(usb_hid.devices)
4141
kbd_layout = KeyboardLayoutUS(kbd)
4242

43-
# variables to envorce timout between icon presses
43+
# variables to enforce timout between icon presses
4444
COOLDOWN_TIME = 0.5
4545
LAST_PRESS_TIME = -1
4646

@@ -132,7 +132,6 @@
132132
# helper method to laod icons for an index by its index in the
133133
# list of layers
134134
def load_layer(layer_index):
135-
136135
# show the loading screen
137136
main_group.append(loading_group)
138137
time.sleep(0.05)
@@ -299,6 +298,17 @@ def load_layer(layer_index):
299298
elif _action[0] == KEY_RELEASE:
300299
kbd.release(*_action[1])
301300

301+
# Change Layer
302+
elif _action[0] == CHANGE_LAYER:
303+
if isinstance(
304+
_action[1], int
305+
) and 0 <= _action[1] < len(
306+
touch_deck_config["layers"]
307+
):
308+
309+
current_layer = _action[1]
310+
load_layer(_action[1])
311+
302312
# if there are multiple actions
303313
if len(_cur_actions) > 1:
304314
# small sleep to make sure

CircuitPython_Touch_Deck/touch_deck_layers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
STRING = 3
77
KEY_PRESS = 4
88
KEY_RELEASE = 5
9+
CHANGE_LAYER = 6
910

1011
touch_deck_config = {
1112
"layers": [

0 commit comments

Comments
 (0)