aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/labeler.yml1
-rw-r--r--.github/workflows/cli.yml1
-rw-r--r--Makefile6
-rwxr-xr-xbin/qmk58
-rw-r--r--build_keyboard.mk19
-rw-r--r--docs/cli_commands.md48
-rw-r--r--docs/contributing.md2
-rw-r--r--docs/de/cli.md19
-rw-r--r--docs/fr-fr/cli.md19
-rw-r--r--docs/hardware_keyboard_guidelines.md28
-rw-r--r--keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md4
-rw-r--r--keyboards/handwired/symmetric70_proto/post_rules.mk2
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk3
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk3
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk3
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk3
-rw-r--r--keyboards/helix/pico/keymaps/biacco/rules.mk4
-rw-r--r--keyboards/helix/pico/keymaps/default/rules.mk4
-rw-r--r--keyboards/helix/pico/keymaps/mtei/rules.mk4
-rw-r--r--keyboards/helix/pico/post_rules.mk (renamed from keyboards/helix/pico/local_features.mk)4
-rw-r--r--keyboards/helix/pico/rules.mk2
-rw-r--r--keyboards/helix/rev2/keymaps/default/rules.mk4
-rw-r--r--keyboards/helix/rev2/keymaps/five_rows/rules.mk4
-rw-r--r--keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk4
-rw-r--r--keyboards/helix/rev2/keymaps/fraanrosi/rules.mk4
-rw-r--r--keyboards/helix/rev2/keymaps/froggy/rules.mk4
-rw-r--r--keyboards/helix/rev2/keymaps/froggy_106/rules.mk4
-rw-r--r--keyboards/helix/rev2/keymaps/led_test/rules.mk4
-rw-r--r--keyboards/helix/rev2/keymaps/yshrsmz/rules.mk4
-rw-r--r--keyboards/helix/rev2/post_rules.mk3
-rw-r--r--lib/python/qmk/cli/__init__.py1
-rw-r--r--lib/python/qmk/cli/console.py303
-rw-r--r--lib/python/qmk/cli/doctor/check.py1
-rwxr-xr-xlib/python/qmk/cli/format/python.py6
-rw-r--r--lib/python/qmk/cli/lint.py145
-rw-r--r--lib/python/qmk/cli/pytest.py2
-rw-r--r--lib/python/qmk/commands.py2
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py2
-rw-r--r--quantum/quantum.c96
-rw-r--r--shell.nix2
-rw-r--r--tmk_core/common/avr/suspend.c98
-rw-r--r--tmk_core/common/chibios/suspend.c85
-rw-r--r--tmk_core/common/suspend.h2
43 files changed, 267 insertions, 750 deletions
diff --git a/.github/labeler.yml b/.github/labeler.yml
index 53921f7f9..41b2475f6 100644
--- a/.github/labeler.yml
+++ b/.github/labeler.yml
@@ -22,7 +22,6 @@ keymap:
22via: 22via:
23 - keyboards/**/keymaps/via/* 23 - keyboards/**/keymaps/via/*
24cli: 24cli:
25 - bin/qmk
26 - requirements.txt 25 - requirements.txt
27 - lib/python/**/* 26 - lib/python/**/*
28python: 27python:
diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml
index 7a8dc8540..3bf9741ac 100644
--- a/.github/workflows/cli.yml
+++ b/.github/workflows/cli.yml
@@ -8,7 +8,6 @@ on:
8 pull_request: 8 pull_request:
9 paths: 9 paths:
10 - 'lib/python/**' 10 - 'lib/python/**'
11 - 'bin/qmk'
12 - 'requirements.txt' 11 - 'requirements.txt'
13 - '.github/workflows/cli.yml' 12 - '.github/workflows/cli.yml'
14 13
diff --git a/Makefile b/Makefile
index bb2201e85..269be720c 100644
--- a/Makefile
+++ b/Makefile
@@ -30,11 +30,7 @@ endif
30endif 30endif
31 31
32# Determine which qmk cli to use 32# Determine which qmk cli to use
33ifeq (,$(shell which qmk)) 33QMK_BIN := qmk
34 QMK_BIN = bin/qmk
35else
36 QMK_BIN = qmk
37endif
38 34
39# avoid 'Entering|Leaving directory' messages 35# avoid 'Entering|Leaving directory' messages
40MAKEFLAGS += --no-print-directory 36MAKEFLAGS += --no-print-directory
diff --git a/bin/qmk b/bin/qmk
deleted file mode 100755
index 617f99282..000000000
--- a/bin/qmk
+++ /dev/null
@@ -1,58 +0,0 @@
1#!/usr/bin/env python3
2"""CLI wrapper for running QMK commands.
3"""
4import os
5import sys
6from pathlib import Path
7
8# Add the QMK python libs to our path
9script_dir = Path(os.path.realpath(__file__)).parent
10qmk_dir = script_dir.parent
11python_lib_dir = Path(qmk_dir / 'lib' / 'python').resolve()
12sys.path.append(str(python_lib_dir))
13
14# Setup the CLI
15import milc # noqa
16
17milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}'
18
19
20@milc.cli.entrypoint('QMK Helper Script')
21def qmk_main(cli):
22 """The function that gets run when no subcommand is provided.
23 """
24 cli.print_help()
25
26
27def main():
28 """Setup our environment and then call the CLI entrypoint.
29 """
30 # Change to the root of our checkout
31 os.environ['ORIG_CWD'] = os.getcwd()
32 os.environ['DEPRECATED_BIN_QMK'] = '1'
33 os.chdir(qmk_dir)
34
35 print('Warning: The bin/qmk script is being deprecated. Please install the QMK CLI: python3 -m pip install qmk', file=sys.stderr)
36
37 # Import the subcommands
38 import milc.subcommand.config # noqa
39 import qmk.cli # noqa
40
41 # Execute
42 return_code = milc.cli()
43
44 if return_code is False:
45 exit(1)
46
47 elif return_code is not True and isinstance(return_code, int):
48 if return_code < 0 or return_code > 255:
49 milc.cli.log.error('Invalid return_code: %d', return_code)
50 exit(255)
51
52 exit(return_code)
53
54 exit(0)
55
56
57if __name__ == '__main__':
58 main()
diff --git a/build_keyboard.mk b/build_keyboard.mk
index 37fa6852f..420643c3e 100644
--- a/build_keyboard.mk
+++ b/build_keyboard.mk
@@ -115,6 +115,7 @@ include $(INFO_RULES_MK)
115# Check for keymap.json first, so we can regenerate keymap.c 115# Check for keymap.json first, so we can regenerate keymap.c
116include build_json.mk 116include build_json.mk
117 117
118# Pull in keymap level rules.mk
118ifeq ("$(wildcard $(KEYMAP_PATH))", "") 119ifeq ("$(wildcard $(KEYMAP_PATH))", "")
119 # Look through the possible keymap folders until we find a matching keymap.c 120 # Look through the possible keymap folders until we find a matching keymap.c
120 ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","") 121 ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_5)/keymap.c)","")
@@ -345,6 +346,7 @@ ifeq ("$(USER_NAME)","")
345endif 346endif
346USER_PATH := users/$(USER_NAME) 347USER_PATH := users/$(USER_NAME)
347 348
349# Pull in user level rules.mk
348-include $(USER_PATH)/rules.mk 350-include $(USER_PATH)/rules.mk
349ifneq ("$(wildcard $(USER_PATH)/config.h)","") 351ifneq ("$(wildcard $(USER_PATH)/config.h)","")
350 CONFIG_H += $(USER_PATH)/config.h 352 CONFIG_H += $(USER_PATH)/config.h
@@ -356,6 +358,23 @@ endif
356# Disable features that a keyboard doesn't support 358# Disable features that a keyboard doesn't support
357-include disable_features.mk 359-include disable_features.mk
358 360
361# Pull in post_rules.mk files from all our subfolders
362ifneq ("$(wildcard $(KEYBOARD_PATH_1)/post_rules.mk)","")
363 include $(KEYBOARD_PATH_1)/post_rules.mk
364endif
365ifneq ("$(wildcard $(KEYBOARD_PATH_2)/post_rules.mk)","")
366 include $(KEYBOARD_PATH_2)/post_rules.mk
367endif
368ifneq ("$(wildcard $(KEYBOARD_PATH_3)/post_rules.mk)","")
369 include $(KEYBOARD_PATH_3)/post_rules.mk
370endif
371ifneq ("$(wildcard $(KEYBOARD_PATH_4)/post_rules.mk)","")
372 include $(KEYBOARD_PATH_4)/post_rules.mk
373endif
374ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_rules.mk)","")
375 include $(KEYBOARD_PATH_5)/post_rules.mk
376endif
377
359ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","") 378ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
360 CONFIG_H += $(KEYMAP_PATH)/config.h 379 CONFIG_H += $(KEYMAP_PATH)/config.h
361endif 380endif
diff --git a/docs/cli_commands.md b/docs/cli_commands.md
index 8fa7ad41d..06568afb4 100644
--- a/docs/cli_commands.md
+++ b/docs/cli_commands.md
@@ -118,54 +118,6 @@ This command lets you configure the behavior of QMK. For the full `qmk config` d
118qmk config [-ro] [config_token1] [config_token2] [...] [config_tokenN] 118qmk config [-ro] [config_token1] [config_token2] [...] [config_tokenN]
119``` 119```
120 120
121## `qmk console`
122
123This command lets you connect to keyboard consoles to get debugging messages. It only works if your keyboard firmware has been compiled with `CONSOLE_ENABLE=yes`.
124
125**Usage**:
126
127```
128qmk console [-d <pid>:<vid>[:<index>]] [-l] [-n] [-t] [-w <seconds>]
129```
130
131**Examples**:
132
133Connect to all available keyboards and show their console messages:
134
135```
136qmk console
137```
138
139List all devices:
140
141```
142qmk console -l
143```
144
145Show only messages from clueboard/66/rev3 keyboards:
146
147```
148qmk console -d C1ED:2370
149```
150
151Show only messages from the second clueboard/66/rev3:
152
153```
154qmk console -d C1ED:2370:2
155```
156
157Show timestamps and VID:PID instead of names:
158
159```
160qmk console -n -t
161```
162
163Disable bootloader messages:
164
165```
166qmk console --no-bootloaders
167```
168
169## `qmk doctor` 121## `qmk doctor`
170 122
171This command examines your environment and alerts you to potential build or flash problems. It can fix many of them if you want it to. 123This command examines your environment and alerts you to potential build or flash problems. It can fix many of them if you want it to.
diff --git a/docs/contributing.md b/docs/contributing.md
index 1d68d22d9..eb033d167 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -105,7 +105,7 @@ enum my_keycodes {
105 105
106Before opening a pull request, you can preview your changes if you have set up the development environment by running this command from the `qmk_firmware/` folder: 106Before opening a pull request, you can preview your changes if you have set up the development environment by running this command from the `qmk_firmware/` folder:
107 107
108 ./bin/qmk docs 108 qmk docs
109 109
110or if you only have Python 3 installed: 110or if you only have Python 3 installed:
111 111
diff --git a/docs/de/cli.md b/docs/de/cli.md
index 7dc02d505..259aeecf7 100644
--- a/docs/de/cli.md
+++ b/docs/de/cli.md
@@ -51,25 +51,6 @@ Wir suchen nach Freiwilligen, die ein `qmk`-Package für weitere Betriebssysteme
51* Installiere mit einem [virtualenv](https://virtualenv.pypa.io/en/latest/). 51* Installiere mit einem [virtualenv](https://virtualenv.pypa.io/en/latest/).
52* Weise den User an, die Umgebungs-Variable `QMK_HOME` zu setzen, um die Firmware-Quelle anders einzustellen als `~/qmk_firmware`. 52* Weise den User an, die Umgebungs-Variable `QMK_HOME` zu setzen, um die Firmware-Quelle anders einzustellen als `~/qmk_firmware`.
53 53
54# Lokale CLI
55
56Wenn Du die globale CLI nicht verwenden möchtest, beinhaltet `qmk_firmware` auch eine lokale CLI. Du kannst sie hier finden: `qmk_firmware/bin/qmk`. Du kannst den `qmk`-Befehl aus irgendeinem Datei-Verzeichnis ausführen und es wird immer auf dieser Kopie von `qmk_firmware` arbeiten.
57
58**Beispiel**:
59
60```
61$ ~/qmk_firmware/bin/qmk hello
62Ψ Hello, World!
63```
64
65## Einschränkungen der lokalen CLI
66
67Hier ein Vergleich mit der globalen CLI:
68
69* Die lokale CLI unterstützt kein `qmk setup` oder `qmk clone`.
70* Die lokale CLI arbeitet immer innerhalb der selben `qmk_firmware`-Verzeichnisstruktur, auch wenn Du mehrere Repositories geklont hast.
71* Die lokale CLI läuft nicht in einer virtualenv. Daher ist es möglich, dass Abhängigkeiten (dependencies) miteinander in Konflikt kommen/stehen.
72
73# CLI-Befehle 54# CLI-Befehle
74 55
75## `qmk compile` 56## `qmk compile`
diff --git a/docs/fr-fr/cli.md b/docs/fr-fr/cli.md
index bfa060f2a..917a9315b 100644
--- a/docs/fr-fr/cli.md
+++ b/docs/fr-fr/cli.md
@@ -48,25 +48,6 @@ Nous recherchons des gens pour créer et maintenir un paquet `qmk` pour plus de
48* Installez en utilisant un virtualenv 48* Installez en utilisant un virtualenv
49* Expliquez à l'utilisateur de définir la variable d'environnement `QMK_Home` pour "check out" les sources du firmware à un autre endroit que `~/qmk_firmware`. 49* Expliquez à l'utilisateur de définir la variable d'environnement `QMK_Home` pour "check out" les sources du firmware à un autre endroit que `~/qmk_firmware`.
50 50
51# CLI locale
52
53Si vous ne voulez pas utiliser la CLI globale, il y a une CLI locale empaquetée avec `qmk_firmware`. Vous pouvez le trouver dans `qmk_firmware/bin/qmk`. Vous pouvez lancer la commande `qmk` depuis n'importe quel répertoire et elle fonctionnera toujours sur cette copie de `qmk_firmware`.
54
55**Exemple**:
56
57```
58$ ~/qmk_firmware/bin/qmk hello
59Ψ Hello, World!
60```
61
62## Limitations de la CLI locale
63
64Il y a quelques limitations à la CLI locale comparé à la globale:
65
66* La CLI locale ne supporte pas `qmk setup` ou `qmk clone`
67* La CLI locale n'opère pas sur le même arbre `qmk_firmware`, même si vous avez plusieurs dépôts clonés.
68* La CLI locale ne s'exécute pas dans un virtualenv, donc il y a des risques que des dépendances seront en conflit
69
70# Les commandes CLI 51# Les commandes CLI
71 52
72## `qmk compile` 53## `qmk compile`
diff --git a/docs/hardware_keyboard_guidelines.md b/docs/hardware_keyboard_guidelines.md
index 7630b44e0..17be7ee6a 100644
--- a/docs/hardware_keyboard_guidelines.md
+++ b/docs/hardware_keyboard_guidelines.md
@@ -144,10 +144,38 @@ The `rules.mk` file can also be placed in a sub-folder, and its reading order is
144 * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/rules.mk` 144 * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/rules.mk`
145 * `keyboards/top_folder/keymaps/a_keymap/rules.mk` 145 * `keyboards/top_folder/keymaps/a_keymap/rules.mk`
146 * `users/a_user_folder/rules.mk` 146 * `users/a_user_folder/rules.mk`
147 * `keyboards/top_folder/sub_1/sub_2/sub_3/sub_4/post_rules.mk`
148 * `keyboards/top_folder/sub_1/sub_2/sub_3/post_rules.mk`
149 * `keyboards/top_folder/sub_1/sub_2/post_rules.mk`
150 * `keyboards/top_folder/sub_1/post_rules.mk`
151* `keyboards/top_folder/post_rules.mk`
147* `common_features.mk` 152* `common_features.mk`
148 153
149Many of the settings written in the `rules.mk` file are interpreted by `common_features.mk`, which sets the necessary source files and compiler options. 154Many of the settings written in the `rules.mk` file are interpreted by `common_features.mk`, which sets the necessary source files and compiler options.
150 155
156The `post_rules.mk` file can interpret `features` of a keyboard-level before `common_features.mk`. For example, when your designed keyboard has the option to implement backlighting or underglow using rgblight.c, writing the following in the `post_rules.mk` makes it easier for the user to configure the `rules.mk`.
157
158* `keyboards/top_folder/keymaps/a_keymap/rules.mk`
159 ```makefile
160 # Please set the following according to the selection of the hardware implementation option.
161 RGBLED_OPTION_TYPE = backlight ## none, backlight or underglow
162 ```
163* `keyboards/top_folder/post_rules.mk`
164 ```makefile
165 ifeq ($(filter $(strip $(RGBLED_OPTION_TYPE))x, nonex backlightx underglowx x),)
166 $(error unknown RGBLED_OPTION_TYPE value "$(RGBLED_OPTION_TYPE)")
167 endif
168
169 ifeq ($(strip $(RGBLED_OPTION_TYPE)),backlight)
170 RGBLIGHT_ENABLE = yes
171 OPT_DEFS += -DRGBLED_NUM=30
172 endif
173 ifeq ($(strip $(RGBLED_OPTION_TYPE)),underglow)
174 RGBLIGHT_ENABLE = yes
175 OPT_DEFS += -DRGBLED_NUM=6
176 endif
177 ```
178
151?> See `build_keyboard.mk` and `common_features.mk` for more details. 179?> See `build_keyboard.mk` and `common_features.mk` for more details.
152 180
153### `<keyboard_name.c>` 181### `<keyboard_name.c>`
diff --git a/keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md b/keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md
index d87258731..9de86be2d 100644
--- a/keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md
+++ b/keyboards/dztech/dz65rgb/keymaps/jumper149/readme.md
@@ -3,13 +3,13 @@
3Run commands in the root directory of this repository. 3Run commands in the root directory of this repository.
4 4
5``` 5```
6./bin/qmk compile && sudo dfu-programmer atmega32u4 erase && sudo dfu-programmer atmega32u4 flash ./dztech_dz65rgb_v2_jumper149.hex && sudo dfu-programmer atmega32u4 reset 6qmk compile && sudo dfu-programmer atmega32u4 erase && sudo dfu-programmer atmega32u4 flash ./dztech_dz65rgb_v2_jumper149.hex && sudo dfu-programmer atmega32u4 reset
7``` 7```
8 8
9## build 9## build
10 10
11``` 11```
12./bin/qmk compile 12qmk compile
13``` 13```
14 14
15## flash 15## flash
diff --git a/keyboards/handwired/symmetric70_proto/post_rules.mk b/keyboards/handwired/symmetric70_proto/post_rules.mk
new file mode 100644
index 000000000..e2d35d60a
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/post_rules.mk
@@ -0,0 +1,2 @@
1KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))local_features.mk
2include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk b/keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk
index de489fcab..fbc1c3bb3 100644
--- a/keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk
+++ b/keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk
@@ -1,6 +1,3 @@
1CUSTOM_MATRIX = yes 1CUSTOM_MATRIX = yes
2SRC += matrix_common.c 2SRC += matrix_common.c
3SRC += matrix_fast/matrix.c 3SRC += matrix_fast/matrix.c
4
5KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))../../local_features.mk
6include $(KEYBOARD_LOCAL_FEATURES_MK)
diff --git a/keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk b/keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk
index 0b2b707ef..73192f4ff 100644
--- a/keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk
+++ b/keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk
@@ -1,6 +1,3 @@
1CUSTOM_MATRIX = yes 1CUSTOM_MATRIX = yes
2SRC += matrix_common.c 2SRC += matrix_common.c
3SRC += matrix_debug/matrix.c 3SRC += matrix_debug/matrix.c
4
5KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))../../local_features.mk
6include $(KEYBOARD_LOCAL_FEATURES_MK)
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk b/keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk
index de489fcab..fbc1c3bb3 100644
--- a/keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk
+++ b/keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk
@@ -1,6 +1,3 @@
1CUSTOM_MATRIX = yes 1CUSTOM_MATRIX = yes
2SRC += matrix_common.c 2SRC += matrix_common.c
3SRC += matrix_fast/matrix.c 3SRC += matrix_fast/matrix.c
4
5KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))../../local_features.mk
6include $(KEYBOARD_LOCAL_FEATURES_MK)
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk b/keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk
index 0b2b707ef..73192f4ff 100644
--- a/keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk
+++ b/keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk
@@ -1,6 +1,3 @@
1CUSTOM_MATRIX = yes 1CUSTOM_MATRIX = yes
2SRC += matrix_common.c 2SRC += matrix_common.c
3SRC += matrix_debug/matrix.c 3SRC += matrix_debug/matrix.c
4
5KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))../../local_features.mk
6include $(KEYBOARD_LOCAL_FEATURES_MK)
diff --git a/keyboards/helix/pico/keymaps/biacco/rules.mk b/keyboards/helix/pico/keymaps/biacco/rules.mk
index 37e49977c..993ade267 100644
--- a/keyboards/helix/pico/keymaps/biacco/rules.mk
+++ b/keyboards/helix/pico/keymaps/biacco/rules.mk
@@ -18,7 +18,3 @@ LTO_ENABLE = no # if firmware size over limit, try this option
18# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) 18# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.)
19LED_ANIMATIONS = no # LED animations 19LED_ANIMATIONS = no # LED animations
20# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 20# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
21
22# convert Helix-specific options (that represent combinations of standard options)
23# into QMK standard options.
24include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/pico/keymaps/default/rules.mk b/keyboards/helix/pico/keymaps/default/rules.mk
index 8f198e380..8977897f9 100644
--- a/keyboards/helix/pico/keymaps/default/rules.mk
+++ b/keyboards/helix/pico/keymaps/default/rules.mk
@@ -18,7 +18,3 @@ LTO_ENABLE = no # if firmware size over limit, try this option
18# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) 18# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.)
19# LED_ANIMATIONS = yes # LED animations 19# LED_ANIMATIONS = yes # LED animations
20# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 20# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
21
22# convert Helix-specific options (that represent combinations of standard options)
23# into QMK standard options.
24include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/pico/keymaps/mtei/rules.mk b/keyboards/helix/pico/keymaps/mtei/rules.mk
index 165233f5f..05a60f67d 100644
--- a/keyboards/helix/pico/keymaps/mtei/rules.mk
+++ b/keyboards/helix/pico/keymaps/mtei/rules.mk
@@ -18,7 +18,3 @@ LTO_ENABLE = no # if firmware size over limit, try this option
18# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) 18# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.)
19# LED_ANIMATIONS = yes # LED animations 19# LED_ANIMATIONS = yes # LED animations
20# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 20# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
21
22# convert Helix-specific options (that represent combinations of standard options)
23# into QMK standard options.
24include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/pico/local_features.mk b/keyboards/helix/pico/post_rules.mk
index be5c739f9..38573d75a 100644
--- a/keyboards/helix/pico/local_features.mk
+++ b/keyboards/helix/pico/post_rules.mk
@@ -1,12 +1,10 @@
1# 1#
2# local_features.mk contains post-processing rules for the Helix keyboard. 2# post_rules.mk contains post-processing rules for the Helix keyboard.
3# 3#
4# Post-processing rules convert keyboard-specific shortcuts (that represent 4# Post-processing rules convert keyboard-specific shortcuts (that represent
5# combinations of standard options) into QMK standard options. 5# combinations of standard options) into QMK standard options.
6# 6#
7 7
8KEYBOARD_LOCAL_FEATURES_MK :=
9
10define HELIX_CUSTOMISE_MSG 8define HELIX_CUSTOMISE_MSG
11 $(info Helix Spacific Build Options) 9 $(info Helix Spacific Build Options)
12 $(info - OLED_ENABLE = $(OLED_ENABLE)) 10 $(info - OLED_ENABLE = $(OLED_ENABLE))
diff --git a/keyboards/helix/pico/rules.mk b/keyboards/helix/pico/rules.mk
index cb9a70e00..12caec37e 100644
--- a/keyboards/helix/pico/rules.mk
+++ b/keyboards/helix/pico/rules.mk
@@ -1,5 +1,3 @@
1KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))local_features.mk
2
3# Helix Spacific Build Options default values 1# Helix Spacific Build Options default values
4OLED_ENABLE = no # OLED_ENABLE 2OLED_ENABLE = no # OLED_ENABLE
5LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" 3LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c"
diff --git a/keyboards/helix/rev2/keymaps/default/rules.mk b/keyboards/helix/rev2/keymaps/default/rules.mk
index c16f3e2b8..58b43a6bd 100644
--- a/keyboards/helix/rev2/keymaps/default/rules.mk
+++ b/keyboards/helix/rev2/keymaps/default/rules.mk
@@ -29,7 +29,3 @@ OLED_SELECT = core
29ifeq ($(strip $(OLED_ENABLE)), yes) 29ifeq ($(strip $(OLED_ENABLE)), yes)
30 SRC += oled_display.c 30 SRC += oled_display.c
31endif 31endif
32
33# convert Helix-specific options (that represent combinations of standard options)
34# into QMK standard options.
35include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/rev2/keymaps/five_rows/rules.mk b/keyboards/helix/rev2/keymaps/five_rows/rules.mk
index e59ce7332..5f7e4668f 100644
--- a/keyboards/helix/rev2/keymaps/five_rows/rules.mk
+++ b/keyboards/helix/rev2/keymaps/five_rows/rules.mk
@@ -95,7 +95,3 @@ endif
95ifeq ($(strip $(OLED_ENABLE)), yes) 95ifeq ($(strip $(OLED_ENABLE)), yes)
96 SRC += oled_display.c 96 SRC += oled_display.c
97endif 97endif
98
99# convert Helix-specific options (that represent combinations of standard options)
100# into QMK standard options.
101include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk b/keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk
index d44382f86..7c4a7b604 100644
--- a/keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk
+++ b/keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk
@@ -17,7 +17,3 @@ HELIX_ROWS = 5 # Helix Rows is 4 or 5
17# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) 17# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.)
18# LED_ANIMATIONS = yes # LED animations 18# LED_ANIMATIONS = yes # LED animations
19# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 19# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
20
21# convert Helix-specific options (that represent combinations of standard options)
22# into QMK standard options.
23include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/rev2/keymaps/fraanrosi/rules.mk b/keyboards/helix/rev2/keymaps/fraanrosi/rules.mk
index 462a83f6e..98585b0d6 100644
--- a/keyboards/helix/rev2/keymaps/fraanrosi/rules.mk
+++ b/keyboards/helix/rev2/keymaps/fraanrosi/rules.mk
@@ -22,7 +22,3 @@ LED_ANIMATIONS = yes # LED animations
22 22
23LED_BACK_ENABLE = no 23LED_BACK_ENABLE = no
24LED_UNDERGLOW_ENABLE = yes 24LED_UNDERGLOW_ENABLE = yes
25
26# convert Helix-specific options (that represent combinations of standard options)
27# into QMK standard options.
28include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/rev2/keymaps/froggy/rules.mk b/keyboards/helix/rev2/keymaps/froggy/rules.mk
index 5a0fd9a2b..2d01c43fe 100644
--- a/keyboards/helix/rev2/keymaps/froggy/rules.mk
+++ b/keyboards/helix/rev2/keymaps/froggy/rules.mk
@@ -17,7 +17,3 @@ LED_BACK_ENABLE = yes # LED backlight (Enable WS2812 RGB underlight.)
17LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) 17LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.)
18LED_ANIMATIONS = yes # LED animations 18LED_ANIMATIONS = yes # LED animations
19# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 19# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
20
21# convert Helix-specific options (that represent combinations of standard options)
22# into QMK standard options.
23include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/rev2/keymaps/froggy_106/rules.mk b/keyboards/helix/rev2/keymaps/froggy_106/rules.mk
index 5a0fd9a2b..2d01c43fe 100644
--- a/keyboards/helix/rev2/keymaps/froggy_106/rules.mk
+++ b/keyboards/helix/rev2/keymaps/froggy_106/rules.mk
@@ -17,7 +17,3 @@ LED_BACK_ENABLE = yes # LED backlight (Enable WS2812 RGB underlight.)
17LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) 17LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.)
18LED_ANIMATIONS = yes # LED animations 18LED_ANIMATIONS = yes # LED animations
19# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 19# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
20
21# convert Helix-specific options (that represent combinations of standard options)
22# into QMK standard options.
23include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/rev2/keymaps/led_test/rules.mk b/keyboards/helix/rev2/keymaps/led_test/rules.mk
index 8b590eee8..3ab27acfc 100644
--- a/keyboards/helix/rev2/keymaps/led_test/rules.mk
+++ b/keyboards/helix/rev2/keymaps/led_test/rules.mk
@@ -23,7 +23,3 @@ ifeq ($(strip $(OLED_ENABLE)), yes)
23 SRC += oled_display.c 23 SRC += oled_display.c
24endif 24endif
25SRC += led_test_init.c 25SRC += led_test_init.c
26
27# convert Helix-specific options (that represent combinations of standard options)
28# into QMK standard options.
29include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/rev2/keymaps/yshrsmz/rules.mk b/keyboards/helix/rev2/keymaps/yshrsmz/rules.mk
index 83dcc9b3b..cd436cd9a 100644
--- a/keyboards/helix/rev2/keymaps/yshrsmz/rules.mk
+++ b/keyboards/helix/rev2/keymaps/yshrsmz/rules.mk
@@ -17,7 +17,3 @@ OLED_ENABLE = yes # OLED_ENABLE
17# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) 17# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.)
18LED_ANIMATIONS = no # LED animations 18LED_ANIMATIONS = no # LED animations
19# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 19# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
20
21# convert Helix-specific options (that represent combinations of standard options)
22# into QMK standard options.
23include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
diff --git a/keyboards/helix/rev2/post_rules.mk b/keyboards/helix/rev2/post_rules.mk
new file mode 100644
index 000000000..4c671d451
--- /dev/null
+++ b/keyboards/helix/rev2/post_rules.mk
@@ -0,0 +1,3 @@
1ifneq ($(strip $(KEYBOARD_LOCAL_FEATURES_MK)),)
2 include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))
3endif
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index f45e33240..292dcbe81 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -35,7 +35,6 @@ subcommands = [
35 'qmk.cli.chibios.confmigrate', 35 'qmk.cli.chibios.confmigrate',
36 'qmk.cli.clean', 36 'qmk.cli.clean',
37 'qmk.cli.compile', 37 'qmk.cli.compile',
38 'qmk.cli.console',
39 'qmk.cli.docs', 38 'qmk.cli.docs',
40 'qmk.cli.doctor', 39 'qmk.cli.doctor',
41 'qmk.cli.fileformat', 40 'qmk.cli.fileformat',
diff --git a/lib/python/qmk/cli/console.py b/lib/python/qmk/cli/console.py
deleted file mode 100644
index 3c508160e..000000000
--- a/lib/python/qmk/cli/console.py
+++ /dev/null
@@ -1,303 +0,0 @@
1"""Acquire debugging information from usb hid devices
2
3cli implementation of https://www.pjrc.com/teensy/hid_listen.html
4"""
5from pathlib import Path
6from threading import Thread
7from time import sleep, strftime
8
9import hid
10import usb.core
11
12from milc import cli
13
14LOG_COLOR = {
15 'next': 0,
16 'colors': [
17 '{fg_blue}',
18 '{fg_cyan}',
19 '{fg_green}',
20 '{fg_magenta}',
21 '{fg_red}',
22 '{fg_yellow}',
23 ],
24}
25
26KNOWN_BOOTLOADERS = {
27 # VID , PID
28 ('03EB', '2FEF'): 'atmel-dfu: ATmega16U2',
29 ('03EB', '2FF0'): 'atmel-dfu: ATmega32U2',
30 ('03EB', '2FF3'): 'atmel-dfu: ATmega16U4',
31 ('03EB', '2FF4'): 'atmel-dfu: ATmega32U4',
32 ('03EB', '2FF9'): 'atmel-dfu: AT90USB64',
33 ('03EB', '2FFA'): 'atmel-dfu: AT90USB162',
34 ('03EB', '2FFB'): 'atmel-dfu: AT90USB128',
35 ('03EB', '6124'): 'Microchip SAM-BA',
36 ('0483', 'DF11'): 'stm32-dfu: STM32 BOOTLOADER',
37 ('16C0', '05DC'): 'USBasp: USBaspLoader',
38 ('16C0', '05DF'): 'bootloadHID: HIDBoot',
39 ('16C0', '0478'): 'halfkay: Teensy Halfkay',
40 ('1B4F', '9203'): 'caterina: Pro Micro 3.3V',
41 ('1B4F', '9205'): 'caterina: Pro Micro 5V',
42 ('1B4F', '9207'): 'caterina: LilyPadUSB',
43 ('1C11', 'B007'): 'kiibohd: Kiibohd DFU Bootloader',
44 ('1EAF', '0003'): 'stm32duino: Maple 003',
45 ('1FFB', '0101'): 'caterina: Polou A-Star 32U4 Bootloader',
46 ('2341', '0036'): 'caterina: Arduino Leonardo',
47 ('2341', '0037'): 'caterina: Arduino Micro',
48 ('239A', '000C'): 'caterina: Adafruit Feather 32U4',
49 ('239A', '000D'): 'caterina: Adafruit ItsyBitsy 32U4 3v',
50 ('239A', '000E'): 'caterina: Adafruit ItsyBitsy 32U4 5v',
51 ('2A03', '0036'): 'caterina: Arduino Leonardo',
52 ('2A03', '0037'): 'caterina: Arduino Micro',
53 ('314B', '0106'): 'apm32-dfu: APM32 DFU ISP Mode',
54 ('03EB', '2067'): 'qmk-hid: HID Bootloader',
55 ('03EB', '2045'): 'lufa-ms: LUFA Mass Storage Bootloader'
56}
57
58
59class MonitorDevice(object):
60 def __init__(self, hid_device, numeric):
61 self.hid_device = hid_device
62 self.numeric = numeric
63 self.device = hid.Device(path=hid_device['path'])
64 self.current_line = ''
65
66 cli.log.info('Console Connected: %(color)s%(manufacturer_string)s %(product_string)s{style_reset_all} (%(color)s%(vendor_id)04X:%(product_id)04X:%(index)d{style_reset_all})', hid_device)
67
68 def read(self, size, encoding='ascii', timeout=1):
69 """Read size bytes from the device.
70 """
71 return self.device.read(size, timeout).decode(encoding)
72
73 def read_line(self):
74 """Read from the device's console until we get a \n.
75 """
76 while '\n' not in self.current_line:
77 self.current_line += self.read(32).replace('\x00', '')
78
79 lines = self.current_line.split('\n', 1)
80 self.current_line = lines[1]
81
82 return lines[0]
83
84 def run_forever(self):
85 while True:
86 try:
87 message = {**self.hid_device, 'text': self.read_line()}
88 identifier = (int2hex(message['vendor_id']), int2hex(message['product_id'])) if self.numeric else (message['manufacturer_string'], message['product_string'])
89 message['identifier'] = ':'.join(identifier)
90 message['ts'] = '{style_dim}{fg_green}%s{style_reset_all} ' % (strftime(cli.config.general.datetime_fmt),) if cli.args.timestamp else ''
91
92 cli.echo('%(ts)s%(color)s%(identifier)s:%(index)d{style_reset_all}: %(text)s' % message)
93
94 except hid.HIDException:
95 break
96
97
98class FindDevices(object):
99 def __init__(self, vid, pid, index, numeric):
100 self.vid = vid
101 self.pid = pid
102 self.index = index
103 self.numeric = numeric
104
105 def run_forever(self):
106 """Process messages from our queue in a loop.
107 """
108 live_devices = {}
109 live_bootloaders = {}
110
111 while True:
112 try:
113 for device in list(live_devices):
114 if not live_devices[device]['thread'].is_alive():
115 cli.log.info('Console Disconnected: %(color)s%(manufacturer_string)s %(product_string)s{style_reset_all} (%(color)s%(vendor_id)04X:%(product_id)04X:%(index)d{style_reset_all})', live_devices[device])
116 del live_devices[device]
117
118 for device in self.find_devices():
119 if device['path'] not in live_devices:
120 device['color'] = LOG_COLOR['colors'][LOG_COLOR['next']]
121 LOG_COLOR['next'] = (LOG_COLOR['next'] + 1) % len(LOG_COLOR['colors'])
122 live_devices[device['path']] = device
123
124 try:
125 monitor = MonitorDevice(device, self.numeric)
126 device['thread'] = Thread(target=monitor.run_forever, daemon=True)
127
128 device['thread'].start()
129 except Exception as e:
130 device['e'] = e
131 device['e_name'] = e.__class__.__name__
132 cli.log.error("Could not connect to %(color)s%(manufacturer_string)s %(product_string)s{style_reset_all} (%(color)s:%(vendor_id)04X:%(product_id)04X:%(index)d): %(e_name)s: %(e)s", device)
133 if cli.config.general.verbose:
134 cli.log.exception(e)
135 del live_devices[device['path']]
136
137 if cli.args.bootloaders:
138 for device in self.find_bootloaders():
139 if device.address in live_bootloaders:
140 live_bootloaders[device.address]._qmk_found = True
141 else:
142 name = KNOWN_BOOTLOADERS[(int2hex(device.idVendor), int2hex(device.idProduct))]
143 cli.log.info('Bootloader Connected: {style_bright}{fg_magenta}%s', name)
144 device._qmk_found = True
145 live_bootloaders[device.address] = device
146
147 for device in list(live_bootloaders):
148 if live_bootloaders[device]._qmk_found:
149 live_bootloaders[device]._qmk_found = False
150 else:
151 name = KNOWN_BOOTLOADERS[(int2hex(live_bootloaders[device].idVendor), int2hex(live_bootloaders[device].idProduct))]
152 cli.log.info('Bootloader Disconnected: {style_bright}{fg_magenta}%s', name)
153 del live_bootloaders[device]
154
155 sleep(.1)
156
157 except KeyboardInterrupt:
158 break
159
160 def is_bootloader(self, hid_device):
161 """Returns true if the device in question matches a known bootloader vid/pid.
162 """
163 return (int2hex(hid_device.idVendor), int2hex(hid_device.idProduct)) in KNOWN_BOOTLOADERS
164
165 def is_console_hid(self, hid_device):
166 """Returns true when the usage page indicates it's a teensy-style console.
167 """
168 return hid_device['usage_page'] == 0xFF31 and hid_device['usage'] == 0x0074
169
170 def is_filtered_device(self, hid_device):
171 """Returns True if the device should be included in the list of available consoles.
172 """
173 return int2hex(hid_device['vendor_id']) == self.vid and int2hex(hid_device['product_id']) == self.pid
174
175 def find_devices_by_report(self, hid_devices):
176 """Returns a list of available teensy-style consoles by doing a brute-force search.
177
178 Some versions of linux don't report usage and usage_page. In that case we fallback to reading the report (possibly inaccurately) ourselves.
179 """
180 devices = []
181
182 for device in hid_devices:
183 path = device['path'].decode('utf-8')
184
185 if path.startswith('/dev/hidraw'):
186 number = path[11:]
187 report = Path(f'/sys/class/hidraw/hidraw{number}/device/report_descriptor')
188
189 if report.exists():
190 rp = report.read_bytes()
191
192 if rp[1] == 0x31 and rp[3] == 0x09:
193 devices.append(device)
194
195 return devices
196
197 def find_bootloaders(self):
198 """Returns a list of available bootloader devices.
199 """
200 return list(filter(self.is_bootloader, usb.core.find(find_all=True)))
201
202 def find_devices(self):
203 """Returns a list of available teensy-style consoles.
204 """
205 hid_devices = hid.enumerate()
206 devices = list(filter(self.is_console_hid, hid_devices))
207
208 if not devices:
209 devices = self.find_devices_by_report(hid_devices)
210
211 if self.vid and self.pid:
212 devices = list(filter(self.is_filtered_device, devices))
213
214 # Add index numbers
215 device_index = {}
216 for device in devices:
217 id = ':'.join((int2hex(device['vendor_id']), int2hex(device['product_id'])))
218
219 if id not in device_index:
220 device_index[id] = 0
221
222 device_index[id] += 1
223 device['index'] = device_index[id]
224
225 return devices
226
227
228def int2hex(number):
229 """Returns a string representation of the number as hex.
230 """
231 return "%04X" % number
232
233
234def list_devices(device_finder):
235 """Show the user a nicely formatted list of devices.
236 """
237 devices = device_finder.find_devices()
238
239 if devices:
240 cli.log.info('Available devices:')
241 for dev in devices:
242 color = LOG_COLOR['colors'][LOG_COLOR['next']]
243 LOG_COLOR['next'] = (LOG_COLOR['next'] + 1) % len(LOG_COLOR['colors'])
244 cli.log.info("\t%s%s:%s:%d{style_reset_all}\t%s %s", color, int2hex(dev['vendor_id']), int2hex(dev['product_id']), dev['index'], dev['manufacturer_string'], dev['product_string'])
245
246 if cli.args.bootloaders:
247 bootloaders = device_finder.find_bootloaders()
248
249 if bootloaders:
250 cli.log.info('Available Bootloaders:')
251
252 for dev in bootloaders:
253 cli.log.info("\t%s:%s\t%s", int2hex(dev.idVendor), int2hex(dev.idProduct), KNOWN_BOOTLOADERS[(int2hex(dev.idVendor), int2hex(dev.idProduct))])
254
255
256@cli.argument('--bootloaders', arg_only=True, default=True, action='store_boolean', help='displaying bootloaders.')
257@cli.argument('-d', '--device', help='Device to select - uses format <pid>:<vid>[:<index>].')
258@cli.argument('-l', '--list', arg_only=True, action='store_true', help='List available hid_listen devices.')
259@cli.argument('-n', '--numeric', arg_only=True, action='store_true', help='Show VID/PID instead of names.')
260@cli.argument('-t', '--timestamp', arg_only=True, action='store_true', help='Print the timestamp for received messages as well.')
261@cli.argument('-w', '--wait', type=int, default=1, help="How many seconds to wait between checks (Default: 1)")
262@cli.subcommand('Acquire debugging information from usb hid devices.', hidden=False if cli.config.user.developer else True)
263def console(cli):
264 """Acquire debugging information from usb hid devices
265 """
266 vid = None
267 pid = None
268 index = 1
269
270 if cli.config.console.device:
271 device = cli.config.console.device.split(':')
272
273 if len(device) == 2:
274 vid, pid = device
275
276 elif len(device) == 3:
277 vid, pid, index = device
278
279 if not index.isdigit():
280 cli.log.error('Device index must be a number! Got "%s" instead.', index)
281 exit(1)
282
283 index = int(index)
284
285 if index < 1:
286 cli.log.error('Device index must be greater than 0! Got %s', index)
287 exit(1)
288
289 else:
290 cli.log.error('Invalid format for device, expected "<pid>:<vid>[:<index>]" but got "%s".', cli.config.console.device)
291 cli.print_help()
292 exit(1)
293
294 vid = vid.upper()
295 pid = pid.upper()
296
297 device_finder = FindDevices(vid, pid, index, cli.args.numeric)
298
299 if cli.args.list:
300 return list_devices(device_finder)
301
302 print('Looking for devices...', flush=True)
303 device_finder.run_forever()
diff --git a/lib/python/qmk/cli/doctor/check.py b/lib/python/qmk/cli/doctor/check.py
index 0807f4151..2d691b64b 100644
--- a/lib/python/qmk/cli/doctor/check.py
+++ b/lib/python/qmk/cli/doctor/check.py
@@ -26,7 +26,6 @@ ESSENTIAL_BINARIES = {
26 'arm-none-eabi-gcc': { 26 'arm-none-eabi-gcc': {
27 'version_arg': '-dumpversion' 27 'version_arg': '-dumpversion'
28 }, 28 },
29 'bin/qmk': {},
30} 29}
31 30
32 31
diff --git a/lib/python/qmk/cli/format/python.py b/lib/python/qmk/cli/format/python.py
index 00612f97e..b32a72640 100755
--- a/lib/python/qmk/cli/format/python.py
+++ b/lib/python/qmk/cli/format/python.py
@@ -11,15 +11,15 @@ def format_python(cli):
11 """Format python code according to QMK's style. 11 """Format python code according to QMK's style.
12 """ 12 """
13 edit = '--diff' if cli.args.dry_run else '--in-place' 13 edit = '--diff' if cli.args.dry_run else '--in-place'
14 yapf_cmd = ['yapf', '-vv', '--recursive', edit, 'bin/qmk', 'lib/python'] 14 yapf_cmd = ['yapf', '-vv', '--recursive', edit, 'lib/python']
15 try: 15 try:
16 cli.run(yapf_cmd, check=True, capture_output=False, stdin=DEVNULL) 16 cli.run(yapf_cmd, check=True, capture_output=False, stdin=DEVNULL)
17 cli.log.info('Python code in `bin/qmk` and `lib/python` is correctly formatted.') 17 cli.log.info('Python code in `lib/python` is correctly formatted.')
18 return True 18 return True
19 19
20 except CalledProcessError: 20 except CalledProcessError:
21 if cli.args.dry_run: 21 if cli.args.dry_run:
22 cli.log.error('Python code in `bin/qmk` and `lib/python` incorrectly formatted!') 22 cli.log.error('Python code in `lib/python` is incorrectly formatted!')
23 else: 23 else:
24 cli.log.error('Error formatting python code!') 24 cli.log.error('Error formatting python code!')
25 25
diff --git a/lib/python/qmk/cli/lint.py b/lib/python/qmk/cli/lint.py
index 02b31fbc4..96593ed69 100644
--- a/lib/python/qmk/cli/lint.py
+++ b/lib/python/qmk/cli/lint.py
@@ -1,72 +1,129 @@
1"""Command to look over a keyboard/keymap and check for common mistakes. 1"""Command to look over a keyboard/keymap and check for common mistakes.
2""" 2"""
3from pathlib import Path
4
3from milc import cli 5from milc import cli
4 6
5from qmk.decorators import automagic_keyboard, automagic_keymap 7from qmk.decorators import automagic_keyboard, automagic_keymap
6from qmk.info import info_json 8from qmk.info import info_json
7from qmk.keyboard import find_readme, keyboard_completer 9from qmk.keyboard import keyboard_completer, list_keyboards
8from qmk.keymap import locate_keymap 10from qmk.keymap import locate_keymap
9from qmk.path import is_keyboard, keyboard 11from qmk.path import is_keyboard, keyboard
10 12
11 13
12@cli.argument('--strict', action='store_true', help='Treat warnings as errors.') 14def keymap_check(kb, km):
13@cli.argument('-kb', '--keyboard', completer=keyboard_completer, help='The keyboard to check.') 15 """Perform the keymap level checks.
14@cli.argument('-km', '--keymap', help='The keymap to check.') 16 """
17 ok = True
18 keymap_path = locate_keymap(kb, km)
19
20 if not keymap_path:
21 ok = False
22 cli.log.error("%s: Can't find %s keymap.", kb, km)
23
24 return ok
25
26
27def rules_mk_assignment_only(keyboard_path):
28 """Check the keyboard-level rules.mk to ensure it only has assignments.
29 """
30 current_path = Path()
31 errors = []
32
33 for path_part in keyboard_path.parts:
34 current_path = current_path / path_part
35 rules_mk = current_path / 'rules.mk'
36
37 if rules_mk.exists():
38 continuation = None
39
40 for i, line in enumerate(rules_mk.open()):
41 line = line.strip()
42
43 if '#' in line:
44 line = line[:line.index('#')]
45
46 if continuation:
47 line = continuation + line
48 continuation = None
49
50 if line:
51 if line[-1] == '\\':
52 continuation = line[:-1]
53 continue
54
55 if line and '=' not in line:
56 errors.append(f'Non-assignment code on line +{i} {rules_mk}: {line}')
57
58 return errors
59
60
61@cli.argument('--strict', action='store_true', help='Treat warnings as errors')
62@cli.argument('-kb', '--keyboard', completer=keyboard_completer, help='Comma separated list of keyboards to check')
63@cli.argument('-km', '--keymap', help='The keymap to check')
64@cli.argument('--all-kb', action='store_true', arg_only=True, help='Check all keyboards')
15@cli.subcommand('Check keyboard and keymap for common mistakes.') 65@cli.subcommand('Check keyboard and keymap for common mistakes.')
16@automagic_keyboard 66@automagic_keyboard
17@automagic_keymap 67@automagic_keymap
18def lint(cli): 68def lint(cli):
19 """Check keyboard and keymap for common mistakes. 69 """Check keyboard and keymap for common mistakes.
20 """ 70 """
21 if not cli.config.lint.keyboard: 71 failed = []
22 cli.log.error('Missing required argument: --keyboard')
23 cli.print_help()
24 return False
25 72
26 if not is_keyboard(cli.config.lint.keyboard): 73 # Determine our keyboard list
27 cli.log.error('No such keyboard: %s', cli.config.lint.keyboard) 74 if cli.args.all_kb:
28 return False 75 if cli.args.keyboard:
76 cli.log.warning('Both --all-kb and --keyboard passed, --all-kb takes presidence.')
29 77
30 # Gather data about the keyboard. 78 keyboard_list = list_keyboards()
31 ok = True 79 elif not cli.config.lint.keyboard:
32 keyboard_path = keyboard(cli.config.lint.keyboard) 80 cli.log.error('Missing required arguments: --keyboard or --all-kb')
33 keyboard_info = info_json(cli.config.lint.keyboard) 81 cli.print_help()
34 readme_path = find_readme(cli.config.lint.keyboard) 82 return False
35 missing_readme_path = keyboard_path / 'readme.md' 83 else:
84 keyboard_list = cli.config.lint.keyboard.split(',')
36 85
37 # Check for errors in the info.json 86 # Lint each keyboard
38 if keyboard_info['parse_errors']: 87 for kb in keyboard_list:
39 ok = False 88 if not is_keyboard(kb):
40 cli.log.error('Errors found when generating info.json.') 89 cli.log.error('No such keyboard: %s', kb)
90 continue
41 91
42 if cli.config.lint.strict and keyboard_info['parse_warnings']: 92 # Gather data about the keyboard.
43 ok = False 93 ok = True
44 cli.log.error('Warnings found when generating info.json (Strict mode enabled.)') 94 keyboard_path = keyboard(kb)
95 keyboard_info = info_json(kb)
45 96
46 # Check for a readme.md and warn if it doesn't exist 97 # Check for errors in the info.json
47 if not readme_path: 98 if keyboard_info['parse_errors']:
48 ok = False 99 ok = False
49 cli.log.error('Missing %s', missing_readme_path) 100 cli.log.error('%s: Errors found when generating info.json.', kb)
50 101
51 # Keymap specific checks 102 if cli.config.lint.strict and keyboard_info['parse_warnings']:
52 if cli.config.lint.keymap: 103 ok = False
53 keymap_path = locate_keymap(cli.config.lint.keyboard, cli.config.lint.keymap) 104 cli.log.error('%s: Warnings found when generating info.json (Strict mode enabled.)', kb)
54 105
55 if not keymap_path: 106 # Check the rules.mk file(s)
107 rules_mk_assignment_errors = rules_mk_assignment_only(keyboard_path)
108 if rules_mk_assignment_errors:
56 ok = False 109 ok = False
57 cli.log.error("Can't find %s keymap for %s keyboard.", cli.config.lint.keymap, cli.config.lint.keyboard) 110 cli.log.error('%s: Non-assignment code found in rules.mk. Move it to post_rules.mk instead.', kb)
58 else: 111 for assignment_error in rules_mk_assignment_errors:
59 keymap_readme = keymap_path.parent / 'readme.md' 112 cli.log.error(assignment_error)
60 if not keymap_readme.exists():
61 cli.log.warning('Missing %s', keymap_readme)
62 113
63 if cli.config.lint.strict: 114 # Keymap specific checks
64 ok = False 115 if cli.config.lint.keymap:
116 if not keymap_check(kb, cli.config.lint.keymap):
117 ok = False
118
119 # Report status
120 if not ok:
121 failed.append(kb)
65 122
66 # Check and report the overall status 123 # Check and report the overall status
67 if ok: 124 if failed:
68 cli.log.info('Lint check passed!') 125 cli.log.error('Lint check failed for: %s', ', '.join(failed))
69 return True 126 return False
70 127
71 cli.log.error('Lint check failed!') 128 cli.log.info('Lint check passed!')
72 return False 129 return True
diff --git a/lib/python/qmk/cli/pytest.py b/lib/python/qmk/cli/pytest.py
index bdb336b9a..a7f01a872 100644
--- a/lib/python/qmk/cli/pytest.py
+++ b/lib/python/qmk/cli/pytest.py
@@ -12,6 +12,6 @@ def pytest(cli):
12 """Run several linting/testing commands. 12 """Run several linting/testing commands.
13 """ 13 """
14 nose2 = cli.run(['nose2', '-v'], capture_output=False, stdin=DEVNULL) 14 nose2 = cli.run(['nose2', '-v'], capture_output=False, stdin=DEVNULL)
15 flake8 = cli.run(['flake8', 'lib/python', 'bin/qmk'], capture_output=False, stdin=DEVNULL) 15 flake8 = cli.run(['flake8', 'lib/python'], capture_output=False, stdin=DEVNULL)
16 16
17 return flake8.returncode | nose2.returncode 17 return flake8.returncode | nose2.returncode
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py
index 421453d83..01c23b261 100644
--- a/lib/python/qmk/commands.py
+++ b/lib/python/qmk/commands.py
@@ -233,7 +233,7 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_va
233 f'VERBOSE={verbose}', 233 f'VERBOSE={verbose}',
234 f'COLOR={color}', 234 f'COLOR={color}',
235 'SILENT=false', 235 'SILENT=false',
236 f'QMK_BIN={"bin/qmk" if "DEPRECATED_BIN_QMK" in os.environ else "qmk"}', 236 'QMK_BIN="qmk"',
237 ]) 237 ])
238 238
239 return make_command 239 return make_command
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index b39fe5e46..e4eaef899 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -83,7 +83,7 @@ def test_hello():
83def test_format_python(): 83def test_format_python():
84 result = check_subcommand('format-python', '--dry-run') 84 result = check_subcommand('format-python', '--dry-run')
85 check_returncode(result) 85 check_returncode(result)
86 assert 'Python code in `bin/qmk` and `lib/python` is correctly formatted.' in result.stdout 86 assert 'Python code in `lib/python` is correctly formatted.' in result.stdout
87 87
88 88
89def test_list_keyboards(): 89def test_list_keyboards():
diff --git a/quantum/quantum.c b/quantum/quantum.c
index e60378afe..9d77fa438 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -480,3 +480,99 @@ void api_send_unicode(uint32_t unicode) {
480__attribute__((weak)) void startup_user() {} 480__attribute__((weak)) void startup_user() {}
481 481
482__attribute__((weak)) void shutdown_user() {} 482__attribute__((weak)) void shutdown_user() {}
483
484/** \brief Run keyboard level Power down
485 *
486 * FIXME: needs doc
487 */
488__attribute__((weak)) void suspend_power_down_user(void) {}
489/** \brief Run keyboard level Power down
490 *
491 * FIXME: needs doc
492 */
493__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
494
495void suspend_power_down_quantum(void) {
496#ifndef NO_SUSPEND_POWER_DOWN
497// Turn off backlight
498# ifdef BACKLIGHT_ENABLE
499 backlight_set(0);
500# endif
501
502# ifdef LED_MATRIX_ENABLE
503 led_matrix_task();
504# endif
505# ifdef RGB_MATRIX_ENABLE
506 rgb_matrix_task();
507# endif
508
509 // Turn off LED indicators
510 uint8_t leds_off = 0;
511# if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
512 if (is_backlight_enabled()) {
513 // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
514 leds_off |= (1 << USB_LED_CAPS_LOCK);
515 }
516# endif
517 led_set(leds_off);
518
519// Turn off audio
520# ifdef AUDIO_ENABLE
521 stop_all_notes();
522# endif
523
524// Turn off underglow
525# if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
526 rgblight_suspend();
527# endif
528
529# if defined(LED_MATRIX_ENABLE)
530 led_matrix_set_suspend_state(true);
531# endif
532# if defined(RGB_MATRIX_ENABLE)
533 rgb_matrix_set_suspend_state(true);
534# endif
535
536# ifdef OLED_ENABLE
537 oled_off();
538# endif
539# ifdef ST7565_ENABLE
540 st7565_off();
541# endif
542#endif
543}
544
545/** \brief run user level code immediately after wakeup
546 *
547 * FIXME: needs doc
548 */
549__attribute__((weak)) void suspend_wakeup_init_user(void) {}
550
551/** \brief run keyboard level code immediately after wakeup
552 *
553 * FIXME: needs doc
554 */
555__attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); }
556
557__attribute__((weak)) void suspend_wakeup_init_quantum(void) {
558// Turn on backlight
559#ifdef BACKLIGHT_ENABLE
560 backlight_init();
561#endif
562
563 // Restore LED indicators
564 led_set(host_keyboard_leds());
565
566// Wake up underglow
567#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
568 rgblight_wakeup();
569#endif
570
571#if defined(LED_MATRIX_ENABLE)
572 led_matrix_set_suspend_state(false);
573#endif
574#if defined(RGB_MATRIX_ENABLE)
575 rgb_matrix_set_suspend_state(false);
576#endif
577 suspend_wakeup_init_kb();
578}
diff --git a/shell.nix b/shell.nix
index c36df032d..5023a3b0f 100644
--- a/shell.nix
+++ b/shell.nix
@@ -14,7 +14,7 @@ let
14 projectDir = ./util/nix; 14 projectDir = ./util/nix;
15 overrides = poetry2nix.overrides.withDefaults (self: super: { 15 overrides = poetry2nix.overrides.withDefaults (self: super: {
16 qmk = super.qmk.overridePythonAttrs(old: { 16 qmk = super.qmk.overridePythonAttrs(old: {
17 # Allow QMK CLI to run "bin/qmk" as a subprocess (the wrapper changes 17 # Allow QMK CLI to run "qmk" as a subprocess (the wrapper changes
18 # $PATH and breaks these invocations). 18 # $PATH and breaks these invocations).
19 dontWrapPythonPrograms = true; 19 dontWrapPythonPrograms = true;
20 }); 20 });
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c
index 690d7f38c..b614746e6 100644
--- a/tmk_core/common/avr/suspend.c
+++ b/tmk_core/common/avr/suspend.c
@@ -16,25 +16,6 @@
16# include "vusb.h" 16# include "vusb.h"
17#endif 17#endif
18 18
19#ifdef BACKLIGHT_ENABLE
20# include "backlight.h"
21#endif
22
23#ifdef AUDIO_ENABLE
24# include "audio.h"
25#endif /* AUDIO_ENABLE */
26
27#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
28# include "rgblight.h"
29#endif
30
31#ifdef LED_MATRIX_ENABLE
32# include "led_matrix.h"
33#endif
34#ifdef RGB_MATRIX_ENABLE
35# include "rgb_matrix.h"
36#endif
37
38/** \brief Suspend idle 19/** \brief Suspend idle
39 * 20 *
40 * FIXME: needs doc 21 * FIXME: needs doc
@@ -50,17 +31,6 @@ void suspend_idle(uint8_t time) {
50 31
51// TODO: This needs some cleanup 32// TODO: This needs some cleanup
52 33
53/** \brief Run keyboard level Power down
54 *
55 * FIXME: needs doc
56 */
57__attribute__((weak)) void suspend_power_down_user(void) {}
58/** \brief Run keyboard level Power down
59 *
60 * FIXME: needs doc
61 */
62__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
63
64#if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) 34#if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect)
65 35
66// clang-format off 36// clang-format off
@@ -135,41 +105,9 @@ void suspend_power_down(void) {
135 if (!vusb_suspended) return; 105 if (!vusb_suspended) return;
136#endif 106#endif
137 107
138 suspend_power_down_kb(); 108 suspend_power_down_quantum();
139 109
140#ifndef NO_SUSPEND_POWER_DOWN 110#ifndef NO_SUSPEND_POWER_DOWN
141 // Turn off backlight
142# ifdef BACKLIGHT_ENABLE
143 backlight_set(0);
144# endif
145
146 // Turn off LED indicators
147 uint8_t leds_off = 0;
148# if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
149 if (is_backlight_enabled()) {
150 // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
151 leds_off |= (1 << USB_LED_CAPS_LOCK);
152 }
153# endif
154 led_set(leds_off);
155
156 // Turn off audio
157# ifdef AUDIO_ENABLE
158 stop_all_notes();
159# endif
160
161 // Turn off underglow
162# if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
163 rgblight_suspend();
164# endif
165
166# if defined(LED_MATRIX_ENABLE)
167 led_matrix_set_suspend_state(true);
168# endif
169# if defined(RGB_MATRIX_ENABLE)
170 rgb_matrix_set_suspend_state(true);
171# endif
172
173 // Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt) 111 // Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt)
174# if defined(WDT_vect) 112# if defined(WDT_vect)
175 power_down(WDTO_15MS); 113 power_down(WDTO_15MS);
@@ -189,18 +127,6 @@ bool suspend_wakeup_condition(void) {
189 return false; 127 return false;
190} 128}
191 129
192/** \brief run user level code immediately after wakeup
193 *
194 * FIXME: needs doc
195 */
196__attribute__((weak)) void suspend_wakeup_init_user(void) {}
197
198/** \brief run keyboard level code immediately after wakeup
199 *
200 * FIXME: needs doc
201 */
202__attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); }
203
204/** \brief run immediately after wakeup 130/** \brief run immediately after wakeup
205 * 131 *
206 * FIXME: needs doc 132 * FIXME: needs doc
@@ -209,27 +135,7 @@ void suspend_wakeup_init(void) {
209 // clear keyboard state 135 // clear keyboard state
210 clear_keyboard(); 136 clear_keyboard();
211 137
212 // Turn on backlight 138 suspend_wakeup_init_quantum();
213#ifdef BACKLIGHT_ENABLE
214 backlight_init();
215#endif
216
217 // Restore LED indicators
218 led_set(host_keyboard_leds());
219
220 // Wake up underglow
221#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
222 rgblight_wakeup();
223#endif
224
225#if defined(LED_MATRIX_ENABLE)
226 led_matrix_set_suspend_state(false);
227#endif
228#if defined(RGB_MATRIX_ENABLE)
229 rgb_matrix_set_suspend_state(false);
230#endif
231
232 suspend_wakeup_init_kb();
233} 139}
234 140
235#if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect) 141#if !defined(NO_SUSPEND_POWER_DOWN) && defined(WDT_vect)
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index 38517e06f..991fe6e08 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -12,25 +12,6 @@
12#include "led.h" 12#include "led.h"
13#include "wait.h" 13#include "wait.h"
14 14
15#ifdef AUDIO_ENABLE
16# include "audio.h"
17#endif /* AUDIO_ENABLE */
18
19#ifdef BACKLIGHT_ENABLE
20# include "backlight.h"
21#endif
22
23#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
24# include "rgblight.h"
25#endif
26
27#ifdef LED_MATRIX_ENABLE
28# include "led_matrix.h"
29#endif
30#ifdef RGB_MATRIX_ENABLE
31# include "rgb_matrix.h"
32#endif
33
34/** \brief suspend idle 15/** \brief suspend idle
35 * 16 *
36 * FIXME: needs doc 17 * FIXME: needs doc
@@ -40,61 +21,12 @@ void suspend_idle(uint8_t time) {
40 wait_ms(time); 21 wait_ms(time);
41} 22}
42 23
43/** \brief Run keyboard level Power down
44 *
45 * FIXME: needs doc
46 */
47__attribute__((weak)) void suspend_power_down_user(void) {}
48/** \brief Run keyboard level Power down
49 *
50 * FIXME: needs doc
51 */
52__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
53
54/** \brief suspend power down 24/** \brief suspend power down
55 * 25 *
56 * FIXME: needs doc 26 * FIXME: needs doc
57 */ 27 */
58void suspend_power_down(void) { 28void suspend_power_down(void) {
59#ifdef BACKLIGHT_ENABLE 29 suspend_power_down_quantum();
60 backlight_set(0);
61#endif
62
63#ifdef LED_MATRIX_ENABLE
64 led_matrix_task();
65#endif
66#ifdef RGB_MATRIX_ENABLE
67 rgb_matrix_task();
68#endif
69
70 // Turn off LED indicators
71 uint8_t leds_off = 0;
72#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
73 if (is_backlight_enabled()) {
74 // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
75 leds_off |= (1 << USB_LED_CAPS_LOCK);
76 }
77#endif
78 led_set(leds_off);
79
80 // TODO: figure out what to power down and how
81 // shouldn't power down TPM/FTM if we want a breathing LED
82 // also shouldn't power down USB
83#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
84 rgblight_suspend();
85#endif
86
87#if defined(LED_MATRIX_ENABLE)
88 led_matrix_set_suspend_state(true);
89#endif
90#if defined(RGB_MATRIX_ENABLE)
91 rgb_matrix_set_suspend_state(true);
92#endif
93#ifdef AUDIO_ENABLE
94 stop_all_notes();
95#endif /* AUDIO_ENABLE */
96
97 suspend_power_down_kb();
98 // on AVR, this enables the watchdog for 15ms (max), and goes to 30 // on AVR, this enables the watchdog for 15ms (max), and goes to
99 // SLEEP_MODE_PWR_DOWN 31 // SLEEP_MODE_PWR_DOWN
100 32
@@ -151,19 +83,6 @@ void suspend_wakeup_init(void) {
151 host_system_send(0); 83 host_system_send(0);
152 host_consumer_send(0); 84 host_consumer_send(0);
153#endif /* EXTRAKEY_ENABLE */ 85#endif /* EXTRAKEY_ENABLE */
154#ifdef BACKLIGHT_ENABLE
155 backlight_init();
156#endif /* BACKLIGHT_ENABLE */
157 led_set(host_keyboard_leds());
158#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
159 rgblight_wakeup();
160#endif
161 86
162#if defined(LED_MATRIX_ENABLE) 87 suspend_wakeup_init_quantum();
163 led_matrix_set_suspend_state(false);
164#endif
165#if defined(RGB_MATRIX_ENABLE)
166 rgb_matrix_set_suspend_state(false);
167#endif
168 suspend_wakeup_init_kb();
169} 88}
diff --git a/tmk_core/common/suspend.h b/tmk_core/common/suspend.h
index 95845e4b6..081735f90 100644
--- a/tmk_core/common/suspend.h
+++ b/tmk_core/common/suspend.h
@@ -10,8 +10,10 @@ void suspend_wakeup_init(void);
10 10
11void suspend_wakeup_init_user(void); 11void suspend_wakeup_init_user(void);
12void suspend_wakeup_init_kb(void); 12void suspend_wakeup_init_kb(void);
13void suspend_wakeup_init_quantum(void);
13void suspend_power_down_user(void); 14void suspend_power_down_user(void);
14void suspend_power_down_kb(void); 15void suspend_power_down_kb(void);
16void suspend_power_down_quantum(void);
15 17
16#ifndef USB_SUSPEND_WAKEUP_DELAY 18#ifndef USB_SUSPEND_WAKEUP_DELAY
17# define USB_SUSPEND_WAKEUP_DELAY 0 19# define USB_SUSPEND_WAKEUP_DELAY 0