diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml
index 28c6bb367985..df727518e577 100644
--- a/.github/workflows/cli.yml
+++ b/.github/workflows/cli.yml
@@ -23,6 +23,6 @@ jobs:
with:
submodules: recursive
- name: Install dependencies
- run: pip3 install -r requirements.txt
+ run: pip3 install -r requirements-dev.txt
- name: Run tests
run: bin/qmk pytest
diff --git a/.gitignore b/.gitignore
index da74bdec8337..adc5d9da6a73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
*.eep
*.elf
*.hex
+*.uf2
*.qmk
!util/bootloader.hex
!quantum/tools/eeprom_reset.hex
diff --git a/Makefile b/Makefile
index 91ab9e4e8ea6..e007ae3679c7 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,13 @@ $(info QMK Firmware $(QMK_VERSION))
endif
endif
+# Determine which qmk cli to use
+ifeq (,$(shell which qmk))
+ QMK_BIN = bin/qmk
+else
+ QMK_BIN = qmk
+endif
+
# avoid 'Entering|Leaving directory' messages
MAKEFLAGS += --no-print-directory
@@ -86,8 +93,8 @@ clean:
.PHONY: distclean
distclean: clean
- echo -n 'Deleting *.bin and *.hex ... '
- rm -f *.bin *.hex
+ echo -n 'Deleting *.bin, *.hex, and *.uf2 ... '
+ rm -f *.bin *.hex *.uf2
echo 'done.'
#Compatibility with the old make variables, anything you specify directly on the command line
@@ -384,7 +391,7 @@ define PARSE_KEYMAP
# Format it in bold
KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
# Specify the variables that we are passing forward to submake
- MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) REQUIRE_PLATFORM_KEY=$$(REQUIRE_PLATFORM_KEY)
+ MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) REQUIRE_PLATFORM_KEY=$$(REQUIRE_PLATFORM_KEY) QMK_BIN=$$(QMK_BIN)
# And the first part of the make command
MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_TARGET)
# The message to display
@@ -501,8 +508,8 @@ endef
%:
# Check if we have the CMP tool installed
cmp $(ROOT_DIR)/Makefile $(ROOT_DIR)/Makefile >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
- # Ensure that bin/qmk works.
- if ! bin/qmk hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; exit 1; fi
+ # Ensure that $(QMK_BIN) works.
+ if ! $(QMK_BIN) hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; exit 1; fi
# Check if the submodules are dirty, and display a warning if they are
ifndef SKIP_GIT
if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 50 --init lib/chibios; fi
diff --git a/bin/qmk b/bin/qmk
index 47b50f83b3bc..a6e8ce08daca 100755
--- a/bin/qmk
+++ b/bin/qmk
@@ -29,8 +29,11 @@ def main():
"""
# Change to the root of our checkout
os.environ['ORIG_CWD'] = os.getcwd()
+ os.environ['DEPRECATED_BIN_QMK'] = '1'
os.chdir(qmk_dir)
+ print('Warning: The bin/qmk script is being deprecated. Please install the QMK CLI: python3 -m pip install qmk', file=sys.stderr)
+
# Import the subcommands
import qmk.cli # noqa
diff --git a/bootloader.mk b/bootloader.mk
index fd76446e99e4..d130dbbcca83 100644
--- a/bootloader.mk
+++ b/bootloader.mk
@@ -89,11 +89,13 @@ ifeq ($(strip $(BOOTLOADER)), USBasp)
BOOTLOADER_SIZE = 4096
endif
ifeq ($(strip $(BOOTLOADER)), lufa-ms)
- # DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!
- # It is extremely prone to bricking, and is only included to support existing boards.
OPT_DEFS += -DBOOTLOADER_MS
BOOTLOADER_SIZE = 6144
FIRMWARE_FORMAT = bin
+ $(info LUFA MASS STORAGE Bootloader selected)
+ $(info DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!)
+ $(info It is extremely prone to bricking, and is only included to support existing boards.)
+ $(info )
endif
ifdef BOOTLOADER_SIZE
OPT_DEFS += -DBOOTLOADER_SIZE=$(strip $(BOOTLOADER_SIZE))
@@ -137,3 +139,6 @@ ifeq ($(strip $(BOOTLOADER)), stm32duino)
DFU_ARGS = -d 1EAF:0003 -a 2 -R
DFU_SUFFIX_ARGS = -v 1EAF -p 0003
endif
+ifeq ($(strip $(BOOTLOADER)), tinyuf2)
+ OPT_DEFS += -DBOOTLOADER_TINYUF2
+endif
diff --git a/build_json.mk b/build_json.mk
index 6e2f9c4c8f28..8822be6a1287 100644
--- a/build_json.mk
+++ b/build_json.mk
@@ -28,4 +28,4 @@ endif
# Generate the keymap.c
$(KEYBOARD_OUTPUT)/src/keymap.c: $(KEYMAP_JSON)
- bin/qmk json2c --quiet --output $(KEYMAP_C) $(KEYMAP_JSON)
+ $(QMK_BIN) json2c --quiet --output $(KEYMAP_C) $(KEYMAP_JSON)
diff --git a/build_keyboard.mk b/build_keyboard.mk
index ec6b026c505f..91a6c23b71af 100644
--- a/build_keyboard.mk
+++ b/build_keyboard.mk
@@ -12,6 +12,9 @@ endif
include common.mk
+# Set the qmk cli to use
+QMK_BIN ?= qmk
+
# Set the filename for the final firmware binary
KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD))
TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP)
@@ -97,7 +100,7 @@ MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP)
MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP)
# Pull in rules from info.json
-INFO_RULES_MK = $(shell bin/qmk generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/rules.mk)
+INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/rules.mk)
include $(INFO_RULES_MK)
# Check for keymap.json first, so we can regenerate keymap.c
@@ -295,13 +298,13 @@ endif
CONFIG_H += $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/layouts.h
$(KEYBOARD_OUTPUT)/src/info_config.h: $(INFO_JSON_FILES)
- bin/qmk generate-config-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_config.h
+ $(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_config.h
$(KEYBOARD_OUTPUT)/src/default_keyboard.h: $(INFO_JSON_FILES)
- bin/qmk generate-keyboard-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.h
+ $(QMK_BIN) generate-keyboard-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.h
$(KEYBOARD_OUTPUT)/src/layouts.h: $(INFO_JSON_FILES)
- bin/qmk generate-layouts --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/layouts.h
+ $(QMK_BIN) generate-layouts --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/layouts.h
generated-files: $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/default_keyboard.h $(KEYBOARD_OUTPUT)/src/layouts.h
diff --git a/common_features.mk b/common_features.mk
index 8c9d0a90c70e..1a9fd46b5590 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -223,14 +223,17 @@ VALID_LED_MATRIX_TYPES := IS31FL3731 custom
ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
ifeq ($(filter $(LED_MATRIX_DRIVER),$(VALID_LED_MATRIX_TYPES)),)
- $(error LED_MATRIX_DRIVER="$(LED_MATRIX_DRIVER)" is not a valid matrix type)
- else
- BACKLIGHT_ENABLE = yes
- BACKLIGHT_DRIVER = custom
- OPT_DEFS += -DLED_MATRIX_ENABLE
- SRC += $(QUANTUM_DIR)/led_matrix.c
- SRC += $(QUANTUM_DIR)/led_matrix_drivers.c
+ $(error "$(LED_MATRIX_DRIVER)" is not a valid matrix type)
endif
+ OPT_DEFS += -DLED_MATRIX_ENABLE
+ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
+ # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
+ OPT_DEFS += -DLIB8_ATTINY
+endif
+ SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
+ SRC += $(QUANTUM_DIR)/led_matrix.c
+ SRC += $(QUANTUM_DIR)/led_matrix_drivers.c
+ CIE1931_CURVE := yes
ifeq ($(strip $(LED_MATRIX_DRIVER)), IS31FL3731)
OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
@@ -347,7 +350,11 @@ endif
VALID_BACKLIGHT_TYPES := pwm timer software custom
BACKLIGHT_ENABLE ?= no
-BACKLIGHT_DRIVER ?= pwm
+ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
+ BACKLIGHT_DRIVER ?= software
+else
+ BACKLIGHT_DRIVER ?= pwm
+endif
ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
ifeq ($(filter $(BACKLIGHT_DRIVER),$(VALID_BACKLIGHT_TYPES)),)
$(error BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
@@ -422,10 +429,6 @@ ifeq ($(strip $(TERMINAL_ENABLE)), yes)
OPT_DEFS += -DUSER_PRINT
endif
-ifeq ($(strip $(USB_HID_ENABLE)), yes)
- include $(TMK_DIR)/protocol/usb_hid.mk
-endif
-
ifeq ($(strip $(WPM_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/wpm.c
OPT_DEFS += -DWPM_ENABLE
@@ -459,6 +462,23 @@ ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/dip_switch.c
endif
+VALID_MAGIC_TYPES := yes full lite
+BOOTMAGIC_ENABLE ?= no
+ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
+ ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),)
+ $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic)
+ endif
+ ifneq ($(strip $(BOOTMAGIC_ENABLE)), full)
+ OPT_DEFS += -DBOOTMAGIC_LITE
+ QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_lite.c
+ else
+ OPT_DEFS += -DBOOTMAGIC_ENABLE
+ QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_full.c
+ endif
+endif
+COMMON_VPATH += $(QUANTUM_DIR)/bootmagic
+QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/magic.c
+
VALID_CUSTOM_MATRIX_TYPES:= yes lite no
CUSTOM_MATRIX ?= no
@@ -673,4 +693,4 @@ ifeq ($(strip $(USBPD_ENABLE)), yes)
# Board designers can add their own driver to $(SRC)
endif
endif
-endif
\ No newline at end of file
+endif
diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema
index ec03a8828be2..c335f49d52fd 100644
--- a/data/schemas/keyboard.jsonschema
+++ b/data/schemas/keyboard.jsonschema
@@ -25,7 +25,7 @@
},
"processor": {
"type": "string",
- "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F411", "STM32G431", "STM32G474", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
+ "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66F18", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L433", "STM32L443", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
},
"board": {
"type": "string",
@@ -34,7 +34,7 @@
},
"bootloader": {
"type": "string",
- "enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "stm32-dfu", "stm32duino", "unknown", "USBasp"]
+ "enum": ["atmel-dfu", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "stm32-dfu", "stm32duino", "unknown", "USBasp", "tinyuf2"]
},
"diode_direction": {
"type": "string",
diff --git a/docs/ChangeLog/20200829.md b/docs/ChangeLog/20200829.md
index 00e0bd1a2872..c6abed5b3023 100644
--- a/docs/ChangeLog/20200829.md
+++ b/docs/ChangeLog/20200829.md
@@ -5,7 +5,7 @@ Four times a year QMK runs a process for merging Breaking Changes. A Breaking Ch
## Changes Requiring User Action :id=changes-requiring-user-action
-### Relocated Keyboards :id-relocated-keyboards
+### Relocated Keyboards :id=relocated-keyboards
#### The Key Company project consolidation ([#9547](https://github.com/qmk/qmk_firmware/pull/9547))
#### relocating boards by flehrad to flehrad/ folder ([#9635](https://github.com/qmk/qmk_firmware/pull/9635))
diff --git a/docs/ChangeLog/20201128.md b/docs/ChangeLog/20201128.md
index 86abd384df74..444132029532 100644
--- a/docs/ChangeLog/20201128.md
+++ b/docs/ChangeLog/20201128.md
@@ -5,7 +5,7 @@ Four times a year QMK runs a process for merging Breaking Changes. A Breaking Ch
## Changes Requiring User Action :id=changes-requiring-user-action
-### Relocated Keyboards :id-relocated-keyboards
+### Relocated Keyboards :id=relocated-keyboards
#### Reduce Helix keyboard build variation ([#8669](https://github.com/qmk/qmk_firmware/pull/8669))
diff --git a/docs/ChangeLog/20210529.md b/docs/ChangeLog/20210529.md
new file mode 100644
index 000000000000..d005aeed3668
--- /dev/null
+++ b/docs/ChangeLog/20210529.md
@@ -0,0 +1,192 @@
+# QMK Breaking Changes - 2021 May 29 Changelog
+
+## Notable Changes :id=notable-changes
+
+### RGB Matrix support for split common ([#11055](https://github.com/qmk/qmk_firmware/pull/11055)) :id=rgb-matrix-split-common
+
+Split boards can now use RGB Matrix without defining a custom matrix.
+
+### Teensy 3.6 support ([#12258](https://github.com/qmk/qmk_firmware/pull/12258)) :id=teensy-3-6-support
+
+Added support for MK66F18 (Teensy 3.6) microcontroller.
+
+### New command: qmk console ([#12828](https://github.com/qmk/qmk_firmware/pull/12828)) :id=new-command-qmk-console
+
+A new `qmk console` command has been added for attaching to your keyboard's console. It operates similiarly to QMK Toolbox by allowing you to connect to one or more keyboard consoles to display debugging messages.
+
+### Improved command: qmk config :id=improve-command-qmk-config
+
+We've updated the `qmk config` command to show only the configuration items you have actually set. You can now display (almost) all of the available configuration options, along with their default values, using `qmk config -a`.
+
+### LED Matrix Improvements ([#12509](https://github.com/qmk/qmk_firmware/pull/12509), [#12580](https://github.com/qmk/qmk_firmware/pull/12580), [#12588](https://github.com/qmk/qmk_firmware/pull/12588), [#12633](https://github.com/qmk/qmk_firmware/pull/12633), [#12651](https://github.com/qmk/qmk_firmware/pull/12651), [#12685](https://github.com/qmk/qmk_firmware/pull/12685)) :id=led-matrix-improvements
+
+LED Matrix has been improved with effects, CIE1931 curves, and a task system.
+
+## Changes Requiring User Action :id=changes-requiring-user-action
+
+### Updated Keyboard Codebases :id=updated-keyboard-codebases
+
+* Durgod keyboard refactor in preparation for adding additional durgod keyboards ([#11978](https://github.com/qmk/qmk_firmware/pull/11978))
+* Updated Function96 with V2 files and removed chconf.h and halconf.h ([#12613](https://github.com/qmk/qmk_firmware/pull/12613))
+* [Keyboard] updated a vendor name / fixed minor keymap issues ([#12881](https://github.com/qmk/qmk_firmware/pull/12881))
+* [Keyboard] Corne - Remove legacy revision support ([#12226](https://github.com/qmk/qmk_firmware/pull/12226))
+
+The following keyboards have had their source moved within QMK:
+
+Old Keyboard Name | New Keyboard Name
+:---------------- | :----------------
+crkbd/rev1/common | crkbd/rev1
+function96 | function96/v1
+nckiibs/flatbread60 | delikeeb/flatbread60
+nckiibs/vaguettelite | delikeeb/vaguettelite
+nckiibs/vanana/rev1 | delikeeb/vanana/rev1
+nckiibs/vanana/rev2 | delikeeb/vanana/rev2
+nckiibs/vaneela | delikeeb/vaneela
+nckiibs/vaneelaex | delikeeb/vaneelaex
+nckiibs/waaffle/rev3/elite_c | delikeeb/waaffle/rev3/elite_c
+nckiibs/waaffle/rev3/pro_micro | delikeeb/waaffle/rev3/pro_micro
+
+The [Function96 V2](https://github.com/qmk/qmk_firmware/tree/0.13.0/keyboards/function96/v2) has also been added as part of these changes.
+
+The codebase for the [Durgod K320](https://github.com/qmk/qmk_firmware/tree/0.13.0/keyboards/durgod/k320) has been reworked in anticipation of additional Durgod keyboards gaining QMK support.
+
+Additionally, the `crkbd/rev1/legacy` keyboard has been removed.
+
+### Bootmagic Deprecation and Refactor ([#12172](https://github.com/qmk/qmk_firmware/pull/12172)) :id=bootmagic-deprecation-and-refactor
+
+QMK has decided to deprecate the full Bootmagic feature and leave Bootmagic Lite as the only remaining option.
+
+This pull request changes the behavior of `BOOTMAGIC_ENABLE` such that specifying `BOOTMAGIC_ENABLE = yes` enables Bootmagic Lite instead of full Bootmagic.
+
+If attempts to use Bootmagic functionality result in unexpected behavior, check your `rules.mk` file and change the `BOOTMAGIC_ENABLE` setting to specify either `lite` or `full`.
+
+#### Tentative Deprecation Schedule
+
+This is the current planned roadmap for the behavior of `BOOTMAGIC_ENABLE`:
+
+- From 2021 May 29, setting `BOOTMAGIC_ENABLE = yes` will enable Bootmagic Lite instead of full Bootmagic.
+- From 2021 Aug 28, `BOOTMAGIC_ENABLE` must be either `yes`, `lite`, or `no` – setting `BOOTMAGIC_ENABLE = full` will cause compilation to fail.
+- From 2021 Nov 27, `BOOTMAGIC_ENABLE` must be either `yes` or `no` – setting `BOOTMAGIC_ENABLE = lite` will cause compilation to fail.
+
+### Removal of LAYOUT_kc ([#12160](https://github.com/qmk/qmk_firmware/pull/12160)) :id=removal-of-layout-kc
+
+We've removed support for `LAYOUT_kc` macros, if your keymap uses one you will need to update it use a regular `LAYOUT` macro.
+
+### Encoder callbacks are now boolean ([#12805](https://github.com/qmk/qmk_firmware/pull/12805), [#12985](https://github.com/qmk/qmk_firmware/pull/12985)) :id=encoder-callback-boolean
+
+To allow for keyboards to override (or not) keymap level code the `encoder_update_kb` function has been changed from `void` to `bool`. You will need to update your function definition to reflect this and ensure that you return a `true` or `false` value.
+
+Example code before change:
+
+```c
+void encoder_update_kb(uint8_t index, bool clockwise) {
+ encoder_update_user(index, clockwise);
+}
+```
+
+Example code after change:
+
+```c
+bool encoder_update_kb(uint8_t index, bool clockwise) {
+ return encoder_update_user(index, clockwise);
+}
+```
+
+## Core Changes :id=core-changes
+
+### Fixes :id=core-fixes
+
+* Fix connection issue in split keyboards when slave and OLED display are connected via I2C (fixes #9335) ([#11487](https://github.com/qmk/qmk_firmware/pull/11487))
+* Terrazzo: Fix wrong LED Matrix function names ([#12561](https://github.com/qmk/qmk_firmware/pull/12561))
+* Apply the "NO_LIMITED_CONTROLLER_CONNECT" fix to atmega16u2 ([#12482](https://github.com/qmk/qmk_firmware/pull/12482))
+* Fix comment parsing ([#12750](https://github.com/qmk/qmk_firmware/pull/12750))
+* Turn OLED off on suspend in soundmonster Corne keymap ([#10419](https://github.com/qmk/qmk_firmware/pull/10419))
+* Fixup build errors on `develop` branch. ([#12723](https://github.com/qmk/qmk_firmware/pull/12723))
+* Fix syntax error when compiling for ARM ([#12866](https://github.com/qmk/qmk_firmware/pull/12866))
+* Add missing LED Matrix suspend code to suspend.c ([#12878](https://github.com/qmk/qmk_firmware/pull/12878))
+* Fix spelling mistake regarding LED Matrix in split_common. ([#12888](https://github.com/qmk/qmk_firmware/pull/12888))
+* [Keymap] Fix QWERTY/DVORAK status output for kzar keymap ([#12895](https://github.com/qmk/qmk_firmware/pull/12895))
+* Fixup housekeeping from being invoked twice per loop. ([#12933](https://github.com/qmk/qmk_firmware/pull/12933))
+* wait for matrix row signal to go HIGH for every row ([#12945](https://github.com/qmk/qmk_firmware/pull/12945))
+* ensure we do not conflict with existing keymap aliases ([#12976](https://github.com/qmk/qmk_firmware/pull/12976))
+* [Keyboard] Fix Terrazzo build failure ([#12977](https://github.com/qmk/qmk_firmware/pull/12977))
+* Do not hard set config in CPTC files ([#11864](https://github.com/qmk/qmk_firmware/pull/11864))
+
+### Additions and Enhancements :id=core-additions
+
+* ARM - Refactor SLEEP_LED to support more platforms ([#8403](https://github.com/qmk/qmk_firmware/pull/8403))
+* Add ability to toggle One Shot functionality ([#4198](https://github.com/qmk/qmk_firmware/pull/4198))
+* Add RGB Matrix support to Split Common ([#11055](https://github.com/qmk/qmk_firmware/pull/11055))
+* Add support for complementary outputs to the ChibiOS WS2812 PWM driver ([#11988](https://github.com/qmk/qmk_firmware/pull/11988))
+* Enable RGB Matrix for Corne ([#12091](https://github.com/qmk/qmk_firmware/pull/12091))
+* Set default OLED Update Interval for Split Keyboards to improve matrix scan performance ([#12107](https://github.com/qmk/qmk_firmware/pull/12107))
+* Add support for MK66F18 (Teensy 3.6) micro controller ([#12258](https://github.com/qmk/qmk_firmware/pull/12258))
+* Split RGB Matrix support for RGBKB Zygomorph ([#11083](https://github.com/qmk/qmk_firmware/pull/11083))
+* Add baudrate and circular buffer to ARM WS2812 SPI config ([#12216](https://github.com/qmk/qmk_firmware/pull/12216))
+* Add keyboard level weak function for slave matrix scan ([#12317](https://github.com/qmk/qmk_firmware/pull/12317))
+* Add link to schematic on EasyEDA for XD60 ([#12018](https://github.com/qmk/qmk_firmware/pull/12018))
+* Add Config functions for LED Matrix ([#12361](https://github.com/qmk/qmk_firmware/pull/12361))
+* Add pin definitions for MK66F18 ([#12419](https://github.com/qmk/qmk_firmware/pull/12419))
+* add kinesis/kint36 keyboard ([#10171](https://github.com/qmk/qmk_firmware/pull/10171))
+* Add support for producing UF2-format binaries. ([#12435](https://github.com/qmk/qmk_firmware/pull/12435))
+* Implement CIE1931 curve for LED Matrix ([#12417](https://github.com/qmk/qmk_firmware/pull/12417))
+* Change `BOOTMAGIC_ENABLE=yes` to use Bootmagic Lite ([#12172](https://github.com/qmk/qmk_firmware/pull/12172))
+* Add kzar keymap for Kinesis Advantage ([#12444](https://github.com/qmk/qmk_firmware/pull/12444))
+* LED Matrix: suspend code ([#12509](https://github.com/qmk/qmk_firmware/pull/12509))
+* LED Matrix: Task system ([#12580](https://github.com/qmk/qmk_firmware/pull/12580))
+* Add missing RGB_MODE_TWINKLE / RGB_M_TW keycodes ([#11935](https://github.com/qmk/qmk_firmware/pull/11935))
+* Enhancement of WPM feature ([#11727](https://github.com/qmk/qmk_firmware/pull/11727))
+* Add Per Key functionality for AutoShift ([#11536](https://github.com/qmk/qmk_firmware/pull/11536))
+* LED Matrix: Reactive effect buffers & advanced indicators ([#12588](https://github.com/qmk/qmk_firmware/pull/12588))
+* LED Matrix: support for Split keyboards ([#12633](https://github.com/qmk/qmk_firmware/pull/12633))
+* add setting to enable infinite timeout for leader key ([#6580](https://github.com/qmk/qmk_firmware/pull/6580), [#12721](https://github.com/qmk/qmk_firmware/pull/12721 "Fix bad PR merge for #6580"))
+* Update ADC driver for STM32F1xx, STM32F3xx, STM32F4xx ([#12403](https://github.com/qmk/qmk_firmware/pull/12403))
+* Add initial support for tinyuf2 bootloader (when hosted on F411 blackpill) ([#12600](https://github.com/qmk/qmk_firmware/pull/12600))
+* Add support for STM32F446 MCU ([#12619](https://github.com/qmk/qmk_firmware/pull/12619))
+* Add STM32L433 and L443 support ([#12063](https://github.com/qmk/qmk_firmware/pull/12063))
+* Added OLED fade out support ([#12086](https://github.com/qmk/qmk_firmware/pull/12086))
+* New command: `qmk console` ([#12828](https://github.com/qmk/qmk_firmware/pull/12828))
+* LED Matrix: Effects! ([#12651](https://github.com/qmk/qmk_firmware/pull/12651))
+* Add setup, clone, and env to the list of commands we allow even with broken modules ([#12868](https://github.com/qmk/qmk_firmware/pull/12868))
+* LED Matrix: Documentation ([#12685](https://github.com/qmk/qmk_firmware/pull/12685))
+* Add function to allow repeated blinking of one layer ([#12237](https://github.com/qmk/qmk_firmware/pull/12237))
+* Add support for up to 4 IS31FL3733 drivers ([#12342](https://github.com/qmk/qmk_firmware/pull/12342))
+* Convert Encoder callbacks to be boolean functions ([#12805](https://github.com/qmk/qmk_firmware/pull/12805), [#12985](https://github.com/qmk/qmk_firmware/pull/12985))
+* [Keymap] Update to Drashna keymap and user code (based on develop) ([#12936](https://github.com/qmk/qmk_firmware/pull/12936))
+* Add Full-duplex serial driver for ARM boards ([#9842](https://github.com/qmk/qmk_firmware/pull/9842))
+* Document LED_MATRIX_FRAMEBUFFER_EFFECTS ([#12987](https://github.com/qmk/qmk_firmware/pull/12987))
+* Backlight: add defines for default level and breathing state ([#12560](https://github.com/qmk/qmk_firmware/pull/12560), [#13024](https://github.com/qmk/qmk_firmware/pull/13024))
+* Add dire message about LUFA mass storage bootloader ([#13014](https://github.com/qmk/qmk_firmware/pull/13014))
+
+### Clean-ups and Optimizations :id=core-optimizations
+
+* Overhaul bootmagic logic to have single entrypoint ([#8532](https://github.com/qmk/qmk_firmware/pull/8532))
+* Refactor of USB code within split_common ([#11890](https://github.com/qmk/qmk_firmware/pull/11890))
+* Begin the process of deprecating `bin/qmk` in favor of the global CLI ([#12109](https://github.com/qmk/qmk_firmware/pull/12109))
+* LED Matrix: decouple from Backlight ([#12054](https://github.com/qmk/qmk_firmware/pull/12054))
+* Remove `FUNC()` ([#12161](https://github.com/qmk/qmk_firmware/pull/12161))
+* Move gpio wait logic to wait.h ([#12067](https://github.com/qmk/qmk_firmware/pull/12067))
+* LED Matrix: Clean up includes ([#12197](https://github.com/qmk/qmk_firmware/pull/12197))
+* Consistently use bin/qmk when that script is called ([#12286](https://github.com/qmk/qmk_firmware/pull/12286))
+* LED Matrix: Additional common_features.mk tweaks ([#12187](https://github.com/qmk/qmk_firmware/pull/12187))
+* LED Matrix: Fix up eeconfig code ([#12327](https://github.com/qmk/qmk_firmware/pull/12327))
+* Big quantum_keycodes cleanup ([#12249](https://github.com/qmk/qmk_firmware/pull/12249))
+* Fix up builds that are now too big for `develop` branch. ([#12495](https://github.com/qmk/qmk_firmware/pull/12495))
+* [Keyboard] kint36: switch to sym_eager_pk debouncing ([#12626](https://github.com/qmk/qmk_firmware/pull/12626))
+* [Keyboard] kint2pp: reduce input latency by ≈10ms ([#12625](https://github.com/qmk/qmk_firmware/pull/12625))
+* eeprom driver: Refactor where eeprom driver initialisation (and EEPROM emulation initialisation) occurs to make it non-target-specific. ([#12671](https://github.com/qmk/qmk_firmware/pull/12671))
+* Change RGB/LED Matrix to use a simple define for USB suspend ([#12697](https://github.com/qmk/qmk_firmware/pull/12697), [#12770](https://github.com/qmk/qmk_firmware/pull/12770 "Fixing transport's led/rgb matrix suspend state logic"))
+* Remove pointless SERIAL_LINK_ENABLE rules ([#12846](https://github.com/qmk/qmk_firmware/pull/12846))
+* Make Swap Hands use PROGMEM ([#12284](https://github.com/qmk/qmk_firmware/pull/12284))
+* Remove KEYMAP and LAYOUT_kc ([#12160](https://github.com/qmk/qmk_firmware/pull/12160))
+* Rename `point_t` -> `led_point_t` ([#12864](https://github.com/qmk/qmk_firmware/pull/12864))
+* Deprecate `send_unicode_hex_string()` ([#12602](https://github.com/qmk/qmk_firmware/pull/12602))
+* [Keyboard] Remove redundant legacy and common headers for crkbd ([#13023](https://github.com/qmk/qmk_firmware/pull/13023))
+
+### QMK Infrastructure and Internals :id=qmk-internals
+
+* trivial change to trigger api update ([`b15288fb87`](https://github.com/qmk/qmk_firmware/commit/b15288fb87))
+* fix some references to bin/qmk that slipped in ([#12832](https://github.com/qmk/qmk_firmware/pull/12832))
+* Resolve a number of warnings in `qmk generate-api` ([#12833](https://github.com/qmk/qmk_firmware/pull/12833))
+* Fix another bin/qmk reference ([#12856](https://github.com/qmk/qmk_firmware/pull/12856))
+* Use milc.subcommand.config instead of qmk.cli.config ([#12915](https://github.com/qmk/qmk_firmware/pull/12915))
diff --git a/docs/_summary.md b/docs/_summary.md
index 825514e6b5d3..38937771f64e 100644
--- a/docs/_summary.md
+++ b/docs/_summary.md
@@ -120,7 +120,7 @@
* Breaking Changes
* [Overview](breaking_changes.md)
* [My Pull Request Was Flagged](breaking_changes_instructions.md)
- * [Most Recent ChangeLog](ChangeLog/20210227.md "QMK v0.12.0 - 2021 Feb 27")
+ * [Most Recent ChangeLog](ChangeLog/20210529.md "QMK v0.13.0 - 2021 May 29")
* [Past Breaking Changes](breaking_changes_history.md)
* C Development
diff --git a/docs/adc_driver.md b/docs/adc_driver.md
index 6e3d513863bb..69fff4b3c28d 100644
--- a/docs/adc_driver.md
+++ b/docs/adc_driver.md
@@ -47,73 +47,79 @@ Note that some of these pins are doubled-up on ADCs with the same channel. This
Also note that the F0 and F3 use different numbering schemes. The F0 has a single ADC and the channels are 0-indexed, whereas the F3 has 4 ADCs and the channels are 1-indexed. This is because the F0 uses the `ADCv1` implementation of the ADC, whereas the F3 uses the `ADCv3` implementation.
-|ADC|Channel|STM32F0xx|STM32F3xx|
-|---|-------|---------|---------|
-|1 |0 |`A0` | |
-|1 |1 |`A1` |`A0` |
-|1 |2 |`A2` |`A1` |
-|1 |3 |`A3` |`A2` |
-|1 |4 |`A4` |`A3` |
-|1 |5 |`A5` |`F4` |
-|1 |6 |`A6` |`C0` |
-|1 |7 |`A7` |`C1` |
-|1 |8 |`B0` |`C2` |
-|1 |9 |`B1` |`C3` |
-|1 |10 |`C0` |`F2` |
-|1 |11 |`C1` | |
-|1 |12 |`C2` | |
-|1 |13 |`C3` | |
-|1 |14 |`C4` | |
-|1 |15 |`C5` | |
-|1 |16 | | |
-|2 |1 | |`A4` |
-|2 |2 | |`A5` |
-|2 |3 | |`A6` |
-|2 |4 | |`A7` |
-|2 |5 | |`C4` |
-|2 |6 | |`C0` |
-|2 |7 | |`C1` |
-|2 |8 | |`C2` |
-|2 |9 | |`C3` |
-|2 |10 | |`F2` |
-|2 |11 | |`C5` |
-|2 |12 | |`B2` |
-|2 |13 | | |
-|2 |14 | | |
-|2 |15 | | |
-|2 |16 | | |
-|3 |1 | |`B1` |
-|3 |2 | |`E9` |
-|3 |3 | |`E13` |
-|3 |4 | | |
-|3 |5 | | |
-|3 |6 | |`E8` |
-|3 |7 | |`D10` |
-|3 |8 | |`D11` |
-|3 |9 | |`D12` |
-|3 |10 | |`D13` |
-|3 |11 | |`D14` |
-|3 |12 | |`B0` |
-|3 |13 | |`E7` |
-|3 |14 | |`E10` |
-|3 |15 | |`E11` |
-|3 |16 | |`E12` |
-|4 |1 | |`E14` |
-|4 |2 | |`B12` |
-|4 |3 | |`B13` |
-|4 |4 | |`B14` |
-|4 |5 | |`B15` |
-|4 |6 | |`E8` |
-|4 |7 | |`D10` |
-|4 |8 | |`D11` |
-|4 |9 | |`D12` |
-|4 |10 | |`D13` |
-|4 |11 | |`D14` |
-|4 |12 | |`D8` |
-|4 |13 | |`D9` |
-|4 |14 | | |
-|4 |15 | | |
-|4 |16 | | |
+|ADC|Channel|STM32F0xx|STM32F1xx|STM32F3xx|STM32F4xx|
+|---|-------|---------|---------|---------|---------|
+|1 |0 |`A0` |`A0` | |`A0` |
+|1 |1 |`A1` |`A1` |`A0` |`A1` |
+|1 |2 |`A2` |`A2` |`A1` |`A2` |
+|1 |3 |`A3` |`A3` |`A2` |`A3` |
+|1 |4 |`A4` |`A4` |`A3` |`A4` |
+|1 |5 |`A5` |`A5` |`F4` |`A5` |
+|1 |6 |`A6` |`A6` |`C0` |`A6` |
+|1 |7 |`A7` |`A7` |`C1` |`A7` |
+|1 |8 |`B0` |`B0` |`C2` |`B0` |
+|1 |9 |`B1` |`B1` |`C3` |`B1` |
+|1 |10 |`C0` |`C0` |`F2` |`C0` |
+|1 |11 |`C1` |`C1` | |`C1` |
+|1 |12 |`C2` |`C2` | |`C2` |
+|1 |13 |`C3` |`C3` | |`C3` |
+|1 |14 |`C4` |`C4` | |`C4` |
+|1 |15 |`C5` |`C5` | |`C5` |
+|1 |16 | | | | |
+|2 |0 | |`A0`¹ | |`A0`² |
+|2 |1 | |`A1`¹ |`A4` |`A1`² |
+|2 |2 | |`A2`¹ |`A5` |`A2`² |
+|2 |3 | |`A3`¹ |`A6` |`A3`² |
+|2 |4 | |`A4`¹ |`A7` |`A4`² |
+|2 |5 | |`A5`¹ |`C4` |`A5`² |
+|2 |6 | |`A6`¹ |`C0` |`A6`² |
+|2 |7 | |`A7`¹ |`C1` |`A7`² |
+|2 |8 | |`B0`¹ |`C2` |`B0`² |
+|2 |9 | |`B1`¹ |`C3` |`B1`² |
+|2 |10 | |`C0`¹ |`F2` |`C0`² |
+|2 |11 | |`C1`¹ |`C5` |`C1`² |
+|2 |12 | |`C2`¹ |`B2` |`C2`² |
+|2 |13 | |`C3`¹ | |`C3`² |
+|2 |14 | |`C4`¹ | |`C4`² |
+|2 |15 | |`C5`¹ | |`C5`² |
+|2 |16 | | | | |
+|3 |0 | |`A0`¹ | |`A0`² |
+|3 |1 | |`A1`¹ |`B1` |`A1`² |
+|3 |2 | |`A2`¹ |`E9` |`A2`² |
+|3 |3 | |`A3`¹ |`E13` |`A3`² |
+|3 |4 | |`F6`¹ | |`F6`² |
+|3 |5 | |`F7`¹ |`B13` |`F7`² |
+|3 |6 | |`F8`¹ |`E8` |`F8`² |
+|3 |7 | |`F9`¹ |`D10` |`F9`² |
+|3 |8 | |`F10`¹ |`D11` |`F10`² |
+|3 |9 | | |`D12` |`F3`² |
+|3 |10 | |`C0`¹ |`D13` |`C0`² |
+|3 |11 | |`C1`¹ |`D14` |`C1`² |
+|3 |12 | |`C2`¹ |`B0` |`C2`² |
+|3 |13 | |`C3`¹ |`E7` |`C3`² |
+|3 |14 | | |`E10` |`F4`² |
+|3 |15 | | |`E11` |`F5`² |
+|3 |16 | | |`E12` | |
+|4 |1 | | |`E14` | |
+|4 |2 | | |`E15` | |
+|4 |3 | | |`B12` | |
+|4 |4 | | |`B14` | |
+|4 |5 | | |`B15` | |
+|4 |6 | | |`E8` | |
+|4 |7 | | |`D10` | |
+|4 |8 | | |`D11` | |
+|4 |9 | | |`D12` | |
+|4 |10 | | |`D13` | |
+|4 |11 | | |`D14` | |
+|4 |12 | | |`D8` | |
+|4 |13 | | |`D9` | |
+|4 |14 | | | | |
+|4 |15 | | | | |
+|4 |16 | | | | |
+
+¹ As of ChibiOS 20.3.4, the ADC driver for STM32F1xx devices supports only ADC1, therefore any configurations involving ADC2 or ADC3 cannot actually be used. In particular, pins `F6`…`F10`, which are present at least on some STM32F103x[C-G] devices, cannot be used as ADC inputs because of this driver limitation.
+
+² Not all STM32F4xx devices have ADC2 and/or ADC3, therefore some configurations shown in this table may be unavailable; in particular, pins `F4`…`F10` cannot be used as ADC inputs on devices which do not have ADC3. Check the device datasheet to confirm which pin functions are supported.
## Functions
@@ -141,10 +147,10 @@ Also note that the F0 and F3 use different numbering schemes. The F0 has a singl
The ARM implementation of the ADC has a few additional options that you can override in your own keyboards and keymaps to change how it operates. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options.
-|`#define` |Type |Default |Description |
-|---------------------|------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-|`ADC_CIRCULAR_BUFFER`|`bool`|`false` |If `true`, then the implementation will use a circular buffer. |
-|`ADC_NUM_CHANNELS` |`int` |`1` |Sets the number of channels that will be scanned as part of an ADC operation. The current implementation only supports `1`. |
-|`ADC_BUFFER_DEPTH` |`int` |`2` |Sets the depth of each result. Since we are only getting a 12-bit result by default, we set this to 2 bytes so we can contain our one value. This could be set to 1 if you opt for an 8-bit or lower result.|
-|`ADC_SAMPLING_RATE` |`int` |`ADC_SMPR_SMP_1P5` |Sets the sampling rate of the ADC. By default, it is set to the fastest setting. |
-|`ADC_RESOLUTION` |`int` |`ADC_CFGR1_RES_12BIT`|The resolution of your result. We choose 12 bit by default, but you can opt for 12, 10, 8, or 6 bit. |
+|`#define` |Type |Default |Description |
+|---------------------|------|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+|`ADC_CIRCULAR_BUFFER`|`bool`|`false` |If `true`, then the implementation will use a circular buffer. |
+|`ADC_NUM_CHANNELS` |`int` |`1` |Sets the number of channels that will be scanned as part of an ADC operation. The current implementation only supports `1`. |
+|`ADC_BUFFER_DEPTH` |`int` |`2` |Sets the depth of each result. Since we are only getting a 10-bit result by default, we set this to 2 bytes so we can contain our one value. This could be set to 1 if you opt for an 8-bit or lower result.|
+|`ADC_SAMPLING_RATE` |`int` |`ADC_SMPR_SMP_1P5` |Sets the sampling rate of the ADC. By default, it is set to the fastest setting. |
+|`ADC_RESOLUTION` |`int` |`ADC_CFGR1_RES_10BIT` or `ADC_CFGR_RES_10BITS`|The resolution of your result. We choose 10 bit by default, but you can opt for 12, 10, 8, or 6 bit. Different MCUs use slightly different names for the resolution constants. |
diff --git a/docs/breaking_changes.md b/docs/breaking_changes.md
index 0503789cdbde..3e85a70761d2 100644
--- a/docs/breaking_changes.md
+++ b/docs/breaking_changes.md
@@ -6,6 +6,7 @@ The breaking change period is when we will merge PR's that change QMK in dangero
## What has been included in past Breaking Changes?
+* [2021 May 29](ChangeLog/20210529.md)
* [2021 Feb 27](ChangeLog/20210227.md)
* [2020 Nov 28](ChangeLog/20201128.md)
* [2020 Aug 29](ChangeLog/20200829.md)
@@ -15,16 +16,16 @@ The breaking change period is when we will merge PR's that change QMK in dangero
## When is the next Breaking Change?
-The next Breaking Change is scheduled for May 29, 2021.
+The next Breaking Change is scheduled for August 28, 2021.
### Important Dates
-* [x] 2021 Feb 27 - `develop` is created. Each push to `master` is subsequently merged to `develop`
-* [ ] 2021 May 01 - `develop` closed to new PR's.
-* [ ] 2021 May 01 - Call for testers.
-* [ ] 2021 May 27 - `master` is locked, no PR's merged.
-* [ ] 2021 May 29 - Merge `develop` to `master`.
-* [ ] 2021 May 29 - `master` is unlocked. PR's can be merged again.
+* [x] 2021 May 29 - `develop` is created. Each push to `master` is subsequently merged to `develop`
+* [ ] 2021 Jul 31 - `develop` closed to new PR's.
+* [ ] 2021 Jul 31 - Call for testers.
+* [ ] 2021 Aug 26 - `master` is locked, no PR's merged.
+* [ ] 2021 Aug 28 - Merge `develop` to `master`.
+* [ ] 2021 Aug 28 - `master` is unlocked. PR's can be merged again.
## What changes will be included?
diff --git a/docs/breaking_changes_history.md b/docs/breaking_changes_history.md
index dd474f1bb7ca..6ba8fe3b0674 100644
--- a/docs/breaking_changes_history.md
+++ b/docs/breaking_changes_history.md
@@ -2,6 +2,7 @@
This page links to all previous changelogs from the QMK Breaking Changes process.
+* [2021 May 29](ChangeLog/20210529.md) - version 0.13.0
* [2021 Feb 27](ChangeLog/20210227.md) - version 0.12.0
* [2020 Nov 28](ChangeLog/20201128.md) - version 0.11.0
* [2020 Aug 29](ChangeLog/20200829.md) - version 0.10.0
diff --git a/docs/cli_commands.md b/docs/cli_commands.md
index 05e9306070d0..581342093a99 100644
--- a/docs/cli_commands.md
+++ b/docs/cli_commands.md
@@ -107,6 +107,54 @@ This command lets you configure the behavior of QMK. For the full `qmk config` d
qmk config [-ro] [config_token1] [config_token2] [...] [config_tokenN]
```
+## `qmk console`
+
+This command lets you connect to keyboard consoles to get debugging messages. It only works if your keyboard firmware has been compiled with `CONSOLE_ENABLED=yes`.
+
+**Usage**:
+
+```
+qmk console [-d :[:]] [-l] [-n] [-t] [-w ]
+```
+
+**Examples**:
+
+Connect to all available keyboards and show their console messages:
+
+```
+qmk console
+```
+
+List all devices:
+
+```
+qmk console -l
+```
+
+Show only messages from clueboard/66/rev3 keyboards:
+
+```
+qmk console -d C1ED:2370
+```
+
+Show only messages from the second clueboard/66/rev3:
+
+```
+qmk console -d C1ED:2370:2
+```
+
+Show timestamps and VID:PID instead of names:
+
+```
+qmk console -n -t
+```
+
+Disable bootloader messages:
+
+```
+qmk console --no-bootloaders
+```
+
## `qmk doctor`
This 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/compatible_microcontrollers.md b/docs/compatible_microcontrollers.md
index 47a4844e7fcd..0f5b140de0b5 100644
--- a/docs/compatible_microcontrollers.md
+++ b/docs/compatible_microcontrollers.md
@@ -28,8 +28,11 @@ You can also use any ARM chip with USB that [ChibiOS](https://www.chibios.org) s
* [STM32F303](https://www.st.com/en/microcontrollers-microprocessors/stm32f303.html)
* [STM32F401](https://www.st.com/en/microcontrollers-microprocessors/stm32f401.html)
* [STM32F411](https://www.st.com/en/microcontrollers-microprocessors/stm32f411.html)
+ * [STM32F446](https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html)
* [STM32G431](https://www.st.com/en/microcontrollers-microprocessors/stm32g4x1.html)
* [STM32G474](https://www.st.com/en/microcontrollers-microprocessors/stm32g4x4.html)
+ * [STM32L433](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x3.html)
+ * [STM32L443](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x3.html)
### NXP (Kinetis)
diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md
index 8e04d9dd38cf..ec7eeaaa0cae 100644
--- a/docs/feature_auto_shift.md
+++ b/docs/feature_auto_shift.md
@@ -109,6 +109,33 @@ Do not Auto Shift numeric keys, zero through nine.
Do not Auto Shift alpha characters, which include A through Z.
+### Auto Shift Per Key
+
+This is a function that allows you to determine which keys shold be autoshifted, much like the tap-hold keys.
+
+The default function looks like this:
+
+```c
+bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+# ifndef NO_AUTO_SHIFT_ALPHA
+ case KC_A ... KC_Z:
+# endif
+# ifndef NO_AUTO_SHIFT_NUMERIC
+ case KC_1 ... KC_0:
+# endif
+# ifndef NO_AUTO_SHIFT_SPECIAL
+ case KC_TAB:
+ case KC_MINUS ... KC_SLASH:
+ case KC_NONUS_BSLASH:
+# endif
+ return true;
+ }
+ return false;
+}
+```
+This functionality is enabled by default, and does not need a define.
+
### AUTO_SHIFT_REPEAT (simple define)
Enables keyrepeat.
diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md
index 74511dd43ff0..d47ecc68242b 100644
--- a/docs/feature_backlight.md
+++ b/docs/feature_backlight.md
@@ -62,15 +62,17 @@ Valid driver values are `pwm`, `software`, `custom` or `no`. See below for help
To configure the backlighting, `#define` these in your `config.h`:
-| Define | Default | Description |
-|------------------------|---------------|-------------------------------------------------------------------------------------------------------------------|
-| `BACKLIGHT_PIN` | *Not defined* | The pin that controls the LED(s) |
-| `BACKLIGHT_LEVELS` | `3` | The number of brightness levels (maximum 31 excluding off) |
-| `BACKLIGHT_CAPS_LOCK` | *Not defined* | Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) |
-| `BACKLIGHT_BREATHING` | *Not defined* | Enable backlight breathing, if supported |
-| `BREATHING_PERIOD` | `6` | The length of one backlight "breath" in seconds |
-| `BACKLIGHT_ON_STATE` | `1` | The state of the backlight pin when the backlight is "on" - `1` for high, `0` for low |
-| `BACKLIGHT_LIMIT_VAL ` | `255` | The maximum duty cycle of the backlight -- `255` allows for full brightness, any lower will decrease the maximum. |
+|Define |Default |Description |
+|-----------------------------|------------------|-----------------------------------------------------------------------------------------------------------------|
+|`BACKLIGHT_PIN` |*Not defined* |The pin that controls the LED(s) |
+|`BACKLIGHT_LEVELS` |`3` |The number of brightness levels (maximum 31 excluding off) |
+|`BACKLIGHT_CAPS_LOCK` |*Not defined* |Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) |
+|`BACKLIGHT_BREATHING` |*Not defined* |Enable backlight breathing, if supported |
+|`BREATHING_PERIOD` |`6` |The length of one backlight "breath" in seconds |
+|`BACKLIGHT_ON_STATE` |`1` |The state of the backlight pin when the backlight is "on" - `1` for high, `0` for low |
+|`BACKLIGHT_LIMIT_VAL` |`255` |The maximum duty cycle of the backlight -- `255` allows for full brightness, any lower will decrease the maximum.|
+|`BACKLIGHT_DEFAULT_LEVEL` |`BACKLIGHT_LEVELS`|The default backlight level to use upon clearing the EEPROM |
+|`BACKLIGHT_DEFAULT_BREATHING`|*Not defined* |Whether to enable backlight breathing upon clearing the EEPROM |
Unless you are designing your own keyboard, you generally should not need to change the `BACKLIGHT_PIN` or `BACKLIGHT_ON_STATE`.
diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md
index 4338c85e84b6..a56f093a3989 100644
--- a/docs/feature_encoders.md
+++ b/docs/feature_encoders.md
@@ -53,15 +53,15 @@ If you are using different pinouts for the encoders on each half of a split keyb
The callback functions can be inserted into your `.c`:
```c
-void encoder_update_kb(uint8_t index, bool clockwise) {
- encoder_update_user(index, clockwise);
+bool encoder_update_kb(uint8_t index, bool clockwise) {
+ return encoder_update_user(index, clockwise);
}
```
or `keymap.c`:
```c
-void encoder_update_user(uint8_t index, bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* First encoder */
if (clockwise) {
tap_code(KC_PGDN);
@@ -75,9 +75,12 @@ void encoder_update_user(uint8_t index, bool clockwise) {
tap_code(KC_UP);
}
}
+ return true;
}
```
+!> If you return `true`, this will allow the keyboard level code to run, as well. Returning `false` will override the keyboard level code. Depending on how the keyboard level function is set up.
+
## Hardware
The A an B lines of the encoders should be wired directly to the MCU, and the C/common lines should be wired to ground.
diff --git a/docs/feature_leader_key.md b/docs/feature_leader_key.md
index 41ff8f1a4e29..f10bca7589f0 100644
--- a/docs/feature_leader_key.md
+++ b/docs/feature_leader_key.md
@@ -72,6 +72,19 @@ SEQ_THREE_KEYS(KC_C, KC_C, KC_C) {
}
```
+## Infinite Leader key timeout
+
+Sometimes your leader key is not on a comfortable places as the rest of keys on your sequence. Imagine that your leader key is one of your outer top right keys, you may need to reposition your hand just to reach your leader key.
+This can make typing the entire sequence on time hard even if you are able to type most of the sequence fast. For example, if your sequence is `Leader + asd` typing `asd` fast is very easy once you have your hands in your home row. However starting the sequence in time after moving your hand out of the home row to reach the leader key and back is not.
+To remove the stress this situation produces to your hands you can enable an infinite timeout just for the leader key. This mean that, after you hit the leader key you will have an infinite amount of time to start the rest of the sequence, allowing you to proper position your hands on the best position to type the rest of the sequence comfortably.
+This infinite timeout only affects the leader key, so in our previous example of `Leader + asd` you will have an infinite amount of time between `Leader` and `a`, but once you start the sequence the timeout you have configured (global or per key) will work normally.
+This way you can configure a very short `LEADER_TIMEOUT` but still have plenty of time to position your hands.
+
+In order to enable this, place this in your `config.h`:
+```c
+#define LEADER_NO_TIMEOUT
+```
+
## Strict Key Processing
By default, the Leader Key feature will filter the keycode out of [`Mod-Tap`](mod_tap.md) and [`Layer Tap`](feature_layers.md#switching-and-toggling-layers) functions when checking for the Leader sequences. That means if you're using `LT(3, KC_A)`, it will pick this up as `KC_A` for the sequence, rather than `LT(3, KC_A)`, giving a more expected behavior for newer users.
diff --git a/docs/feature_led_matrix.md b/docs/feature_led_matrix.md
index f4a6616340c3..9c3e2c7f3d21 100644
--- a/docs/feature_led_matrix.md
+++ b/docs/feature_led_matrix.md
@@ -1,14 +1,14 @@
-# LED Matrix Lighting
+# LED Matrix Lighting :id=led-matrix-lighting
This feature allows you to use LED matrices driven by external drivers. It hooks into the backlight system so you can use the same keycodes as backlighting to control it.
If you want to use RGB LED's you should use the [RGB Matrix Subsystem](feature_rgb_matrix.md) instead.
-## Driver configuration
+## Driver configuration :id=driver-configuration
+---
+### IS31FL3731 :id=is31fl3731
-### IS31FL3731
-
-There is basic support for addressable LED matrix lighting with the I2C IS31FL3731 RGB controller. To enable it, add this to your `rules.mk`:
+There is basic support for addressable LED matrix lighting with the I2C IS31FL3731 LED controller. To enable it, add this to your `rules.mk`:
```make
LED_MATRIX_ENABLE = yes
@@ -19,7 +19,7 @@ You can use between 1 and 4 IS31FL3731 IC's. Do not specify `LED_DRIVER_ADDR_
| Variable | Description | Default |
|----------|-------------|---------|
-| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages | 100 |
+| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
| `LED_DRIVER_COUNT` | (Required) How many LED driver IC's are present | |
| `DRIVER_LED_TOTAL` | (Required) How many LED lights are present across all drivers | |
@@ -42,59 +42,336 @@ Here is an example using 2 drivers.
#define LED_DRIVER_ADDR_2 0b1110110
#define LED_DRIVER_COUNT 2
-#define LED_DRIVER_1_LED_COUNT 25
-#define LED_DRIVER_2_LED_COUNT 24
-#define DRIVER_LED_TOTAL LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL
+#define LED_DRIVER_1_LED_TOTAL 25
+#define LED_DRIVER_2_LED_TOTAL 24
+#define DRIVER_LED_TOTAL (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)
```
-Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations.
+!> Note the parentheses, this is so when `LED_DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)` will give very different results than `rand() % LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL`.
Define these arrays listing all the LEDs in your `.c`:
```c
- const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
- /* Refer to IS31 manual for these locations
- * driver
- * | LED address
- * | | */
- { 0, C1_1 },
- { 0, C1_15 },
- // ...
- }
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | LED address
+ * | | */
+ { 0, C1_1 },
+ { 0, C1_15 },
+ // ...
+}
```
Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/issi/is31fl3731-simple.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` ).
-## Keycodes
+---
+
+From this point forward the configuration is the same for all the drivers. The `led_config_t` struct provides a key electrical matrix to led index lookup table, what the physical position of each LED is on the board, and what type of key or usage the LED if the LED represents. Here is a brief example:
+
+```c
+led_config_t g_led_config = { {
+ // Key Matrix to LED Index
+ { 5, NO_LED, NO_LED, 0 },
+ { NO_LED, NO_LED, NO_LED, NO_LED },
+ { 4, NO_LED, NO_LED, 1 },
+ { 3, NO_LED, NO_LED, 2 }
+}, {
+ // LED Index to Physical Position
+ { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 }
+}, {
+ // LED Index to Flag
+ 1, 4, 4, 4, 4, 1
+} };
+```
+
+The first part, `// Key Matrix to LED Index`, tells the system what key this LED represents by using the key's electrical matrix row & col. The second part, `// LED Index to Physical Position` represents the LED's physical `{ x, y }` position on the keyboard. The default expected range of values for `{ x, y }` is the inclusive range `{ 0..224, 0..64 }`. This default expected range is due to effects that calculate the center of the keyboard for their animations. The easiest way to calculate these positions is imagine your keyboard is a grid, and the top left of the keyboard represents `{ x, y }` coordinate `{ 0, 0 }` and the bottom right of your keyboard represents `{ 224, 64 }`. Using this as a basis, you can use the following formula to calculate the physical position:
+
+```c
+x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION
+y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION
+```
+
+Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout.
+
+As mentioned earlier, the center of the keyboard by default is expected to be `{ 112, 32 }`, but this can be changed if you want to more accurately calculate the LED's physical `{ x, y }` positions. Keyboard designers can implement `#define LED_MATRIX_CENTER { 112, 32 }` in their config.h file with the new center point of the keyboard, or where they want it to be allowing more possibilities for the `{ x, y }` values. Do note that the maximum value for x or y is 255, and the recommended maximum is 224 as this gives animations runoff room before they reset.
+
+`// LED Index to Flag` is a bitmask, whether or not a certain LEDs is of a certain type. It is recommended that LEDs are set to only 1 type.
+
+## Flags :id=flags
+
+|Define |Value |Description |
+|----------------------------|------|-------------------------------------------------|
+|`HAS_FLAGS(bits, flags)` |*n/a* |Evaluates to `true` if `bits` has all `flags` set|
+|`HAS_ANY_FLAGS(bits, flags)`|*n/a* |Evaluates to `true` if `bits` has any `flags` set|
+|`LED_FLAG_NONE` |`0x00`|If this LED has no flags |
+|`LED_FLAG_ALL` |`0xFF`|If this LED has all flags |
+|`LED_FLAG_MODIFIER` |`0x01`|If the LED is on a modifier key |
+|`LED_FLAG_KEYLIGHT` |`0x04`|If the LED is for key backlight |
+|`LED_FLAG_INDICATOR` |`0x08`|If the LED is for keyboard state indication |
+
+## Keycodes :id=keycodes
+
+All LED matrix keycodes are currently shared with the [Backlight feature](feature_backlight.md).
+
+|Key |Description |
+|---------|-----------------------------|
+|`BL_TOGG`|Toggle LED Matrix on or off |
+|`BL_STEP`|Cycle through modes |
+|`BL_ON` |Turn on LED Matrix |
+|`BL_OFF` |Turn off LED Matrix |
+|`BL_INC` |Increase the brightness level|
+|`BL_DEC` |Decrease the brightness level|
+
+## LED Matrix Effects :id=led-matrix-effects
+
+These are the effects that are currently available:
+
+```c
+enum led_matrix_effects {
+ LED_MATRIX_NONE = 0,
+ LED_MATRIX_SOLID = 1, // Static single val, no speed support
+ LED_MATRIX_ALPHAS_MODS, // Static dual val, speed is val for LEDs marked as modifiers
+ LED_MATRIX_BREATHING, // Cycling brightness animation
+ LED_MATRIX_BAND, // Band fading brightness scrolling left to right
+ LED_MATRIX_BAND_PINWHEEL, // 3 blade spinning pinwheel fades brightness
+ LED_MATRIX_BAND_SPIRAL, // Spinning spiral fades brightness
+ LED_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right
+ LED_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom
+ LED_MATRIX_CYCLE_OUT_IN, // Full gradient scrolling out to in
+ LED_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard
+#if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES)
+ LED_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit then fades out
+ LED_MATRIX_SOLID_REACTIVE_WIDE // Value pulses near a single key hit then fades out
+ LED_MATRIX_SOLID_REACTIVE_MULTIWIDE // Value pulses near multiple key hits then fades out
+ LED_MATRIX_SOLID_REACTIVE_CROSS // Value pulses the same column and row of a single key hit then fades out
+ LED_MATRIX_SOLID_REACTIVE_MULTICROSS // Value pulses the same column and row of multiple key hits then fades out
+ LED_MATRIX_SOLID_REACTIVE_NEXUS // Value pulses away on the same column and row of a single key hit then fades out
+ LED_MATRIX_SOLID_REACTIVE_MULTINEXUS // Value pulses away on the same column and row of multiple key hits then fades out
+ LED_MATRIX_SOLID_SPLASH, // Value pulses away from a single key hit then fades out
+ LED_MATRIX_SOLID_MULTISPLASH, // Value pulses away from multiple key hits then fades out
+#endif
+ LED_MATRIX_WAVE_LEFT_RIGHT // Sine wave scrolling from left to right
+ LED_MATRIX_WAVE_UP_DOWN // Sine wave scrolling from up to down
+ LED_MATRIX_EFFECT_MAX
+};
+```
+
+You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:
+
+
+|Define |Description |
+|-------------------------------------------------------|-----------------------------------------------|
+|`#define DISABLE_LED_MATRIX_ALPHAS_MODS` |Disables `LED_MATRIX_ALPHAS_MODS` |
+|`#define DISABLE_LED_MATRIX_BREATHING` |Disables `LED_MATRIX_BREATHING` |
+|`#define DISABLE_LED_MATRIX_BAND` |Disables `LED_MATRIX_BAND` |
+|`#define DISABLE_LED_MATRIX_BAND_PINWHEEL` |Disables `LED_MATRIX_BAND_PINWHEEL` |
+|`#define DISABLE_LED_MATRIX_BAND_SPIRAL` |Disables `LED_MATRIX_BAND_SPIRAL` |
+|`#define DISABLE_LED_MATRIX_CYCLE_LEFT_RIGHT` |Disables `LED_MATRIX_CYCLE_LEFT_RIGHT` |
+|`#define DISABLE_LED_MATRIX_CYCLE_UP_DOWN` |Disables `LED_MATRIX_CYCLE_UP_DOWN` |
+|`#define DISABLE_LED_MATRIX_CYCLE_OUT_IN` |Disables `LED_MATRIX_CYCLE_OUT_IN` |
+|`#define DISABLE_LED_MATRIX_DUAL_BEACON` |Disables `LED_MATRIX_DUAL_BEACON` |
+|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `LED_MATRIX_SOLID_REACTIVE_SIMPLE` |
+|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE` |Disables `LED_MATRIX_SOLID_REACTIVE_WIDE` |
+|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE` |Disables `LED_MATRIX_SOLID_REACTIVE_MULTIWIDE` |
+|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS` |Disables `LED_MATRIX_SOLID_REACTIVE_CROSS` |
+|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS` |Disables `LED_MATRIX_SOLID_REACTIVE_MULTICROSS`|
+|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS` |Disables `LED_MATRIX_SOLID_REACTIVE_NEXUS` |
+|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS` |Disables `LED_MATRIX_SOLID_REACTIVE_MULTINEXUS`|
+|`#define DISABLE_LED_MATRIX_SOLID_SPLASH` |Disables `LED_MATRIX_SOLID_SPLASH` |
+|`#define DISABLE_LED_MATRIX_SOLID_MULTISPLASH` |Disables `LED_MATRIX_SOLID_MULTISPLASH` |
+|`#define DISABLE_LED_MATRIX_WAVE_LEFT_RIGHT` |Disables `LED_MATRIX_WAVE_LEFT_RIGHT` |
+|`#define DISABLE_LED_MATRIX_WAVE_UP_DOWN` |Disables `LED_MATRIX_WAVE_UP_DOWN` |
+
+## Custom LED Matrix Effects :id=custom-led-matrix-effects
+
+By setting `LED_MATRIX_CUSTOM_USER` (and/or `LED_MATRIX_CUSTOM_KB`) in `rules.mk`, new effects can be defined directly from userspace, without having to edit any QMK core files.
+
+To declare new effects, create a new `led_matrix_user/kb.inc` that looks something like this:
+
+`led_matrix_user.inc` should go in the root of the keymap directory.
+`led_matrix_kb.inc` should go in the root of the keyboard directory.
+
+To use custom effects in your code, simply prepend `LED_MATRIX_CUSTOM_` to the effect name specified in `LED_MATRIX_EFFECT()`. For example, an effect declared as `LED_MATRIX_EFFECT(my_cool_effect)` would be referenced with:
+
+```c
+led_matrix_mode(led_MATRIX_CUSTOM_my_cool_effect);
+```
+
+```c
+// !!! DO NOT ADD #pragma once !!! //
+
+// Step 1.
+// Declare custom effects using the LED_MATRIX_EFFECT macro
+// (note the lack of semicolon after the macro!)
+LED_MATRIX_EFFECT(my_cool_effect)
+LED_MATRIX_EFFECT(my_cool_effect2)
+
+// Step 2.
+// Define effects inside the `LED_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block
+#ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+// e.g: A simple effect, self-contained within a single method
+static bool my_cool_effect(effect_params_t* params) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ led_matrix_set_value(i, 0xFF);
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+// e.g: A more complex effect, relying on external methods and state, with
+// dedicated init and run methods
+static uint8_t some_global_state;
+static void my_cool_effect2_complex_init(effect_params_t* params) {
+ some_global_state = 1;
+}
+static bool my_cool_effect2_complex_run(effect_params_t* params) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ led_matrix_set_value(i, some_global_state++);
+ }
+
+ return led_max < DRIVER_LED_TOTAL;
+}
+static bool my_cool_effect2(effect_params_t* params) {
+ if (params->init) my_cool_effect2_complex_init(params);
+ return my_cool_effect2_complex_run(params);
+}
+
+#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+```
+
+For inspiration and examples, check out the built-in effects under `quantum/led_matrix_animations/`
+
+
+
+
+
+
+
+
+
+## Additional `config.h` Options :id=additional-configh-options
+
+```c
+#define LED_MATRIX_KEYPRESSES // reacts to keypresses
+#define LED_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
+#define LED_MATRIX_FRAMEBUFFER_EFFECTS // enable framebuffer effects
+#define LED_DISABLE_TIMEOUT 0 // number of milliseconds to wait until led automatically turns off
+#define LED_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects
+#define LED_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
+#define LED_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
+#define LED_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness)
+#define LED_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs
+#define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID // Sets the default mode, if none has been set
+#define LED_MATRIX_STARTUP_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
+#define LED_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set
+#define LED_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
+ // If LED_MATRIX_KEYPRESSES or LED_MATRIX_KEYRELEASES is enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
+```
+
+## EEPROM storage :id=eeprom-storage
+
+The EEPROM for it is currently shared with the RGB Matrix system (it's generally assumed only one feature would be used at a time), but could be configured to use its own 32bit address with:
+
+```c
+#define EECONFIG_LED_MATRIX (uint32_t *)28
+```
+
+Where `28` is an unused index from `eeconfig.h`.
+
+### Direct Operation :id=direct-operation
+|Function |Description |
+|--------------------------------------------|-------------|
+|`led_matrix_set_value_all(v)` |Set all of the LEDs to the given value, where `v` is between 0 and 255 (not written to EEPROM) |
+|`led_matrix_set_value(index, v)` |Set a single LED to the given value, where `v` is between 0 and 255, and `index` is between 0 and `DRIVER_LED_TOTAL` (not written to EEPROM) |
+
+### Disable/Enable Effects :id=disable-enable-effects
+|Function |Description |
+|--------------------------------------------|-------------|
+|`led_matrix_toggle()` |Toggle effect range LEDs between on and off |
+|`led_matrix_toggle_noeeprom()` |Toggle effect range LEDs between on and off (not written to EEPROM) |
+|`led_matrix_enable()` |Turn effect range LEDs on, based on their previous state |
+|`led_matrix_enable_noeeprom()` |Turn effect range LEDs on, based on their previous state (not written to EEPROM) |
+|`led_matrix_disable()` |Turn effect range LEDs off, based on their previous state |
+|`led_matrix_disable_noeeprom()` |Turn effect range LEDs off, based on their previous state (not written to EEPROM) |
-All LED matrix keycodes are currently shared with the [backlight system](feature_backlight.md).
+### Change Effect Mode :id=change-effect-mode
+|Function |Description |
+|--------------------------------------------|-------------|
+|`led_matrix_mode(mode)` |Set the mode, if LED animations are enabled |
+|`led_matrix_mode_noeeprom(mode)` |Set the mode, if LED animations are enabled (not written to EEPROM) |
+|`led_matrix_step()` |Change the mode to the next LED animation in the list of enabled LED animations |
+|`led_matrix_step_noeeprom()` |Change the mode to the next LED animation in the list of enabled LED animations (not written to EEPROM) |
+|`led_matrix_step_reverse()` |Change the mode to the previous LED animation in the list of enabled LED animations |
+|`led_matrix_step_reverse_noeeprom()` |Change the mode to the previous LED animation in the list of enabled LED animations (not written to EEPROM) |
+|`led_matrix_increase_speed()` |Increase the speed of the animations |
+|`led_matrix_increase_speed_noeeprom()` |Increase the speed of the animations (not written to EEPROM) |
+|`led_matrix_decrease_speed()` |Decrease the speed of the animations |
+|`led_matrix_decrease_speed_noeeprom()` |Decrease the speed of the animations (not written to EEPROM) |
+|`led_matrix_set_speed(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 |
+|`led_matrix_set_speed_noeeprom(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 (not written to EEPROM) |
-## LED Matrix Effects
+### Change Value :id=change-value
+|Function |Description |
+|--------------------------------------------|-------------|
+|`led_matrix_increase_val()` |Increase the value for effect range LEDs. This wraps around at maximum value |
+|`led_matrix_increase_val_noeeprom()` |Increase the value for effect range LEDs. This wraps around at maximum value (not written to EEPROM) |
+|`led_matrix_decrease_val()` |Decrease the value for effect range LEDs. This wraps around at minimum value |
+|`led_matrix_decrease_val_noeeprom()` |Decrease the value for effect range LEDs. This wraps around at minimum value (not written to EEPROM) |
-Currently no LED matrix effects have been created.
+### Query Current Status :id=query-current-status
+|Function |Description |
+|---------------------------------|---------------------------|
+|`led_matrix_is_enabled()` |Gets current on/off status |
+|`led_matrix_get_mode()` |Gets current mode |
+|`led_matrix_get_val()` |Gets current val |
+|`led_matrix_get_speed()` |Gets current speed |
+|`led_matrix_get_suspend_state()` |Gets current suspend state |
-## Custom Layer Effects
+## Callbacks :id=callbacks
-Custom layer effects can be done by defining this in your `.c`:
+### Indicators :id=indicators
+If you want to set custom indicators, such as an LED for Caps Lock, or layer indication, you can use the `led_matrix_indicators_kb` or `led_matrix_indicators_user` function for that:
```c
void led_matrix_indicators_kb(void) {
- led_matrix_set_index_value(index, value);
+ led_matrix_set_color(index, value);
}
```
-A similar function works in the keymap as `led_matrix_indicators_user`.
+In addition, there are the advanced indicator functions. These are aimed at those with heavily customized displays, where rendering every LED per cycle is expensive. This includes a special macro to help make this easier to use: `LED_MATRIX_INDICATOR_SET_VALUE(i, v)`.
+
+```c
+void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
+ LED_MATRIX_INDICATOR_SET_VALUE(index, value);
+}
+```
-## Suspended State
+## Suspended State :id=suspended-state
+To use the suspend feature, make sure that `#define LED_DISABLE_WHEN_USB_SUSPENDED true` is added to the `config.h` file.
-To use the suspend feature, add this to your `.c`:
+Additionally add this to your `.c`:
```c
void suspend_power_down_kb(void) {
led_matrix_set_suspend_state(true);
+ suspend_power_down_user();
}
void suspend_wakeup_init_kb(void) {
led_matrix_set_suspend_state(false);
+ suspend_wakeup_init_user();
+}
+```
+or add this to your `keymap.c`:
+```c
+void suspend_power_down_user(void) {
+ led_matrix_set_suspend_state(true);
+}
+
+void suspend_wakeup_init_user(void) {
+ led_matrix_set_suspend_state(false);
}
-```
\ No newline at end of file
+```
diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md
index 44202487f15e..d2dc6103a687 100644
--- a/docs/feature_oled_driver.md
+++ b/docs/feature_oled_driver.md
@@ -145,6 +145,8 @@ void oled_task_user(void) {
|`OLED_FONT_WIDTH` |`6` |The font width |
|`OLED_FONT_HEIGHT` |`8` |The font height (untested) |
|`OLED_TIMEOUT` |`60000` |Turns off the OLED screen after 60000ms of keyboard inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. |
+|`OLED_FADE_OUT` |*Not defined* |Enables fade out animation. Use together with `OLED_TIMEOUT`. |
+|`OLED_FADE_OUT_INTERVAL` |`0` |The speed of fade out animation, from 0 to 15. Larger values are slower. |
|`OLED_SCROLL_TIMEOUT` |`0` |Scrolls the OLED screen after 0ms of OLED inactivity. Helps reduce OLED Burn-in. Set to 0 to disable. |
|`OLED_SCROLL_TIMEOUT_RIGHT`|*Not defined* |Scroll timeout direction is right when defined, left when undefined. |
|`OLED_IC` |`OLED_IC_SSD1306`|Set to `OLED_IC_SH1106` if you're using the SH1106 OLED controller. |
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index dd9c98c5eb42..169443fb85a5 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -15,7 +15,20 @@ RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = IS31FL3731
```
-Configure the hardware via your `config.h`:
+You can use between 1 and 4 IS31FL3731 IC's. Do not specify `DRIVER_ADDR_` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`:
+
+| Variable | Description | Default |
+|----------|-------------|---------|
+| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
+| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
+| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
+| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
+| `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
+| `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
+| `DRIVER_ADDR_3` | (Optional) Address for the third RGB driver | |
+| `DRIVER_ADDR_4` | (Optional) Address for the fourth RGB driver | |
+
+Here is an example using 2 drivers.
```c
// This is a 7-bit address, that gets left-shifted and bit 0
@@ -36,8 +49,6 @@ Configure the hardware via your `config.h`:
!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
-Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations.
-
Define these arrays listing all the LEDs in your `.c`:
```c
@@ -53,12 +64,10 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
}
```
-Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/issi/is31fl3731.h`. The `driver` is the index of the driver you defined in your `config.h` (`0` or `1` right now).
+Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/issi/is31fl3731.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3`).
---
-### IS31FL3733/IS31FL3737 :id=is31fl3733is31fl3737
-
-!> For the IS31FL3737, replace all instances of `IS31FL3733` below with `IS31FL3737`.
+### IS31FL3733 :id=is31fl3733
There is basic support for addressable RGB matrix lighting with the I2C IS31FL3733 RGB controller. To enable it, add this to your `rules.mk`:
@@ -67,7 +76,24 @@ RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = IS31FL3733
```
-Configure the hardware via your `config.h`:
+You can use between 1 and 4 IS31FL3733 IC's. Do not specify `DRIVER_ADDR_` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`:
+
+| Variable | Description | Default |
+|----------|-------------|---------|
+| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
+| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
+| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
+| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
+| `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
+| `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
+| `DRIVER_ADDR_3` | (Optional) Address for the third RGB driver | |
+| `DRIVER_ADDR_4` | (Optional) Address for the fourth RGB driver | |
+| `DRIVER_SYNC_1` | (Optional) Sync configuration for the first RGB driver | 0 |
+| `DRIVER_SYNC_2` | (Optional) Sync configuration for the second RGB driver | 0 |
+| `DRIVER_SYNC_3` | (Optional) Sync configuration for the third RGB driver | 0 |
+| `DRIVER_SYNC_4` | (Optional) Sync configuration for the fourth RGB driver | 0 |
+
+Here is an example using 2 drivers.
```c
// This is a 7-bit address, that gets left-shifted and bit 0
@@ -81,6 +107,58 @@ Configure the hardware via your `config.h`:
// ADDR2 represents A3:A2 of the 7-bit address.
// The result is: 0b101(ADDR2)(ADDR1)
#define DRIVER_ADDR_1 0b1010000
+#define DRIVER_ADDR_2 0b1010011
+
+#define DRIVER_COUNT 2
+#define DRIVER_1_LED_TOTAL 58
+#define DRIVER_2_LED_TOTAL 10
+#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
+```
+
+!> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
+
+Currently only 4 drivers are supported, but it would be trivial to support all 8 combinations.
+
+Define these arrays listing all the LEDs in your `.c`:
+
+```c
+const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
+/* Refer to IS31 manual for these locations
+ * driver
+ * | R location
+ * | | G location
+ * | | | B location
+ * | | | | */
+ {0, B_1, A_1, C_1},
+ ....
+}
+```
+
+Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3733.pdf) and the header file `drivers/issi/is31fl3733.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` for now).
+
+---
+### IS31FL3737 :id=is31fl3737
+
+There is basic support for addressable RGB matrix lighting with the I2C IS31FL3737 RGB controller. To enable it, add this to your `rules.mk`:
+
+```makefile
+RGB_MATRIX_ENABLE = yes
+RGB_MATRIX_DRIVER = IS31FL3737
+```
+
+Configure the hardware via your `config.h`:
+
+```c
+// This is a 7-bit address, that gets left-shifted and bit 0
+// set to 0 for write, 1 for read (as per I2C protocol)
+// The address will vary depending on your wiring:
+// 0000 <-> GND
+// 0101 <-> SCL
+// 1010 <-> SDA
+// 1111 <-> VCC
+// ADDR represents A3:A0 of the 7-bit address.
+// The result is: 0b101(ADDR)
+#define DRIVER_ADDR_1 0b1010000
#define DRIVER_ADDR_2 0b1010000 // this is here for compliancy reasons.
#define DRIVER_COUNT 2
@@ -105,7 +183,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
}
```
-Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3733.pdf) and the header file `drivers/issi/is31fl3733.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0` right now).
+Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3737.pdf) and the header file `drivers/issi/is31fl3737.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0` right now).
---
@@ -284,7 +362,6 @@ You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `con
|Define |Description |
|-------------------------------------------------------|-----------------------------------------------|
-|`#define DISABLE_RGB_MATRIX_SOLID_COLOR` |Disables `RGB_MATRIX_SOLID_COLOR` |
|`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` |
|`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` |
|`#define DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT` |Disables `MATRIX_GRADIENT_LEFT_RIGHT` |
@@ -399,7 +476,7 @@ static bool my_cool_effect2(effect_params_t* params) {
#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
```
-For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animation/`
+For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animations/`
## Colors :id=colors
@@ -438,7 +515,7 @@ These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blo
#define RGB_MATRIX_FRAMEBUFFER_EFFECTS // enable framebuffer effects
#define RGB_DISABLE_TIMEOUT 0 // number of milliseconds to wait until rgb automatically turns off
#define RGB_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects
-#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
+#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
#define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
#define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness)
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
@@ -448,11 +525,13 @@ These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blo
#define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
#define RGB_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set
#define RGB_MATRIX_DISABLE_KEYCODES // disables control of rgb matrix by keycodes (must use code functions to control the feature)
+#define RGB_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
+ // If RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
```
## EEPROM storage :id=eeprom-storage
-The EEPROM for it is currently shared with the RGBLIGHT system (it's generally assumed only one RGB would be used at a time), but could be configured to use its own 32bit address with:
+The EEPROM for it is currently shared with the LED Matrix system (it's generally assumed only one feature would be used at a time), but could be configured to use its own 32bit address with:
```c
#define EECONFIG_RGB_MATRIX (uint32_t *)28
diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md
index 79977b7aa17a..994a014a2817 100644
--- a/docs/feature_rgblight.md
+++ b/docs/feature_rgblight.md
@@ -74,6 +74,7 @@ Changing the **Value** sets the overall brightness.
|`RGB_MODE_XMAS` |`RGB_M_X` |Christmas animation mode |
|`RGB_MODE_GRADIENT`|`RGB_M_G` |Static gradient animation mode |
|`RGB_MODE_RGBTEST` |`RGB_M_T` |Red, Green, Blue test animation mode |
+|`RGB_MODE_TWINKLE` |`RGB_M_TW`|Twinkle animation mode |
!> By default, if you have both the RGB Light and the [RGB Matrix](feature_rgb_matrix.md) feature enabled, these keycodes will work for both features, at the same time. You can disable the keycode functionality by defining the `*_DISABLE_KEYCODES` option for the specific feature.
@@ -309,6 +310,18 @@ void post_process_record_user(uint16_t keycode, keyrecord_t *record) {
}
```
+You can also use `rgblight_blink_layer_repeat` to specify the amount of times the layer is supposed to blink. Using the layers from above,
+```c
+void post_process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case DEBUG:
+ rgblight_blink_layer_repeat(debug_enable ? 0 : 1, 200, 3);
+ break;
+ }
+}
+```
+would turn the layer 0 (or 1) on and off again three times when `DEBUG` is pressed.
+
### Overriding RGB Lighting on/off status
Normally lighting layers are not shown when RGB Lighting is disabled (e.g. with `RGB_TOG` keycode). If you would like lighting layers to work even when the RGB Lighting is otherwise off, add `#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF` to your `config.h`.
diff --git a/docs/feature_swap_hands.md b/docs/feature_swap_hands.md
index 009477d20334..cbc574b6b866 100644
--- a/docs/feature_swap_hands.md
+++ b/docs/feature_swap_hands.md
@@ -7,7 +7,7 @@ The swap-hands action allows support for one-handed typing without requiring a s
The configuration table is a simple 2-dimensional array to map from column/row to new column/row. Example `hand_swap_config` for Planck:
```C
-const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
+const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
{{11, 0}, {10, 0}, {9, 0}, {8, 0}, {7, 0}, {6, 0}, {5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}},
{{11, 1}, {10, 1}, {9, 1}, {8, 1}, {7, 1}, {6, 1}, {5, 1}, {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 1}},
{{11, 2}, {10, 2}, {9, 2}, {8, 2}, {7, 2}, {6, 2}, {5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}},
diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md
index 1208ac0064df..6c3e2a1a2fba 100644
--- a/docs/feature_unicode.md
+++ b/docs/feature_unicode.md
@@ -230,7 +230,7 @@ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
Example uses include sending Unicode strings when a key is pressed, as described in [Macros](feature_macros.md).
-### `send_unicode_hex_string()`
+### `send_unicode_hex_string()` (Deprecated)
Similar to `send_unicode_string()`, but the characters are represented by their Unicode code points, written in hexadecimal and separated by spaces. For example, the table flip above would be achieved with:
diff --git a/docs/feature_wpm.md b/docs/feature_wpm.md
index 12dd08057985..c8ec3a7f3274 100644
--- a/docs/feature_wpm.md
+++ b/docs/feature_wpm.md
@@ -1,25 +1,62 @@
# Word Per Minute (WPM) Calculcation
-The WPM feature uses time between keystrokes to compute a rolling average words
-per minute rate and makes this available for various uses.
+The WPM feature uses time between keystrokes to compute a rolling average words per minute rate and makes this available for various uses.
Enable the WPM system by adding this to your `rules.mk`:
WPM_ENABLE = yes
-For split keyboards using soft serial, the computed WPM
-score will be available on the master AND slave half.
+For split keyboards using soft serial, the computed WPM score will be available on the master AND slave half.
-## Public Functions
-
-`uint8_t get_current_wpm(void);`
-This function returns the current WPM as an unsigned integer.
+## Configuration
+|Define |Default | Description |
+|-----------------------------|--------------|------------------------------------------------------------------------------------------|
+|`WPM_SMOOTHING` |`0.0487` | Sets the smoothing to about 40 keystrokes |
+|`WPM_ESTIMATED_WORD_SIZE` |`5` | This is the value used when estimating average word size (for regression and normal use) |
+|`WPM_ALLOW_COUNT_REGRESSOIN` |_Not defined_ | If defined allows the WPM to be decreased when hitting Delete or Backspace |
+## Public Functions
-## Customized keys for WPM calc
-
-By default, the WPM score only includes letters, numbers, space and some
-punctuation. If you want to change the set of characters considered as part of
-the WPM calculation, you can implement `wpm_keycode_user(uint16_t keycode)`
-and return true for any characters you would like included in the calculation,
-or false to not count that particular keycode.
+|Function |Description |
+|--------------------------|--------------------------------------------------|
+|`get_current_wpm(void)` | Returns the current WPM as a value between 0-255 |
+|`set_current_wpm(x)` | Sets the current WPM to `x` (between 0-255) |
+
+## Callbacks
+
+By default, the WPM score only includes letters, numbers, space and some punctuation. If you want to change the set of characters considered as part of the WPM calculation, you can implement your own `bool wpm_keycode_user(uint16_t keycode)` and return true for any characters you would like included in the calculation, or false to not count that particular keycode.
+
+For instance, the default is:
+
+```c
+bool wpm_keycode_user(uint16_t keycode) {
+ if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
+ keycode = keycode & 0xFF;
+ } else if (keycode > 0xFF) {
+ keycode = 0;
+ }
+ if ((keycode >= KC_A && keycode <= KC_0) || (keycode >= KC_TAB && keycode <= KC_SLASH)) {
+ return true;
+ }
+
+ return false;
+}
+```
+
+Additionally, if `WPM_ALLOW_COUNT_REGRESSION` is defined, there is the `uint8_t wpm_regress_count(uint16_t keycode)` function that allows you to decrease the WPM. This is useful if you want to be able to penalize certain keycodes (or even combinations).
+
+__attribute__((weak)) uint8_t wpm_regress_count(uint16_t keycode) {
+ bool weak_modded = (keycode >= QK_LCTL && keycode < QK_LSFT) || (keycode >= QK_RCTL && keycode < QK_RSFT);
+
+ if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
+ keycode = keycode & 0xFF;
+ } else if (keycode > 0xFF) {
+ keycode = 0;
+ }
+ if (((get_mods() | get_oneshot_mods()) & MOD_MASK_CTRL} || weak_modded) && (keycode == KC_DEL || keycode == KC_BSPC)) {
+ return WPM_ESTIMATED_WORD_SIZE;
+ }
+ if (keycode == KC_DEL || keycode == KC_BSPC) {
+ return 1;
+ }
+}
diff --git a/docs/flashing.md b/docs/flashing.md
index 7804a6bad8d3..83c97444e106 100644
--- a/docs/flashing.md
+++ b/docs/flashing.md
@@ -249,3 +249,29 @@ Flashing sequence:
2. Wait for the OS to detect the device
3. Flash a .bin file
4. Reset the device into application mode (may be done automatically)
+
+## tinyuf2
+
+Keyboards may opt into supporting the tinyuf2 bootloader. This is currently only supported on the F411 blackpill.
+
+The `rules.mk` setting for this bootloader is `tinyuf2`, and can be specified at the keymap or user level.
+
+To ensure compatibility with the tinyuf2 bootloader, make sure this block is present in your `rules.mk`:
+
+```make
+# Bootloader selection
+BOOTLOADER = tinyuf2
+```
+
+Compatible flashers:
+
+* Any application able to copy a file from one place to another, such as _macOS Finder_ or _Windows Explorer_.
+
+Flashing sequence:
+
+1. Enter the bootloader using any of the following methods:
+ * Tap the `RESET` keycode
+ * Double-tap the `nRST` button on the PCB.
+2. Wait for the OS to detect the device
+3. Copy the .uf2 file to the new USB disk
+4. Wait for the keyboard to become available
diff --git a/docs/ja/compatible_microcontrollers.md b/docs/ja/compatible_microcontrollers.md
index fdd11f14fa10..b675b038d271 100644
--- a/docs/ja/compatible_microcontrollers.md
+++ b/docs/ja/compatible_microcontrollers.md
@@ -33,8 +33,11 @@ QMK は十分な容量のフラッシュメモリを備えた USB 対応 AVR ま
* [STM32F303](https://www.st.com/en/microcontrollers-microprocessors/stm32f303.html)
* [STM32F401](https://www.st.com/en/microcontrollers-microprocessors/stm32f401.html)
* [STM32F411](https://www.st.com/en/microcontrollers-microprocessors/stm32f411.html)
+* [STM32F446](https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html)
* [STM32G431](https://www.st.com/en/microcontrollers-microprocessors/stm32g4x1.html)
* [STM32G474](https://www.st.com/en/microcontrollers-microprocessors/stm32g4x4.html)
+* [STM32L433](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x3.html)
+* [STM32L443](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x3.html)
### NXP (Kinetis)
diff --git a/docs/ja/feature_led_matrix.md b/docs/ja/feature_led_matrix.md
index b73487ca63ee..62e22859fb78 100644
--- a/docs/ja/feature_led_matrix.md
+++ b/docs/ja/feature_led_matrix.md
@@ -76,7 +76,7 @@ I2C IS31FL3731 RGB コントローラを使ったアドレス指定可能な LED
カスタムレイヤー効果は `.c` 内で以下を定義することで行うことができます:
void led_matrix_indicators_kb(void) {
- led_matrix_set_index_value(index, value);
+ led_matrix_set_value(index, value);
}
同様の関数がキーマップ内で `led_matrix_indicators_user` として動作します。
diff --git a/docs/ja/feature_swap_hands.md b/docs/ja/feature_swap_hands.md
index 3150801c5542..5164584e8a47 100644
--- a/docs/ja/feature_swap_hands.md
+++ b/docs/ja/feature_swap_hands.md
@@ -12,7 +12,7 @@
設定テーブルは列/行から新しい列/行にマップするための単純な2次元配列です。Planck の `hand_swap_config` の例:
```C
-const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
+const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
{{11, 0}, {10, 0}, {9, 0}, {8, 0}, {7, 0}, {6, 0}, {5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}},
{{11, 1}, {10, 1}, {9, 1}, {8, 1}, {7, 1}, {6, 1}, {5, 1}, {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 1}},
{{11, 2}, {10, 2}, {9, 2}, {8, 2}, {7, 2}, {6, 2}, {5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}},
diff --git a/docs/keycodes.md b/docs/keycodes.md
index 9acf8b683961..f3c519b13096 100644
--- a/docs/keycodes.md
+++ b/docs/keycodes.md
@@ -516,6 +516,9 @@ See also: [One Shot Keys](one_shot_keys.md)
|------------|----------------------------------|
|`OSM(mod)` |Hold `mod` for one keypress |
|`OSL(layer)`|Switch to `layer` for one keypress|
+|`OS_ON` |Turns One Shot keys on |
+|`OS_OFF` |Turns One Shot keys off |
+|`OS_TOGG` |Toggles One Shot keys status |
## Space Cadet :id=space-cadet
diff --git a/docs/one_shot_keys.md b/docs/one_shot_keys.md
index 9a082d7d6dcf..9fc5486299d9 100644
--- a/docs/one_shot_keys.md
+++ b/docs/one_shot_keys.md
@@ -17,6 +17,9 @@ You can control the behavior of one shot keys by defining these in `config.h`:
* `OSM(mod)` - Momentarily hold down *mod*. You must use the `MOD_*` keycodes as shown in [Mod Tap](mod_tap.md), not the `KC_*` codes.
* `OSL(layer)` - momentary switch to *layer*.
+* `OS_ON` - Turns on One Shot keys.
+* `OS_OFF` - Turns off One Shot keys. OSM act as regular mod keys, OSL act like `MO`.
+* `ON_TOGG` - Toggles the one shot key status.
Sometimes, you want to activate a one-shot key as part of a macro or tap dance routine.
diff --git a/docs/serial_driver.md b/docs/serial_driver.md
index c98f4c117631..359fc5955152 100644
--- a/docs/serial_driver.md
+++ b/docs/serial_driver.md
@@ -3,16 +3,18 @@ This driver powers the [Split Keyboard](feature_split_keyboard.md) feature.
?> Serial in this context should be read as **sending information one bit at a time**, rather than implementing UART/USART/RS485/RS232 standards.
-All drivers in this category have the following characteristics:
-* Provides data and signaling over a single conductor
-* Limited to single master, single slave
+Drivers in this category have the following characteristics:
+* bit bang and USART Half-duplex provide data and signaling over a single conductor
+* USART Full-duplex provide data and signaling over two conductors
+* They are all limited to single master and single slave communication scheme
## Supported Driver Types
| | AVR | ARM |
-|-------------------|--------------------|--------------------|
+| ----------------- | ------------------ | ------------------ |
| bit bang | :heavy_check_mark: | :heavy_check_mark: |
| USART Half-duplex | | :heavy_check_mark: |
+| USART Full-duplex | | :heavy_check_mark: |
## Driver configuration
@@ -42,7 +44,7 @@ Configure the driver via your config.h:
Along with the generic options above, you must also turn on the `PAL_USE_CALLBACKS` feature in your halconf.h.
### USART Half-duplex
-Targeting STM32 boards where communication is offloaded to a USART hardware device. The advantage is that this provides fast and accurate timings. `SOFT_SERIAL_PIN` for this driver is the configured USART TX pin. **The TX pin must have appropriate pull-up resistors**. To configure it, add this to your rules.mk:
+Targeting STM32 boards where communication is offloaded to a USART hardware device. The advantage over bitbang is that this provides fast and accurate timings. `SERIAL_PIN_TX` for this driver is the configured USART TX pin. As this Pin is configured in open-drain mode an **external pull-up resistor is needed to keep the line high** (resistor values of 1.5k to 8.2k are known to work). To configure it, add this to your rules.mk:
```make
SERIAL_DRIVER = usart
@@ -50,7 +52,8 @@ SERIAL_DRIVER = usart
Configure the hardware via your config.h:
```c
-#define SOFT_SERIAL_PIN B6 // USART TX pin
+#define SOFT_SERIAL_PIN B6 // USART TX pin
+//#define USART1_REMAP // Remap USART TX and RX pins on STM32F103 MCUs, see table below.
#define SELECT_SOFT_SERIAL_SPEED 1 // or 0, 2, 3, 4, 5
// 0: about 460800 baud
// 1: about 230400 baud (default)
@@ -58,7 +61,7 @@ Configure the hardware via your config.h:
// 3: about 57600 baud
// 4: about 38400 baud
// 5: about 19200 baud
-#define SERIAL_USART_DRIVER SD1 // USART driver of TX pin. default: SD1
+#define SERIAL_USART_DRIVER SD1 // USART driver of TX pin. default: SD1
#define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7
#define SERIAL_USART_TIMEOUT 100 // USART driver timeout. default 100
```
@@ -68,3 +71,140 @@ You must also enable the ChibiOS `SERIAL` feature:
* In your board's mcuconf.h: `#define STM32_SERIAL_USE_USARTn TRUE` (where 'n' matches the peripheral number of your selected USART on the MCU)
Do note that the configuration required is for the `SERIAL` peripheral, not the `UART` peripheral.
+
+### USART Full-duplex
+Targeting STM32 boards where communication is offloaded to a USART hardware device. The advantage over bitbang is that this provides fast and accurate timings. USART Full-Duplex requires two conductors **without** pull-up resistors instead of one conductor with a pull-up resistor unlike the Half-duplex driver, but it is more efficent as it uses DMA transfers, which can result in even faster transmission speeds.
+
+#### Pin configuration
+
+`SERIAL_USART_TX_PIN` is the USART `TX` pin, `SERIAL_USART_RX_PIN` is the USART `RX` pin. No external pull-up resistors are needed as the `TX` pin operates in push-pull mode. To use this driver the usart peripherals `TX` and `RX` pins must be configured with the correct Alternate-functions. If you are using a Proton-C everything is already setup, same is true for STM32F103 MCUs. For MCUs which are using a modern flexible GPIO configuration you have to specify these by setting `SERIAL_USART_TX_PAL_MODE` and `SERIAL_USART_RX_PAL_MODE`. Refeer to the corresponding datasheets of your MCU or find those settings in the table below.
+
+#### Connecting the halves and Pin Swap
+Please note that `TX` of the master half has to be connected with the `RX` pin of the slave half and `RX` of the master half has to be connected with the `TX` pin of the slave half! Usually this pin swap has to be done outside of the MCU e.g. with cables or on the pcb. Some MCUs like the STM32F303 used on the Proton-C allow this pin swap directly inside the MCU, this feature can be enabled using `#define SERIAL_USART_PIN_SWAP` in your config.h.
+
+#### Setup
+To use the driver, add this to your rules.mk:
+
+```make
+SERIAL_DRIVER = usart_duplex
+```
+
+Next configure the hardware via your config.h:
+
+```c
+#define SERIAL_USART_TX_PIN B6 // USART TX pin
+#define SERIAL_USART_RX_PIN B7 // USART RX pin
+//#define USART1_REMAP // Remap USART TX and RX pins on STM32F103 MCUs, see table below.
+//#define SERIAL_USART_PIN_SWAP // Swap TX and RX pins if keyboard is master halve.
+ // Check if this feature is necessary with your keyboard design and available on the mcu.
+#define SELECT_SOFT_SERIAL_SPEED 1 // or 0, 2, 3, 4, 5
+ // 0: 460800 baud
+ // 1: 230400 baud (default)
+ // 2: 115200 baud
+ // 3: 57600 baud
+ // 4: 38400 baud
+ // 5: 19200 baud
+#define SERIAL_USART_DRIVER UARTD1 // USART driver of TX and RX pin. default: UARTD1
+#define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7
+#define SERIAL_USART_RX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7
+#define SERIAL_USART_TIMEOUT 100 // USART driver timeout. default 100
+```
+
+You must also enable the ChibiOS `UART` with blocking api feature:
+* In your board's halconf.h: `#define HAL_USE_UART TRUE` and `#define UART_USE_WAIT TRUE`
+* In your board's mcuconf.h: `#define STM32_UART_USE_USARTn TRUE` (where 'n' matches the peripheral number of your selected USART on the MCU)
+
+Do note that the configuration required is for the `UART` peripheral, not the `SERIAL` peripheral.
+
+#### Pins for USART Peripherals with Alternate Functions for selected STM32 MCUs
+
+##### STM32F303 / Proton-C [Datasheet](https://www.st.com/resource/en/datasheet/stm32f303cc.pdf)
+
+Pin Swap available: :heavy_check_mark:
+
+| Pin | Function | Mode |
+| ---------- | -------- | ---- |
+| **USART1** | | |
+| PA9 | TX | AF7 |
+| PA10 | RX | AF7 |
+| PB6 | TX | AF7 |
+| PB7 | RX | AF7 |
+| PC4 | TX | AF7 |
+| PC5 | RX | AF7 |
+| PE0 | TX | AF7 |
+| PE1 | RX | AF7 |
+| **USART2** | | |
+| PA2 | TX | AF7 |
+| PA3 | RX | AF7 |
+| PA14 | TX | AF7 |
+| PA15 | RX | AF7 |
+| PB3 | TX | AF7 |
+| PB4 | RX | AF7 |
+| PD5 | TX | AF7 |
+| PD6 | RX | AF7 |
+| **USART3** | | |
+| PB10 | TX | AF7 |
+| PB11 | RX | AF7 |
+| PC10 | TX | AF7 |
+| PC11 | RX | AF7 |
+| PD8 | TX | AF7 |
+| PD9 | RX | AF7 |
+
+##### STM32F072 [Datasheet](https://www.st.com/resource/en/datasheet/stm32f072c8.pdf)
+
+Pin Swap available: :heavy_check_mark:
+
+| Pin | Function | Mode |
+| ------ | -------- | ---- |
+| USART1 | | |
+| PA9 | TX | AF1 |
+| PA10 | RX | AF1 |
+| PB6 | TX | AF0 |
+| PB7 | RX | AF0 |
+| USART2 | | |
+| PA2 | TX | AF1 |
+| PA3 | RX | AF1 |
+| PA14 | TX | AF1 |
+| PA15 | RX | AF1 |
+| USART3 | | |
+| PB10 | TX | AF4 |
+| PB11 | RX | AF4 |
+| PC4 | TX | AF1 |
+| PC5 | RX | AF1 |
+| PC10 | TX | AF1 |
+| PC11 | RX | AF1 |
+| PD8 | TX | AF0 |
+| PD9 | RX | AF0 |
+| USART4 | | |
+| PA0 | TX | AF4 |
+| PA1 | RX | AF4 |
+
+##### STM32F103 Medium Density (C8-CB) [Datasheet](https://www.st.com/resource/en/datasheet/stm32f103c8.pdf)
+
+Pin Swap available: N/A
+
+TX Pin is always Alternate Function Push-Pull, RX Pin is always regular input pin for any USART peripheral. **For STM32F103 no additional Alternate Function configuration is necessary. QMK is already configured.**
+
+Pin remapping:
+
+The pins of USART Peripherals use default Pins that can be remapped to use other pins using the AFIO registers. Default pins are marked **bold**. Add the appropriate defines to your config.h file.
+
+| Pin | Function | Mode | USART_REMAP |
+| ---------- | -------- | ---- | ------------------- |
+| **USART1** | | | |
+| **PA9** | TX | AFPP | |
+| **PA10** | RX | IN | |
+| PB6 | TX | AFPP | USART1_REMAP |
+| PB7 | RX | IN | USART1_REMAP |
+| **USART2** | | | |
+| **PA2** | TX | AFPP | |
+| **PA3** | RX | IN | |
+| PD5 | TX | AFPP | USART2_REMAP |
+| PD6 | RX | IN | USART2_REMAP |
+| **USART3** | | | |
+| **PB10** | TX | AFPP | |
+| **PB11** | RX | IN | |
+| PC10 | TX | AFPP | USART3_PARTIALREMAP |
+| PC11 | RX | IN | USART3_PARTIALREMAP |
+| PD8 | TX | AFPP | USART3_FULLREMAP |
+| PD9 | RX | IN | USART3_FULLREMAP |
diff --git a/docs/ws2812_driver.md b/docs/ws2812_driver.md
index cca6827ec8d5..e69400364cb9 100644
--- a/docs/ws2812_driver.md
+++ b/docs/ws2812_driver.md
@@ -77,6 +77,25 @@ Configure the hardware via your config.h:
You must also turn on the SPI feature in your halconf.h and mcuconf.h
+#### Circular Buffer Mode
+Some boards may flicker while in the normal buffer mode. To fix this issue, circular buffer mode may be used to rectify the issue.
+
+By default, the circular buffer mode is disabled.
+
+To enable this alternative buffer mode, place this into your `config.h` file:
+```c
+#define WS2812_SPI_USE_CIRCULAR_BUFFER
+```
+
+#### Setting baudrate with divisor
+To adjust the baudrate at which the SPI peripheral is configured, users will need to derive the target baudrate from the clock tree provided by STM32CubeMX.
+
+Only divisors of 2, 4, 8, 16, 32, 64, 128 and 256 are supported by hardware.
+
+|Define |Default|Description |
+|--------------------|-------|-------------------------------------|
+|`WS2812_SPI_DIVISOR`|`16` |SPI source clock peripheral divisor |
+
#### Testing Notes
While not an exhaustive list, the following table provides the scenarios that have been partially validated:
@@ -102,11 +121,14 @@ Configure the hardware via your config.h:
#define WS2812_PWM_DRIVER PWMD2 // default: PWMD2
#define WS2812_PWM_CHANNEL 2 // default: 2
#define WS2812_PWM_PAL_MODE 2 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 2
+//#define WS2812_PWM_COMPLEMENTARY_OUTPUT // Define for a complementary timer output (TIMx_CHyN); omit for a normal timer output (TIMx_CHy).
#define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM2_UP // DMAMUX configuration for TIMx_UP -- only required if your MCU has a DMAMUX peripheral, see the respective reference manual for the appropriate values for your MCU.
```
+Note that using a complementary timer output (TIMx_CHyN) is possible only for advanced-control timers (TIM1, TIM8, TIM20 on STM32), and the `STM32_PWM_USE_ADVANCED` option in mcuconf.h must be set to `TRUE`. Complementary outputs of general-purpose timers are not supported due to ChibiOS limitations.
+
You must also turn on the PWM feature in your halconf.h and mcuconf.h
#### Testing Notes
diff --git a/drivers/chibios/analog.c b/drivers/chibios/analog.c
index 2b3872afbb02..8c476fcac205 100644
--- a/drivers/chibios/analog.c
+++ b/drivers/chibios/analog.c
@@ -101,7 +101,11 @@
// Options are 12, 10, 8, and 6 bit.
#ifndef ADC_RESOLUTION
-# define ADC_RESOLUTION ADC_CFGR1_RES_10BIT
+# ifdef ADC_CFGR_RES_10BITS // ADCv3, ADCv4
+# define ADC_RESOLUTION ADC_CFGR_RES_10BITS
+# else // ADCv1, ADCv5, or the bodge for ADCv2 above
+# define ADC_RESOLUTION ADC_CFGR1_RES_10BIT
+# endif
#endif
static ADCConfig adcCfg = {};
@@ -119,7 +123,7 @@ static ADCConversionGroup adcConversionGroup = {
.smpr = ADC_SAMPLING_RATE,
#elif defined(USE_ADCV2)
# if !defined(STM32F1XX)
- .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without...
+ .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without...
# endif
.smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE),
.smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE),
@@ -161,8 +165,8 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) {
case B0: return TO_MUX( ADC_CHANNEL_IN12, 2 );
case B1: return TO_MUX( ADC_CHANNEL_IN1, 2 );
case B2: return TO_MUX( ADC_CHANNEL_IN12, 1 );
- case B12: return TO_MUX( ADC_CHANNEL_IN2, 3 );
- case B13: return TO_MUX( ADC_CHANNEL_IN3, 3 );
+ case B12: return TO_MUX( ADC_CHANNEL_IN3, 3 );
+ case B13: return TO_MUX( ADC_CHANNEL_IN5, 2 );
case B14: return TO_MUX( ADC_CHANNEL_IN4, 3 );
case B15: return TO_MUX( ADC_CHANNEL_IN5, 3 );
case C0: return TO_MUX( ADC_CHANNEL_IN6, 0 ); // Can also be ADC2
@@ -189,11 +193,52 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) {
case E15: return TO_MUX( ADC_CHANNEL_IN2, 3 );
case F2: return TO_MUX( ADC_CHANNEL_IN10, 0 ); // Can also be ADC2
case F4: return TO_MUX( ADC_CHANNEL_IN5, 0 );
-#elif defined(STM32F4XX) // TODO: add all pins
+#elif defined(STM32F4XX)
case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 );
- //case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 );
-#elif defined(STM32F1XX) // TODO: add all pins
+ case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 );
+ case A2: return TO_MUX( ADC_CHANNEL_IN2, 0 );
+ case A3: return TO_MUX( ADC_CHANNEL_IN3, 0 );
+ case A4: return TO_MUX( ADC_CHANNEL_IN4, 0 );
+ case A5: return TO_MUX( ADC_CHANNEL_IN5, 0 );
+ case A6: return TO_MUX( ADC_CHANNEL_IN6, 0 );
+ case A7: return TO_MUX( ADC_CHANNEL_IN7, 0 );
+ case B0: return TO_MUX( ADC_CHANNEL_IN8, 0 );
+ case B1: return TO_MUX( ADC_CHANNEL_IN9, 0 );
+ case C0: return TO_MUX( ADC_CHANNEL_IN10, 0 );
+ case C1: return TO_MUX( ADC_CHANNEL_IN11, 0 );
+ case C2: return TO_MUX( ADC_CHANNEL_IN12, 0 );
+ case C3: return TO_MUX( ADC_CHANNEL_IN13, 0 );
+ case C4: return TO_MUX( ADC_CHANNEL_IN14, 0 );
+ case C5: return TO_MUX( ADC_CHANNEL_IN15, 0 );
+# if STM32_ADC_USE_ADC3
+ case F3: return TO_MUX( ADC_CHANNEL_IN9, 2 );
+ case F4: return TO_MUX( ADC_CHANNEL_IN14, 2 );
+ case F5: return TO_MUX( ADC_CHANNEL_IN15, 2 );
+ case F6: return TO_MUX( ADC_CHANNEL_IN4, 2 );
+ case F7: return TO_MUX( ADC_CHANNEL_IN5, 2 );
+ case F8: return TO_MUX( ADC_CHANNEL_IN6, 2 );
+ case F9: return TO_MUX( ADC_CHANNEL_IN7, 2 );
+ case F10: return TO_MUX( ADC_CHANNEL_IN8, 2 );
+# endif
+#elif defined(STM32F1XX)
case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 );
+ case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 );
+ case A2: return TO_MUX( ADC_CHANNEL_IN2, 0 );
+ case A3: return TO_MUX( ADC_CHANNEL_IN3, 0 );
+ case A4: return TO_MUX( ADC_CHANNEL_IN4, 0 );
+ case A5: return TO_MUX( ADC_CHANNEL_IN5, 0 );
+ case A6: return TO_MUX( ADC_CHANNEL_IN6, 0 );
+ case A7: return TO_MUX( ADC_CHANNEL_IN7, 0 );
+ case B0: return TO_MUX( ADC_CHANNEL_IN8, 0 );
+ case B1: return TO_MUX( ADC_CHANNEL_IN9, 0 );
+ case C0: return TO_MUX( ADC_CHANNEL_IN10, 0 );
+ case C1: return TO_MUX( ADC_CHANNEL_IN11, 0 );
+ case C2: return TO_MUX( ADC_CHANNEL_IN12, 0 );
+ case C3: return TO_MUX( ADC_CHANNEL_IN13, 0 );
+ case C4: return TO_MUX( ADC_CHANNEL_IN14, 0 );
+ case C5: return TO_MUX( ADC_CHANNEL_IN15, 0 );
+ // STM32F103x[C-G] in 144-pin packages also have analog inputs on F6...F10, but they are on ADC3, and the
+ // ChibiOS ADC driver for STM32F1xx currently supports only ADC1, therefore these pins are not usable.
#endif
}
diff --git a/drivers/chibios/serial_usart.c b/drivers/chibios/serial_usart.c
index 7c81b16464f4..cae29388c3bf 100644
--- a/drivers/chibios/serial_usart.c
+++ b/drivers/chibios/serial_usart.c
@@ -1,13 +1,20 @@
-#include "quantum.h"
-#include "serial.h"
-#include "print.h"
-
-#include
-#include
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
-#ifndef USART_CR1_M0
-# define USART_CR1_M0 USART_CR1_M // some platforms (f1xx) dont have this so
-#endif
+#include "serial_usart.h"
#ifndef USE_GPIOV1
// The default PAL alternate modes are used to signal that the pins are used for USART
@@ -20,50 +27,10 @@
# define SERIAL_USART_DRIVER SD1
#endif
-#ifndef SERIAL_USART_CR1
-# define SERIAL_USART_CR1 (USART_CR1_PCE | USART_CR1_PS | USART_CR1_M0) // parity enable, odd parity, 9 bit length
-#endif
-
-#ifndef SERIAL_USART_CR2
-# define SERIAL_USART_CR2 (USART_CR2_STOP_1) // 2 stop bits
-#endif
-
-#ifndef SERIAL_USART_CR3
-# define SERIAL_USART_CR3 0
-#endif
-
#ifdef SOFT_SERIAL_PIN
# define SERIAL_USART_TX_PIN SOFT_SERIAL_PIN
#endif
-#ifndef SELECT_SOFT_SERIAL_SPEED
-# define SELECT_SOFT_SERIAL_SPEED 1
-#endif
-
-#ifdef SERIAL_USART_SPEED
-// Allow advanced users to directly set SERIAL_USART_SPEED
-#elif SELECT_SOFT_SERIAL_SPEED == 0
-# define SERIAL_USART_SPEED 460800
-#elif SELECT_SOFT_SERIAL_SPEED == 1
-# define SERIAL_USART_SPEED 230400
-#elif SELECT_SOFT_SERIAL_SPEED == 2
-# define SERIAL_USART_SPEED 115200
-#elif SELECT_SOFT_SERIAL_SPEED == 3
-# define SERIAL_USART_SPEED 57600
-#elif SELECT_SOFT_SERIAL_SPEED == 4
-# define SERIAL_USART_SPEED 38400
-#elif SELECT_SOFT_SERIAL_SPEED == 5
-# define SERIAL_USART_SPEED 19200
-#else
-# error invalid SELECT_SOFT_SERIAL_SPEED value
-#endif
-
-#ifndef SERIAL_USART_TIMEOUT
-# define SERIAL_USART_TIMEOUT 100
-#endif
-
-#define HANDSHAKE_MAGIC 7
-
static inline msg_t sdWriteHalfDuplex(SerialDriver* driver, uint8_t* data, uint8_t size) {
msg_t ret = sdWrite(driver, data, size);
@@ -123,6 +90,10 @@ __attribute__((weak)) void usart_init(void) {
#else
palSetLineMode(SERIAL_USART_TX_PIN, PAL_MODE_ALTERNATE(SERIAL_USART_TX_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
#endif
+
+#if defined(USART_REMAP)
+ USART_REMAP;
+#endif
}
void usart_master_init(void) {
diff --git a/drivers/chibios/serial_usart.h b/drivers/chibios/serial_usart.h
new file mode 100644
index 000000000000..fee7b4d159c3
--- /dev/null
+++ b/drivers/chibios/serial_usart.h
@@ -0,0 +1,90 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+#include "quantum.h"
+#include "serial.h"
+#include "printf.h"
+
+#include
+#include
+
+#ifndef USART_CR1_M0
+# define USART_CR1_M0 USART_CR1_M // some platforms (f1xx) dont have this so
+#endif
+
+#ifndef SERIAL_USART_CR1
+# define SERIAL_USART_CR1 (USART_CR1_PCE | USART_CR1_PS | USART_CR1_M0) // parity enable, odd parity, 9 bit length
+#endif
+
+#ifndef SERIAL_USART_CR2
+# define SERIAL_USART_CR2 (USART_CR2_STOP_1) // 2 stop bits
+#endif
+
+#ifndef SERIAL_USART_CR3
+# define SERIAL_USART_CR3 0
+#endif
+
+#if defined(USART1_REMAP)
+# define USART_REMAP \
+ do { \
+ (AFIO->MAPR |= AFIO_MAPR_USART1_REMAP); \
+ } while (0)
+#elif defined(USART2_REMAP)
+# define USART_REMAP \
+ do { \
+ (AFIO->MAPR |= AFIO_MAPR_USART2_REMAP); \
+ } while (0)
+#elif defined(USART3_PARTIALREMAP)
+# define USART_REMAP \
+ do { \
+ (AFIO->MAPR |= AFIO_MAPR_USART3_REMAP_PARTIALREMAP); \
+ } while (0)
+#elif defined(USART3_FULLREMAP)
+# define USART_REMAP \
+ do { \
+ (AFIO->MAPR |= AFIO_MAPR_USART3_REMAP_FULLREMAP); \
+ } while (0)
+#endif
+
+#ifndef SELECT_SOFT_SERIAL_SPEED
+# define SELECT_SOFT_SERIAL_SPEED 1
+#endif
+
+#ifdef SERIAL_USART_SPEED
+// Allow advanced users to directly set SERIAL_USART_SPEED
+#elif SELECT_SOFT_SERIAL_SPEED == 0
+# define SERIAL_USART_SPEED 460800
+#elif SELECT_SOFT_SERIAL_SPEED == 1
+# define SERIAL_USART_SPEED 230400
+#elif SELECT_SOFT_SERIAL_SPEED == 2
+# define SERIAL_USART_SPEED 115200
+#elif SELECT_SOFT_SERIAL_SPEED == 3
+# define SERIAL_USART_SPEED 57600
+#elif SELECT_SOFT_SERIAL_SPEED == 4
+# define SERIAL_USART_SPEED 38400
+#elif SELECT_SOFT_SERIAL_SPEED == 5
+# define SERIAL_USART_SPEED 19200
+#else
+# error invalid SELECT_SOFT_SERIAL_SPEED value
+#endif
+
+#ifndef SERIAL_USART_TIMEOUT
+# define SERIAL_USART_TIMEOUT 100
+#endif
+
+#define HANDSHAKE_MAGIC 7
diff --git a/drivers/chibios/serial_usart_duplex.c b/drivers/chibios/serial_usart_duplex.c
new file mode 100644
index 000000000000..cc9b889ac201
--- /dev/null
+++ b/drivers/chibios/serial_usart_duplex.c
@@ -0,0 +1,261 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "serial_usart.h"
+
+#include
+
+#if !defined(USE_GPIOV1)
+// The default PAL alternate modes are used to signal that the pins are used for USART
+# if !defined(SERIAL_USART_TX_PAL_MODE)
+# define SERIAL_USART_TX_PAL_MODE 7
+# endif
+# if !defined(SERIAL_USART_RX_PAL_MODE)
+# define SERIAL_USART_RX_PAL_MODE 7
+# endif
+#endif
+
+#if !defined(SERIAL_USART_DRIVER)
+# define SERIAL_USART_DRIVER UARTD1
+#endif
+
+#if !defined(SERIAL_USART_TX_PIN)
+# define SERIAL_USART_TX_PIN A9
+#endif
+
+#if !defined(SERIAL_USART_RX_PIN)
+# define SERIAL_USART_RX_PIN A10
+#endif
+
+#define SIGNAL_HANDSHAKE_RECEIVED 0x1
+
+void handle_transactions_slave(uint8_t sstd_index);
+static void receive_transaction_handshake(UARTDriver* uartp, uint16_t received_handshake);
+
+/*
+ * UART driver configuration structure. We use the blocking DMA enabled API and
+ * the rxchar callback to receive handshake tokens but only on the slave halve.
+ */
+// clang-format off
+static UARTConfig uart_config = {
+ .txend1_cb = NULL,
+ .txend2_cb = NULL,
+ .rxend_cb = NULL,
+ .rxchar_cb = NULL,
+ .rxerr_cb = NULL,
+ .timeout_cb = NULL,
+ .speed = (SERIAL_USART_SPEED),
+ .cr1 = (SERIAL_USART_CR1),
+ .cr2 = (SERIAL_USART_CR2),
+ .cr3 = (SERIAL_USART_CR3)
+};
+// clang-format on
+
+static SSTD_t* Transaction_table = NULL;
+static uint8_t Transaction_table_size = 0;
+static atomic_uint_least8_t handshake = 0xFF;
+static thread_reference_t tp_target = NULL;
+
+/*
+ * This callback is invoked when a character is received but the application
+ * was not ready to receive it, the character is passed as parameter.
+ * Receive transaction table index from initiator, which doubles as basic handshake token. */
+static void receive_transaction_handshake(UARTDriver* uartp, uint16_t received_handshake) {
+ /* Check if received handshake is not a valid transaction id.
+ * Please note that we can still catch a seemingly valid handshake
+ * i.e. a byte from a ongoing transfer which is in the allowed range.
+ * So this check mainly prevents any obviously wrong handshakes and
+ * subsequent wakeups of the receiving thread, which is a costly operation. */
+ if (received_handshake > Transaction_table_size) {
+ return;
+ }
+
+ handshake = (uint8_t)received_handshake;
+ chSysLockFromISR();
+ /* Wakeup receiving thread to start a transaction. */
+ chEvtSignalI(tp_target, (eventmask_t)SIGNAL_HANDSHAKE_RECEIVED);
+ chSysUnlockFromISR();
+}
+
+__attribute__((weak)) void usart_init(void) {
+#if defined(USE_GPIOV1)
+ palSetLineMode(SERIAL_USART_TX_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
+ palSetLineMode(SERIAL_USART_RX_PIN, PAL_MODE_INPUT);
+#else
+ palSetLineMode(SERIAL_USART_TX_PIN, PAL_MODE_ALTERNATE(SERIAL_USART_TX_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+ palSetLineMode(SERIAL_USART_RX_PIN, PAL_MODE_ALTERNATE(SERIAL_USART_RX_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
+#endif
+}
+
+/*
+ * This thread runs on the slave half and reacts to transactions initiated from the master.
+ */
+static THD_WORKING_AREA(waSlaveThread, 1024);
+static THD_FUNCTION(SlaveThread, arg) {
+ (void)arg;
+ chRegSetThreadName("slave_usart_tx_rx");
+
+ while (true) {
+ /* We sleep as long as there is no handshake waiting for us. */
+ chEvtWaitAny((eventmask_t)SIGNAL_HANDSHAKE_RECEIVED);
+ handle_transactions_slave(handshake);
+ }
+}
+
+void soft_serial_target_init(SSTD_t* const sstd_table, int sstd_table_size) {
+ Transaction_table = sstd_table;
+ Transaction_table_size = (uint8_t)sstd_table_size;
+ usart_init();
+
+#if defined(USART_REMAP)
+ USART_REMAP;
+#endif
+
+ tp_target = chThdCreateStatic(waSlaveThread, sizeof(waSlaveThread), HIGHPRIO, SlaveThread, NULL);
+
+ // Start receiving handshake tokens on slave halve
+ uart_config.rxchar_cb = receive_transaction_handshake;
+ uartStart(&SERIAL_USART_DRIVER, &uart_config);
+}
+
+/**
+ * @brief React to transactions started by the master.
+ * This version uses duplex send and receive usart pheriphals and DMA backed transfers.
+ */
+void inline handle_transactions_slave(uint8_t sstd_index) {
+ size_t buffer_size = 0;
+ msg_t msg = 0;
+ SSTD_t* trans = &Transaction_table[sstd_index];
+
+ /* Send back the handshake which is XORed as a simple checksum,
+ to signal that the slave is ready to receive possible transaction buffers */
+ sstd_index ^= HANDSHAKE_MAGIC;
+ buffer_size = (size_t)sizeof(sstd_index);
+ msg = uartSendTimeout(&SERIAL_USART_DRIVER, &buffer_size, &sstd_index, TIME_MS2I(SERIAL_USART_TIMEOUT));
+
+ if (msg != MSG_OK) {
+ if (trans->status) {
+ *trans->status = TRANSACTION_NO_RESPONSE;
+ }
+ return;
+ }
+
+ /* Receive transaction buffer from the master. If this transaction requires it.*/
+ buffer_size = (size_t)trans->initiator2target_buffer_size;
+ if (buffer_size) {
+ msg = uartReceiveTimeout(&SERIAL_USART_DRIVER, &buffer_size, trans->initiator2target_buffer, TIME_MS2I(SERIAL_USART_TIMEOUT));
+ if (msg != MSG_OK) {
+ if (trans->status) {
+ *trans->status = TRANSACTION_NO_RESPONSE;
+ }
+ return;
+ }
+ }
+
+ /* Send transaction buffer to the master. If this transaction requires it. */
+ buffer_size = (size_t)trans->target2initiator_buffer_size;
+ if (buffer_size) {
+ msg = uartSendFullTimeout(&SERIAL_USART_DRIVER, &buffer_size, trans->target2initiator_buffer, TIME_MS2I(SERIAL_USART_TIMEOUT));
+ if (msg != MSG_OK) {
+ if (trans->status) {
+ *trans->status = TRANSACTION_NO_RESPONSE;
+ }
+ return;
+ }
+ }
+
+ if (trans->status) {
+ *trans->status = TRANSACTION_ACCEPTED;
+ }
+}
+
+void soft_serial_initiator_init(SSTD_t* const sstd_table, int sstd_table_size) {
+ Transaction_table = sstd_table;
+ Transaction_table_size = (uint8_t)sstd_table_size;
+ usart_init();
+
+#if defined(SERIAL_USART_PIN_SWAP)
+ uart_config.cr2 |= USART_CR2_SWAP; // master has swapped TX/RX pins
+#endif
+
+#if defined(USART_REMAP)
+ USART_REMAP;
+#endif
+
+ uartStart(&SERIAL_USART_DRIVER, &uart_config);
+}
+
+/**
+ * @brief Start transaction from the master to the slave.
+ * This version uses duplex send and receive usart pheriphals and DMA backed transfers.
+ *
+ * @param index Transaction Table index of the transaction to start.
+ * @return int TRANSACTION_NO_RESPONSE in case of Timeout.
+ * TRANSACTION_TYPE_ERROR in case of invalid transaction index.
+ * TRANSACTION_END in case of success.
+ */
+#if !defined(SERIAL_USE_MULTI_TRANSACTION)
+int soft_serial_transaction(void) {
+ uint8_t sstd_index = 0;
+#else
+int soft_serial_transaction(int index) {
+ uint8_t sstd_index = index;
+#endif
+
+ if (sstd_index > Transaction_table_size) {
+ return TRANSACTION_TYPE_ERROR;
+ }
+
+ SSTD_t* const trans = &Transaction_table[sstd_index];
+ msg_t msg = 0;
+ size_t buffer_size = (size_t)sizeof(sstd_index);
+
+ /* Send transaction table index to the slave, which doubles as basic handshake token. */
+ uartSendFullTimeout(&SERIAL_USART_DRIVER, &buffer_size, &sstd_index, TIME_MS2I(SERIAL_USART_TIMEOUT));
+
+ uint8_t sstd_index_shake = 0xFF;
+ buffer_size = (size_t)sizeof(sstd_index_shake);
+
+ /* Receive the handshake token from the slave. The token was XORed by the slave as a simple checksum.
+ If the tokens match, the master will start to send and receive possible transaction buffers. */
+ msg = uartReceiveTimeout(&SERIAL_USART_DRIVER, &buffer_size, &sstd_index_shake, TIME_MS2I(SERIAL_USART_TIMEOUT));
+ if (msg != MSG_OK || (sstd_index_shake != (sstd_index ^ HANDSHAKE_MAGIC))) {
+ dprintln("USART: Handshake Failed");
+ return TRANSACTION_NO_RESPONSE;
+ }
+
+ /* Send transaction buffer to the slave. If this transaction requires it. */
+ buffer_size = (size_t)trans->initiator2target_buffer_size;
+ if (buffer_size) {
+ msg = uartSendFullTimeout(&SERIAL_USART_DRIVER, &buffer_size, trans->initiator2target_buffer, TIME_MS2I(SERIAL_USART_TIMEOUT));
+ if (msg != MSG_OK) {
+ dprintln("USART: Send Failed");
+ return TRANSACTION_NO_RESPONSE;
+ }
+ }
+
+ /* Receive transaction buffer from the slave. If this transaction requires it. */
+ buffer_size = (size_t)trans->target2initiator_buffer_size;
+ if (buffer_size) {
+ msg = uartReceiveTimeout(&SERIAL_USART_DRIVER, &buffer_size, trans->target2initiator_buffer, TIME_MS2I(SERIAL_USART_TIMEOUT));
+ if (msg != MSG_OK) {
+ dprintln("USART: Receive Failed");
+ return TRANSACTION_NO_RESPONSE;
+ }
+ }
+
+ return TRANSACTION_END;
+}
diff --git a/drivers/chibios/ws2812_pwm.c b/drivers/chibios/ws2812_pwm.c
index 140120d488de..e6af55b6b361 100644
--- a/drivers/chibios/ws2812_pwm.c
+++ b/drivers/chibios/ws2812_pwm.c
@@ -27,6 +27,15 @@
# error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP"
#endif
+#ifndef WS2812_PWM_COMPLEMENTARY_OUTPUT
+# define WS2812_PWM_OUTPUT_MODE PWM_OUTPUT_ACTIVE_HIGH
+#else
+# if !STM32_PWM_USE_ADVANCED
+# error "WS2812_PWM_COMPLEMENTARY_OUTPUT requires STM32_PWM_USE_ADVANCED == TRUE"
+# endif
+# define WS2812_PWM_OUTPUT_MODE PWM_COMPLEMENTARY_OUTPUT_ACTIVE_HIGH
+#endif
+
// Push Pull or Open Drain Configuration
// Default Push Pull
#ifndef WS2812_EXTERNAL_PULLUP
@@ -247,7 +256,7 @@ void ws2812_init(void) {
.channels =
{
[0 ... 3] = {.mode = PWM_OUTPUT_DISABLED, .callback = NULL}, // Channels default to disabled
- [WS2812_PWM_CHANNEL - 1] = {.mode = PWM_OUTPUT_ACTIVE_HIGH, .callback = NULL}, // Turn on the channel we care about
+ [WS2812_PWM_CHANNEL - 1] = {.mode = WS2812_PWM_OUTPUT_MODE, .callback = NULL}, // Turn on the channel we care about
},
.cr2 = 0,
.dier = TIM_DIER_UDE, // DMA on update event for next period
diff --git a/drivers/chibios/ws2812_spi.c b/drivers/chibios/ws2812_spi.c
index 89df2987b548..e02cbabc02df 100644
--- a/drivers/chibios/ws2812_spi.c
+++ b/drivers/chibios/ws2812_spi.c
@@ -32,6 +32,37 @@
# endif
#endif
+// Define SPI config speed
+// baudrate should target 3.2MHz
+// F072 fpclk = 48MHz
+// 48/16 = 3Mhz
+#if WS2812_SPI_DIVISOR == 2
+# define WS2812_SPI_DIVISOR (0)
+#elif WS2812_SPI_DIVISOR == 4
+# define WS2812_SPI_DIVISOR (SPI_CR1_BR_0)
+#elif WS2812_SPI_DIVISOR == 8
+# define WS2812_SPI_DIVISOR (SPI_CR1_BR_1)
+#elif WS2812_SPI_DIVISOR == 16 // same as default
+# define WS2812_SPI_DIVISOR (SPI_CR1_BR_1 | SPI_CR1_BR_0)
+#elif WS2812_SPI_DIVISOR == 32
+# define WS2812_SPI_DIVISOR (SPI_CR1_BR_2)
+#elif WS2812_SPI_DIVISOR == 64
+# define WS2812_SPI_DIVISOR (SPI_CR1_BR_2 | SPI_CR1_BR_0)
+#elif WS2812_SPI_DIVISOR == 128
+# define WS2812_SPI_DIVISOR (SPI_CR1_BR_2 | SPI_CR1_BR_1)
+#elif WS2812_SPI_DIVISOR == 256
+# define WS2812_SPI_DIVISOR (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
+#else
+# define WS2812_SPI_DIVISOR (SPI_CR1_BR_1 | SPI_CR1_BR_0) // default
+#endif
+
+// Use SPI circular buffer
+#ifdef WS2812_SPI_USE_CIRCULAR_BUFFER
+# define WS2812_SPI_BUFFER_MODE 1 // circular buffer
+#else
+# define WS2812_SPI_BUFFER_MODE 0 // normal buffer
+#endif
+
#define BYTES_FOR_LED_BYTE 4
#define NB_COLORS 3
#define BYTES_FOR_LED (BYTES_FOR_LED_BYTE * NB_COLORS)
@@ -81,14 +112,14 @@ void ws2812_init(void) {
palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE);
// TODO: more dynamic baudrate
- static const SPIConfig spicfg = {
- 0, NULL, PAL_PORT(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN),
- SPI_CR1_BR_1 | SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us (2.25 MHz)
- };
+ static const SPIConfig spicfg = {WS2812_SPI_BUFFER_MODE, NULL, PAL_PORT(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN), WS2812_SPI_DIVISOR};
spiAcquireBus(&WS2812_SPI); /* Acquire ownership of the bus. */
spiStart(&WS2812_SPI, &spicfg); /* Setup transfer parameters. */
spiSelect(&WS2812_SPI); /* Slave Select assertion. */
+#ifdef WS2812_SPI_USE_CIRCULAR_BUFFER
+ spiStartSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf);
+#endif
}
void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
@@ -104,9 +135,11 @@ void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
// Send async - each led takes ~0.03ms, 50 leds ~1.5ms, animations flushing faster than send will cause issues.
// Instead spiSend can be used to send synchronously (or the thread logic can be added back).
-#ifdef WS2812_SPI_SYNC
+#ifndef WS2812_SPI_USE_CIRCULAR_BUFFER
+# ifdef WS2812_SPI_SYNC
spiSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf);
-#else
+# else
spiStartSend(&WS2812_SPI, sizeof(txbuf) / sizeof(txbuf[0]), txbuf);
+# endif
#endif
}
diff --git a/drivers/issi/is31fl3733.c b/drivers/issi/is31fl3733.c
index dddf0cb73480..d99e5339c912 100644
--- a/drivers/issi/is31fl3733.c
+++ b/drivers/issi/is31fl3733.c
@@ -68,7 +68,7 @@ uint8_t g_twi_transfer_buffer[20];
uint8_t g_pwm_buffer[DRIVER_COUNT][192];
bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
-uint8_t g_led_control_registers[DRIVER_COUNT][24] = {{0}, {0}};
+uint8_t g_led_control_registers[DRIVER_COUNT][24] = {0};
bool g_led_control_registers_update_required[DRIVER_COUNT] = {false};
bool IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index 92c64399e291..082115d53434 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -24,6 +24,8 @@ along with this program. If not, see .
#include "progmem.h"
+#include "keyboard.h"
+
// Used commands from spec sheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
// for SH1106: https://www.velleman.eu/downloads/29/infosheets/sh1106_datasheet.pdf
@@ -71,6 +73,11 @@ along with this program. If not, see .
#define PRE_CHARGE_PERIOD 0xD9
#define VCOM_DETECT 0xDB
+// Advance Graphic Commands
+#define FADE_BLINK 0x23
+#define ENABLE_FADE 0x20
+#define ENABLE_BLINK 0x30
+
// Charge Pump Commands
#define CHARGE_PUMP 0x8D
@@ -152,6 +159,12 @@ static void InvertCharacter(uint8_t *cursor) {
}
bool oled_init(uint8_t rotation) {
+#if defined(USE_I2C) && defined(SPLIT_KEYBOARD)
+ if (!is_keyboard_master()) {
+ return true;
+ }
+#endif
+
oled_rotation = oled_init_user(rotation);
if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
oled_rotation_width = OLED_DISPLAY_WIDTH;
@@ -539,7 +552,13 @@ bool oled_on(void) {
oled_timeout = timer_read32() + OLED_TIMEOUT;
#endif
- static const uint8_t PROGMEM display_on[] = {I2C_CMD, DISPLAY_ON};
+ static const uint8_t PROGMEM display_on[] =
+#ifdef OLED_FADE_OUT
+ {I2C_CMD, FADE_BLINK, 0x00};
+#else
+ {I2C_CMD, DISPLAY_ON};
+#endif
+
if (!oled_active) {
if (I2C_TRANSMIT_P(display_on) != I2C_STATUS_SUCCESS) {
print("oled_on cmd failed\n");
@@ -555,7 +574,13 @@ bool oled_off(void) {
return !oled_active;
}
- static const uint8_t PROGMEM display_off[] = {I2C_CMD, DISPLAY_OFF};
+ static const uint8_t PROGMEM display_off[] =
+#ifdef OLED_FADE_OUT
+ {I2C_CMD, FADE_BLINK, ENABLE_FADE | OLED_FADE_OUT_INTERVAL};
+#else
+ {I2C_CMD, DISPLAY_OFF};
+#endif
+
if (oled_active) {
if (I2C_TRANSMIT_P(display_off) != I2C_STATUS_SUCCESS) {
print("oled_off cmd failed\n");
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 72ab21247d59..cbf5380ee089 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -154,10 +154,22 @@ along with this program. If not, see .
# endif
#endif
+#if !defined(OLED_FADE_OUT_INTERVAL)
+# define OLED_FADE_OUT_INTERVAL 0x00
+#endif
+
+#if OLED_FADE_OUT_INTERVAL > 0x0F || OLED_FADE_OUT_INTERVAL < 0x00
+# error OLED_FADE_OUT_INTERVAL must be between 0x00 and 0x0F
+#endif
+
#if !defined(OLED_I2C_TIMEOUT)
# define OLED_I2C_TIMEOUT 100
#endif
+#if !defined(OLED_UPDATE_INTERVAL) && defined(SPLIT_KEYBOARD)
+# define OLED_UPDATE_INTERVAL 50
+#endif
+
typedef struct __attribute__((__packed__)) {
uint8_t *current_element;
uint16_t remaining_element_count;
diff --git a/layouts/community/ergodox/bocaj/rules.mk b/layouts/community/ergodox/bocaj/rules.mk
index 88eaf39f8e86..c6a306fdaa3d 100644
--- a/layouts/community/ergodox/bocaj/rules.mk
+++ b/layouts/community/ergodox/bocaj/rules.mk
@@ -1,4 +1,4 @@
-BOOTMAGIC_ENABLE = yes
+BOOTMAGIC_ENABLE = full
TAP_DANCE_ENABLE = no
COMMAND_ENABLE = no # Commands for debug and configuration
CONSOLE_ENABLE = yes
diff --git a/layouts/community/ergodox/drashna/keymap.c b/layouts/community/ergodox/drashna/keymap.c
index 2bcf672a91f6..3e1460606025 100644
--- a/layouts/community/ergodox/drashna/keymap.c
+++ b/layouts/community/ergodox/drashna/keymap.c
@@ -19,9 +19,6 @@
#ifdef UNICODEMAP_ENABLE
# include "drashna_unicode.h"
#endif // UNICODEMAP_ENABLE
-#ifndef UNICODE_ENABLE
-# define UC(x) KC_NO
-#endif
enum more_custom_keycodes {
KC_SWAP_NUM = NEW_SAFE_RANGE,
@@ -199,20 +196,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_____________CARPLAX_QFMLWY_L3_____________, _____________CARPLAX_QFMLWY_R3_____________
),
-
-// Reverts OSM(Shift) to normal Shifts. However, may not need since we fixed the issue with RDP (LOCAL RESOURCES)
- [_MODS] = LAYOUT_ergodox_pretty_wrapper(
- _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
- _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
- _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
- KC_LSFT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_RSFT,
- _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
- _______, _______, _______, _______,
- _______, _______,
- _______, _______, _______, _______, _______, _______
- ),
-
-
/* Keymap 4: Customized Overwatch Layout
*
* ,--------------------------------------------------. ,--------------------------------------------------.
@@ -303,7 +286,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_MAKE, _______, _______, _______, _______, _______, UC_MOD, KC_NUKE, _________________ADJUST_R1_________________, KC_RST,
VRSN, _________________ADJUST_L1_________________, _______, _______, _________________ADJUST_R1_________________, EEP_RST,
_______, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, RGB_IDL,
- _______, _________________ADJUST_L3_________________, _______, _______, _________________ADJUST_R3_________________, TG(_MODS),
+ _______, _________________ADJUST_L3_________________, _______, _______, _________________ADJUST_R3_________________, TG_MODS,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______,
@@ -466,9 +449,12 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
RGB_MATRIX_INDICATOR_SET_COLOR(25, 0x7A, 0x00, 0xFF); // 3
}
-
- if (userspace_config.rgb_layer_change) {
- bool mods_enabled = IS_LAYER_ON(_MODS);
+# if defined(RGBLIGHT_ENABLE)
+ if (!userspace_config.rgb_layer_change)
+# else
+ if (userspace_config.rgb_layer_change)
+# endif
+ {
switch (get_highest_layer(layer_state|default_layer_state)) {
case _GAMEPAD:
rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
@@ -486,28 +472,28 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _QWERTY:
- rgb_matrix_layer_helper(HSV_CYAN, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_CYAN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _COLEMAK:
- rgb_matrix_layer_helper(HSV_MAGENTA, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_MAGENTA, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _DVORAK:
- rgb_matrix_layer_helper(HSV_SPRINGGREEN, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_SPRINGGREEN, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _WORKMAN:
- rgb_matrix_layer_helper(HSV_GOLDENROD, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_GOLDENROD, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _NORMAN:
- rgb_matrix_layer_helper(HSV_CORAL, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_CORAL, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _MALTRON:
- rgb_matrix_layer_helper(HSV_YELLOW, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_YELLOW, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _EUCALYN:
- rgb_matrix_layer_helper(HSV_PINK, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_PINK, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _CARPLAX:
- rgb_matrix_layer_helper(HSV_BLUE, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_BLUE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
}
}
diff --git a/layouts/community/ergodox/drashna/rules.mk b/layouts/community/ergodox/drashna/rules.mk
index 51b4c9a6010f..31f4788fad24 100644
--- a/layouts/community/ergodox/drashna/rules.mk
+++ b/layouts/community/ergodox/drashna/rules.mk
@@ -1,5 +1,5 @@
BOOTMAGIC_ENABLE = lite
-TAP_DANCE_ENABLE = yes
+TAP_DANCE_ENABLE = no
COMMAND_ENABLE = no # Commands for debug and configuration
CONSOLE_ENABLE = no
SPACE_CADET_ENABLE = no
diff --git a/layouts/community/ortho_4x12/bocaj/keymap.c b/layouts/community/ortho_4x12/bocaj/keymap.c
index 89d4d1d9ab61..6adbb6d61b80 100644
--- a/layouts/community/ortho_4x12/bocaj/keymap.c
+++ b/layouts/community/ortho_4x12/bocaj/keymap.c
@@ -237,7 +237,7 @@ void rgb_matrix_indicators_user(void) {
void matrix_init_keymap(void) {}
#ifdef ENCODER_ENABLE
-void encoder_update(bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
switch (get_highest_layer(layer_state)) {
case _RAISE:
clockwise ? tap_code(KC_VOLD) : tap_code(KC_VOLU);
@@ -260,6 +260,7 @@ void encoder_update(bool clockwise) {
# ifdef AUDIO_CLICKY
clicky_play();
# endif
+ return true;
}
#endif // ENCODER_ENABLE
diff --git a/layouts/community/ortho_4x12/bocaj/rules.mk b/layouts/community/ortho_4x12/bocaj/rules.mk
index 3383cfd35f3b..5c642e65ca35 100644
--- a/layouts/community/ortho_4x12/bocaj/rules.mk
+++ b/layouts/community/ortho_4x12/bocaj/rules.mk
@@ -32,7 +32,6 @@ ifeq ($(strip $(KEYBOARD)), planck/light)
endif
ifeq ($(strip $(KEYBOARD)), planck/ez)
RGBLIGHT_ENABLE = no
- # SERIAL_LINK_ENABLE = yes
ENCODER_ENABLE = yes
RGB_MATRIX_ENABLE = IS31FL3737
INDICATOR_LIGHTS = yes
diff --git a/layouts/community/ortho_4x12/brandonschlack/keymap.c b/layouts/community/ortho_4x12/brandonschlack/keymap.c
index d4c1a4a867ea..ea9d2950642f 100644
--- a/layouts/community/ortho_4x12/brandonschlack/keymap.c
+++ b/layouts/community/ortho_4x12/brandonschlack/keymap.c
@@ -121,7 +121,7 @@ uint16_t muse_counter = 0;
uint8_t muse_offset = 70;
uint16_t muse_tempo = 50;
-void encoder_update_keymap(uint8_t index, bool clockwise) {
+bool encoder_update_keymap(uint8_t index, bool clockwise) {
if (muse_mode) {
if (IS_LAYER_ON(_RAISE)) {
if (clockwise) {
@@ -151,6 +151,7 @@ void encoder_update_keymap(uint8_t index, bool clockwise) {
#endif
}
}
+ return true;
}
void dip_switch_update_user(uint8_t index, bool active) {
diff --git a/layouts/community/ortho_4x12/buswerks/keymap.c b/layouts/community/ortho_4x12/buswerks/keymap.c
index 95d9e7019a90..455db2a8a569 100644
--- a/layouts/community/ortho_4x12/buswerks/keymap.c
+++ b/layouts/community/ortho_4x12/buswerks/keymap.c
@@ -142,7 +142,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
-void encoder_update(bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
if (IS_LAYER_ON(_RAISE) || IS_LAYER_ON(_LOWER)) {
if (clockwise) {
register_code(KC_VOLU);
@@ -170,6 +170,5 @@ void encoder_update(bool clockwise) {
#endif
}
}
+ return true;
}
-
-
diff --git a/layouts/community/ortho_4x12/drashna/keymap.c b/layouts/community/ortho_4x12/drashna/keymap.c
index 61f22dfe95ed..82594b9fd4a5 100644
--- a/layouts/community/ortho_4x12/drashna/keymap.c
+++ b/layouts/community/ortho_4x12/drashna/keymap.c
@@ -115,13 +115,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_____________CARPLAX_QFMLWY_L3_____________, _____________CARPLAX_QFMLWY_R3_____________
),
- [_MODS] = LAYOUT_ortho_4x12_wrapper(
- _______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- _______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- KC_LSFT, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
- ),
-
[_LOWER] = LAYOUT_ortho_4x12_wrapper(
KC_TILD, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_BSPC,
KC_DEL, _________________LOWER_L2__________________, _________________LOWER_R2__________________, KC_PIPE,
@@ -262,31 +255,30 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
default: {
- bool mods_enabled = IS_LAYER_ON(_MODS);
switch (get_highest_layer(default_layer_state)) {
case _QWERTY:
- rgb_matrix_layer_helper(HSV_CYAN, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_CYAN, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _COLEMAK:
- rgb_matrix_layer_helper(HSV_MAGENTA, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_MAGENTA, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _DVORAK:
- rgb_matrix_layer_helper(HSV_SPRINGGREEN, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_SPRINGGREEN, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _WORKMAN:
- rgb_matrix_layer_helper(HSV_GOLDENROD, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_GOLDENROD, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _NORMAN:
- rgb_matrix_layer_helper(HSV_CORAL, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_CORAL, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _MALTRON:
- rgb_matrix_layer_helper(HSV_YELLOW, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_YELLOW, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _EUCALYN:
- rgb_matrix_layer_helper(HSV_PINK, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_PINK, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
case _CARPLAX:
- rgb_matrix_layer_helper(HSV_BLUE, mods_enabled, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ rgb_matrix_layer_helper(HSV_BLUE, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
}
break;
@@ -348,7 +340,7 @@ void matrix_init_keymap(void) {
#endif // RGB_MATRIX_INIT
#ifdef ENCODER_ENABLE
-void encoder_update(bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
switch (get_highest_layer(layer_state)) {
case _RAISE:
clockwise ? tap_code(KC_VOLD) : tap_code(KC_VOLU);
@@ -371,6 +363,7 @@ void encoder_update(bool clockwise) {
# ifdef AUDIO_CLICKY
clicky_play();
# endif
+ return true;
}
#endif // ENCODER_ENABLE
diff --git a/layouts/community/ortho_4x12/drashna/rules.mk b/layouts/community/ortho_4x12/drashna/rules.mk
index 2a9576758f31..06a250ee79cc 100644
--- a/layouts/community/ortho_4x12/drashna/rules.mk
+++ b/layouts/community/ortho_4x12/drashna/rules.mk
@@ -32,7 +32,6 @@ ifeq ($(strip $(KEYBOARD)), planck/light)
endif
ifeq ($(strip $(KEYBOARD)), planck/ez)
RGBLIGHT_ENABLE = no
- # SERIAL_LINK_ENABLE = yes
ENCODER_ENABLE = yes
RGB_MATRIX_ENABLE = yes
INDICATOR_LIGHTS = yes
diff --git a/layouts/community/ortho_4x12/jackhumbert/keymap.c b/layouts/community/ortho_4x12/jackhumbert/keymap.c
index f9a3e1686ffb..08abf78d1429 100644
--- a/layouts/community/ortho_4x12/jackhumbert/keymap.c
+++ b/layouts/community/ortho_4x12/jackhumbert/keymap.c
@@ -130,7 +130,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
};
-void encoder_update(bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) {
#ifdef MOUSEKEY_ENABLE
tap_code(KC_MS_WH_DOWN);
@@ -144,6 +144,7 @@ void encoder_update(bool clockwise) {
tap_code(KC_PGUP);
#endif
}
+ return true;
}
bool music_mask_user(uint16_t keycode) {
diff --git a/layouts/community/ortho_4x12/juno/keymap.c b/layouts/community/ortho_4x12/juno/keymap.c
index 2b16b9955e6d..b3ef8fce536b 100644
--- a/layouts/community/ortho_4x12/juno/keymap.c
+++ b/layouts/community/ortho_4x12/juno/keymap.c
@@ -10,7 +10,7 @@ enum planck_layers {
_RAISE,
_PLOVER,
_ADJUST,
-
+
_FN1,
_DPAD,
_DPADNUM
@@ -23,7 +23,7 @@ enum planck_keycodes {
PLOVER,
BACKLIT,
EXT_PLV,
-
+
DP_ON,
DP_OFF
};
@@ -49,7 +49,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_ENT),
- KC_APP, KC_LCTL, KC_LGUI, KC_LALT, LOWER, SPACEFN, SPACEFN, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT
+ KC_APP, KC_LCTL, KC_LGUI, KC_LALT, LOWER, SPACEFN, SPACEFN, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT
),
/* Colemak
@@ -218,10 +218,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#ifdef AUDIO_ENABLE
float plover_song[][2] = SONG(PLOVER_SOUND);
float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
-
+
// Borrowing audio from unused audio
// Caps Lock on and off sound too similar
-
+
float caps_song_on[][2] = SONG(NUM_LOCK_ON_SOUND);
float caps_song_off[][2] = SONG(SCROLL_LOCK_ON_SOUND);
@@ -236,7 +236,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
}
#else
-
+
layer_state_t layer_state_set_user(layer_state_t state) {
// LED control, lighting up when Fn layer is activated
state = update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
@@ -256,7 +256,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
return state;
}
-#endif
+#endif
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
@@ -324,8 +324,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
return false;
break;
-
-
+
+
// Play audio upon switching Caps Lock and custom layers
case KC_CAPS:
@@ -339,26 +339,26 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#endif
}
return true;
-
+
case DP_ON:
if (record->event.pressed) {
-
+
} else {
#ifdef AUDIO_ENABLE
PLAY_SONG(dpad_song_on);
#endif
-
+
layer_off(_FN1);
layer_on(_DPAD);
}
-
+
case DP_OFF:
if (record->event.pressed) {
- #ifdef AUDIO_ENABLE
+ #ifdef AUDIO_ENABLE
PLAY_SONG(dpad_song_off);
#endif
-
- layer_off(_DPAD);
+
+ layer_off(_DPAD);
}
}
return true;
@@ -370,7 +370,7 @@ uint16_t muse_counter = 0;
uint8_t muse_offset = 70;
uint16_t muse_tempo = 50;
-void encoder_update(bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
if (muse_mode) {
if (IS_LAYER_ON(_RAISE)) {
if (clockwise) {
@@ -392,6 +392,7 @@ void encoder_update(bool clockwise) {
tap_code(KC_PGUP);
}
}
+ return true;
}
void dip_update(uint8_t index, bool active) {
diff --git a/layouts/community/ortho_4x12/junonum/keymap.c b/layouts/community/ortho_4x12/junonum/keymap.c
index 67f7efde45f1..82ff4d63a7b3 100644
--- a/layouts/community/ortho_4x12/junonum/keymap.c
+++ b/layouts/community/ortho_4x12/junonum/keymap.c
@@ -268,7 +268,7 @@ uint16_t muse_counter = 0;
uint8_t muse_offset = 70;
uint16_t muse_tempo = 50;
-void encoder_update(bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
if (muse_mode) {
if (IS_LAYER_ON(_RAISE)) {
if (clockwise) {
@@ -290,6 +290,7 @@ void encoder_update(bool clockwise) {
tap_code(KC_PGUP);
}
}
+ return true;
}
void dip_update(uint8_t index, bool active) {
diff --git a/layouts/community/ortho_4x12/mguterl/keymap.c b/layouts/community/ortho_4x12/mguterl/keymap.c
index 2be2d449e34e..66039b61e6c3 100644
--- a/layouts/community/ortho_4x12/mguterl/keymap.c
+++ b/layouts/community/ortho_4x12/mguterl/keymap.c
@@ -257,7 +257,7 @@ uint16_t muse_counter = 0;
uint8_t muse_offset = 70;
uint16_t muse_tempo = 50;
-void encoder_update(bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
if (muse_mode) {
if (IS_LAYER_ON(_RAISE)) {
if (clockwise) {
@@ -287,6 +287,7 @@ void encoder_update(bool clockwise) {
#endif
}
}
+ return true;
}
void dip_switch_update_user(uint8_t index, bool active) {
diff --git a/layouts/community/ortho_4x12/mindsound/keymap.c b/layouts/community/ortho_4x12/mindsound/keymap.c
index 613f11d1349e..336545502f61 100644
--- a/layouts/community/ortho_4x12/mindsound/keymap.c
+++ b/layouts/community/ortho_4x12/mindsound/keymap.c
@@ -185,7 +185,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return true;
}
-void encoder_update(bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) {
register_code(KC_VOLU);
unregister_code(KC_VOLU);
@@ -193,6 +193,7 @@ void encoder_update(bool clockwise) {
register_code(KC_VOLD);
unregister_code(KC_VOLD);
}
+ return true;
}
// flicker implementation:
diff --git a/layouts/community/ortho_4x12/rs/keymap.c b/layouts/community/ortho_4x12/rs/keymap.c
index c6d6f14cad02..a8a057f3d7f9 100644
--- a/layouts/community/ortho_4x12/rs/keymap.c
+++ b/layouts/community/ortho_4x12/rs/keymap.c
@@ -24,29 +24,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// |------+------+------+------+------+------+------+------+------+------+------+------|
LSFT , Z , X , C , V , B , N , M , COMM , DOT , SLSH , ENTS ,
// |------+------+------+------+------+------+------+------+------+------+------+------|
- , , LCTL , LALT , LGUI , SPC , SPC , BCOD , FN , , LEFT , RGHT
+ TRNS , TRNS , LCTL , LALT , LGUI , SPC , SPC , BCOD , FN , TRNS , LEFT , RGHT
// `-----------------------------------------------------------------------------------'
),
[_CODE] = LAYOUT_kc(
// ,-----------------------------------------------------------------------------------.
- GRV , EXLM , AT , HASH , DLR , PERC , CIRC , LPLT , ASTR , RPGT , NEQL , ,
+ GRV , EXLM , AT , HASH , DLR , PERC , CIRC , LPLT , ASTR , RPGT , NEQL , TRNS ,
// |------+------+------+------+------+------+------+------+------+------+------+------|
- , 1 , 2 , 3 , 4 , 5 , MINS , LBRC , UP , RBRC , , BSLS ,
+ TRNS , 1 , 2 , 3 , 4 , 5 , MINS , LBRC , UP , RBRC , TRNS , BSLS ,
// |------+------+------+------+------+------+------+------+------+------+------+------|
- , 6 , 7 , 8 , 9 , 0 , AMPR , LEFT , DOWN , RGHT , , PIPE ,
+ TRNS , 6 , 7 , 8 , 9 , 0 , AMPR , LEFT , DOWN , RGHT , TRNS , PIPE ,
// |------+------+------+------+------+------+------+------+------+------+------+------|
- , , , , , DOT , , , , , ,
+ TRNS , TRNS , TRNS , TRNS , TRNS , DOT , TRNS , TRNS , TRNS , TRNS , TRNS , TRNS
// `-----------------------------------------------------------------------------------'
),
[_FN] = LAYOUT_kc(
// ,-----------------------------------------------------------------------------------.
- , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 , F10 , F11 ,
+ TRNS , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 , F10 , F11 ,
// |------+------+------+------+------+------+------+------+------+------+------+------|
- BLTG , BLUP , , , , BRMU , VOLU , , PGUP , , , ,
+ BLTG , BLUP , TRNS , TRNS , TRNS , BRMU , VOLU , TRNS , PGUP , TRNS , TRNS , TRNS ,
// |------+------+------+------+------+------+------+------+------+------+------+------|
- BLTG , BLDN , , , RST , BRMD , VOLD , CTRA , PGDN , CTRE , , ,
+ BLTG , BLDN , TRNS , TRNS , RST , BRMD , VOLD , CTRA , PGDN , CTRE , TRNS , TRNS ,
// |------+------+------+------+------+------+------+------+------+------+------+------|
- , , , , , , MUTE , , , , ,
+ TRNS , TRNS , TRNS , TRNS , TRNS , TRNS , MUTE , TRNS , TRNS , TRNS , TRNS , TRNS
// `-----------------------------------------------------------------------------------'
),
};
diff --git a/layouts/community/ortho_5x12/brandonschlack/keymap.c b/layouts/community/ortho_5x12/brandonschlack/keymap.c
index 4d7b7483adc2..c9c94fc967d2 100644
--- a/layouts/community/ortho_5x12/brandonschlack/keymap.c
+++ b/layouts/community/ortho_5x12/brandonschlack/keymap.c
@@ -116,7 +116,7 @@ uint16_t muse_counter = 0;
uint8_t muse_offset = 70;
uint16_t muse_tempo = 50;
-void encoder_update_keymap(uint8_t index, bool clockwise) {
+bool encoder_update_keymap(uint8_t index, bool clockwise) {
if (muse_mode) {
if (IS_LAYER_ON(_RAISE)) {
if (clockwise) {
@@ -146,6 +146,7 @@ void encoder_update_keymap(uint8_t index, bool clockwise) {
#endif
}
}
+ return true;
}
void dip_switch_update_user(uint8_t index, bool active) {
diff --git a/layouts/community/ortho_5x12/drashna/keymap.c b/layouts/community/ortho_5x12/drashna/keymap.c
index 9f6622c7d5b1..f882ead171b1 100644
--- a/layouts/community/ortho_5x12/drashna/keymap.c
+++ b/layouts/community/ortho_5x12/drashna/keymap.c
@@ -67,14 +67,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_________________WORKMAN_L3________________, _________________WORKMAN_R3________________
),
-[_MODS] = LAYOUT_ortho_5x12_wrapper(
- _______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- _______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- _______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- KC_LSFT, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
-),
-
/* Lower
* ,-----------------------------------------------------------------------------------.
* | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
diff --git a/layouts/community/split_3x6_3/drashna/keymap.c b/layouts/community/split_3x6_3/drashna/keymap.c
index 65e05f64b6da..5a2d2f2e2703 100644
--- a/layouts/community/split_3x6_3/drashna/keymap.c
+++ b/layouts/community/split_3x6_3/drashna/keymap.c
@@ -90,13 +90,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_____________CARPLAX_QFMLWY_L3_____________, _____________CARPLAX_QFMLWY_R3_____________
),
- [_MODS] = LAYOUT_split_3x6_3_wrapper(
- _______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- _______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
- KC_LSFT, ___________________BLANK___________________, ___________________BLANK___________________, KC_RSFT,
- _______, _______, _______, _______, _______, _______
- ),
-
[_LOWER] = LAYOUT_split_3x6_3_wrapper(
KC_F11, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_F11,
KC_F12, _________________LOWER_L2__________________, _________________LOWER_R2__________________, KC_PIPE,
@@ -179,7 +172,6 @@ void check_default_layer(uint8_t mode, uint8_t type, uint8_t led_min, uint8_t le
}
void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
- if (!is_keyboard_master()) return;
if (userspace_config.rgb_layer_change) {
switch (get_highest_layer(layer_state)) {
case _GAMEPAD:
@@ -198,7 +190,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
rgb_matrix_layer_helper(HSV_RED, 0, rgb_matrix_config.speed, LED_FLAG_UNDERGLOW, led_min, led_max);
break;
default: {
- check_default_layer(IS_LAYER_ON(_MODS), LED_FLAG_UNDERGLOW, led_min, led_max);
+ check_default_layer(0, LED_FLAG_UNDERGLOW, led_min, led_max);
break;
}
}
diff --git a/layouts/community/split_3x6_3/drashna/rules.mk b/layouts/community/split_3x6_3/drashna/rules.mk
index db284f78dc0b..cbb0b1c113ba 100644
--- a/layouts/community/split_3x6_3/drashna/rules.mk
+++ b/layouts/community/split_3x6_3/drashna/rules.mk
@@ -3,27 +3,26 @@
# change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically
#
-BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE = no # Mouse keys(+4700)
-EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
-CONSOLE_ENABLE = no # Console for debug(+400)
+BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
+MOUSEKEY_ENABLE = no # Mouse keys
+EXTRAKEY_ENABLE = yes # Audio control and System control
+CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
-MIDI_ENABLE = no # MIDI controls
-AUDIO_ENABLE = no # Audio output on port C6
+AUDIO_ENABLE = no # Audio output
UNICODE_ENABLE = no # Unicode
-BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
+BLUETOOTH_ENABLE = no # Enable Bluetooth
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
SWAP_HANDS_ENABLE = no # Enable one-hand typing
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
-ifeq ($(strip $(KEYBOARD)), crkbd/rev1/common)
+ifeq ($(strip $(KEYBOARD)), crkbd/rev1)
OLED_DRIVER_ENABLE = yes
RGB_MATRIX_ENABLE = yes
- HAPTIC_ENABLE = SOLENOID
+ HAPTIC_ENABLE = no
BOOTLOADER = qmk-dfu
endif
@@ -31,4 +30,5 @@ ifeq ($(strip $(CTPC)), yes)
HAPTIC_ENABLE = no
WS2812_DRIVER = pwm # won't work without a patch to the ctpc mk file
SERIAL_DRIVER = usart
+ SWAP_HANDS_ENABLE = yes
endif
diff --git a/layouts/community/split_3x6_3/drashna/ssd1306.c b/layouts/community/split_3x6_3/drashna/ssd1306.c
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/lib/python/qmk/c_parse.py b/lib/python/qmk/c_parse.py
index d4f39c8839ce..991373d5693a 100644
--- a/lib/python/qmk/c_parse.py
+++ b/lib/python/qmk/c_parse.py
@@ -8,7 +8,7 @@
from qmk.comment_remover import comment_remover
default_key_entry = {'x': -1, 'y': 0, 'w': 1}
-single_comment_regex = re.compile(r' */[/*].*$')
+single_comment_regex = re.compile(r'\s+/[/*].*$')
multi_comment_regex = re.compile(r'/\*(.|\n)*?\*/', re.MULTILINE)
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index d07790d1182a..48812ae4bad5 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -12,6 +12,20 @@
from milc import cli, __VERSION__
from milc.questions import yesno
+import_names = {
+ # A mapping of package name to importable name
+ 'pep8-naming': 'pep8ext_naming',
+ 'pyusb': 'usb.core',
+}
+
+safe_commands = [
+ # A list of subcommands we always run, even when the module imports fail
+ 'clone',
+ 'config',
+ 'env',
+ 'setup',
+]
+
def _run_cmd(*command):
"""Run a command in a subshell.
@@ -50,8 +64,8 @@ def _find_broken_requirements(requirements):
module_import = module_name.replace('-', '_')
# Not every module is importable by its own name.
- if module_name == "pep8-naming":
- module_import = "pep8ext_naming"
+ if module_name in import_names:
+ module_import = import_names[module_name]
if not find_spec(module_import):
broken_modules.append(module_name)
@@ -107,32 +121,31 @@ def _broken_module_imports(requirements):
# Check to make sure we have all our dependencies
msg_install = 'Please run `python3 -m pip install -r %s` to install required python dependencies.'
-
-if _broken_module_imports('requirements.txt'):
- if yesno('Would you like to install the required Python modules?'):
- _run_cmd(sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt')
- else:
- print()
- print(msg_install % (str(Path('requirements.txt').resolve()),))
- print()
- exit(1)
-
-if cli.config.user.developer:
- args = sys.argv[1:]
- while args and args[0][0] == '-':
- del args[0]
- if not args or args[0] != 'config':
- if _broken_module_imports('requirements-dev.txt'):
- if yesno('Would you like to install the required developer Python modules?'):
- _run_cmd(sys.executable, '-m', 'pip', 'install', '-r', 'requirements-dev.txt')
- elif yesno('Would you like to disable developer mode?'):
- _run_cmd(sys.argv[0], 'config', 'user.developer=None')
- else:
- print()
- print(msg_install % (str(Path('requirements-dev.txt').resolve()),))
- print('You can also turn off developer mode: qmk config user.developer=None')
- print()
- exit(1)
+args = sys.argv[1:]
+while args and args[0][0] == '-':
+ del args[0]
+
+if not args or args[0] not in safe_commands:
+ if _broken_module_imports('requirements.txt'):
+ if yesno('Would you like to install the required Python modules?'):
+ _run_cmd(sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt')
+ else:
+ print()
+ print(msg_install % (str(Path('requirements.txt').resolve()),))
+ print()
+ exit(1)
+
+ if cli.config.user.developer and _broken_module_imports('requirements-dev.txt'):
+ if yesno('Would you like to install the required developer Python modules?'):
+ _run_cmd(sys.executable, '-m', 'pip', 'install', '-r', 'requirements-dev.txt')
+ elif yesno('Would you like to disable developer mode?'):
+ _run_cmd(sys.argv[0], 'config', 'user.developer=None')
+ else:
+ print()
+ print(msg_install % (str(Path('requirements-dev.txt').resolve()),))
+ print('You can also turn off developer mode: qmk config user.developer=None')
+ print()
+ exit(1)
# Import our subcommands
from . import bux # noqa
@@ -142,6 +155,7 @@ def _broken_module_imports(requirements):
from . import clean # noqa
from . import compile # noqa
from milc.subcommand import config # noqa
+from . import console # noqa
from . import docs # noqa
from . import doctor # noqa
from . import fileformat # noqa
diff --git a/lib/python/qmk/cli/console.py b/lib/python/qmk/cli/console.py
new file mode 100644
index 000000000000..45ff0c8bee11
--- /dev/null
+++ b/lib/python/qmk/cli/console.py
@@ -0,0 +1,302 @@
+"""Acquire debugging information from usb hid devices
+
+cli implementation of https://www.pjrc.com/teensy/hid_listen.html
+"""
+from pathlib import Path
+from threading import Thread
+from time import sleep, strftime
+
+import hid
+import usb.core
+
+from milc import cli
+
+LOG_COLOR = {
+ 'next': 0,
+ 'colors': [
+ '{fg_blue}',
+ '{fg_cyan}',
+ '{fg_green}',
+ '{fg_magenta}',
+ '{fg_red}',
+ '{fg_yellow}',
+ ],
+}
+
+KNOWN_BOOTLOADERS = {
+ # VID , PID
+ ('03EB', '2FEF'): 'atmel-dfu: ATmega16U2',
+ ('03EB', '2FF0'): 'atmel-dfu: ATmega32U2',
+ ('03EB', '2FF3'): 'atmel-dfu: ATmega16U4',
+ ('03EB', '2FF4'): 'atmel-dfu: ATmega32U4',
+ ('03EB', '2FF9'): 'atmel-dfu: AT90USB64',
+ ('03EB', '2FFA'): 'atmel-dfu: AT90USB162',
+ ('03EB', '2FFB'): 'atmel-dfu: AT90USB128',
+ ('03EB', '6124'): 'Microchip SAM-BA',
+ ('0483', 'DF11'): 'stm32-dfu: STM32 BOOTLOADER',
+ ('16C0', '05DC'): 'USBasp: USBaspLoader',
+ ('16C0', '05DF'): 'bootloadHID: HIDBoot',
+ ('16C0', '0478'): 'halfkay: Teensy Halfkay',
+ ('1B4F', '9203'): 'caterina: Pro Micro 3.3V',
+ ('1B4F', '9205'): 'caterina: Pro Micro 5V',
+ ('1B4F', '9207'): 'caterina: LilyPadUSB',
+ ('1C11', 'B007'): 'kiibohd: Kiibohd DFU Bootloader',
+ ('1EAF', '0003'): 'stm32duino: Maple 003',
+ ('1FFB', '0101'): 'caterina: Polou A-Star 32U4 Bootloader',
+ ('2341', '0036'): 'caterina: Arduino Leonardo',
+ ('2341', '0037'): 'caterina: Arduino Micro',
+ ('239A', '000C'): 'caterina: Adafruit Feather 32U4',
+ ('239A', '000D'): 'caterina: Adafruit ItsyBitsy 32U4 3v',
+ ('239A', '000E'): 'caterina: Adafruit ItsyBitsy 32U4 5v',
+ ('239A', '000E'): 'caterina: Adafruit ItsyBitsy 32U4 5v',
+ ('2A03', '0036'): 'caterina: Arduino Leonardo',
+ ('2A03', '0037'): 'caterina: Arduino Micro',
+ ('314B', '0106'): 'apm32-dfu: APM32 DFU ISP Mode'
+}
+
+
+class MonitorDevice(object):
+ def __init__(self, hid_device, numeric):
+ self.hid_device = hid_device
+ self.numeric = numeric
+ self.device = hid.Device(path=hid_device['path'])
+ self.current_line = ''
+
+ 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)
+
+ def read(self, size, encoding='ascii', timeout=1):
+ """Read size bytes from the device.
+ """
+ return self.device.read(size, timeout).decode(encoding)
+
+ def read_line(self):
+ """Read from the device's console until we get a \n.
+ """
+ while '\n' not in self.current_line:
+ self.current_line += self.read(32).replace('\x00', '')
+
+ lines = self.current_line.split('\n', 1)
+ self.current_line = lines[1]
+
+ return lines[0]
+
+ def run_forever(self):
+ while True:
+ try:
+ message = {**self.hid_device, 'text': self.read_line()}
+ identifier = (int2hex(message['vendor_id']), int2hex(message['product_id'])) if self.numeric else (message['manufacturer_string'], message['product_string'])
+ message['identifier'] = ':'.join(identifier)
+ message['ts'] = '{style_dim}{fg_green}%s{style_reset_all} ' % (strftime(cli.config.general.datetime_fmt),) if cli.args.timestamp else ''
+
+ cli.echo('%(ts)s%(color)s%(identifier)s:%(index)d{style_reset_all}: %(text)s' % message)
+
+ except hid.HIDException:
+ break
+
+
+class FindDevices(object):
+ def __init__(self, vid, pid, index, numeric):
+ self.vid = vid
+ self.pid = pid
+ self.index = index
+ self.numeric = numeric
+
+ def run_forever(self):
+ """Process messages from our queue in a loop.
+ """
+ live_devices = {}
+ live_bootloaders = {}
+
+ while True:
+ try:
+ for device in list(live_devices):
+ if not live_devices[device]['thread'].is_alive():
+ 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])
+ del live_devices[device]
+
+ for device in self.find_devices():
+ if device['path'] not in live_devices:
+ device['color'] = LOG_COLOR['colors'][LOG_COLOR['next']]
+ LOG_COLOR['next'] = (LOG_COLOR['next'] + 1) % len(LOG_COLOR['colors'])
+ live_devices[device['path']] = device
+
+ try:
+ monitor = MonitorDevice(device, self.numeric)
+ device['thread'] = Thread(target=monitor.run_forever, daemon=True)
+
+ device['thread'].start()
+ except Exception as e:
+ device['e'] = e
+ device['e_name'] = e.__class__.__name__
+ 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)
+ if cli.config.general.verbose:
+ cli.log.exception(e)
+ del live_devices[device['path']]
+
+ if cli.args.bootloaders:
+ for device in self.find_bootloaders():
+ if device.address in live_bootloaders:
+ live_bootloaders[device.address]._qmk_found = True
+ else:
+ name = KNOWN_BOOTLOADERS[(int2hex(device.idVendor), int2hex(device.idProduct))]
+ cli.log.info('Bootloader Connected: {style_bright}{fg_magenta}%s', name)
+ device._qmk_found = True
+ live_bootloaders[device.address] = device
+
+ for device in list(live_bootloaders):
+ if live_bootloaders[device]._qmk_found:
+ live_bootloaders[device]._qmk_found = False
+ else:
+ name = KNOWN_BOOTLOADERS[(int2hex(live_bootloaders[device].idVendor), int2hex(live_bootloaders[device].idProduct))]
+ cli.log.info('Bootloader Disconnected: {style_bright}{fg_magenta}%s', name)
+ del live_bootloaders[device]
+
+ sleep(.1)
+
+ except KeyboardInterrupt:
+ break
+
+ def is_bootloader(self, hid_device):
+ """Returns true if the device in question matches a known bootloader vid/pid.
+ """
+ return (int2hex(hid_device.idVendor), int2hex(hid_device.idProduct)) in KNOWN_BOOTLOADERS
+
+ def is_console_hid(self, hid_device):
+ """Returns true when the usage page indicates it's a teensy-style console.
+ """
+ return hid_device['usage_page'] == 0xFF31 and hid_device['usage'] == 0x0074
+
+ def is_filtered_device(self, hid_device):
+ """Returns True if the device should be included in the list of available consoles.
+ """
+ return int2hex(hid_device['vendor_id']) == self.vid and int2hex(hid_device['product_id']) == self.pid
+
+ def find_devices_by_report(self, hid_devices):
+ """Returns a list of available teensy-style consoles by doing a brute-force search.
+
+ Some versions of linux don't report usage and usage_page. In that case we fallback to reading the report (possibly inaccurately) ourselves.
+ """
+ devices = []
+
+ for device in hid_devices:
+ path = device['path'].decode('utf-8')
+
+ if path.startswith('/dev/hidraw'):
+ number = path[11:]
+ report = Path(f'/sys/class/hidraw/hidraw{number}/device/report_descriptor')
+
+ if report.exists():
+ rp = report.read_bytes()
+
+ if rp[1] == 0x31 and rp[3] == 0x09:
+ devices.append(device)
+
+ return devices
+
+ def find_bootloaders(self):
+ """Returns a list of available bootloader devices.
+ """
+ return list(filter(self.is_bootloader, usb.core.find(find_all=True)))
+
+ def find_devices(self):
+ """Returns a list of available teensy-style consoles.
+ """
+ hid_devices = hid.enumerate()
+ devices = list(filter(self.is_console_hid, hid_devices))
+
+ if not devices:
+ devices = self.find_devices_by_report(hid_devices)
+
+ if self.vid and self.pid:
+ devices = list(filter(self.is_filtered_device, devices))
+
+ # Add index numbers
+ device_index = {}
+ for device in devices:
+ id = ':'.join((int2hex(device['vendor_id']), int2hex(device['product_id'])))
+
+ if id not in device_index:
+ device_index[id] = 0
+
+ device_index[id] += 1
+ device['index'] = device_index[id]
+
+ return devices
+
+
+def int2hex(number):
+ """Returns a string representation of the number as hex.
+ """
+ return "%04X" % number
+
+
+def list_devices(device_finder):
+ """Show the user a nicely formatted list of devices.
+ """
+ devices = device_finder.find_devices()
+
+ if devices:
+ cli.log.info('Available devices:')
+ for dev in devices:
+ color = LOG_COLOR['colors'][LOG_COLOR['next']]
+ LOG_COLOR['next'] = (LOG_COLOR['next'] + 1) % len(LOG_COLOR['colors'])
+ 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'])
+
+ if cli.args.bootloaders:
+ bootloaders = device_finder.find_bootloaders()
+
+ if bootloaders:
+ cli.log.info('Available Bootloaders:')
+
+ for dev in bootloaders:
+ cli.log.info("\t%s:%s\t%s", int2hex(dev.idVendor), int2hex(dev.idProduct), KNOWN_BOOTLOADERS[(int2hex(dev.idVendor), int2hex(dev.idProduct))])
+
+
+@cli.argument('--bootloaders', arg_only=True, default=True, action='store_boolean', help='displaying bootloaders.')
+@cli.argument('-d', '--device', help='Device to select - uses format :[:].')
+@cli.argument('-l', '--list', arg_only=True, action='store_true', help='List available hid_listen devices.')
+@cli.argument('-n', '--numeric', arg_only=True, action='store_true', help='Show VID/PID instead of names.')
+@cli.argument('-t', '--timestamp', arg_only=True, action='store_true', help='Print the timestamp for received messages as well.')
+@cli.argument('-w', '--wait', type=int, default=1, help="How many seconds to wait between checks (Default: 1)")
+@cli.subcommand('Acquire debugging information from usb hid devices.', hidden=False if cli.config.user.developer else True)
+def console(cli):
+ """Acquire debugging information from usb hid devices
+ """
+ vid = None
+ pid = None
+ index = 1
+
+ if cli.config.console.device:
+ device = cli.config.console.device.split(':')
+
+ if len(device) == 2:
+ vid, pid = device
+
+ elif len(device) == 3:
+ vid, pid, index = device
+
+ if not index.isdigit():
+ cli.log.error('Device index must be a number! Got "%s" instead.', index)
+ exit(1)
+
+ index = int(index)
+
+ if index < 1:
+ cli.log.error('Device index must be greater than 0! Got %s', index)
+ exit(1)
+
+ else:
+ cli.log.error('Invalid format for device, expected ":[:]" but got "%s".', cli.config.console.device)
+ cli.print_help()
+ exit(1)
+
+ vid = vid.upper()
+ pid = pid.upper()
+
+ device_finder = FindDevices(vid, pid, index, cli.args.numeric)
+
+ if cli.args.list:
+ return list_devices(device_finder)
+
+ print('Looking for devices...', flush=True)
+ device_finder.run_forever()
diff --git a/lib/python/qmk/cli/generate/layouts.py b/lib/python/qmk/cli/generate/layouts.py
index ad6946d6cf19..4de982f822f2 100755
--- a/lib/python/qmk/cli/generate/layouts.py
+++ b/lib/python/qmk/cli/generate/layouts.py
@@ -85,7 +85,9 @@ def generate_layouts(cli):
for alias, target in kb_info_json.get('layout_aliases', {}).items():
layouts_h_lines.append('')
- layouts_h_lines.append('#define %s %s' % (alias, target))
+ layouts_h_lines.append(f'#ifndef {alias}')
+ layouts_h_lines.append(f'# define {alias} {target}')
+ layouts_h_lines.append('#endif')
# Show the results
layouts_h = '\n'.join(layouts_h_lines) + '\n'
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py
index ee049e8af7c0..3a35c11031c2 100644
--- a/lib/python/qmk/commands.py
+++ b/lib/python/qmk/commands.py
@@ -201,6 +201,7 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, **env_va
f'VERBOSE={verbose}',
f'COLOR={color}',
'SILENT=false',
+ f'QMK_BIN={"bin/qmk" if "DEPRECATED_BIN_QMK" in os.environ else "qmk"}',
])
return make_command
diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py
index 3ed69f3bf95c..49e5e0eb42d0 100644
--- a/lib/python/qmk/constants.py
+++ b/lib/python/qmk/constants.py
@@ -10,7 +10,7 @@
MAX_KEYBOARD_SUBFOLDERS = 5
# Supported processor types
-CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F411', 'STM32G431', 'STM32G474'
+CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66F18', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L433', 'STM32L443'
LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index a7b70a7d9993..afdbc8142917 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -7,7 +7,7 @@
def check_subcommand(command, *args):
- cmd = ['bin/qmk', command, *args]
+ cmd = ['qmk', command, *args]
result = cli.run(cmd, stdin=DEVNULL, combined_output=True)
return result
@@ -16,7 +16,7 @@ def check_subcommand_stdin(file_to_read, command, *args):
"""Pipe content of a file to a command and return output.
"""
with open(file_to_read, encoding='utf-8') as my_file:
- cmd = ['bin/qmk', command, *args]
+ cmd = ['qmk', command, *args]
result = cli.run(cmd, stdin=my_file, combined_output=True)
return result
diff --git a/message.mk b/message.mk
index 3240c041b9b0..79d1957397ec 100644
--- a/message.mk
+++ b/message.mk
@@ -47,10 +47,12 @@ MSG_SIZE_AFTER = Size after:
MSG_COFF = Converting to AVR COFF:
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
MSG_FLASH = Creating load file for flashing:
+MSG_UF2 = Creating UF2 file for deployment:
MSG_EEPROM = Creating load file for EEPROM:
MSG_BIN = Creating binary load file for flashing:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_EXECUTING = Executing:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling:
MSG_COMPILING_CXX = Compiling:
@@ -86,7 +88,7 @@ MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT
MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n
MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
MSG_FILE_NEAR_LIMIT = The firmware size is approaching the maximum - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
-MSG_PYTHON_MISSING = $(ERROR_COLOR)ERROR:$(NO_COLOR) Can not run bin/qmk!\n\n\
+MSG_PYTHON_MISSING = $(ERROR_COLOR)ERROR:$(NO_COLOR) Can not run \"qmk\" command!\n\n\
Please run $(BOLD)util/qmk_install.sh$(NO_COLOR) to install all the dependencies QMK requires.\n\n
MSG_FLASH_BOOTLOADER = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's bootloader is not specified or is not supported by the \":flash\" target at this time.\n\n
MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n
diff --git a/platforms/chibios/BLACKPILL_STM32_F411/ld/STM32F411xC_tinyuf2.ld b/platforms/chibios/BLACKPILL_STM32_F411/ld/STM32F411xC_tinyuf2.ld
new file mode 100644
index 000000000000..82253d3de5db
--- /dev/null
+++ b/platforms/chibios/BLACKPILL_STM32_F411/ld/STM32F411xC_tinyuf2.ld
@@ -0,0 +1,89 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * STM32F411xC memory setup.
+ */
+MEMORY
+{
+ flash0 (rx) : org = 0x08000000 + 64k, len = 256k - 64k /* tinyuf2 bootloader requires app to be located at 64k offset for this MCU */
+ flash1 (rx) : org = 0x00000000, len = 0
+ flash2 (rx) : org = 0x00000000, len = 0
+ flash3 (rx) : org = 0x00000000, len = 0
+ flash4 (rx) : org = 0x00000000, len = 0
+ flash5 (rx) : org = 0x00000000, len = 0
+ flash6 (rx) : org = 0x00000000, len = 0
+ flash7 (rx) : org = 0x00000000, len = 0
+ ram0 (wx) : org = 0x20000000, len = 128k
+ ram1 (wx) : org = 0x00000000, len = 0
+ ram2 (wx) : org = 0x00000000, len = 0
+ ram3 (wx) : org = 0x00000000, len = 0
+ ram4 (wx) : org = 0x00000000, len = 0
+ ram5 (wx) : org = 0x00000000, len = 0
+ ram6 (wx) : org = 0x00000000, len = 0
+ ram7 (wx) : org = 0x00000000, len = 0
+}
+
+/* For each data/text section two region are defined, a virtual region
+ and a load region (_LMA suffix).*/
+
+/* Flash region to be used for exception vectors.*/
+REGION_ALIAS("VECTORS_FLASH", flash0);
+REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
+
+/* Flash region to be used for constructors and destructors.*/
+REGION_ALIAS("XTORS_FLASH", flash0);
+REGION_ALIAS("XTORS_FLASH_LMA", flash0);
+
+/* Flash region to be used for code text.*/
+REGION_ALIAS("TEXT_FLASH", flash0);
+REGION_ALIAS("TEXT_FLASH_LMA", flash0);
+
+/* Flash region to be used for read only data.*/
+REGION_ALIAS("RODATA_FLASH", flash0);
+REGION_ALIAS("RODATA_FLASH_LMA", flash0);
+
+/* Flash region to be used for various.*/
+REGION_ALIAS("VARIOUS_FLASH", flash0);
+REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
+
+/* Flash region to be used for RAM(n) initialization data.*/
+REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
+
+/* RAM region to be used for Main stack. This stack accommodates the processing
+ of all exceptions and interrupts.*/
+REGION_ALIAS("MAIN_STACK_RAM", ram0);
+
+/* RAM region to be used for the process stack. This is the stack used by
+ the main() function.*/
+REGION_ALIAS("PROCESS_STACK_RAM", ram0);
+
+/* RAM region to be used for data segment.*/
+REGION_ALIAS("DATA_RAM", ram0);
+REGION_ALIAS("DATA_RAM_LMA", flash0);
+
+/* RAM region to be used for BSS segment.*/
+REGION_ALIAS("BSS_RAM", ram0);
+
+/* RAM region to be used for the default heap.*/
+REGION_ALIAS("HEAP_RAM", ram0);
+
+/* Generic rules inclusion.*/
+INCLUDE rules.ld
+
+/* TinyUF2 bootloader reset support */
+_board_dfu_dbl_tap = ORIGIN(ram0) + 64k - 4; /* this is based off the linker file for tinyuf2 */
+
diff --git a/platforms/chibios/BLACKPILL_STM32_F411/ld/STM32F411xE_tinyuf2.ld b/platforms/chibios/BLACKPILL_STM32_F411/ld/STM32F411xE_tinyuf2.ld
new file mode 100644
index 000000000000..1656c67bf75c
--- /dev/null
+++ b/platforms/chibios/BLACKPILL_STM32_F411/ld/STM32F411xE_tinyuf2.ld
@@ -0,0 +1,89 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * STM32F411xE memory setup.
+ */
+MEMORY
+{
+ flash0 (rx) : org = 0x08000000 + 64k, len = 512k - 64k /* tinyuf2 bootloader requires app to be located at 64k offset for this MCU */
+ flash1 (rx) : org = 0x00000000, len = 0
+ flash2 (rx) : org = 0x00000000, len = 0
+ flash3 (rx) : org = 0x00000000, len = 0
+ flash4 (rx) : org = 0x00000000, len = 0
+ flash5 (rx) : org = 0x00000000, len = 0
+ flash6 (rx) : org = 0x00000000, len = 0
+ flash7 (rx) : org = 0x00000000, len = 0
+ ram0 (wx) : org = 0x20000000, len = 128k
+ ram1 (wx) : org = 0x00000000, len = 0
+ ram2 (wx) : org = 0x00000000, len = 0
+ ram3 (wx) : org = 0x00000000, len = 0
+ ram4 (wx) : org = 0x00000000, len = 0
+ ram5 (wx) : org = 0x00000000, len = 0
+ ram6 (wx) : org = 0x00000000, len = 0
+ ram7 (wx) : org = 0x00000000, len = 0
+}
+
+/* For each data/text section two region are defined, a virtual region
+ and a load region (_LMA suffix).*/
+
+/* Flash region to be used for exception vectors.*/
+REGION_ALIAS("VECTORS_FLASH", flash0);
+REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
+
+/* Flash region to be used for constructors and destructors.*/
+REGION_ALIAS("XTORS_FLASH", flash0);
+REGION_ALIAS("XTORS_FLASH_LMA", flash0);
+
+/* Flash region to be used for code text.*/
+REGION_ALIAS("TEXT_FLASH", flash0);
+REGION_ALIAS("TEXT_FLASH_LMA", flash0);
+
+/* Flash region to be used for read only data.*/
+REGION_ALIAS("RODATA_FLASH", flash0);
+REGION_ALIAS("RODATA_FLASH_LMA", flash0);
+
+/* Flash region to be used for various.*/
+REGION_ALIAS("VARIOUS_FLASH", flash0);
+REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
+
+/* Flash region to be used for RAM(n) initialization data.*/
+REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
+
+/* RAM region to be used for Main stack. This stack accommodates the processing
+ of all exceptions and interrupts.*/
+REGION_ALIAS("MAIN_STACK_RAM", ram0);
+
+/* RAM region to be used for the process stack. This is the stack used by
+ the main() function.*/
+REGION_ALIAS("PROCESS_STACK_RAM", ram0);
+
+/* RAM region to be used for data segment.*/
+REGION_ALIAS("DATA_RAM", ram0);
+REGION_ALIAS("DATA_RAM_LMA", flash0);
+
+/* RAM region to be used for BSS segment.*/
+REGION_ALIAS("BSS_RAM", ram0);
+
+/* RAM region to be used for the default heap.*/
+REGION_ALIAS("HEAP_RAM", ram0);
+
+/* Generic rules inclusion.*/
+INCLUDE rules.ld
+
+/* TinyUF2 bootloader reset support */
+_board_dfu_dbl_tap = ORIGIN(ram0) + 64k - 4; /* this is based off the linker file for tinyuf2 */
+
diff --git a/platforms/chibios/GENERIC_STM32_F446XE/board/board.mk b/platforms/chibios/GENERIC_STM32_F446XE/board/board.mk
new file mode 100644
index 000000000000..57897941caa9
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_F446XE/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F446RE/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F446RE
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/GENERIC_STM32_F446XE/configs/board.h b/platforms/chibios/GENERIC_STM32_F446XE/configs/board.h
new file mode 100644
index 000000000000..80dfcffa991b
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_F446XE/configs/board.h
@@ -0,0 +1,24 @@
+/* Copyright 2020 Nick Brassel (tzarc)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#define STM32_HSECLK 16000000
+// The following is required to disable the pull-down on PA9, when PA9 is used for the keyboard matrix:
+#define BOARD_OTG_NOVBUSSENS
+
+#include_next "board.h"
+
+#undef STM32_HSE_BYPASS
diff --git a/platforms/chibios/GENERIC_STM32_F446XE/configs/config.h b/platforms/chibios/GENERIC_STM32_F446XE/configs/config.h
new file mode 100644
index 000000000000..cc52a953ed4d
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_F446XE/configs/config.h
@@ -0,0 +1,23 @@
+/* Copyright 2021 Andrei Purdea
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/* Address for jumping to bootloader on STM32 chips. */
+/* It is chip dependent, the correct number can be looked up by checking against ST's application note AN2606.
+ */
+#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
+#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
+# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
+#endif
diff --git a/platforms/chibios/GENERIC_STM32_F446XE/configs/mcuconf.h b/platforms/chibios/GENERIC_STM32_F446XE/configs/mcuconf.h
new file mode 100644
index 000000000000..d2de75590ed7
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_F446XE/configs/mcuconf.h
@@ -0,0 +1,361 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+/*
+ * STM32F4xx drivers configuration.
+ * The following settings override the default settings present in
+ * the various device driver implementation headers.
+ * Note that the settings for each driver only have effect if the whole
+ * driver is enabled in halconf.h.
+ *
+ * IRQ priorities:
+ * 15...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...3 Lowest...Highest.
+ */
+
+#define STM32F4xx_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+#define STM32_NO_INIT FALSE
+#define STM32_HSI_ENABLED FALSE
+#define STM32_LSI_ENABLED TRUE
+#define STM32_HSE_ENABLED TRUE
+#define STM32_LSE_ENABLED FALSE
+#define STM32_CLOCK48_REQUIRED TRUE
+#define STM32_SW STM32_SW_PLL
+#define STM32_PLLSRC STM32_PLLSRC_HSE
+#define STM32_PLLM_VALUE 8
+#define STM32_PLLN_VALUE 180
+#define STM32_PLLP_VALUE 2
+#define STM32_PLLQ_VALUE 7
+#define STM32_PLLI2SN_VALUE 192
+#define STM32_PLLI2SM_VALUE 8
+#define STM32_PLLI2SR_VALUE 4
+#define STM32_PLLI2SP_VALUE 4
+#define STM32_PLLI2SQ_VALUE 4
+#define STM32_PLLSAIN_VALUE 192
+#define STM32_PLLSAIM_VALUE 8
+#define STM32_PLLSAIP_VALUE 8
+#define STM32_PLLSAIQ_VALUE 4
+#define STM32_HPRE STM32_HPRE_DIV1
+#define STM32_PPRE1 STM32_PPRE1_DIV4
+#define STM32_PPRE2 STM32_PPRE2_DIV2
+#define STM32_RTCSEL STM32_RTCSEL_LSI
+#define STM32_RTCPRE_VALUE 8
+#define STM32_MCO1SEL STM32_MCO1SEL_HSE
+#define STM32_MCO1PRE STM32_MCO1PRE_DIV1
+#define STM32_MCO2SEL STM32_MCO2SEL_PLLI2S
+#define STM32_MCO2PRE STM32_MCO2PRE_DIV1
+#define STM32_I2SSRC STM32_I2SSRC_PLLI2S
+#define STM32_SAI1SEL STM32_SAI2SEL_PLLR
+#define STM32_SAI2SEL STM32_SAI2SEL_PLLR
+#define STM32_CK48MSEL STM32_CK48MSEL_PLLALT
+#define STM32_PVD_ENABLE FALSE
+#define STM32_PLS STM32_PLS_LEV0
+#define STM32_BKPRAM_ENABLE FALSE
+
+/*
+ * IRQ system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY 6
+#define STM32_IRQ_EXTI1_PRIORITY 6
+#define STM32_IRQ_EXTI2_PRIORITY 6
+#define STM32_IRQ_EXTI3_PRIORITY 6
+#define STM32_IRQ_EXTI4_PRIORITY 6
+#define STM32_IRQ_EXTI5_9_PRIORITY 6
+#define STM32_IRQ_EXTI10_15_PRIORITY 6
+#define STM32_IRQ_EXTI16_PRIORITY 6
+#define STM32_IRQ_EXTI17_PRIORITY 15
+#define STM32_IRQ_EXTI18_PRIORITY 6
+#define STM32_IRQ_EXTI19_PRIORITY 6
+#define STM32_IRQ_EXTI20_PRIORITY 6
+#define STM32_IRQ_EXTI21_PRIORITY 15
+#define STM32_IRQ_EXTI22_PRIORITY 15
+
+/*
+ * ADC driver system settings.
+ */
+#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
+#define STM32_ADC_USE_ADC1 FALSE
+#define STM32_ADC_USE_ADC2 FALSE
+#define STM32_ADC_USE_ADC3 FALSE
+#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
+#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
+#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
+#define STM32_ADC_ADC1_DMA_PRIORITY 2
+#define STM32_ADC_ADC2_DMA_PRIORITY 2
+#define STM32_ADC_ADC3_DMA_PRIORITY 2
+#define STM32_ADC_IRQ_PRIORITY 6
+#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6
+#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 6
+#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 6
+
+/*
+ * CAN driver system settings.
+ */
+#define STM32_CAN_USE_CAN1 FALSE
+#define STM32_CAN_USE_CAN2 FALSE
+#define STM32_CAN_CAN1_IRQ_PRIORITY 11
+#define STM32_CAN_CAN2_IRQ_PRIORITY 11
+
+/*
+ * DAC driver system settings.
+ */
+#define STM32_DAC_DUAL_MODE FALSE
+#define STM32_DAC_USE_DAC1_CH1 FALSE
+#define STM32_DAC_USE_DAC1_CH2 FALSE
+#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
+#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
+
+/*
+ * GPT driver system settings.
+ */
+#define STM32_GPT_USE_TIM1 FALSE
+#define STM32_GPT_USE_TIM2 FALSE
+#define STM32_GPT_USE_TIM3 FALSE
+#define STM32_GPT_USE_TIM4 FALSE
+#define STM32_GPT_USE_TIM5 FALSE
+#define STM32_GPT_USE_TIM6 FALSE
+#define STM32_GPT_USE_TIM7 FALSE
+#define STM32_GPT_USE_TIM8 FALSE
+#define STM32_GPT_USE_TIM9 FALSE
+#define STM32_GPT_USE_TIM11 FALSE
+#define STM32_GPT_USE_TIM12 FALSE
+#define STM32_GPT_USE_TIM14 FALSE
+#define STM32_GPT_TIM1_IRQ_PRIORITY 7
+#define STM32_GPT_TIM2_IRQ_PRIORITY 7
+#define STM32_GPT_TIM3_IRQ_PRIORITY 7
+#define STM32_GPT_TIM4_IRQ_PRIORITY 7
+#define STM32_GPT_TIM5_IRQ_PRIORITY 7
+#define STM32_GPT_TIM6_IRQ_PRIORITY 7
+#define STM32_GPT_TIM7_IRQ_PRIORITY 7
+#define STM32_GPT_TIM8_IRQ_PRIORITY 7
+#define STM32_GPT_TIM9_IRQ_PRIORITY 7
+#define STM32_GPT_TIM11_IRQ_PRIORITY 7
+#define STM32_GPT_TIM12_IRQ_PRIORITY 7
+#define STM32_GPT_TIM14_IRQ_PRIORITY 7
+
+/*
+ * I2C driver system settings.
+ */
+#define STM32_I2C_USE_I2C1 FALSE
+#define STM32_I2C_USE_I2C2 FALSE
+#define STM32_I2C_USE_I2C3 FALSE
+#define STM32_I2C_BUSY_TIMEOUT 50
+#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
+#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
+#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
+#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
+#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_I2C_I2C1_IRQ_PRIORITY 5
+#define STM32_I2C_I2C2_IRQ_PRIORITY 5
+#define STM32_I2C_I2C3_IRQ_PRIORITY 5
+#define STM32_I2C_I2C1_DMA_PRIORITY 3
+#define STM32_I2C_I2C2_DMA_PRIORITY 3
+#define STM32_I2C_I2C3_DMA_PRIORITY 3
+#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
+
+/*
+ * I2S driver system settings.
+ */
+#define STM32_I2S_USE_SPI2 FALSE
+#define STM32_I2S_USE_SPI3 FALSE
+#define STM32_I2S_SPI2_IRQ_PRIORITY 10
+#define STM32_I2S_SPI3_IRQ_PRIORITY 10
+#define STM32_I2S_SPI2_DMA_PRIORITY 1
+#define STM32_I2S_SPI3_DMA_PRIORITY 1
+#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
+#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
+#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure")
+
+/*
+ * ICU driver system settings.
+ */
+#define STM32_ICU_USE_TIM1 FALSE
+#define STM32_ICU_USE_TIM2 FALSE
+#define STM32_ICU_USE_TIM3 FALSE
+#define STM32_ICU_USE_TIM4 FALSE
+#define STM32_ICU_USE_TIM5 FALSE
+#define STM32_ICU_USE_TIM8 FALSE
+#define STM32_ICU_USE_TIM9 FALSE
+#define STM32_ICU_TIM1_IRQ_PRIORITY 7
+#define STM32_ICU_TIM2_IRQ_PRIORITY 7
+#define STM32_ICU_TIM3_IRQ_PRIORITY 7
+#define STM32_ICU_TIM4_IRQ_PRIORITY 7
+#define STM32_ICU_TIM5_IRQ_PRIORITY 7
+#define STM32_ICU_TIM8_IRQ_PRIORITY 7
+#define STM32_ICU_TIM9_IRQ_PRIORITY 7
+
+/*
+ * MAC driver system settings.
+ */
+#define STM32_MAC_TRANSMIT_BUFFERS 2
+#define STM32_MAC_RECEIVE_BUFFERS 4
+#define STM32_MAC_BUFFERS_SIZE 1522
+#define STM32_MAC_PHY_TIMEOUT 100
+#define STM32_MAC_ETH1_CHANGE_PHY_STATE TRUE
+#define STM32_MAC_ETH1_IRQ_PRIORITY 13
+#define STM32_MAC_IP_CHECKSUM_OFFLOAD 0
+
+/*
+ * PWM driver system settings.
+ */
+#define STM32_PWM_USE_ADVANCED FALSE
+#define STM32_PWM_USE_TIM1 FALSE
+#define STM32_PWM_USE_TIM2 FALSE
+#define STM32_PWM_USE_TIM3 FALSE
+#define STM32_PWM_USE_TIM4 FALSE
+#define STM32_PWM_USE_TIM5 FALSE
+#define STM32_PWM_USE_TIM8 FALSE
+#define STM32_PWM_USE_TIM9 FALSE
+#define STM32_PWM_TIM1_IRQ_PRIORITY 7
+#define STM32_PWM_TIM2_IRQ_PRIORITY 7
+#define STM32_PWM_TIM3_IRQ_PRIORITY 7
+#define STM32_PWM_TIM4_IRQ_PRIORITY 7
+#define STM32_PWM_TIM5_IRQ_PRIORITY 7
+#define STM32_PWM_TIM8_IRQ_PRIORITY 7
+#define STM32_PWM_TIM9_IRQ_PRIORITY 7
+
+/*
+ * SDC driver system settings.
+ */
+#define STM32_SDC_SDIO_DMA_PRIORITY 3
+#define STM32_SDC_SDIO_IRQ_PRIORITY 9
+#define STM32_SDC_WRITE_TIMEOUT_MS 1000
+#define STM32_SDC_READ_TIMEOUT_MS 1000
+#define STM32_SDC_CLOCK_ACTIVATION_DELAY 10
+#define STM32_SDC_SDIO_UNALIGNED_SUPPORT TRUE
+#define STM32_SDC_SDIO_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
+
+/*
+ * SERIAL driver system settings.
+ */
+#define STM32_SERIAL_USE_USART1 FALSE
+#define STM32_SERIAL_USE_USART2 FALSE
+#define STM32_SERIAL_USE_USART3 FALSE
+#define STM32_SERIAL_USE_UART4 FALSE
+#define STM32_SERIAL_USE_UART5 FALSE
+#define STM32_SERIAL_USE_USART6 FALSE
+#define STM32_SERIAL_USE_UART7 FALSE
+#define STM32_SERIAL_USE_UART8 FALSE
+#define STM32_SERIAL_USART1_PRIORITY 12
+#define STM32_SERIAL_USART2_PRIORITY 12
+#define STM32_SERIAL_USART3_PRIORITY 12
+#define STM32_SERIAL_UART4_PRIORITY 12
+#define STM32_SERIAL_UART5_PRIORITY 12
+#define STM32_SERIAL_USART6_PRIORITY 12
+#define STM32_SERIAL_UART7_PRIORITY 12
+#define STM32_SERIAL_UART8_PRIORITY 12
+
+/*
+ * SPI driver system settings.
+ */
+#define STM32_SPI_USE_SPI1 FALSE
+#define STM32_SPI_USE_SPI2 FALSE
+#define STM32_SPI_USE_SPI3 FALSE
+#define STM32_SPI_USE_SPI4 FALSE
+#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
+#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
+#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
+#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
+#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_SPI_SPI4_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
+#define STM32_SPI_SPI4_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
+#define STM32_SPI_SPI1_DMA_PRIORITY 1
+#define STM32_SPI_SPI2_DMA_PRIORITY 1
+#define STM32_SPI_SPI3_DMA_PRIORITY 1
+#define STM32_SPI_SPI4_DMA_PRIORITY 1
+#define STM32_SPI_SPI1_IRQ_PRIORITY 10
+#define STM32_SPI_SPI2_IRQ_PRIORITY 10
+#define STM32_SPI_SPI3_IRQ_PRIORITY 10
+#define STM32_SPI_SPI4_IRQ_PRIORITY 10
+#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
+
+/*
+ * ST driver system settings.
+ */
+#define STM32_ST_IRQ_PRIORITY 8
+#define STM32_ST_USE_TIMER 2
+
+/*
+ * UART driver system settings.
+ */
+#define STM32_UART_USE_USART1 FALSE
+#define STM32_UART_USE_USART2 FALSE
+#define STM32_UART_USE_USART3 FALSE
+#define STM32_UART_USE_UART4 FALSE
+#define STM32_UART_USE_UART5 FALSE
+#define STM32_UART_USE_USART6 FALSE
+#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
+#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
+#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
+#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
+#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
+#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
+#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
+#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
+#define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
+#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
+#define STM32_UART_USART1_IRQ_PRIORITY 12
+#define STM32_UART_USART2_IRQ_PRIORITY 12
+#define STM32_UART_USART3_IRQ_PRIORITY 12
+#define STM32_UART_UART4_IRQ_PRIORITY 12
+#define STM32_UART_UART5_IRQ_PRIORITY 12
+#define STM32_UART_USART6_IRQ_PRIORITY 12
+#define STM32_UART_USART1_DMA_PRIORITY 0
+#define STM32_UART_USART2_DMA_PRIORITY 0
+#define STM32_UART_USART3_DMA_PRIORITY 0
+#define STM32_UART_UART4_DMA_PRIORITY 0
+#define STM32_UART_UART5_DMA_PRIORITY 0
+#define STM32_UART_USART6_DMA_PRIORITY 0
+#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
+
+/*
+ * USB driver system settings.
+ */
+#define STM32_USB_USE_OTG1 TRUE
+#define STM32_USB_USE_OTG2 FALSE
+#define STM32_USB_OTG1_IRQ_PRIORITY 14
+#define STM32_USB_OTG2_IRQ_PRIORITY 14
+#define STM32_USB_OTG1_RX_FIFO_SIZE 512
+#define STM32_USB_OTG2_RX_FIFO_SIZE 1024
+#define STM32_USB_OTG_THREAD_PRIO LOWPRIO
+#define STM32_USB_OTG_THREAD_STACK_SIZE 128
+#define STM32_USB_OTGFIFO_FILL_BASEPRI 0
+
+/*
+ * WDG driver system settings.
+ */
+#define STM32_WDG_USE_IWDG FALSE
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/GENERIC_STM32_L433XC/board/board.mk b/platforms/chibios/GENERIC_STM32_L433XC/board/board.mk
new file mode 100644
index 000000000000..1250385eb8e2
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_L433XC/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/GENERIC_STM32_L433XC/configs/board.h b/platforms/chibios/GENERIC_STM32_L433XC/configs/board.h
new file mode 100644
index 000000000000..51f9724f942a
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_L433XC/configs/board.h
@@ -0,0 +1,24 @@
+/* Copyright 2018-2021 Harrison Chan (@Xelus)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#include_next "board.h"
+
+#undef STM32L432xx
+
+// Pretend that we're an L443xx as the ChibiOS definitions for L432/L433 mistakenly don't enable GPIOH, I2C2, or SPI2.
+// Until ChibiOS upstream is fixed, this should be kept at L443, as nothing in QMK currently utilises the crypto peripheral on the L443.
+#define STM32L443xx
diff --git a/platforms/chibios/GENERIC_STM32_L433XC/configs/config.h b/platforms/chibios/GENERIC_STM32_L433XC/configs/config.h
new file mode 100644
index 000000000000..c27c61b19aa4
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_L433XC/configs/config.h
@@ -0,0 +1,26 @@
+/* Copyright 2018-2021 Harrison Chan (@Xelus)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/* Address for jumping to bootloader on STM32 chips. */
+/* It is chip dependent, the correct number can be looked up by checking against ST's application note AN2606.
+ */
+#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
+
+#define PAL_STM32_OSPEED_HIGHEST PAL_STM32_OSPEED_HIGH
+
+#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
+# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
+#endif
diff --git a/platforms/chibios/GENERIC_STM32_L433XC/configs/mcuconf.h b/platforms/chibios/GENERIC_STM32_L433XC/configs/mcuconf.h
new file mode 100644
index 000000000000..948c740f6e2b
--- /dev/null
+++ b/platforms/chibios/GENERIC_STM32_L433XC/configs/mcuconf.h
@@ -0,0 +1,292 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * STM32L4xx drivers configuration.
+ * The following settings override the default settings present in
+ * the various device driver implementation headers.
+ * Note that the settings for each driver only have effect if the whole
+ * driver is enabled in halconf.h.
+ *
+ * IRQ priorities:
+ * 15...0 Lowest...Highest.
+ *
+ * DMA priorities:
+ * 0...3 Lowest...Highest.
+ */
+
+#ifndef MCUCONF_H
+#define MCUCONF_H
+
+#define STM32L4xx_MCUCONF
+#define STM32L443_MCUCONF
+
+/*
+ * HAL driver system settings.
+ */
+#define STM32_NO_INIT FALSE
+#define STM32_VOS STM32_VOS_RANGE1
+#define STM32_PVD_ENABLE FALSE
+#define STM32_PLS STM32_PLS_LEV0
+#define STM32_HSI16_ENABLED TRUE
+#define STM32_HSI48_ENABLED TRUE
+#define STM32_LSI_ENABLED TRUE
+#define STM32_HSE_ENABLED FALSE
+#define STM32_LSE_ENABLED FALSE
+#define STM32_MSIPLL_ENABLED FALSE
+#define STM32_MSIRANGE STM32_MSIRANGE_4M
+#define STM32_MSISRANGE STM32_MSISRANGE_4M
+#define STM32_SW STM32_SW_PLL
+#define STM32_PLLSRC STM32_PLLSRC_HSI16
+#define STM32_PLLM_VALUE 1
+#define STM32_PLLN_VALUE 10
+#define STM32_PLLPDIV_VALUE 0
+#define STM32_PLLP_VALUE 7
+#define STM32_PLLQ_VALUE 2
+#define STM32_PLLR_VALUE 2
+#define STM32_HPRE STM32_HPRE_DIV1
+#define STM32_PPRE1 STM32_PPRE1_DIV1
+#define STM32_PPRE2 STM32_PPRE2_DIV1
+#define STM32_STOPWUCK STM32_STOPWUCK_MSI
+#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
+#define STM32_MCOPRE STM32_MCOPRE_DIV1
+#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
+#define STM32_PLLSAI1N_VALUE 24
+#define STM32_PLLSAI1PDIV_VALUE 0
+#define STM32_PLLSAI1P_VALUE 7
+#define STM32_PLLSAI1Q_VALUE 2
+#define STM32_PLLSAI1R_VALUE 2
+
+/*
+ * Peripherals clock sources.
+ */
+#define STM32_USART1SEL STM32_USART1SEL_SYSCLK
+#define STM32_USART2SEL STM32_USART2SEL_SYSCLK
+#define STM32_USART3SEL STM32_USART3SEL_SYSCLK
+#define STM32_LPUART1SEL STM32_LPUART1SEL_SYSCLK
+#define STM32_I2C1SEL STM32_I2C1SEL_SYSCLK
+#define STM32_I2C2SEL STM32_I2C2SEL_SYSCLK
+#define STM32_I2C3SEL STM32_I2C3SEL_SYSCLK
+#define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK1
+#define STM32_LPTIM2SEL STM32_LPTIM2SEL_PCLK1
+#define STM32_SAI1SEL STM32_SAI1SEL_OFF
+#define STM32_CLK48SEL STM32_CLK48SEL_HSI48
+#define STM32_ADCSEL STM32_ADCSEL_SYSCLK
+#define STM32_SWPMI1SEL STM32_SWPMI1SEL_PCLK1
+#define STM32_RTCSEL STM32_RTCSEL_LSI
+
+/*
+ * IRQ system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY 6
+#define STM32_IRQ_EXTI1_PRIORITY 6
+#define STM32_IRQ_EXTI2_PRIORITY 6
+#define STM32_IRQ_EXTI3_PRIORITY 6
+#define STM32_IRQ_EXTI4_PRIORITY 6
+#define STM32_IRQ_EXTI5_9_PRIORITY 6
+#define STM32_IRQ_EXTI10_15_PRIORITY 6
+#define STM32_IRQ_EXTI1635_38_PRIORITY 6
+#define STM32_IRQ_EXTI18_PRIORITY 6
+#define STM32_IRQ_EXTI19_PRIORITY 6
+#define STM32_IRQ_EXTI20_PRIORITY 6
+#define STM32_IRQ_EXTI21_22_PRIORITY 15
+
+#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
+#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
+#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
+#define STM32_IRQ_TIM1_CC_PRIORITY 7
+#define STM32_IRQ_TIM2_PRIORITY 7
+#define STM32_IRQ_TIM6_PRIORITY 7
+#define STM32_IRQ_TIM7_PRIORITY 7
+
+#define STM32_IRQ_USART1_PRIORITY 12
+#define STM32_IRQ_USART2_PRIORITY 12
+#define STM32_IRQ_USART3_PRIORITY 12
+#define STM32_IRQ_LPUART1_PRIORITY 12
+
+/*
+ * ADC driver system settings.
+ */
+#define STM32_ADC_COMPACT_SAMPLES FALSE
+#define STM32_ADC_USE_ADC1 FALSE
+#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
+#define STM32_ADC_ADC1_DMA_PRIORITY 2
+#define STM32_ADC_ADC12_IRQ_PRIORITY 5
+#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
+#define STM32_ADC_ADC123_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
+#define STM32_ADC_ADC123_PRESC ADC_CCR_PRESC_DIV2
+
+/*
+ * CAN driver system settings.
+ */
+#define STM32_CAN_USE_CAN1 FALSE
+#define STM32_CAN_CAN1_IRQ_PRIORITY 11
+
+/*
+ * DAC driver system settings.
+ */
+#define STM32_DAC_DUAL_MODE FALSE
+#define STM32_DAC_USE_DAC1_CH1 FALSE
+#define STM32_DAC_USE_DAC1_CH2 FALSE
+#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
+#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
+#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
+#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+
+/*
+ * GPT driver system settings.
+ */
+#define STM32_GPT_USE_TIM1 FALSE
+#define STM32_GPT_USE_TIM2 FALSE
+#define STM32_GPT_USE_TIM6 FALSE
+#define STM32_GPT_USE_TIM7 FALSE
+#define STM32_GPT_USE_TIM15 FALSE
+#define STM32_GPT_USE_TIM16 FALSE
+
+/*
+ * I2C driver system settings.
+ */
+#define STM32_I2C_USE_I2C1 FALSE
+#define STM32_I2C_USE_I2C2 FALSE
+#define STM32_I2C_USE_I2C3 FALSE
+#define STM32_I2C_BUSY_TIMEOUT 50
+#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
+#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
+#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
+#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
+#define STM32_I2C_I2C1_IRQ_PRIORITY 5
+#define STM32_I2C_I2C2_IRQ_PRIORITY 5
+#define STM32_I2C_I2C3_IRQ_PRIORITY 5
+#define STM32_I2C_I2C1_DMA_PRIORITY 3
+#define STM32_I2C_I2C2_DMA_PRIORITY 3
+#define STM32_I2C_I2C3_DMA_PRIORITY 3
+#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
+
+/*
+ * ICU driver system settings.
+ */
+#define STM32_ICU_USE_TIM1 FALSE
+#define STM32_ICU_USE_TIM2 FALSE
+#define STM32_ICU_USE_TIM15 FALSE
+#define STM32_ICU_USE_TIM16 FALSE
+
+/*
+ * PWM driver system settings.
+ */
+#define STM32_PWM_USE_ADVANCED FALSE
+#define STM32_PWM_USE_TIM1 FALSE
+#define STM32_PWM_USE_TIM2 FALSE
+#define STM32_PWM_USE_TIM15 FALSE
+#define STM32_PWM_USE_TIM16 FALSE
+
+/*
+ * RTC driver system settings.
+ */
+#define STM32_RTC_PRESA_VALUE 32
+#define STM32_RTC_PRESS_VALUE 1024
+#define STM32_RTC_CR_INIT 0
+#define STM32_RTC_TAMPCR_INIT 0
+
+/*
+ * SDMMC drive system settings.
+ */
+#define STM32_SDC_USE_SDMMC1 FALSE
+#define STM32_SDC_SDMMC_UNALIGNED_SUPPORT TRUE
+#define STM32_SDC_SDMMC_WRITE_TIMEOUT 1000
+#define STM32_SDC_SDMMC_READ_TIMEOUT 1000
+#define STM32_SDC_SDMMC_CLOCK_DELAY 10
+#define STM32_SDC_SDMMC1_DMA_PRIORITY 3
+#define STM32_SDC_SDMMC1_IRQ_PRIORITY 9
+#define STM32_SDC_SDMMC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
+
+/*
+ * SERIAL driver system settings.
+ */
+#define STM32_SERIAL_USE_USART1 FALSE
+#define STM32_SERIAL_USE_USART2 FALSE
+#define STM32_SERIAL_USE_USART3 FALSE
+#define STM32_SERIAL_USE_LPUART1 FALSE
+#define STM32_SERIAL_USART1_PRIORITY 12
+#define STM32_SERIAL_USART2_PRIORITY 12
+#define STM32_SERIAL_USART3_PRIORITY 12
+#define STM32_SERIAL_LPUART1_PRIORITY 12
+
+/*
+ * SPI driver system settings.
+ */
+#define STM32_SPI_USE_SPI1 FALSE
+#define STM32_SPI_USE_SPI2 FALSE
+#define STM32_SPI_USE_SPI3 FALSE
+#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
+#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
+#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
+#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
+#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
+#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
+#define STM32_SPI_SPI1_DMA_PRIORITY 1
+#define STM32_SPI_SPI2_DMA_PRIORITY 1
+#define STM32_SPI_SPI3_DMA_PRIORITY 1
+#define STM32_SPI_SPI1_IRQ_PRIORITY 10
+#define STM32_SPI_SPI2_IRQ_PRIORITY 10
+#define STM32_SPI_SPI3_IRQ_PRIORITY 10
+#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
+
+/*
+ * ST driver system settings.
+ */
+#define STM32_ST_IRQ_PRIORITY 8
+#define STM32_ST_USE_TIMER 2
+
+/*
+ * TRNG driver system settings.
+ */
+#define STM32_TRNG_USE_RNG1 FALSE
+
+/*
+ * UART driver system settings.
+ */
+#define STM32_UART_USE_USART1 FALSE
+#define STM32_UART_USE_USART2 FALSE
+#define STM32_UART_USE_USART3 FALSE
+#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
+#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 6)
+#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
+#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
+#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
+#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
+#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
+
+/*
+ * USB driver system settings.
+ */
+#define STM32_USB_USE_USB1 TRUE
+#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
+#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
+
+/*
+ * WDG driver system settings.
+ */
+#define STM32_WDG_USE_IWDG FALSE
+
+/*
+ * WSPI driver system settings.
+ */
+#define STM32_WSPI_USE_QUADSPI1 FALSE
+#define STM32_WSPI_QUADSPI1_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
+
+#endif /* MCUCONF_H */
diff --git a/platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk b/platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk
index 3fa73a96e03a..d0a337bad7fe 100644
--- a/platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk
+++ b/platforms/chibios/QMK_PROTON_C/convert_to_proton_c.mk
@@ -5,8 +5,5 @@ BOARD := QMK_PROTON_C
OPT_DEFS += -DCONVERT_TO_PROTON_C
# These are defaults based on what has been implemented for ARM boards
-AUDIO_ENABLE = yes
-WS2812_DRIVER = bitbang
-
-# Force task driven PWM until ARM can provide automatic configuration
-BACKLIGHT_DRIVER = software
\ No newline at end of file
+AUDIO_ENABLE ?= yes
+WS2812_DRIVER ?= bitbang
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c
index 113beb832f61..dfb98419e6c9 100644
--- a/quantum/backlight/backlight.c
+++ b/quantum/backlight/backlight.c
@@ -17,11 +17,16 @@ along with this program. If not, see .
#include "quantum.h"
#include "backlight.h"
+#include "eeprom.h"
#include "eeconfig.h"
#include "debug.h"
backlight_config_t backlight_config;
+#ifndef BACKLIGHT_DEFAULT_LEVEL
+# define BACKLIGHT_DEFAULT_LEVEL BACKLIGHT_LEVELS
+#endif
+
#ifdef BACKLIGHT_BREATHING
// TODO: migrate to backlight_config_t
static uint8_t breathing_period = BREATHING_PERIOD;
@@ -35,6 +40,7 @@ void backlight_init(void) {
/* check signature */
if (!eeconfig_is_enabled()) {
eeconfig_init();
+ eeconfig_update_backlight_default();
}
backlight_config.raw = eeconfig_read_backlight();
if (backlight_config.level > BACKLIGHT_LEVELS) {
@@ -152,11 +158,23 @@ void backlight_level(uint8_t level) {
eeconfig_update_backlight(backlight_config.raw);
}
-/** \brief Update current backlight state to EEPROM
- *
- */
+uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
+
+void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
+
void eeconfig_update_backlight_current(void) { eeconfig_update_backlight(backlight_config.raw); }
+void eeconfig_update_backlight_default(void) {
+ backlight_config.enable = 1;
+#ifdef BACKLIGHT_DEFAULT_BREATHING
+ backlight_config.breathing = 1;
+#else
+ backlight_config.breathing = 0;
+#endif
+ backlight_config.level = BACKLIGHT_DEFAULT_LEVEL;
+ eeconfig_update_backlight(backlight_config.raw);
+}
+
/** \brief Get backlight level
*
* FIXME: needs doc
diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h
index 3e506737d44b..c30c70fd6266 100644
--- a/quantum/backlight/backlight.h
+++ b/quantum/backlight/backlight.h
@@ -55,7 +55,11 @@ void backlight_decrease(void);
void backlight_level_noeeprom(uint8_t level);
void backlight_level(uint8_t level);
uint8_t get_backlight_level(void);
+
+uint8_t eeconfig_read_backlight(void);
+void eeconfig_update_backlight(uint8_t val);
void eeconfig_update_backlight_current(void);
+void eeconfig_update_backlight_default(void);
// implementation specific
void backlight_init_ports(void);
diff --git a/quantum/bootmagic/bootmagic.h b/quantum/bootmagic/bootmagic.h
new file mode 100644
index 000000000000..959750178d38
--- /dev/null
+++ b/quantum/bootmagic/bootmagic.h
@@ -0,0 +1,24 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#if defined(BOOTMAGIC_ENABLE)
+# include "bootmagic_full.h"
+#elif defined(BOOTMAGIC_LITE)
+# include "bootmagic_lite.h"
+#endif
+
+void bootmagic(void);
diff --git a/tmk_core/common/bootmagic.c b/quantum/bootmagic/bootmagic_full.c
similarity index 73%
rename from tmk_core/common/bootmagic.c
rename to quantum/bootmagic/bootmagic_full.c
index c1b3adf94df1..a7a0dcfcb2cb 100644
--- a/tmk_core/common/bootmagic.c
+++ b/quantum/bootmagic/bootmagic_full.c
@@ -1,3 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#include
#include
#include "wait.h"
@@ -10,18 +25,35 @@
#include "eeconfig.h"
#include "bootmagic.h"
-keymap_config_t keymap_config;
-
-/** \brief Bootmagic
+/** \brief Scan Keycode
*
* FIXME: needs doc
*/
-void bootmagic(void) {
- /* check signature */
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
+static bool scan_keycode(uint8_t keycode) {
+ for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
+ matrix_row_t matrix_row = matrix_get_row(r);
+ for (uint8_t c = 0; c < MATRIX_COLS; c++) {
+ if (matrix_row & ((matrix_row_t)1 << c)) {
+ if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) {
+ return true;
+ }
+ }
+ }
}
+ return false;
+}
+
+/** \brief Bootmagic Scan Keycode
+ *
+ * FIXME: needs doc
+ */
+static bool bootmagic_scan_keycode(uint8_t keycode) {
+ if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false;
+
+ return scan_keycode(keycode);
+}
+void bootmagic(void) {
/* do scans in case of bounce */
print("bootmagic scan: ... ");
uint8_t scan = 100;
@@ -46,8 +78,6 @@ void bootmagic(void) {
bootloader_jump();
}
- /* debug enable */
- debug_config.raw = eeconfig_read_debug();
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) {
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) {
debug_config.matrix = !debug_config.matrix;
@@ -61,8 +91,6 @@ void bootmagic(void) {
}
eeconfig_update_debug(debug_config.raw);
- /* keymap config */
- keymap_config.raw = eeconfig_read_keymap();
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) {
keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock;
}
@@ -93,71 +121,27 @@ void bootmagic(void) {
uint8_t default_layer = 0;
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) {
default_layer |= (1 << 0);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) {
default_layer |= (1 << 1);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) {
default_layer |= (1 << 2);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) {
default_layer |= (1 << 3);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) {
default_layer |= (1 << 4);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) {
default_layer |= (1 << 5);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) {
default_layer |= (1 << 6);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) {
default_layer |= (1 << 7);
}
- if (default_layer) {
- eeconfig_update_default_layer(default_layer);
- default_layer_set((layer_state_t)default_layer);
- } else {
- default_layer = eeconfig_read_default_layer();
- default_layer_set((layer_state_t)default_layer);
- }
- /* Also initialize layer state to trigger callback functions for layer_state */
- layer_state_set_kb((layer_state_t)layer_state);
+ eeconfig_update_default_layer(default_layer);
/* EE_HANDS handedness */
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) {
eeconfig_update_handedness(true);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) {
eeconfig_update_handedness(false);
}
}
-
-/** \brief Scan Keycode
- *
- * FIXME: needs doc
- */
-static bool scan_keycode(uint8_t keycode) {
- for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
- matrix_row_t matrix_row = matrix_get_row(r);
- for (uint8_t c = 0; c < MATRIX_COLS; c++) {
- if (matrix_row & ((matrix_row_t)1 << c)) {
- if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) {
- return true;
- }
- }
- }
- }
- return false;
-}
-
-/** \brief Bootmagic Scan Keycode
- *
- * FIXME: needs doc
- */
-bool bootmagic_scan_keycode(uint8_t keycode) {
- if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false;
-
- return scan_keycode(keycode);
-}
diff --git a/tmk_core/common/bootmagic.h b/quantum/bootmagic/bootmagic_full.h
similarity index 79%
rename from tmk_core/common/bootmagic.h
rename to quantum/bootmagic/bootmagic_full.h
index 8209d0194f6c..28f914c1b638 100644
--- a/tmk_core/common/bootmagic.h
+++ b/quantum/bootmagic/bootmagic_full.h
@@ -1,3 +1,19 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
#pragma once
/* FIXME: Add special doxygen comments for defines here. */
@@ -96,7 +112,4 @@
#endif
#ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_7
# define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7
-#endif
-
-void bootmagic(void);
-bool bootmagic_scan_keycode(uint8_t keycode);
+#endif
\ No newline at end of file
diff --git a/tmk_core/common/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c
similarity index 65%
rename from tmk_core/common/bootmagic_lite.c
rename to quantum/bootmagic/bootmagic_lite.c
index cbf756a1756b..9cbdcb0bbdfc 100644
--- a/tmk_core/common/bootmagic_lite.c
+++ b/quantum/bootmagic/bootmagic_lite.c
@@ -1,3 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#include "quantum.h"
/** \brief Reset eeprom
@@ -47,3 +62,5 @@ __attribute__((weak)) void bootmagic_lite(void) {
bootloader_jump();
}
}
+
+void bootmagic(void) { bootmagic_lite(); }
diff --git a/quantum/bootmagic/bootmagic_lite.h b/quantum/bootmagic/bootmagic_lite.h
new file mode 100644
index 000000000000..17777e6b4a53
--- /dev/null
+++ b/quantum/bootmagic/bootmagic_lite.h
@@ -0,0 +1,25 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#ifndef BOOTMAGIC_LITE_COLUMN
+# define BOOTMAGIC_LITE_COLUMN 0
+#endif
+#ifndef BOOTMAGIC_LITE_ROW
+# define BOOTMAGIC_LITE_ROW 0
+#endif
+
+void bootmagic_lite(void);
diff --git a/quantum/bootmagic/magic.c b/quantum/bootmagic/magic.c
new file mode 100644
index 000000000000..f1cb11c39576
--- /dev/null
+++ b/quantum/bootmagic/magic.c
@@ -0,0 +1,54 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include
+#include
+#include "wait.h"
+#include "matrix.h"
+#include "bootloader.h"
+#include "debug.h"
+#include "keymap.h"
+#include "host.h"
+#include "action_layer.h"
+#include "eeconfig.h"
+#include "bootmagic.h"
+
+keymap_config_t keymap_config;
+
+__attribute__((weak)) void bootmagic(void) {}
+
+/** \brief Magic
+ *
+ * FIXME: Needs doc
+ */
+void magic(void) {
+ /* check signature */
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+
+ /* init globals */
+ debug_config.raw = eeconfig_read_debug();
+ keymap_config.raw = eeconfig_read_keymap();
+
+ bootmagic();
+
+ /* read here just incase bootmagic process changed its value */
+ layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer();
+ default_layer_set(default_layer);
+
+ /* Also initialize layer state to trigger callback functions for layer_state */
+ layer_state_set_kb((layer_state_t)layer_state);
+}
diff --git a/quantum/bootmagic/magic.h b/quantum/bootmagic/magic.h
new file mode 100644
index 000000000000..2c3969b85ca5
--- /dev/null
+++ b/quantum/bootmagic/magic.h
@@ -0,0 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+void magic(void);
diff --git a/quantum/config_common.h b/quantum/config_common.h
index d93477b27e03..661609ef2ae2 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -24,4 +24,7 @@
#define COL2ROW 0
#define ROW2COL 1
+// Deprecated alias - avoid using
+#define KEYMAP LAYOUT
+
#include "song_list.h"
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 2ed64c1e3074..c30bf01cb2f6 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -59,9 +59,9 @@ static uint8_t thisHand, thatHand;
static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0};
#endif
-__attribute__((weak)) void encoder_update_user(int8_t index, bool clockwise) {}
+__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; }
-__attribute__((weak)) void encoder_update_kb(int8_t index, bool clockwise) { encoder_update_user(index, clockwise); }
+__attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); }
void encoder_init(void) {
#if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT)
@@ -94,14 +94,14 @@ void encoder_init(void) {
#endif
}
-static bool encoder_update(int8_t index, uint8_t state) {
+static bool encoder_update(uint8_t index, uint8_t state) {
bool changed = false;
uint8_t i = index;
#ifdef ENCODER_RESOLUTIONS
- int8_t resolution = encoder_resolutions[i];
+ uint8_t resolution = encoder_resolutions[i];
#else
- int8_t resolution = ENCODER_RESOLUTION;
+ uint8_t resolution = ENCODER_RESOLUTION;
#endif
#ifdef SPLIT_KEYBOARD
diff --git a/quantum/encoder.h b/quantum/encoder.h
index db6f220da4a4..25dc77721da9 100644
--- a/quantum/encoder.h
+++ b/quantum/encoder.h
@@ -22,8 +22,8 @@
void encoder_init(void);
bool encoder_read(void);
-void encoder_update_kb(int8_t index, bool clockwise);
-void encoder_update_user(int8_t index, bool clockwise);
+bool encoder_update_kb(uint8_t index, bool clockwise);
+bool encoder_update_user(uint8_t index, bool clockwise);
#ifdef SPLIT_KEYBOARD
void encoder_state_raw(uint8_t* slave_state);
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h
index f878168c5fb4..d7e334fdc8fa 100644
--- a/quantum/keycode_config.h
+++ b/quantum/keycode_config.h
@@ -37,6 +37,7 @@ typedef union {
bool nkro : 1;
bool swap_lctl_lgui : 1;
bool swap_rctl_rgui : 1;
+ bool oneshot_disable : 1;
};
} keymap_config_t;
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c
index 4f1f06c7ac23..d612fbfa9da8 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -17,79 +17,143 @@
* along with this program. If not, see .
*/
-#include
-#include
-#include "quantum.h"
#include "led_matrix.h"
#include "progmem.h"
#include "config.h"
#include "eeprom.h"
#include
#include
+#include "led_tables.h"
-led_eeconfig_t led_matrix_eeconfig;
+#include
-#ifndef MAX
-# define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+#ifndef LED_MATRIX_CENTER
+const led_point_t k_led_matrix_center = {112, 32};
+#else
+const led_point_t k_led_matrix_center = LED_MATRIX_CENTER;
#endif
-#ifndef MIN
-# define MIN(a, b) ((a) < (b) ? (a) : (b))
+// Generic effect runners
+#include "led_matrix_runners/effect_runner_dx_dy_dist.h"
+#include "led_matrix_runners/effect_runner_dx_dy.h"
+#include "led_matrix_runners/effect_runner_i.h"
+#include "led_matrix_runners/effect_runner_sin_cos_i.h"
+#include "led_matrix_runners/effect_runner_reactive.h"
+#include "led_matrix_runners/effect_runner_reactive_splash.h"
+
+// ------------------------------------------
+// -----Begin led effect includes macros-----
+#define LED_MATRIX_EFFECT(name)
+#define LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+#include "led_matrix_animations/led_matrix_effects.inc"
+#ifdef LED_MATRIX_CUSTOM_KB
+# include "led_matrix_kb.inc"
#endif
+#ifdef LED_MATRIX_CUSTOM_USER
+# include "led_matrix_user.inc"
+#endif
+
+#undef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#undef LED_MATRIX_EFFECT
+// -----End led effect includes macros-------
+// ------------------------------------------
-#ifndef LED_DISABLE_AFTER_TIMEOUT
-# define LED_DISABLE_AFTER_TIMEOUT 0
+#if defined(LED_DISABLE_AFTER_TIMEOUT) && !defined(LED_DISABLE_TIMEOUT)
+# define LED_DISABLE_TIMEOUT (LED_DISABLE_AFTER_TIMEOUT * 1200UL)
#endif
-#ifndef LED_DISABLE_WHEN_USB_SUSPENDED
-# define LED_DISABLE_WHEN_USB_SUSPENDED false
+#ifndef LED_DISABLE_TIMEOUT
+# define LED_DISABLE_TIMEOUT 0
#endif
-#ifndef EECONFIG_LED_MATRIX
-# define EECONFIG_LED_MATRIX EECONFIG_RGBLIGHT
+#if LED_DISABLE_WHEN_USB_SUSPENDED == false
+# undef LED_DISABLE_WHEN_USB_SUSPENDED
#endif
-#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > 255
-# define LED_MATRIX_MAXIMUM_BRIGHTNESS 255
+#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
+# undef LED_MATRIX_MAXIMUM_BRIGHTNESS
+# define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
#endif
-bool g_suspend_state = false;
+#if !defined(LED_MATRIX_VAL_STEP)
+# define LED_MATRIX_VAL_STEP 8
+#endif
-// Global tick at 20 Hz
-uint32_t g_tick = 0;
+#if !defined(LED_MATRIX_SPD_STEP)
+# define LED_MATRIX_SPD_STEP 16
+#endif
-// Ticks since this key was last hit.
-uint8_t g_key_hit[DRIVER_LED_TOTAL];
+#if !defined(LED_MATRIX_STARTUP_MODE)
+# define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID
+#endif
-// Ticks since any key was last hit.
-uint32_t g_any_key_hit = 0;
+#if !defined(LED_MATRIX_STARTUP_VAL)
+# define LED_MATRIX_STARTUP_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS
+#endif
-uint32_t eeconfig_read_led_matrix(void) { return eeprom_read_dword(EECONFIG_LED_MATRIX); }
+#if !defined(LED_MATRIX_STARTUP_SPD)
+# define LED_MATRIX_STARTUP_SPD UINT8_MAX / 2
+#endif
-void eeconfig_update_led_matrix(uint32_t config_value) { eeprom_update_dword(EECONFIG_LED_MATRIX, config_value); }
+// globals
+led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
+uint32_t g_led_timer;
+#ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS
+uint8_t g_led_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
+#endif // LED_MATRIX_FRAMEBUFFER_EFFECTS
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+last_hit_t g_last_hit_tracker;
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
+
+// internals
+static bool suspend_state = false;
+static uint8_t led_last_enable = UINT8_MAX;
+static uint8_t led_last_effect = UINT8_MAX;
+static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false};
+static led_task_states led_task_state = SYNCING;
+#if LED_DISABLE_TIMEOUT > 0
+static uint32_t led_anykey_timer;
+#endif // LED_DISABLE_TIMEOUT > 0
+
+// double buffers
+static uint32_t led_timer_buffer;
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+static last_hit_t last_hit_buffer;
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
+
+// split led matrix
+#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT;
+#endif
+
+void eeconfig_read_led_matrix(void) { eeprom_read_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); }
+
+void eeconfig_update_led_matrix(void) { eeprom_update_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); }
void eeconfig_update_led_matrix_default(void) {
dprintf("eeconfig_update_led_matrix_default\n");
led_matrix_eeconfig.enable = 1;
- led_matrix_eeconfig.mode = LED_MATRIX_UNIFORM_BRIGHTNESS;
- led_matrix_eeconfig.val = 128;
- led_matrix_eeconfig.speed = 0;
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
+ led_matrix_eeconfig.mode = LED_MATRIX_STARTUP_MODE;
+ led_matrix_eeconfig.val = LED_MATRIX_STARTUP_VAL;
+ led_matrix_eeconfig.speed = LED_MATRIX_STARTUP_SPD;
+ led_matrix_eeconfig.flags = LED_FLAG_ALL;
+ eeconfig_update_led_matrix();
}
void eeconfig_debug_led_matrix(void) {
- dprintf("led_matrix_eeconfig eeprom\n");
+ dprintf("led_matrix_eeconfig EEPROM\n");
dprintf("led_matrix_eeconfig.enable = %d\n", led_matrix_eeconfig.enable);
dprintf("led_matrix_eeconfig.mode = %d\n", led_matrix_eeconfig.mode);
dprintf("led_matrix_eeconfig.val = %d\n", led_matrix_eeconfig.val);
dprintf("led_matrix_eeconfig.speed = %d\n", led_matrix_eeconfig.speed);
+ dprintf("led_matrix_eeconfig.flags = %d\n", led_matrix_eeconfig.flags);
}
-uint8_t g_last_led_hit[LED_HITS_TO_REMEMBER] = {255};
-uint8_t g_last_led_count = 0;
+__attribute__((weak)) uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; }
-uint8_t map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
- uint8_t led_count = 0;
+uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
+ uint8_t led_count = led_matrix_map_row_column_to_led_kb(row, column, led_i);
uint8_t led_index = g_led_config.matrix_co[row][column];
if (led_index != NO_LED) {
led_i[led_count] = led_index;
@@ -100,88 +164,235 @@ uint8_t map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
void led_matrix_update_pwm_buffers(void) { led_matrix_driver.flush(); }
-void led_matrix_set_index_value(int index, uint8_t value) { led_matrix_driver.set_value(index, value); }
-
-void led_matrix_set_index_value_all(uint8_t value) { led_matrix_driver.set_value_all(value); }
-
-bool process_led_matrix(uint16_t keycode, keyrecord_t *record) {
- if (record->event.pressed) {
- uint8_t led[8];
- uint8_t led_count = map_row_column_to_led(record->event.key.row, record->event.key.col, led);
- if (led_count > 0) {
- for (uint8_t i = LED_HITS_TO_REMEMBER; i > 1; i--) {
- g_last_led_hit[i - 1] = g_last_led_hit[i - 2];
- }
- g_last_led_hit[0] = led[0];
- g_last_led_count = MIN(LED_HITS_TO_REMEMBER, g_last_led_count + 1);
- }
- for (uint8_t i = 0; i < led_count; i++) g_key_hit[led[i]] = 0;
- g_any_key_hit = 0;
- } else {
-#ifdef LED_MATRIX_KEYRELEASES
- uint8_t led[8];
- uint8_t led_count = map_row_column_to_led(record->event.key.row, record->event.key.col, led);
- for (uint8_t i = 0; i < led_count; i++) g_key_hit[led[i]] = 255;
+void led_matrix_set_value(int index, uint8_t value) {
+#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ if (!is_keyboard_left() && index >= k_led_matrix_split[0])
+# ifdef USE_CIE1931_CURVE
+ led_matrix_driver.set_value(index - k_led_matrix_split[0], pgm_read_byte(&CIE1931_CURVE[value]));
+# else
+ led_matrix_driver.set_value(index - k_led_matrix_split[0], value);
+# endif
+ else if (is_keyboard_left() && index < k_led_matrix_split[0])
+#endif
+#ifdef USE_CIE1931_CURVE
+ led_matrix_driver.set_value(index, pgm_read_byte(&CIE1931_CURVE[value]));
+#else
+ led_matrix_driver.set_value(index, value);
+#endif
+}
- g_any_key_hit = 255;
+void led_matrix_set_value_all(uint8_t value) {
+#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) led_matrix_set_value(i, value);
+#else
+# ifdef USE_CIE1931_CURVE
+ led_matrix_driver.set_value_all(pgm_read_byte(&CIE1931_CURVE[value]));
+# else
+ led_matrix_driver.set_value_all(value);
+# endif
#endif
- }
- return true;
}
-void led_matrix_set_suspend_state(bool state) { g_suspend_state = state; }
+void process_led_matrix(uint8_t row, uint8_t col, bool pressed) {
+#ifndef LED_MATRIX_SPLIT
+ if (!is_keyboard_master()) return;
+#endif
+#if LED_DISABLE_TIMEOUT > 0
+ led_anykey_timer = 0;
+#endif // LED_DISABLE_TIMEOUT > 0
-// All LEDs off
-void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); }
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+ uint8_t led[LED_HITS_TO_REMEMBER];
+ uint8_t led_count = 0;
-// Uniform brightness
-void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(LED_MATRIX_MAXIMUM_BRIGHTNESS / BACKLIGHT_LEVELS * led_matrix_eeconfig.val); }
+# if defined(LED_MATRIX_KEYRELEASES)
+ if (!pressed)
+# elif defined(LED_MATRIX_KEYPRESSES)
+ if (pressed)
+# endif // defined(LED_MATRIX_KEYRELEASES)
+ {
+ led_count = led_matrix_map_row_column_to_led(row, col, led);
+ }
-void led_matrix_custom(void) {}
+ if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) {
+ memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count);
+ memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count);
+ memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit
+ memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count);
+ last_hit_buffer.count--;
+ }
-void led_matrix_task(void) {
- if (!led_matrix_eeconfig.enable) {
- led_matrix_all_off();
- led_matrix_indicators();
- return;
+ for (uint8_t i = 0; i < led_count; i++) {
+ uint8_t index = last_hit_buffer.count;
+ last_hit_buffer.x[index] = g_led_config.point[led[i]].x;
+ last_hit_buffer.y[index] = g_led_config.point[led[i]].y;
+ last_hit_buffer.index[index] = led[i];
+ last_hit_buffer.tick[index] = 0;
+ last_hit_buffer.count++;
}
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
- g_tick++;
+#if defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_LED_MATRIX_TYPING_HEATMAP)
+ if (led_matrix_eeconfig.mode == LED_MATRIX_TYPING_HEATMAP) {
+ process_led_matrix_typing_heatmap(row, col);
+ }
+#endif // defined(LED_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_LED_MATRIX_TYPING_HEATMAP)
+}
- if (g_any_key_hit < 0xFFFFFFFF) {
- g_any_key_hit++;
+static bool led_matrix_none(effect_params_t *params) {
+ if (!params->init) {
+ return false;
}
- for (int led = 0; led < DRIVER_LED_TOTAL; led++) {
- if (g_key_hit[led] < 255) {
- if (g_key_hit[led] == 254) g_last_led_count = MAX(g_last_led_count - 1, 0);
- g_key_hit[led]++;
+ led_matrix_set_value_all(0);
+ return false;
+}
+
+static void led_task_timers(void) {
+#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0
+ uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer);
+#endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0
+ led_timer_buffer = sync_timer_read32();
+
+ // Update double buffer timers
+#if LED_DISABLE_TIMEOUT > 0
+ if (led_anykey_timer < UINT32_MAX) {
+ if (UINT32_MAX - deltaTime < led_anykey_timer) {
+ led_anykey_timer = UINT32_MAX;
+ } else {
+ led_anykey_timer += deltaTime;
}
}
+#endif // LED_DISABLE_TIMEOUT > 0
+
+ // Update double buffer last hit timers
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+ uint8_t count = last_hit_buffer.count;
+ for (uint8_t i = 0; i < count; ++i) {
+ if (UINT16_MAX - deltaTime < last_hit_buffer.tick[i]) {
+ last_hit_buffer.count--;
+ continue;
+ }
+ last_hit_buffer.tick[i] += deltaTime;
+ }
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
+}
- // Ideally we would also stop sending zeros to the LED driver PWM buffers
- // while suspended and just do a software shutdown. This is a cheap hack for now.
- bool suspend_backlight = ((g_suspend_state && LED_DISABLE_WHEN_USB_SUSPENDED) || (LED_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > LED_DISABLE_AFTER_TIMEOUT * 60 * 20));
- uint8_t effect = suspend_backlight ? 0 : led_matrix_eeconfig.mode;
+static void led_task_sync(void) {
+ // next task
+ if (sync_timer_elapsed32(g_led_timer) >= LED_MATRIX_LED_FLUSH_LIMIT) led_task_state = STARTING;
+}
+
+static void led_task_start(void) {
+ // reset iter
+ led_effect_params.iter = 0;
+
+ // update double buffers
+ g_led_timer = led_timer_buffer;
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+ g_last_hit_tracker = last_hit_buffer;
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
+
+ // next task
+ led_task_state = RENDERING;
+}
+
+static void led_task_render(uint8_t effect) {
+ bool rendering = false;
+ led_effect_params.init = (effect != led_last_effect) || (led_matrix_eeconfig.enable != led_last_enable);
+ if (led_effect_params.flags != led_matrix_eeconfig.flags) {
+ led_effect_params.flags = led_matrix_eeconfig.flags;
+ led_matrix_set_value_all(0);
+ }
- // this gets ticked at 20 Hz.
// each effect can opt to do calculations
// and/or request PWM buffer updates.
switch (effect) {
- case LED_MATRIX_UNIFORM_BRIGHTNESS:
- led_matrix_uniform_brightness();
+ case LED_MATRIX_NONE:
+ rendering = led_matrix_none(&led_effect_params);
break;
- default:
- led_matrix_custom();
+
+// ---------------------------------------------
+// -----Begin led effect switch case macros-----
+#define LED_MATRIX_EFFECT(name, ...) \
+ case LED_MATRIX_##name: \
+ rendering = name(&led_effect_params); \
+ break;
+#include "led_matrix_animations/led_matrix_effects.inc"
+#undef LED_MATRIX_EFFECT
+
+#if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER)
+# define LED_MATRIX_EFFECT(name, ...) \
+ case LED_MATRIX_CUSTOM_##name: \
+ rendering = name(&led_effect_params); \
break;
+# ifdef LED_MATRIX_CUSTOM_KB
+# include "led_matrix_kb.inc"
+# endif
+# ifdef LED_MATRIX_CUSTOM_USER
+# include "led_matrix_user.inc"
+# endif
+# undef LED_MATRIX_EFFECT
+#endif
+ // -----End led effect switch case macros-------
+ // ---------------------------------------------
}
- if (!suspend_backlight) {
- led_matrix_indicators();
+ led_effect_params.iter++;
+
+ // next task
+ if (!rendering) {
+ led_task_state = FLUSHING;
+ if (!led_effect_params.init && effect == LED_MATRIX_NONE) {
+ // We only need to flush once if we are LED_MATRIX_NONE
+ led_task_state = SYNCING;
+ }
}
+}
+
+static void led_task_flush(uint8_t effect) {
+ // update last trackers after the first full render so we can init over several frames
+ led_last_effect = effect;
+ led_last_enable = led_matrix_eeconfig.enable;
+
+ // update pwm buffers
+ led_matrix_update_pwm_buffers();
- // Tell the LED driver to update its state
- led_matrix_driver.flush();
+ // next task
+ led_task_state = SYNCING;
+}
+
+void led_matrix_task(void) {
+ led_task_timers();
+
+ // Ideally we would also stop sending zeros to the LED driver PWM buffers
+ // while suspended and just do a software shutdown. This is a cheap hack for now.
+ bool suspend_backlight = suspend_state ||
+#if LED_DISABLE_TIMEOUT > 0
+ (led_anykey_timer > (uint32_t)LED_DISABLE_TIMEOUT) ||
+#endif // LED_DISABLE_TIMEOUT > 0
+ false;
+
+ uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode;
+
+ switch (led_task_state) {
+ case STARTING:
+ led_task_start();
+ break;
+ case RENDERING:
+ led_task_render(effect);
+ if (effect) {
+ led_matrix_indicators();
+ led_matrix_indicators_advanced(&led_effect_params);
+ }
+ break;
+ case FLUSHING:
+ led_task_flush(effect);
+ break;
+ case SYNCING:
+ led_task_sync();
+ break;
+ }
}
void led_matrix_indicators(void) {
@@ -193,33 +404,42 @@ __attribute__((weak)) void led_matrix_indicators_kb(void) {}
__attribute__((weak)) void led_matrix_indicators_user(void) {}
-// void led_matrix_set_indicator_index(uint8_t *index, uint8_t row, uint8_t column)
-// {
-// if (row >= MATRIX_ROWS)
-// {
-// // Special value, 255=none, 254=all
-// *index = row;
-// }
-// else
-// {
-// // This needs updated to something like
-// // uint8_t led[8];
-// // uint8_t led_count = map_row_column_to_led(row, column, led);
-// // for(uint8_t i = 0; i < led_count; i++)
-// map_row_column_to_led(row, column, index);
-// }
-// }
+void led_matrix_indicators_advanced(effect_params_t *params) {
+ /* special handling is needed for "params->iter", since it's already been incremented.
+ * Could move the invocations to led_task_render, but then it's missing a few checks
+ * and not sure which would be better. Otherwise, this should be called from
+ * led_task_render, right before the iter++ line.
+ */
+#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL
+ uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * (params->iter - 1);
+ uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT;
+ if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL;
+#else
+ uint8_t min = 0;
+ uint8_t max = DRIVER_LED_TOTAL;
+#endif
+ led_matrix_indicators_advanced_kb(min, max);
+ led_matrix_indicators_advanced_user(min, max);
+}
+
+__attribute__((weak)) void led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {}
+
+__attribute__((weak)) void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {}
void led_matrix_init(void) {
led_matrix_driver.init();
- // Wait half a second for the driver to finish initializing
- wait_ms(500);
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+ g_last_hit_tracker.count = 0;
+ for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
+ g_last_hit_tracker.tick[i] = UINT16_MAX;
+ }
- // clear the key hits
- for (int led = 0; led < DRIVER_LED_TOTAL; led++) {
- g_key_hit[led] = 255;
+ last_hit_buffer.count = 0;
+ for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) {
+ last_hit_buffer.tick[i] = UINT16_MAX;
}
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
if (!eeconfig_is_enabled()) {
dprintf("led_matrix_init_drivers eeconfig is not enabled.\n");
@@ -227,122 +447,137 @@ void led_matrix_init(void) {
eeconfig_update_led_matrix_default();
}
- led_matrix_eeconfig.raw = eeconfig_read_led_matrix();
-
+ eeconfig_read_led_matrix();
if (!led_matrix_eeconfig.mode) {
dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n");
eeconfig_update_led_matrix_default();
- led_matrix_eeconfig.raw = eeconfig_read_led_matrix();
}
-
eeconfig_debug_led_matrix(); // display current eeprom values
}
-// Deals with the messy details of incrementing an integer
-static uint8_t increment(uint8_t value, uint8_t step, uint8_t min, uint8_t max) {
- int16_t new_value = value;
- new_value += step;
- return MIN(MAX(new_value, min), max);
+void led_matrix_set_suspend_state(bool state) {
+#ifdef LED_DISABLE_WHEN_USB_SUSPENDED
+ if (state) {
+ led_matrix_set_value_all(0); // turn off all LEDs when suspending
+ }
+ suspend_state = state;
+#endif
}
-static uint8_t decrement(uint8_t value, uint8_t step, uint8_t min, uint8_t max) {
- int16_t new_value = value;
- new_value -= step;
- return MIN(MAX(new_value, min), max);
-}
+bool led_matrix_get_suspend_state(void) { return suspend_state; }
-// void *backlight_get_custom_key_value_eeprom_address(uint8_t led) {
-// // 3 bytes per value
-// return EECONFIG_LED_MATRIX + (led * 3);
-// }
-
-// void backlight_get_key_value(uint8_t led, uint8_t *value) {
-// void *address = backlight_get_custom_key_value_eeprom_address(led);
-// value = eeprom_read_byte(address);
-// }
-
-// void backlight_set_key_value(uint8_t row, uint8_t column, uint8_t value) {
-// uint8_t led[8];
-// uint8_t led_count = map_row_column_to_led(row, column, led);
-// for(uint8_t i = 0; i < led_count; i++) {
-// if (led[i] < DRIVER_LED_TOTAL) {
-// void *address = backlight_get_custom_key_value_eeprom_address(led[i]);
-// eeprom_update_byte(address, value);
-// }
-// }
-// }
-
-uint32_t led_matrix_get_tick(void) { return g_tick; }
-
-void led_matrix_toggle(void) {
+void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
led_matrix_eeconfig.enable ^= 1;
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
+ led_task_state = STARTING;
+ if (write_to_eeprom) {
+ eeconfig_update_led_matrix();
+ }
+ dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable);
}
+void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); }
+void led_matrix_toggle(void) { led_matrix_toggle_eeprom_helper(true); }
void led_matrix_enable(void) {
- led_matrix_eeconfig.enable = 1;
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
+ led_matrix_enable_noeeprom();
+ eeconfig_update_led_matrix();
}
-void led_matrix_enable_noeeprom(void) { led_matrix_eeconfig.enable = 1; }
+void led_matrix_enable_noeeprom(void) {
+ if (!led_matrix_eeconfig.enable) led_task_state = STARTING;
+ led_matrix_eeconfig.enable = 1;
+}
void led_matrix_disable(void) {
+ led_matrix_disable_noeeprom();
+ eeconfig_update_led_matrix();
+}
+
+void led_matrix_disable_noeeprom(void) {
+ if (led_matrix_eeconfig.enable) led_task_state = STARTING;
led_matrix_eeconfig.enable = 0;
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
}
-void led_matrix_disable_noeeprom(void) { led_matrix_eeconfig.enable = 0; }
+uint8_t led_matrix_is_enabled(void) { return led_matrix_eeconfig.enable; }
-void led_matrix_step(void) {
- led_matrix_eeconfig.mode++;
- if (led_matrix_eeconfig.mode >= LED_MATRIX_EFFECT_MAX) {
- led_matrix_eeconfig.mode = 1;
+void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
+ if (!led_matrix_eeconfig.enable) {
+ return;
}
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
-}
-
-void led_matrix_step_reverse(void) {
- led_matrix_eeconfig.mode--;
- if (led_matrix_eeconfig.mode < 1) {
+ if (mode < 1) {
+ led_matrix_eeconfig.mode = 1;
+ } else if (mode >= LED_MATRIX_EFFECT_MAX) {
led_matrix_eeconfig.mode = LED_MATRIX_EFFECT_MAX - 1;
+ } else {
+ led_matrix_eeconfig.mode = mode;
+ }
+ led_task_state = STARTING;
+ if (write_to_eeprom) {
+ eeconfig_update_led_matrix();
}
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
+ dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode);
}
+void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); }
+void led_matrix_mode(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, true); }
-void led_matrix_increase_val(void) {
- led_matrix_eeconfig.val = increment(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS);
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
-}
+uint8_t led_matrix_get_mode(void) { return led_matrix_eeconfig.mode; }
-void led_matrix_decrease_val(void) {
- led_matrix_eeconfig.val = decrement(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS);
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
+void led_matrix_step_helper(bool write_to_eeprom) {
+ uint8_t mode = led_matrix_eeconfig.mode + 1;
+ led_matrix_mode_eeprom_helper((mode < LED_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom);
}
+void led_matrix_step_noeeprom(void) { led_matrix_step_helper(false); }
+void led_matrix_step(void) { led_matrix_step_helper(true); }
-void led_matrix_increase_speed(void) {
- led_matrix_eeconfig.speed = increment(led_matrix_eeconfig.speed, 1, 0, 3);
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw); // EECONFIG needs to be increased to support this
+void led_matrix_step_reverse_helper(bool write_to_eeprom) {
+ uint8_t mode = led_matrix_eeconfig.mode - 1;
+ led_matrix_mode_eeprom_helper((mode < 1) ? LED_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom);
}
+void led_matrix_step_reverse_noeeprom(void) { led_matrix_step_reverse_helper(false); }
+void led_matrix_step_reverse(void) { led_matrix_step_reverse_helper(true); }
-void led_matrix_decrease_speed(void) {
- led_matrix_eeconfig.speed = decrement(led_matrix_eeconfig.speed, 1, 0, 3);
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw); // EECONFIG needs to be increased to support this
+void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) {
+ if (!led_matrix_eeconfig.enable) {
+ return;
+ }
+ led_matrix_eeconfig.val = (val > LED_MATRIX_MAXIMUM_BRIGHTNESS) ? LED_MATRIX_MAXIMUM_BRIGHTNESS : val;
+ if (write_to_eeprom) {
+ eeconfig_update_led_matrix();
+ }
+ dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val);
}
+void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); }
+void led_matrix_set_val(uint8_t val) { led_matrix_set_val_eeprom_helper(val, true); }
-void led_matrix_mode(uint8_t mode, bool eeprom_write) {
- led_matrix_eeconfig.mode = mode;
- if (eeprom_write) {
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
+uint8_t led_matrix_get_val(void) { return led_matrix_eeconfig.val; }
+
+void led_matrix_increase_val_helper(bool write_to_eeprom) { led_matrix_set_val_eeprom_helper(qadd8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); }
+void led_matrix_increase_val_noeeprom(void) { led_matrix_increase_val_helper(false); }
+void led_matrix_increase_val(void) { led_matrix_increase_val_helper(true); }
+
+void led_matrix_decrease_val_helper(bool write_to_eeprom) { led_matrix_set_val_eeprom_helper(qsub8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); }
+void led_matrix_decrease_val_noeeprom(void) { led_matrix_decrease_val_helper(false); }
+void led_matrix_decrease_val(void) { led_matrix_decrease_val_helper(true); }
+
+void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) {
+ led_matrix_eeconfig.speed = speed;
+ if (write_to_eeprom) {
+ eeconfig_update_led_matrix();
}
+ dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed);
}
+void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); }
+void led_matrix_set_speed(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, true); }
-uint8_t led_matrix_get_mode(void) { return led_matrix_eeconfig.mode; }
+uint8_t led_matrix_get_speed(void) { return led_matrix_eeconfig.speed; }
-void led_matrix_set_value_noeeprom(uint8_t val) { led_matrix_eeconfig.val = val; }
+void led_matrix_increase_speed_helper(bool write_to_eeprom) { led_matrix_set_speed_eeprom_helper(qadd8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); }
+void led_matrix_increase_speed_noeeprom(void) { led_matrix_increase_speed_helper(false); }
+void led_matrix_increase_speed(void) { led_matrix_increase_speed_helper(true); }
-void led_matrix_set_value(uint8_t val) {
- led_matrix_set_value_noeeprom(val);
- eeconfig_update_led_matrix(led_matrix_eeconfig.raw);
-}
+void led_matrix_decrease_speed_helper(bool write_to_eeprom) { led_matrix_set_speed_eeprom_helper(qsub8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); }
+void led_matrix_decrease_speed_noeeprom(void) { led_matrix_decrease_speed_helper(false); }
+void led_matrix_decrease_speed(void) { led_matrix_decrease_speed_helper(true); }
+
+led_flags_t led_matrix_get_flags(void) { return led_matrix_eeconfig.flags; }
-void backlight_set(uint8_t val) { led_matrix_set_value(val); }
+void led_matrix_set_flags(led_flags_t flags) { led_matrix_eeconfig.flags = flags; }
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h
index 85bae43c15fa..0984de73b3a5 100644
--- a/quantum/led_matrix.h
+++ b/quantum/led_matrix.h
@@ -19,61 +19,120 @@
#pragma once
+#include
+#include
#include "led_matrix_types.h"
+#include "quantum.h"
-#ifndef BACKLIGHT_ENABLE
-# error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE
+#ifdef IS31FL3731
+# include "is31fl3731-simple.h"
#endif
+#ifndef LED_MATRIX_LED_FLUSH_LIMIT
+# define LED_MATRIX_LED_FLUSH_LIMIT 16
+#endif
+
+#ifndef LED_MATRIX_LED_PROCESS_LIMIT
+# define LED_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5
+#endif
+
+#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL
+# define LED_MATRIX_USE_LIMITS(min, max) \
+ uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \
+ uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \
+ if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL;
+#else
+# define LED_MATRIX_USE_LIMITS(min, max) \
+ uint8_t min = 0; \
+ uint8_t max = DRIVER_LED_TOTAL;
+#endif
+
+#define LED_MATRIX_TEST_LED_FLAGS() \
+ if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue
+
enum led_matrix_effects {
- LED_MATRIX_UNIFORM_BRIGHTNESS = 1,
- // All new effects go above this line
+ LED_MATRIX_NONE = 0,
+
+// --------------------------------------
+// -----Begin led effect enum macros-----
+#define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_##name,
+#include "led_matrix_animations/led_matrix_effects.inc"
+#undef LED_MATRIX_EFFECT
+
+#if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER)
+# define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_CUSTOM_##name,
+# ifdef LED_MATRIX_CUSTOM_KB
+# include "led_matrix_kb.inc"
+# endif
+# ifdef LED_MATRIX_CUSTOM_USER
+# include "led_matrix_user.inc"
+# endif
+# undef LED_MATRIX_EFFECT
+#endif
+ // --------------------------------------
+ // -----End led effect enum macros-------
+
LED_MATRIX_EFFECT_MAX
};
-void led_matrix_set_index_value(int index, uint8_t value);
-void led_matrix_set_index_value_all(uint8_t value);
+void eeconfig_update_led_matrix_default(void);
+void eeconfig_update_led_matrix(void);
+void eeconfig_debug_led_matrix(void);
+
+uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i);
+uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i);
+
+void led_matrix_set_value(int index, uint8_t value);
+void led_matrix_set_value_all(uint8_t value);
+
+void process_led_matrix(uint8_t row, uint8_t col, bool pressed);
+
+void led_matrix_task(void);
// This runs after another backlight effect and replaces
-// colors already set
+// values already set
void led_matrix_indicators(void);
void led_matrix_indicators_kb(void);
void led_matrix_indicators_user(void);
-void led_matrix_init(void);
-void led_matrix_setup_drivers(void);
-
-void led_matrix_set_suspend_state(bool state);
-void led_matrix_set_indicator_state(uint8_t state);
+void led_matrix_indicators_advanced(effect_params_t *params);
+void led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max);
+void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max);
-void led_matrix_task(void);
+void led_matrix_init(void);
-// This should not be called from an interrupt
-// (eg. from a timer interrupt).
-// Call this while idle (in between matrix scans).
-// If the buffer is dirty, it will update the driver with the buffer.
-void led_matrix_update_pwm_buffers(void);
-
-bool process_led_matrix(uint16_t keycode, keyrecord_t *record);
-
-uint32_t led_matrix_get_tick(void);
-
-void led_matrix_toggle(void);
-void led_matrix_enable(void);
-void led_matrix_enable_noeeprom(void);
-void led_matrix_disable(void);
-void led_matrix_disable_noeeprom(void);
-void led_matrix_step(void);
-void led_matrix_step_reverse(void);
-void led_matrix_increase_val(void);
-void led_matrix_decrease_val(void);
-void led_matrix_increase_speed(void);
-void led_matrix_decrease_speed(void);
-void led_matrix_mode(uint8_t mode, bool eeprom_write);
-void led_matrix_mode_noeeprom(uint8_t mode);
-uint8_t led_matrix_get_mode(void);
-void led_matrix_set_value(uint8_t mode);
-void led_matrix_set_value_noeeprom(uint8_t mode);
+void led_matrix_set_suspend_state(bool state);
+bool led_matrix_get_suspend_state(void);
+void led_matrix_toggle(void);
+void led_matrix_toggle_noeeprom(void);
+void led_matrix_enable(void);
+void led_matrix_enable_noeeprom(void);
+void led_matrix_disable(void);
+void led_matrix_disable_noeeprom(void);
+uint8_t led_matrix_is_enabled(void);
+void led_matrix_mode(uint8_t mode);
+void led_matrix_mode_noeeprom(uint8_t mode);
+uint8_t led_matrix_get_mode(void);
+void led_matrix_step(void);
+void led_matrix_step_noeeprom(void);
+void led_matrix_step_reverse(void);
+void led_matrix_step_reverse_noeeprom(void);
+void led_matrix_set_val(uint8_t val);
+void led_matrix_set_val_noeeprom(uint8_t val);
+uint8_t led_matrix_get_val(void);
+void led_matrix_increase_val(void);
+void led_matrix_increase_val_noeeprom(void);
+void led_matrix_decrease_val(void);
+void led_matrix_decrease_val_noeeprom(void);
+void led_matrix_set_speed(uint8_t speed);
+void led_matrix_set_speed_noeeprom(uint8_t speed);
+uint8_t led_matrix_get_speed(void);
+void led_matrix_increase_speed(void);
+void led_matrix_increase_speed_noeeprom(void);
+void led_matrix_decrease_speed(void);
+void led_matrix_decrease_speed_noeeprom(void);
+led_flags_t led_matrix_get_flags(void);
+void led_matrix_set_flags(led_flags_t flags);
typedef struct {
/* Perform any initialisation required for the other driver functions to work. */
@@ -91,4 +150,11 @@ extern const led_matrix_driver_t led_matrix_driver;
extern led_eeconfig_t led_matrix_eeconfig;
+extern uint32_t g_led_timer;
extern led_config_t g_led_config;
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+extern last_hit_t g_last_hit_tracker;
+#endif
+#ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS
+extern uint8_t g_led_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
+#endif
diff --git a/quantum/led_matrix_animations/alpha_mods_anim.h b/quantum/led_matrix_animations/alpha_mods_anim.h
new file mode 100644
index 000000000000..6f69f6892b25
--- /dev/null
+++ b/quantum/led_matrix_animations/alpha_mods_anim.h
@@ -0,0 +1,24 @@
+#ifndef DISABLE_LED_MATRIX_ALPHAS_MODS
+LED_MATRIX_EFFECT(ALPHAS_MODS)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+// alphas = val1, mods = val2
+bool ALPHAS_MODS(effect_params_t* params) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t val1 = led_matrix_eeconfig.val;
+ uint8_t val2 = val1 + led_matrix_eeconfig.speed;
+
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
+ led_matrix_set_value(i, val2);
+ } else {
+ led_matrix_set_value(i, val1);
+ }
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_ALPHAS_MODS
diff --git a/quantum/led_matrix_animations/band_anim.h b/quantum/led_matrix_animations/band_anim.h
new file mode 100644
index 000000000000..523dba1b78b0
--- /dev/null
+++ b/quantum/led_matrix_animations/band_anim.h
@@ -0,0 +1,13 @@
+#ifndef DISABLE_LED_MATRIX_BAND
+LED_MATRIX_EFFECT(BAND)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t BAND_math(uint8_t val, uint8_t i, uint8_t time) {
+ int16_t v = val - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
+ return scale8(v < 0 ? 0 : v, val);
+}
+
+bool BAND(effect_params_t* params) { return effect_runner_i(params, &BAND_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_BAND
diff --git a/quantum/led_matrix_animations/band_pinwheel_anim.h b/quantum/led_matrix_animations/band_pinwheel_anim.h
new file mode 100644
index 000000000000..fb3b835cad52
--- /dev/null
+++ b/quantum/led_matrix_animations/band_pinwheel_anim.h
@@ -0,0 +1,10 @@
+#ifndef DISABLE_LED_MATRIX_BAND_PINWHEEL
+LED_MATRIX_EFFECT(BAND_PINWHEEL)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t BAND_PINWHEEL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t time) { return scale8(val - time - atan2_8(dy, dx) * 3, val); }
+
+bool BAND_PINWHEEL(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_BAND_PINWHEEL
diff --git a/quantum/led_matrix_animations/band_spiral_anim.h b/quantum/led_matrix_animations/band_spiral_anim.h
new file mode 100644
index 000000000000..fca22aad9c81
--- /dev/null
+++ b/quantum/led_matrix_animations/band_spiral_anim.h
@@ -0,0 +1,10 @@
+#ifndef DISABLE_LED_MATRIX_BAND_SPIRAL
+LED_MATRIX_EFFECT(BAND_SPIRAL)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t BAND_SPIRAL_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { return scale8(val + dist - time - atan2_8(dy, dx), val); }
+
+bool BAND_SPIRAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_BAND_SPIRAL
diff --git a/quantum/led_matrix_animations/breathing_anim.h b/quantum/led_matrix_animations/breathing_anim.h
new file mode 100644
index 000000000000..00310e3f651a
--- /dev/null
+++ b/quantum/led_matrix_animations/breathing_anim.h
@@ -0,0 +1,19 @@
+#ifndef DISABLE_LED_MATRIX_BREATHING
+LED_MATRIX_EFFECT(BREATHING)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+bool BREATHING(effect_params_t* params) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t val = led_matrix_eeconfig.val;
+ uint16_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 8);
+ val = scale8(abs8(sin8(time) - 128) * 2, val);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ led_matrix_set_value(i, val);
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_BREATHING
diff --git a/quantum/led_matrix_animations/cycle_left_right_anim.h b/quantum/led_matrix_animations/cycle_left_right_anim.h
new file mode 100644
index 000000000000..51e81d57ca54
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_left_right_anim.h
@@ -0,0 +1,10 @@
+#ifndef DISABLE_LED_MATRIX_CYCLE_LEFT_RIGHT
+LED_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t CYCLE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(g_led_config.point[i].x - time, val); }
+
+bool CYCLE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_CYCLE_LEFT_RIGHT
diff --git a/quantum/led_matrix_animations/cycle_out_in_anim.h b/quantum/led_matrix_animations/cycle_out_in_anim.h
new file mode 100644
index 000000000000..f62061552c67
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_out_in_anim.h
@@ -0,0 +1,10 @@
+#ifndef DISABLE_LED_MATRIX_CYCLE_OUT_IN
+LED_MATRIX_EFFECT(CYCLE_OUT_IN)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t CYCLE_OUT_IN_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { return scale8(3 * dist / 2 + time, val); }
+
+bool CYCLE_OUT_IN(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_CYCLE_OUT_IN
diff --git a/quantum/led_matrix_animations/cycle_up_down_anim.h b/quantum/led_matrix_animations/cycle_up_down_anim.h
new file mode 100644
index 000000000000..bd1d12567235
--- /dev/null
+++ b/quantum/led_matrix_animations/cycle_up_down_anim.h
@@ -0,0 +1,10 @@
+#ifndef DISABLE_LED_MATRIX_CYCLE_UP_DOWN
+LED_MATRIX_EFFECT(CYCLE_UP_DOWN)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t CYCLE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(g_led_config.point[i].y - time, val); }
+
+bool CYCLE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &CYCLE_UP_DOWN_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_CYCLE_UP_DOWN
diff --git a/quantum/led_matrix_animations/dual_beacon_anim.h b/quantum/led_matrix_animations/dual_beacon_anim.h
new file mode 100644
index 000000000000..9b8a7877c916
--- /dev/null
+++ b/quantum/led_matrix_animations/dual_beacon_anim.h
@@ -0,0 +1,10 @@
+#ifndef DISABLE_LED_MATRIX_DUAL_BEACON
+LED_MATRIX_EFFECT(DUAL_BEACON)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t DUAL_BEACON_math(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { return scale8(((g_led_config.point[i].y - k_led_matrix_center.y) * cos + (g_led_config.point[i].x - k_led_matrix_center.x) * sin) / 128, val); }
+
+bool DUAL_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_DUAL_BEACON
diff --git a/quantum/led_matrix_animations/led_matrix_effects.inc b/quantum/led_matrix_animations/led_matrix_effects.inc
new file mode 100644
index 000000000000..67237c568358
--- /dev/null
+++ b/quantum/led_matrix_animations/led_matrix_effects.inc
@@ -0,0 +1,18 @@
+// Add your new core led matrix effect here, order determins enum order, requires "led_matrix_animations/ directory
+#include "led_matrix_animations/solid_anim.h"
+#include "led_matrix_animations/alpha_mods_anim.h"
+#include "led_matrix_animations/breathing_anim.h"
+#include "led_matrix_animations/band_anim.h"
+#include "led_matrix_animations/band_pinwheel_anim.h"
+#include "led_matrix_animations/band_spiral_anim.h"
+#include "led_matrix_animations/cycle_left_right_anim.h"
+#include "led_matrix_animations/cycle_up_down_anim.h"
+#include "led_matrix_animations/cycle_out_in_anim.h"
+#include "led_matrix_animations/dual_beacon_anim.h"
+#include "led_matrix_animations/solid_reactive_simple_anim.h"
+#include "led_matrix_animations/solid_reactive_wide.h"
+#include "led_matrix_animations/solid_reactive_cross.h"
+#include "led_matrix_animations/solid_reactive_nexus.h"
+#include "led_matrix_animations/solid_splash_anim.h"
+#include "led_matrix_animations/wave_left_right_anim.h"
+#include "led_matrix_animations/wave_up_down_anim.h"
diff --git a/quantum/led_matrix_animations/solid_anim.h b/quantum/led_matrix_animations/solid_anim.h
new file mode 100644
index 000000000000..4c9e43c581a3
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_anim.h
@@ -0,0 +1,15 @@
+LED_MATRIX_EFFECT(SOLID)
+#ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+bool SOLID(effect_params_t* params) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t val = led_matrix_eeconfig.val;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ led_matrix_set_value(i, val);
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/led_matrix_animations/solid_reactive_cross.h b/quantum/led_matrix_animations/solid_reactive_cross.h
new file mode 100644
index 000000000000..f402d99b3722
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_cross.h
@@ -0,0 +1,35 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS)
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
+LED_MATRIX_EFFECT(SOLID_REACTIVE_CROSS)
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
+LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS)
+# endif
+
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t SOLID_REACTIVE_CROSS_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+ uint16_t effect = tick + dist;
+ dx = dx < 0 ? dx * -1 : dx;
+ dy = dy < 0 ? dy * -1 : dy;
+ dx = dx * 16 > 255 ? 255 : dx * 16;
+ dy = dy * 16 > 255 ? 255 : dy * 16;
+ effect += dx > dy ? dy : dx;
+ if (effect > 255) effect = 255;
+ return qadd8(val, 255 - effect);
+}
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
+bool SOLID_REACTIVE_CROSS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); }
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
+bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); }
+# endif
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS)
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/solid_reactive_nexus.h b/quantum/led_matrix_animations/solid_reactive_nexus.h
new file mode 100644
index 000000000000..4d0d2522639c
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_nexus.h
@@ -0,0 +1,32 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS)
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
+LED_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS)
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
+LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS)
+# endif
+
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t SOLID_REACTIVE_NEXUS_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+ uint16_t effect = tick - dist;
+ if (effect > 255) effect = 255;
+ if (dist > 72) effect = 255;
+ if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255;
+ return qadd8(val, 255 - effect);
+}
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
+bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); }
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
+bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); }
+# endif
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS)
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/solid_reactive_simple_anim.h b/quantum/led_matrix_animations/solid_reactive_simple_anim.h
new file mode 100644
index 000000000000..30e2527f600e
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_simple_anim.h
@@ -0,0 +1,12 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
+LED_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t SOLID_REACTIVE_SIMPLE_math(uint8_t val, uint16_t offset) { return scale8(255 - offset, val); }
+
+bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // DISABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/solid_reactive_wide.h b/quantum/led_matrix_animations/solid_reactive_wide.h
new file mode 100644
index 000000000000..34a230c25931
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_reactive_wide.h
@@ -0,0 +1,30 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# if !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE)
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
+LED_MATRIX_EFFECT(SOLID_REACTIVE_WIDE)
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
+LED_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE)
+# endif
+
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t SOLID_REACTIVE_WIDE_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+ uint16_t effect = tick + dist * 5;
+ if (effect > 255) effect = 255;
+ return qadd8(val, 255 - effect);
+}
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
+bool SOLID_REACTIVE_WIDE(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); }
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
+bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); }
+# endif
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE)
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/solid_splash_anim.h b/quantum/led_matrix_animations/solid_splash_anim.h
new file mode 100644
index 000000000000..4f6ba3d343bf
--- /dev/null
+++ b/quantum/led_matrix_animations/solid_splash_anim.h
@@ -0,0 +1,30 @@
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+# if !defined(DISABLE_LED_MATRIX_SOLID_SPLASH) || !defined(DISABLE_LED_MATRIX_SOLID_MULTISPLASH)
+
+# ifndef DISABLE_LED_MATRIX_SOLID_SPLASH
+LED_MATRIX_EFFECT(SOLID_SPLASH)
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_MULTISPLASH
+LED_MATRIX_EFFECT(SOLID_MULTISPLASH)
+# endif
+
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+uint8_t SOLID_SPLASH_math(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
+ uint16_t effect = tick - dist;
+ if (effect > 255) effect = 255;
+ return qadd8(val, 255 - effect);
+}
+
+# ifndef DISABLE_LED_MATRIX_SOLID_SPLASH
+bool SOLID_SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); }
+# endif
+
+# ifndef DISABLE_LED_MATRIX_SOLID_MULTISPLASH
+bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); }
+# endif
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+# endif // !defined(DISABLE_LED_MATRIX_SPLASH) && !defined(DISABLE_LED_MATRIX_MULTISPLASH)
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_animations/wave_left_right_anim.h b/quantum/led_matrix_animations/wave_left_right_anim.h
new file mode 100644
index 000000000000..736f22ddc516
--- /dev/null
+++ b/quantum/led_matrix_animations/wave_left_right_anim.h
@@ -0,0 +1,10 @@
+#ifndef DISABLE_LED_MATRIX_WAVE_LEFT_RIGHT
+LED_MATRIX_EFFECT(WAVE_LEFT_RIGHT)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t WAVE_LEFT_RIGHT_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(sin8(g_led_config.point[i].x - time), val); }
+
+bool WAVE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &WAVE_LEFT_RIGHT_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_WAVE_LEFT_RIGHT
diff --git a/quantum/led_matrix_animations/wave_up_down_anim.h b/quantum/led_matrix_animations/wave_up_down_anim.h
new file mode 100644
index 000000000000..3cab0597d4f3
--- /dev/null
+++ b/quantum/led_matrix_animations/wave_up_down_anim.h
@@ -0,0 +1,10 @@
+#ifndef DISABLE_LED_MATRIX_WAVE_UP_DOWN
+LED_MATRIX_EFFECT(WAVE_UP_DOWN)
+# ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
+
+static uint8_t WAVE_UP_DOWN_math(uint8_t val, uint8_t i, uint8_t time) { return scale8(sin8(g_led_config.point[i].y - time), val); }
+
+bool WAVE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &WAVE_UP_DOWN_math); }
+
+# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // DISABLE_LED_MATRIX_WAVE_UP_DOWN
diff --git a/quantum/led_matrix_drivers.c b/quantum/led_matrix_drivers.c
index eddf3f28635d..1d46b2c50661 100644
--- a/quantum/led_matrix_drivers.c
+++ b/quantum/led_matrix_drivers.c
@@ -15,9 +15,6 @@
* along with this program. If not, see .
*/
-#include
-#include
-#include "quantum.h"
#include "led_matrix.h"
/* Each driver needs to define a struct:
@@ -30,10 +27,6 @@
#if defined(IS31FL3731) || defined(IS31FL3733)
-# if defined(IS31FL3731)
-# include "is31fl3731-simple.h"
-# endif
-
# include "i2c_master.h"
static void init(void) {
@@ -53,16 +46,28 @@ static void init(void) {
# endif
# else
# ifdef LED_DRIVER_ADDR_1
- IS31FL3733_init(LED_DRIVER_ADDR_1, 0);
+# ifndef LED_DRIVER_SYNC_1
+# define LED_DRIVER_SYNC_1 0
+# endif
+ IS31FL3733_init(LED_DRIVER_ADDR_1, LED_DRIVER_SYNC_1);
# endif
# ifdef LED_DRIVER_ADDR_2
- IS31FL3733_init(LED_DRIVER_ADDR_2, 0);
+# ifndef LED_DRIVER_SYNC_2
+# define LED_DRIVER_SYNC_2 0
+# endif
+ IS31FL3733_init(LED_DRIVER_ADDR_2, LED_DRIVER_SYNC_2);
# endif
# ifdef LED_DRIVER_ADDR_3
- IS31FL3733_init(LED_DRIVER_ADDR_3, 0);
+# ifndef LED_DRIVER_SYNC_3
+# define LED_DRIVER_SYNC_3 0
+# endif
+ IS31FL3733_init(LED_DRIVER_ADDR_3, LED_DRIVER_SYNC_3);
# endif
# ifdef LED_DRIVER_ADDR_4
- IS31FL3733_init(LED_DRIVER_ADDR_4, 0);
+# ifndef LED_DRIVER_SYNC_4
+# define LED_DRIVER_SYNC_4 0
+# endif
+ IS31FL3733_init(LED_DRIVER_ADDR_4, LED_DRIVER_SYNC_4);
# endif
# endif
diff --git a/quantum/led_matrix_runners/effect_runner_dx_dy.h b/quantum/led_matrix_runners/effect_runner_dx_dy.h
new file mode 100644
index 000000000000..ef97631b9089
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_dx_dy.h
@@ -0,0 +1,16 @@
+#pragma once
+
+typedef uint8_t (*dx_dy_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t time);
+
+bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 2);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ int16_t dx = g_led_config.point[i].x - k_led_matrix_center.x;
+ int16_t dy = g_led_config.point[i].y - k_led_matrix_center.y;
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, dx, dy, time));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
diff --git a/quantum/led_matrix_runners/effect_runner_dx_dy_dist.h b/quantum/led_matrix_runners/effect_runner_dx_dy_dist.h
new file mode 100644
index 000000000000..5ef5938be05d
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_dx_dy_dist.h
@@ -0,0 +1,17 @@
+#pragma once
+
+typedef uint8_t (*dx_dy_dist_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint8_t time);
+
+bool effect_runner_dx_dy_dist(effect_params_t* params, dx_dy_dist_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 2);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ int16_t dx = g_led_config.point[i].x - k_led_matrix_center.x;
+ int16_t dy = g_led_config.point[i].y - k_led_matrix_center.y;
+ uint8_t dist = sqrt16(dx * dx + dy * dy);
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, dx, dy, dist, time));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
diff --git a/quantum/led_matrix_runners/effect_runner_i.h b/quantum/led_matrix_runners/effect_runner_i.h
new file mode 100644
index 000000000000..b3015759be54
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_i.h
@@ -0,0 +1,14 @@
+#pragma once
+
+typedef uint8_t (*i_f)(uint8_t val, uint8_t i, uint8_t time);
+
+bool effect_runner_i(effect_params_t* params, i_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 4);
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, i, time));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
diff --git a/quantum/led_matrix_runners/effect_runner_reactive.h b/quantum/led_matrix_runners/effect_runner_reactive.h
new file mode 100644
index 000000000000..4369ea8c498a
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_reactive.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+
+typedef uint8_t (*reactive_f)(uint8_t val, uint16_t offset);
+
+bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint16_t max_tick = 65535 / led_matrix_eeconfig.speed;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ uint16_t tick = max_tick;
+ // Reverse search to find most recent key hit
+ for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) {
+ if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
+ tick = g_last_hit_tracker.tick[j];
+ break;
+ }
+ }
+
+ uint16_t offset = scale16by8(tick, led_matrix_eeconfig.speed);
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, offset));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_runners/effect_runner_reactive_splash.h b/quantum/led_matrix_runners/effect_runner_reactive_splash.h
new file mode 100644
index 000000000000..d6eb9731ee3a
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_reactive_splash.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+
+typedef uint8_t (*reactive_splash_f)(uint8_t val, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick);
+
+bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, reactive_splash_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t count = g_last_hit_tracker.count;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ uint8_t val = 0;
+ for (uint8_t j = start; j < count; j++) {
+ int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
+ int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
+ uint8_t dist = sqrt16(dx * dx + dy * dy);
+ uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], led_matrix_eeconfig.speed);
+ val = effect_func(val, dx, dy, dist, tick);
+ }
+ led_matrix_set_value(i, scale8(val, led_matrix_eeconfig.val));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
+
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/led_matrix_runners/effect_runner_sin_cos_i.h b/quantum/led_matrix_runners/effect_runner_sin_cos_i.h
new file mode 100644
index 000000000000..4a5219abd120
--- /dev/null
+++ b/quantum/led_matrix_runners/effect_runner_sin_cos_i.h
@@ -0,0 +1,16 @@
+#pragma once
+
+typedef uint8_t (*sin_cos_i_f)(uint8_t val, int8_t sin, int8_t cos, uint8_t i, uint8_t time);
+
+bool effect_runner_sin_cos_i(effect_params_t* params, sin_cos_i_f effect_func) {
+ LED_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint16_t time = scale16by8(g_led_timer, led_matrix_eeconfig.speed / 4);
+ int8_t cos_value = cos8(time) - 128;
+ int8_t sin_value = sin8(time) - 128;
+ for (uint8_t i = led_min; i < led_max; i++) {
+ LED_MATRIX_TEST_LED_FLAGS();
+ led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, cos_value, sin_value, i, time));
+ }
+ return led_max < DRIVER_LED_TOTAL;
+}
diff --git a/quantum/led_matrix_types.h b/quantum/led_matrix_types.h
index 669b67042ba9..61cdbd9b8e02 100644
--- a/quantum/led_matrix_types.h
+++ b/quantum/led_matrix_types.h
@@ -29,15 +29,42 @@
# pragma pack(push, 1)
#endif
+#if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES)
+# define LED_MATRIX_KEYREACTIVE_ENABLED
+#endif
+
// Last led hit
#ifndef LED_HITS_TO_REMEMBER
# define LED_HITS_TO_REMEMBER 8
#endif // LED_HITS_TO_REMEMBER
+#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
+typedef struct PACKED {
+ uint8_t count;
+ uint8_t x[LED_HITS_TO_REMEMBER];
+ uint8_t y[LED_HITS_TO_REMEMBER];
+ uint8_t index[LED_HITS_TO_REMEMBER];
+ uint16_t tick[LED_HITS_TO_REMEMBER];
+} last_hit_t;
+#endif // LED_MATRIX_KEYREACTIVE_ENABLED
+
+typedef enum led_task_states { STARTING, RENDERING, FLUSHING, SYNCING } led_task_states;
+
+typedef uint8_t led_flags_t;
+
+typedef struct PACKED {
+ uint8_t iter;
+ led_flags_t flags;
+ bool init;
+} effect_params_t;
+
typedef struct PACKED {
uint8_t x;
uint8_t y;
-} point_t;
+} led_point_t;
+
+#define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
+#define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00)
#define LED_FLAG_ALL 0xFF
#define LED_FLAG_NONE 0x00
@@ -48,19 +75,20 @@ typedef struct PACKED {
#define NO_LED 255
typedef struct PACKED {
- uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
- point_t point[DRIVER_LED_TOTAL];
- uint8_t flags[DRIVER_LED_TOTAL];
+ uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
+ led_point_t point[DRIVER_LED_TOTAL];
+ uint8_t flags[DRIVER_LED_TOTAL];
} led_config_t;
typedef union {
uint32_t raw;
struct PACKED {
- uint8_t enable : 2;
- uint8_t mode : 6;
- uint16_t reserved;
- uint8_t val;
- uint8_t speed; // EECONFIG needs to be increased to support this
+ uint8_t enable : 2;
+ uint8_t mode : 6;
+ uint16_t reserved;
+ uint8_t val;
+ uint8_t speed; // EECONFIG needs to be increased to support this
+ led_flags_t flags;
};
} led_eeconfig_t;
diff --git a/quantum/matrix.c b/quantum/matrix.c
index c027b7bf27a7..34d6af2e6df2 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -116,9 +116,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Unselect row
unselect_row(current_row);
- if (current_row + 1 < MATRIX_ROWS) {
- matrix_output_unselect_delay(); // wait for row signal to go HIGH
- }
+ matrix_output_unselect_delay(); // wait for all Col signals to go HIGH
// If the row has changed, store the row and return the changed flag.
if (current_matrix[current_row] != current_row_value) {
@@ -178,9 +176,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
// Unselect col
unselect_col(current_col);
- if (current_col + 1 < MATRIX_COLS) {
- matrix_output_unselect_delay(); // wait for col signal to go HIGH
- }
+ matrix_output_unselect_delay(); // wait for all Row signals to go HIGH
return matrix_changed;
}
diff --git a/quantum/matrix.h b/quantum/matrix.h
index ce57010a4754..3fe691aaee69 100644
--- a/quantum/matrix.h
+++ b/quantum/matrix.h
@@ -74,6 +74,11 @@ void matrix_scan_kb(void);
void matrix_init_user(void);
void matrix_scan_user(void);
+#ifdef SPLIT_KEYBOARD
+void matrix_slave_scan_kb(void);
+void matrix_slave_scan_user(void);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk
index f7329fc4d9fe..9268c4522e61 100644
--- a/quantum/mcu_selection.mk
+++ b/quantum/mcu_selection.mk
@@ -81,6 +81,33 @@ ifneq ($(findstring MK20DX256, $(MCU)),)
BOARD ?= PJRC_TEENSY_3_1
endif
+ifneq ($(findstring MK66F18, $(MCU)),)
+ # Cortex version
+ MCU = cortex-m4
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ ARMV = 7
+
+ ## chip/board settings
+ # - the next two should match the directories in
+ # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY = KINETIS
+ MCU_SERIES = MK66F18
+
+ # Linker script to use
+ # - it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or /ld/
+ MCU_LDSCRIPT ?= MK66FX1M0
+
+ # Startup code to use
+ # - it should exist in /os/common/startup/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP ?= MK66F18
+
+ # Board: it should exist either in /os/hal/boards/,
+ # /boards/, or drivers/boards/
+ BOARD ?= PJRC_TEENSY_3_6
+endif
+
ifneq ($(findstring STM32F042, $(MCU)),)
# Cortex version
MCU = cortex-m0
@@ -112,6 +139,9 @@ ifneq ($(findstring STM32F042, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32F0
endif
ifneq ($(findstring STM32F072, $(MCU)),)
@@ -145,6 +175,9 @@ ifneq ($(findstring STM32F072, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32F0
endif
ifneq ($(findstring STM32F103, $(MCU)),)
@@ -178,6 +211,9 @@ ifneq ($(findstring STM32F103, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32F1
endif
ifneq ($(findstring STM32F303, $(MCU)),)
@@ -211,6 +247,9 @@ ifneq ($(findstring STM32F303, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32F3
endif
ifneq ($(findstring STM32F401, $(MCU)),)
@@ -244,6 +283,9 @@ ifneq ($(findstring STM32F401, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32F4
endif
ifneq ($(findstring STM32F411, $(MCU)),)
@@ -262,7 +304,12 @@ ifneq ($(findstring STM32F411, $(MCU)),)
# Linker script to use
# - it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/
# or /ld/
- MCU_LDSCRIPT ?= STM32F411xE
+ ifeq ($(strip $(BOOTLOADER)), tinyuf2)
+ MCU_LDSCRIPT ?= STM32F411xE_tinyuf2
+ FIRMWARE_FORMAT ?= uf2
+ else
+ MCU_LDSCRIPT ?= STM32F411xE
+ endif
# Startup code to use
# - it should exist in /os/common/startup/ARMCMx/compilers/GCC/mk/
@@ -277,6 +324,43 @@ ifneq ($(findstring STM32F411, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32F4
+endif
+
+ifneq ($(findstring STM32F446, $(MCU)),)
+ # Cortex version
+ MCU = cortex-m4
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ ARMV = 7
+
+ ## chip/board settings
+ # - the next two should match the directories in
+ # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY = STM32
+ MCU_SERIES = STM32F4xx
+
+ # Linker script to use
+ # - it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or /os/common/startup/ARMCMx/compilers/GCC/ld/
+ # or /ld/
+ MCU_LDSCRIPT ?= STM32F446xE
+
+ # Startup code to use
+ # - it should exist in /os/common/startup/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP ?= stm32f4xx
+
+ # Board: it should exist either in /os/hal/boards/,
+ # /boards/, or drivers/boards/
+ BOARD ?= GENERIC_STM32_F446XE
+
+ USE_FPU ?= yes
+
+ # Options to pass to dfu-util when flashing
+ DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
+ DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
endif
ifneq ($(findstring STM32G431, $(MCU)),)
@@ -310,6 +394,9 @@ ifneq ($(findstring STM32G431, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32G4
endif
ifneq ($(findstring STM32G474, $(MCU)),)
@@ -343,6 +430,47 @@ ifneq ($(findstring STM32G474, $(MCU)),)
# Options to pass to dfu-util when flashing
DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32G4
+endif
+
+ifneq (,$(filter $(MCU),STM32L433 STM32L443))
+ # Cortex version
+ MCU = cortex-m4
+
+ # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
+ ARMV = 7
+
+ ## chip/board settings
+ # - the next two should match the directories in
+ # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
+ MCU_FAMILY = STM32
+ MCU_SERIES = STM32L4xx
+
+ # Linker script to use
+ # - it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/
+ # or /ld/
+ MCU_LDSCRIPT ?= STM32L432xC
+
+ # Startup code to use
+ # - it should exist in /os/common/startup/ARMCMx/compilers/GCC/mk/
+ MCU_STARTUP ?= stm32l4xx
+
+ # Board: it should exist either in /os/hal/boards/,
+ # /boards/, or drivers/boards/
+ BOARD ?= GENERIC_STM32_L433XC
+
+ PLATFORM_NAME ?= platform_l432
+
+ USE_FPU ?= yes
+
+ # Options to pass to dfu-util when flashing
+ DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
+ DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
+
+ # UF2 settings
+ UF2_FAMILY ?= STM32L4
endif
ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287))
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index bf359e994dc3..51b0efdb47c1 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -216,7 +216,18 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
# endif
}
}
+ if (get_auto_shifted_key(keycode, record)) {
+ if (record->event.pressed) {
+ return autoshift_press(keycode, now, record);
+ } else {
+ autoshift_end(keycode, now, false);
+ return false;
+ }
+ }
+ return true;
+}
+__attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
# ifndef NO_AUTO_SHIFT_ALPHA
case KC_A ... KC_Z:
@@ -229,14 +240,9 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
case KC_MINUS ... KC_SLASH:
case KC_NONUS_BSLASH:
# endif
- if (record->event.pressed) {
- return autoshift_press(keycode, now, record);
- } else {
- autoshift_end(keycode, now, false);
- return false;
- }
+ return true;
}
- return true;
+ return false;
}
#endif
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h
index 5b2718f11ca6..00a9ab036fe3 100644
--- a/quantum/process_keycode/process_auto_shift.h
+++ b/quantum/process_keycode/process_auto_shift.h
@@ -31,3 +31,4 @@ bool get_autoshift_state(void);
uint16_t get_autoshift_timeout(void);
void set_autoshift_timeout(uint16_t timeout);
void autoshift_matrix_scan(void);
+bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record);
diff --git a/quantum/process_keycode/process_backlight.c b/quantum/process_keycode/process_backlight.c
index 4d12f6813a92..8b70339a55b9 100644
--- a/quantum/process_keycode/process_backlight.c
+++ b/quantum/process_keycode/process_backlight.c
@@ -16,11 +16,35 @@
#include "process_backlight.h"
-#include "backlight.h"
+#ifdef LED_MATRIX_ENABLE
+# include "led_matrix.h"
+#else
+# include "backlight.h"
+#endif
bool process_backlight(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
+#ifdef LED_MATRIX_ENABLE
+ case BL_ON:
+ led_matrix_enable();
+ return false;
+ case BL_OFF:
+ led_matrix_disable();
+ return false;
+ case BL_DEC:
+ led_matrix_decrease_val();
+ return false;
+ case BL_INC:
+ led_matrix_increase_val();
+ return false;
+ case BL_TOGG:
+ led_matrix_toggle();
+ return false;
+ case BL_STEP:
+ led_matrix_step();
+ return false;
+#else
case BL_ON:
backlight_level(BACKLIGHT_LEVELS);
return false;
@@ -39,10 +63,11 @@ bool process_backlight(uint16_t keycode, keyrecord_t *record) {
case BL_STEP:
backlight_step();
return false;
-#ifdef BACKLIGHT_BREATHING
+# ifdef BACKLIGHT_BREATHING
case BL_BRTG:
backlight_toggle_breathing();
return false;
+# endif
#endif
}
}
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index 58a615d85a59..cf63f2514137 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -49,7 +49,10 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) {
// Leader key set-up
if (record->event.pressed) {
if (leading) {
- if (timer_elapsed(leader_time) < LEADER_TIMEOUT) {
+# ifndef LEADER_NO_TIMEOUT
+ if (timer_elapsed(leader_time) < LEADER_TIMEOUT)
+# endif // LEADER_NO_TIMEOUT
+ {
# ifndef LEADER_KEY_STRICT_KEY_PROCESSING
if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
keycode = keycode & 0xFF;
diff --git a/quantum/process_keycode/process_leader.h b/quantum/process_keycode/process_leader.h
index 9844f27a1bbd..f3fe14a43216 100644
--- a/quantum/process_keycode/process_leader.h
+++ b/quantum/process_keycode/process_leader.h
@@ -35,4 +35,9 @@ void qk_leader_start(void);
extern uint16_t leader_time; \
extern uint16_t leader_sequence[5]; \
extern uint8_t leader_sequence_size
-#define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
+
+#ifdef LEADER_NO_TIMEOUT
+# define LEADER_DICTIONARY() if (leading && leader_sequence_size > 0 && timer_elapsed(leader_time) > LEADER_TIMEOUT)
+#else
+# define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT)
+#endif
diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c
index 5dd8e7809df2..167c0c03c9e0 100644
--- a/quantum/process_keycode/process_rgb.c
+++ b/quantum/process_keycode/process_rgb.c
@@ -205,6 +205,11 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) {
case RGB_MODE_RGBTEST:
#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_RGB_TEST)
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
+#endif
+ return false;
+ case RGB_MODE_TWINKLE:
+#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_TWINKLE)
+ handleKeycodeRGBMode(RGBLIGHT_MODE_TWINKLE, RGBLIGHT_MODE_TWINKLE_end);
#endif
return false;
}
diff --git a/quantum/quantum.c b/quantum/quantum.c
index b40b40544a0b..8ccdb774bdff 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -15,6 +15,7 @@
*/
#include "quantum.h"
+#include "magic.h"
#ifdef BLUETOOTH_ENABLE
# include "outputselect.h"
@@ -233,7 +234,7 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef AUDIO_ENABLE
process_audio(keycode, record) &&
#endif
-#ifdef BACKLIGHT_ENABLE
+#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
process_backlight(keycode, record) &&
#endif
#ifdef STENO_ENABLE
@@ -317,6 +318,17 @@ bool process_record_quantum(keyrecord_t *record) {
case OUT_BT:
set_output(OUTPUT_BLUETOOTH);
return false;
+#endif
+#ifndef NO_ACTION_ONESHOT
+ case ONESHOT_TOGGLE:
+ oneshot_toggle();
+ break;
+ case ONESHOT_ENABLE:
+ oneshot_enable();
+ break;
+ case ONESHOT_DISABLE:
+ oneshot_disable();
+ break;
#endif
}
}
@@ -341,26 +353,20 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_
void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); }
void matrix_init_quantum() {
-#ifdef BOOTMAGIC_LITE
- bootmagic_lite();
-#endif
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
+ magic();
#if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN)
// TODO: remove calls to led_init_ports from keyboards and remove ifdef
led_init_ports();
#endif
#ifdef BACKLIGHT_ENABLE
-# ifdef LED_MATRIX_ENABLE
- led_matrix_init();
-# else
backlight_init_ports();
-# endif
#endif
#ifdef AUDIO_ENABLE
audio_init();
#endif
+#ifdef LED_MATRIX_ENABLE
+ led_matrix_init();
+#endif
#ifdef RGB_MATRIX_ENABLE
rgb_matrix_init();
#endif
diff --git a/quantum/quantum.h b/quantum/quantum.h
index e24a4c43a3dc..e4a7c5723ceb 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -30,11 +30,11 @@
#include "keymap.h"
#ifdef BACKLIGHT_ENABLE
-# ifdef LED_MATRIX_ENABLE
-# include "led_matrix.h"
-# else
-# include "backlight.h"
-# endif
+# include "backlight.h"
+#endif
+
+#ifdef LED_MATRIX_ENABLE
+# include "led_matrix.h"
#endif
#if defined(RGBLIGHT_ENABLE)
@@ -52,6 +52,7 @@
#include "action_layer.h"
#include "eeconfig.h"
#include "bootloader.h"
+#include "bootmagic.h"
#include "timer.h"
#include "sync_timer.h"
#include "config_common.h"
@@ -97,7 +98,7 @@ extern layer_state_t layer_state;
# include "process_music.h"
#endif
-#ifdef BACKLIGHT_ENABLE
+#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
# include "process_backlight.h"
#endif
@@ -199,37 +200,8 @@ extern layer_state_t layer_state;
# include "usbpd.h"
#endif
-// Function substitutions to ease GPIO manipulation
-#if defined(__AVR__)
-
-/* The AVR series GPIOs have a one clock read delay for changes in the digital input signal.
- * But here's more margin to make it two clocks. */
-# if !defined(GPIO_INPUT_PIN_DELAY)
-# define GPIO_INPUT_PIN_DELAY 2
-# endif
-# define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)
-
-#elif defined(__ARMEL__) || defined(__ARMEB__)
-
-/* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus
- * to which the GPIO is connected.
- * The connected buses differ depending on the various series of MCUs.
- * And since the instruction execution clock of the CPU and the bus clock of GPIO are different,
- * there is a delay of several clocks to read the change of the input signal.
- *
- * Define this delay with the GPIO_INPUT_PIN_DELAY macro.
- * If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used.
- * (A fairly large value of 0.25 microseconds is set.)
- */
-# if !defined(GPIO_INPUT_PIN_DELAY)
-# if defined(STM32_SYSCLK)
-# define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4)
-# elif defined(KINETIS_SYSCLK_FREQUENCY)
-# define GPIO_INPUT_PIN_DELAY (KINETIS_SYSCLK_FREQUENCY / 1000000L / 4)
-# endif
-# endif
-# define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)
-
+#ifdef ENCODER_ENABLE
+# include "encoder.h"
#endif
// For tri-layer
@@ -256,15 +228,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record);
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
-#ifndef BOOTMAGIC_LITE_COLUMN
-# define BOOTMAGIC_LITE_COLUMN 0
-#endif
-#ifndef BOOTMAGIC_LITE_ROW
-# define BOOTMAGIC_LITE_ROW 0
-#endif
-
-void bootmagic_lite(void);
-
void reset_keyboard(void);
void startup_user(void);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index e49f8dcdaadf..316c20fcef89 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -16,19 +16,7 @@
#pragma once
-#if defined(SEQUENCER_ENABLE)
-# include "sequencer.h"
-#endif
-
-#ifndef MIDI_ENABLE_STRICT
-# define MIDI_ENABLE_STRICT 0
-#endif
-
-#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
-# ifndef MIDI_TONE_KEYCODE_OCTAVES
-# define MIDI_TONE_KEYCODE_OCTAVES 3
-# endif
-#endif
+#include "sequencer.h"
// Fillers to make layering more clear
#define _______ KC_TRNS
@@ -67,6 +55,8 @@ enum quantum_keycodes {
QK_ONE_SHOT_LAYER_MAX = 0x54FF,
QK_ONE_SHOT_MOD = 0x5500,
QK_ONE_SHOT_MOD_MAX = 0x55FF,
+ QK_SWAP_HANDS = 0x5600,
+ QK_SWAP_HANDS_MAX = 0x56FF,
QK_TAP_DANCE = 0x5700,
QK_TAP_DANCE_MAX = 0x57FF,
QK_LAYER_TAP_TOGGLE = 0x5800,
@@ -77,507 +67,458 @@ enum quantum_keycodes {
QK_STENO_BOLT = 0x5A30,
QK_STENO_GEMINI = 0x5A31,
QK_STENO_MAX = 0x5A3F,
- QK_SWAP_HANDS = 0x5B00,
- QK_SWAP_HANDS_MAX = 0x5BFF,
- QK_MOD_TAP = 0x6000,
- QK_MOD_TAP_MAX = 0x7FFF,
- QK_UNICODE = 0x8000,
- QK_UNICODE_MAX = 0xFFFF,
- QK_UNICODEMAP = 0x8000,
- QK_UNICODEMAP_MAX = 0xBFFF,
- QK_UNICODEMAP_PAIR = 0xC000,
- QK_UNICODEMAP_PAIR_MAX = 0xFFFF,
+ // 0x5C00 - 0x5FFF are reserved, see below
+ QK_MOD_TAP = 0x6000,
+ QK_MOD_TAP_MAX = 0x7FFF,
+ QK_UNICODE = 0x8000,
+ QK_UNICODE_MAX = 0xFFFF,
+ QK_UNICODEMAP = 0x8000,
+ QK_UNICODEMAP_MAX = 0xBFFF,
+ QK_UNICODEMAP_PAIR = 0xC000,
+ QK_UNICODEMAP_PAIR_MAX = 0xFFFF,
// Loose keycodes - to be used directly
RESET = 0x5C00,
- DEBUG,
- MAGIC_SWAP_CONTROL_CAPSLOCK,
- MAGIC_CAPSLOCK_TO_CONTROL,
- MAGIC_SWAP_LALT_LGUI,
- MAGIC_SWAP_RALT_RGUI,
- MAGIC_NO_GUI,
- MAGIC_SWAP_GRAVE_ESC,
- MAGIC_SWAP_BACKSLASH_BACKSPACE,
- MAGIC_HOST_NKRO,
- MAGIC_SWAP_ALT_GUI,
- MAGIC_UNSWAP_CONTROL_CAPSLOCK,
- MAGIC_UNCAPSLOCK_TO_CONTROL,
- MAGIC_UNSWAP_LALT_LGUI,
- MAGIC_UNSWAP_RALT_RGUI,
- MAGIC_UNNO_GUI,
- MAGIC_UNSWAP_GRAVE_ESC,
- MAGIC_UNSWAP_BACKSLASH_BACKSPACE,
- MAGIC_UNHOST_NKRO,
- MAGIC_UNSWAP_ALT_GUI,
- MAGIC_TOGGLE_NKRO,
- MAGIC_TOGGLE_ALT_GUI,
- GRAVE_ESC,
-
-// Leader key
-#ifdef LEADER_ENABLE
- KC_LEAD,
-#endif
-
-// Auto Shift setup
-#ifndef AUTO_SHIFT_NO_SETUP
- KC_ASUP,
- KC_ASDN,
- KC_ASRP,
-#endif
- KC_ASTG,
- KC_ASON,
- KC_ASOFF,
-
- // Audio on/off/toggle
- AU_ON,
- AU_OFF,
- AU_TOG,
-
- // Faux clicky as part of main audio feature
- CLICKY_TOGGLE,
- CLICKY_ENABLE,
- CLICKY_DISABLE,
- CLICKY_UP,
- CLICKY_DOWN,
- CLICKY_RESET,
-
- // Music mode on/off/toggle
- MU_ON,
- MU_OFF,
- MU_TOG,
-
- // Music mode cycle
- MU_MOD,
-
- // Music voice iterate
- MUV_IN,
- MUV_DE,
-
-// Midi
-#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
- MI_ON,
- MI_OFF,
- MI_TOG,
-#endif
-
-#if !MIDI_ENABLE_STRICT || (defined(MIDI_ENABLE) && defined(MIDI_ADVANCED))
- MIDI_TONE_MIN,
-
-# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 0
- MI_C = MIDI_TONE_MIN,
- MI_Cs,
+ DEBUG, // 5C01
+
+ // Magic
+ MAGIC_SWAP_CONTROL_CAPSLOCK, // 5C02
+ MAGIC_CAPSLOCK_TO_CONTROL, // 5C03
+ MAGIC_SWAP_LALT_LGUI, // 5C04
+ MAGIC_SWAP_RALT_RGUI, // 5C05
+ MAGIC_NO_GUI, // 5C06
+ MAGIC_SWAP_GRAVE_ESC, // 5C07
+ MAGIC_SWAP_BACKSLASH_BACKSPACE, // 5C08
+ MAGIC_HOST_NKRO, // 5C09
+ MAGIC_SWAP_ALT_GUI, // 5C0A
+ MAGIC_UNSWAP_CONTROL_CAPSLOCK, // 5C0B
+ MAGIC_UNCAPSLOCK_TO_CONTROL, // 5C0C
+ MAGIC_UNSWAP_LALT_LGUI, // 5C0D
+ MAGIC_UNSWAP_RALT_RGUI, // 5C0E
+ MAGIC_UNNO_GUI, // 5C0F
+ MAGIC_UNSWAP_GRAVE_ESC, // 5C10
+ MAGIC_UNSWAP_BACKSLASH_BACKSPACE, // 5C11
+ MAGIC_UNHOST_NKRO, // 5C12
+ MAGIC_UNSWAP_ALT_GUI, // 5C13
+ MAGIC_TOGGLE_NKRO, // 5C14
+ MAGIC_TOGGLE_ALT_GUI, // 5C15
+
+ // Grave Escape
+ GRAVE_ESC, // 5C16
+
+ // Auto Shift
+ KC_ASUP, // 5C17
+ KC_ASDN, // 5C18
+ KC_ASRP, // 5C19
+ KC_ASTG, // 5C1A
+ KC_ASON, // 5C1B
+ KC_ASOFF, // 5C1C
+
+ // Audio
+ AU_ON, // 5C1D
+ AU_OFF, // 5C1E
+ AU_TOG, // 5C1F
+
+ // Audio Clicky
+ CLICKY_TOGGLE, // 5C20
+ CLICKY_ENABLE, // 5C21
+ CLICKY_DISABLE, // 5C22
+ CLICKY_UP, // 5C23
+ CLICKY_DOWN, // 5C24
+ CLICKY_RESET, // 5C25
+
+ // Music mode
+ MU_ON, // 5C26
+ MU_OFF, // 5C27
+ MU_TOG, // 5C28
+ MU_MOD, // 5C29
+ MUV_IN, // 5C2A
+ MUV_DE, // 5C2B
+
+ // MIDI
+ MI_ON, // 5C2C
+ MI_OFF, // 5C2D
+ MI_TOG, // 5C2E
+
+ MI_C, // 5C2F
+ MI_Cs, // 5C30
MI_Db = MI_Cs,
- MI_D,
- MI_Ds,
+ MI_D, // 5C31
+ MI_Ds, // 5C32
MI_Eb = MI_Ds,
- MI_E,
- MI_F,
- MI_Fs,
+ MI_E, // 5C33
+ MI_F, // 5C34
+ MI_Fs, // 5C35
MI_Gb = MI_Fs,
- MI_G,
- MI_Gs,
+ MI_G, // 5C36
+ MI_Gs, // 5C37
MI_Ab = MI_Gs,
- MI_A,
- MI_As,
+ MI_A, // 5C38
+ MI_As, // 5C39
MI_Bb = MI_As,
- MI_B,
-# endif
+ MI_B, // 5C3A
-# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 1
- MI_C_1,
- MI_Cs_1,
+ MI_C_1, // 5C3B
+ MI_Cs_1, // 5C3C
MI_Db_1 = MI_Cs_1,
- MI_D_1,
- MI_Ds_1,
+ MI_D_1, // 5C3D
+ MI_Ds_1, // 5C3E
MI_Eb_1 = MI_Ds_1,
- MI_E_1,
- MI_F_1,
- MI_Fs_1,
+ MI_E_1, // 5C3F
+ MI_F_1, // 5C40
+ MI_Fs_1, // 5C41
MI_Gb_1 = MI_Fs_1,
- MI_G_1,
- MI_Gs_1,
+ MI_G_1, // 5C42
+ MI_Gs_1, // 5C43
MI_Ab_1 = MI_Gs_1,
- MI_A_1,
- MI_As_1,
+ MI_A_1, // 5C44
+ MI_As_1, // 5C45
MI_Bb_1 = MI_As_1,
- MI_B_1,
-# endif
+ MI_B_1, // 5C46
-# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 2
- MI_C_2,
- MI_Cs_2,
+ MI_C_2, // 5C47
+ MI_Cs_2, // 5C48
MI_Db_2 = MI_Cs_2,
- MI_D_2,
- MI_Ds_2,
+ MI_D_2, // 5C49
+ MI_Ds_2, // 5C4A
MI_Eb_2 = MI_Ds_2,
- MI_E_2,
- MI_F_2,
- MI_Fs_2,
+ MI_E_2, // 5C4B
+ MI_F_2, // 5C4C
+ MI_Fs_2, // 5C4D
MI_Gb_2 = MI_Fs_2,
- MI_G_2,
- MI_Gs_2,
+ MI_G_2, // 5C4E
+ MI_Gs_2, // 5C4F
MI_Ab_2 = MI_Gs_2,
- MI_A_2,
- MI_As_2,
+ MI_A_2, // 5C50
+ MI_As_2, // 5C51
MI_Bb_2 = MI_As_2,
- MI_B_2,
-# endif
+ MI_B_2, // 5C52
-# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 3
- MI_C_3,
- MI_Cs_3,
+ MI_C_3, // 5C53
+ MI_Cs_3, // 5C54
MI_Db_3 = MI_Cs_3,
- MI_D_3,
- MI_Ds_3,
+ MI_D_3, // 5C55
+ MI_Ds_3, // 5C56
MI_Eb_3 = MI_Ds_3,
- MI_E_3,
- MI_F_3,
- MI_Fs_3,
+ MI_E_3, // 5C57
+ MI_F_3, // 5C58
+ MI_Fs_3, // 5C59
MI_Gb_3 = MI_Fs_3,
- MI_G_3,
- MI_Gs_3,
+ MI_G_3, // 5C5A
+ MI_Gs_3, // 5C5B
MI_Ab_3 = MI_Gs_3,
- MI_A_3,
- MI_As_3,
+ MI_A_3, // 5C5C
+ MI_As_3, // 5C5D
MI_Bb_3 = MI_As_3,
- MI_B_3,
-# endif
+ MI_B_3, // 5C5E
-# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 4
- MI_C_4,
- MI_Cs_4,
+ MI_C_4, // 5C5F
+ MI_Cs_4, // 5C60
MI_Db_4 = MI_Cs_4,
- MI_D_4,
- MI_Ds_4,
+ MI_D_4, // 5C61
+ MI_Ds_4, // 5C62
MI_Eb_4 = MI_Ds_4,
- MI_E_4,
- MI_F_4,
- MI_Fs_4,
+ MI_E_4, // 5C63
+ MI_F_4, // 5C64
+ MI_Fs_4, // 5C65
MI_Gb_4 = MI_Fs_4,
- MI_G_4,
- MI_Gs_4,
+ MI_G_4, // 5C66
+ MI_Gs_4, // 5C67
MI_Ab_4 = MI_Gs_4,
- MI_A_4,
- MI_As_4,
+ MI_A_4, // 5C68
+ MI_As_4, // 5C69
MI_Bb_4 = MI_As_4,
- MI_B_4,
-# endif
+ MI_B_4, // 5C6A
-# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
- MI_C_5,
- MI_Cs_5,
+ MI_C_5, // 5C6B
+ MI_Cs_5, // 5C6C
MI_Db_5 = MI_Cs_5,
- MI_D_5,
- MI_Ds_5,
+ MI_D_5, // 5C6D
+ MI_Ds_5, // 5C6E
MI_Eb_5 = MI_Ds_5,
- MI_E_5,
- MI_F_5,
- MI_Fs_5,
+ MI_E_5, // 5C6F
+ MI_F_5, // 5C70
+ MI_Fs_5, // 5C71
MI_Gb_5 = MI_Fs_5,
- MI_G_5,
- MI_Gs_5,
+ MI_G_5, // 5C72
+ MI_Gs_5, // 5C73
MI_Ab_5 = MI_Gs_5,
- MI_A_5,
- MI_As_5,
+ MI_A_5, // 5C74
+ MI_As_5, // 5C75
MI_Bb_5 = MI_As_5,
- MI_B_5,
-# endif
-
-# if !MIDI_ENABLE_STRICT || MIDI_TONE_KEYCODE_OCTAVES > 5
- MIDI_TONE_MAX = MI_B_5,
-# elif MIDI_TONE_KEYCODE_OCTAVES > 4
- MIDI_TONE_MAX = MI_B_4,
-# elif MIDI_TONE_KEYCODE_OCTAVES > 3
- MIDI_TONE_MAX = MI_B_3,
-# elif MIDI_TONE_KEYCODE_OCTAVES > 2
- MIDI_TONE_MAX = MI_B_2,
-# elif MIDI_TONE_KEYCODE_OCTAVES > 1
- MIDI_TONE_MAX = MI_B_1,
-# elif MIDI_TONE_KEYCODE_OCTAVES > 0
- MIDI_TONE_MAX = MI_B,
-# endif
-
- MIDI_OCTAVE_MIN,
- MI_OCT_N2 = MIDI_OCTAVE_MIN,
- MI_OCT_N1,
- MI_OCT_0,
- MI_OCT_1,
- MI_OCT_2,
- MI_OCT_3,
- MI_OCT_4,
- MI_OCT_5,
- MI_OCT_6,
- MI_OCT_7,
- MIDI_OCTAVE_MAX = MI_OCT_7,
- MI_OCTD, // octave down
- MI_OCTU, // octave up
-
- MIDI_TRANSPOSE_MIN,
- MI_TRNS_N6 = MIDI_TRANSPOSE_MIN,
- MI_TRNS_N5,
- MI_TRNS_N4,
- MI_TRNS_N3,
- MI_TRNS_N2,
- MI_TRNS_N1,
- MI_TRNS_0,
- MI_TRNS_1,
- MI_TRNS_2,
- MI_TRNS_3,
- MI_TRNS_4,
- MI_TRNS_5,
- MI_TRNS_6,
- MIDI_TRANSPOSE_MAX = MI_TRNS_6,
- MI_TRNSD, // transpose down
- MI_TRNSU, // transpose up
-
- MIDI_VELOCITY_MIN,
- MI_VEL_0 = MIDI_VELOCITY_MIN,
-# ifdef VIA_ENABLE
- MI_VEL_1 = MIDI_VELOCITY_MIN,
-# else
- MI_VEL_1,
-# endif
- MI_VEL_2,
- MI_VEL_3,
- MI_VEL_4,
- MI_VEL_5,
- MI_VEL_6,
- MI_VEL_7,
- MI_VEL_8,
- MI_VEL_9,
- MI_VEL_10,
- MIDI_VELOCITY_MAX = MI_VEL_10,
- MI_VELD, // velocity down
- MI_VELU, // velocity up
-
- MIDI_CHANNEL_MIN,
- MI_CH1 = MIDI_CHANNEL_MIN,
- MI_CH2,
- MI_CH3,
- MI_CH4,
- MI_CH5,
- MI_CH6,
- MI_CH7,
- MI_CH8,
- MI_CH9,
- MI_CH10,
- MI_CH11,
- MI_CH12,
- MI_CH13,
- MI_CH14,
- MI_CH15,
- MI_CH16,
- MIDI_CHANNEL_MAX = MI_CH16,
- MI_CHD, // previous channel
- MI_CHU, // next channel
-
- MI_ALLOFF, // all notes off
-
- MI_SUS, // sustain
- MI_PORT, // portamento
- MI_SOST, // sostenuto
- MI_SOFT, // soft pedal
- MI_LEG, // legato
-
- MI_MOD, // modulation
- MI_MODSD, // decrease modulation speed
- MI_MODSU, // increase modulation speed
-
- MI_BENDD, // Bend down
- MI_BENDU, // Bend up
-#endif // MIDI_ADVANCED
-
- // Backlight functionality
- BL_ON,
- BL_OFF,
- BL_DEC,
- BL_INC,
- BL_TOGG,
- BL_STEP,
- BL_BRTG,
-
- // RGB functionality
- RGB_TOG,
- RGB_MODE_FORWARD,
- RGB_MODE_REVERSE,
- RGB_HUI,
- RGB_HUD,
- RGB_SAI,
- RGB_SAD,
- RGB_VAI,
- RGB_VAD,
- RGB_SPI,
- RGB_SPD,
- RGB_MODE_PLAIN,
- RGB_MODE_BREATHE,
- RGB_MODE_RAINBOW,
- RGB_MODE_SWIRL,
- RGB_MODE_SNAKE,
- RGB_MODE_KNIGHT,
- RGB_MODE_XMAS,
- RGB_MODE_GRADIENT,
- RGB_MODE_RGBTEST,
-
- // Momentum matching toggle
- VLK_TOG,
-
- // Left shift, open paren
- KC_LSPO,
-
- // Right shift, close paren
- KC_RSPC,
-
- // Shift, Enter
- KC_SFTENT,
-
- // Printing
- PRINT_ON,
- PRINT_OFF,
-
- // output selection
- OUT_AUTO,
- OUT_USB,
-#ifdef BLUETOOTH_ENABLE
- OUT_BT,
-#endif
-
-#ifdef KEY_LOCK_ENABLE
- KC_LOCK,
+ MI_B_5, // 5C76
+
+ MI_OCT_N2, // 5C77
+ MI_OCT_N1, // 5C78
+ MI_OCT_0, // 5C79
+ MI_OCT_1, // 5C7A
+ MI_OCT_2, // 5C7B
+ MI_OCT_3, // 5C7C
+ MI_OCT_4, // 5C7D
+ MI_OCT_5, // 5C7E
+ MI_OCT_6, // 5C7F
+ MI_OCT_7, // 5C80
+ MI_OCTD, // 5C81
+ MI_OCTU, // 5C82
+
+ MI_TRNS_N6, // 5C83
+ MI_TRNS_N5, // 5C84
+ MI_TRNS_N4, // 5C85
+ MI_TRNS_N3, // 5C86
+ MI_TRNS_N2, // 5C87
+ MI_TRNS_N1, // 5C88
+ MI_TRNS_0, // 5C89
+ MI_TRNS_1, // 5C8A
+ MI_TRNS_2, // 5C8B
+ MI_TRNS_3, // 5C8C
+ MI_TRNS_4, // 5C8D
+ MI_TRNS_5, // 5C8E
+ MI_TRNS_6, // 5C8F
+ MI_TRNSD, // 5C90
+ MI_TRNSU, // 5C91
+
+ MI_VEL_0, // 5C92
+#ifdef VIA_ENABLE
+ MI_VEL_1 = MI_VEL_0,
+#else
+ MI_VEL_1, // 5C93
#endif
-
-#ifdef TERMINAL_ENABLE
- TERM_ON,
- TERM_OFF,
-#endif
-
- EEPROM_RESET,
-
- UNICODE_MODE_FORWARD,
- UNICODE_MODE_REVERSE,
- UNICODE_MODE_MAC,
- UNICODE_MODE_LNX,
- UNICODE_MODE_WIN,
- UNICODE_MODE_BSD,
- UNICODE_MODE_WINC,
-
- HPT_ON,
- HPT_OFF,
- HPT_TOG,
- HPT_RST,
- HPT_FBK,
- HPT_BUZ,
- HPT_MODI,
- HPT_MODD,
- HPT_CONT,
- HPT_CONI,
- HPT_COND,
- HPT_DWLI,
- HPT_DWLD,
-
- // Left control, open paren
- KC_LCPO,
-
- // Right control, close paren
- KC_RCPC,
-
- // Left control, open paren
- KC_LAPO,
-
- // Right control, close paren
- KC_RAPC,
-
- CMB_ON,
- CMB_OFF,
- CMB_TOG,
-
- MAGIC_SWAP_LCTL_LGUI,
- MAGIC_SWAP_RCTL_RGUI,
- MAGIC_UNSWAP_LCTL_LGUI,
- MAGIC_UNSWAP_RCTL_RGUI,
- MAGIC_SWAP_CTL_GUI,
- MAGIC_UNSWAP_CTL_GUI,
- MAGIC_TOGGLE_CTL_GUI,
- MAGIC_EE_HANDS_LEFT,
- MAGIC_EE_HANDS_RIGHT,
+ MI_VEL_2, // 5C94
+ MI_VEL_3, // 5C95
+ MI_VEL_4, // 5C96
+ MI_VEL_5, // 5C97
+ MI_VEL_6, // 5C98
+ MI_VEL_7, // 5C99
+ MI_VEL_8, // 5C9A
+ MI_VEL_9, // 5C9B
+ MI_VEL_10, // 5C9C
+ MI_VELD, // 5C9D
+ MI_VELU, // 5C9E
+
+ MI_CH1, // 5C9F
+ MI_CH2, // 5CA0
+ MI_CH3, // 5CA1
+ MI_CH4, // 5CA2
+ MI_CH5, // 5CA3
+ MI_CH6, // 5CA4
+ MI_CH7, // 5CA5
+ MI_CH8, // 5CA6
+ MI_CH9, // 5CA7
+ MI_CH10, // 5CA8
+ MI_CH11, // 5CA9
+ MI_CH12, // 5CAA
+ MI_CH13, // 5CAB
+ MI_CH14, // 5CAC
+ MI_CH15, // 5CAD
+ MI_CH16, // 5CAE
+ MI_CHD, // 5CAF
+ MI_CHU, // 5CB0
+
+ MI_ALLOFF, // 5CB1
+
+ MI_SUS, // 5CB2
+ MI_PORT, // 5CB3
+ MI_SOST, // 5CB4
+ MI_SOFT, // 5CB5
+ MI_LEG, // 5CB6
+
+ MI_MOD, // 5CB7
+ MI_MODSD, // 5CB8
+ MI_MODSU, // 5CB9
+
+ MI_BENDD, // 5CBA
+ MI_BENDU, // 5CBB
+
+ // Backlight
+ BL_ON, // 5CBC
+ BL_OFF, // 5CBD
+ BL_DEC, // 5CBE
+ BL_INC, // 5CBF
+ BL_TOGG, // 5CC0
+ BL_STEP, // 5CC1
+ BL_BRTG, // 5CC2
+
+ // RGB underglow/matrix
+ RGB_TOG, // 5CC3
+ RGB_MODE_FORWARD, // 5CC4
+ RGB_MODE_REVERSE, // 5CC5
+ RGB_HUI, // 5CC6
+ RGB_HUD, // 5CC7
+ RGB_SAI, // 5CC8
+ RGB_SAD, // 5CC9
+ RGB_VAI, // 5CCA
+ RGB_VAD, // 5CCB
+ RGB_SPI, // 5CCC
+ RGB_SPD, // 5CCD
+ RGB_MODE_PLAIN, // 5CCE
+ RGB_MODE_BREATHE, // 5CCF
+ RGB_MODE_RAINBOW, // 5CD0
+ RGB_MODE_SWIRL, // 5CD1
+ RGB_MODE_SNAKE, // 5CD2
+ RGB_MODE_KNIGHT, // 5CD3
+ RGB_MODE_XMAS, // 5CD4
+ RGB_MODE_GRADIENT, // 5CD5
+ RGB_MODE_RGBTEST, // 5CD6
+
+ // Velocikey
+ VLK_TOG, // 5CD7
+
+ // Space Cadet
+ KC_LSPO, // 5CD8
+ KC_RSPC, // 5CD9
+ KC_SFTENT, // 5CDA
+
+ // Thermal Printer
+ PRINT_ON, // 5CDB
+ PRINT_OFF, // 5CDC
+
+ // Bluetooth: output selection
+ OUT_AUTO, // 5CDD
+ OUT_USB, // 5CDE
+
+ // Clear EEPROM
+ EEPROM_RESET, // 5CDF
+
+ // Unicode
+ UNICODE_MODE_FORWARD, // 5CE0
+ UNICODE_MODE_REVERSE, // 5CE1
+ UNICODE_MODE_MAC, // 5CE2
+ UNICODE_MODE_LNX, // 5CE3
+ UNICODE_MODE_WIN, // 5CE4
+ UNICODE_MODE_BSD, // 5CE5
+ UNICODE_MODE_WINC, // 5CE6
+
+ // Haptic
+ HPT_ON, // 5CE7
+ HPT_OFF, // 5CE8
+ HPT_TOG, // 5CE9
+ HPT_RST, // 5CEA
+ HPT_FBK, // 5CEB
+ HPT_BUZ, // 5CEC
+ HPT_MODI, // 5CED
+ HPT_MODD, // 5CEE
+ HPT_CONT, // 5CEF
+ HPT_CONI, // 5CF0
+ HPT_COND, // 5CF1
+ HPT_DWLI, // 5CF2
+ HPT_DWLD, // 5CF3
+
+ // Space Cadet (continued)
+ KC_LCPO, // 5CF4
+ KC_RCPC, // 5CF5
+ KC_LAPO, // 5CF6
+ KC_RAPC, // 5CF7
+
+ // Combos
+ CMB_ON, // 5CF8
+ CMB_OFF, // 5CF9
+ CMB_TOG, // 5CFA
+
+ // Magic (continued)
+ MAGIC_SWAP_LCTL_LGUI, // 5CFB
+ MAGIC_SWAP_RCTL_RGUI, // 5CFC
+ MAGIC_UNSWAP_LCTL_LGUI, // 5CFD
+ MAGIC_UNSWAP_RCTL_RGUI, // 5CFE
+ MAGIC_SWAP_CTL_GUI, // 5CFF
+ MAGIC_UNSWAP_CTL_GUI, // 5D00
+ MAGIC_TOGGLE_CTL_GUI, // 5D01
+ MAGIC_EE_HANDS_LEFT, // 5D02
+ MAGIC_EE_HANDS_RIGHT, // 5D03
// Dynamic Macros
- DYN_REC_START1,
- DYN_REC_START2,
- DYN_REC_STOP,
- DYN_MACRO_PLAY1,
- DYN_MACRO_PLAY2,
-
- JS_BUTTON0,
- JS_BUTTON_MIN = JS_BUTTON0,
- JS_BUTTON1,
- JS_BUTTON2,
- JS_BUTTON3,
- JS_BUTTON4,
- JS_BUTTON5,
- JS_BUTTON6,
- JS_BUTTON7,
- JS_BUTTON8,
- JS_BUTTON9,
- JS_BUTTON10,
- JS_BUTTON11,
- JS_BUTTON12,
- JS_BUTTON13,
- JS_BUTTON14,
- JS_BUTTON15,
- JS_BUTTON16,
- JS_BUTTON17,
- JS_BUTTON18,
- JS_BUTTON19,
- JS_BUTTON20,
- JS_BUTTON21,
- JS_BUTTON22,
- JS_BUTTON23,
- JS_BUTTON24,
- JS_BUTTON25,
- JS_BUTTON26,
- JS_BUTTON27,
- JS_BUTTON28,
- JS_BUTTON29,
- JS_BUTTON30,
- JS_BUTTON31,
- JS_BUTTON_MAX = JS_BUTTON31,
-
-#if defined(SEQUENCER_ENABLE)
- SQ_ON,
- SQ_OFF,
- SQ_TOG,
-
- SQ_TMPD, // Decrease tempo
- SQ_TMPU, // Increase tempo
+ DYN_REC_START1, // 5D04
+ DYN_REC_START2, // 5D05
+ DYN_REC_STOP, // 5D06
+ DYN_MACRO_PLAY1, // 5D07
+ DYN_MACRO_PLAY2, // 5D08
+
+ // Joystick
+ JS_BUTTON0, // 5D09
+ JS_BUTTON1, // 5D0A
+ JS_BUTTON2, // 5D0B
+ JS_BUTTON3, // 5D0C
+ JS_BUTTON4, // 5D0D
+ JS_BUTTON5, // 5D0E
+ JS_BUTTON6, // 5D0F
+ JS_BUTTON7, // 5D10
+ JS_BUTTON8, // 5D11
+ JS_BUTTON9, // 5D12
+ JS_BUTTON10, // 5D13
+ JS_BUTTON11, // 5D14
+ JS_BUTTON12, // 5D15
+ JS_BUTTON13, // 5D16
+ JS_BUTTON14, // 5D17
+ JS_BUTTON15, // 5D18
+ JS_BUTTON16, // 5D19
+ JS_BUTTON17, // 5D1A
+ JS_BUTTON18, // 5D1B
+ JS_BUTTON19, // 5D1C
+ JS_BUTTON20, // 5D1D
+ JS_BUTTON21, // 5D1E
+ JS_BUTTON22, // 5D1F
+ JS_BUTTON23, // 5D20
+ JS_BUTTON24, // 5D21
+ JS_BUTTON25, // 5D22
+ JS_BUTTON26, // 5D23
+ JS_BUTTON27, // 5D24
+ JS_BUTTON28, // 5D25
+ JS_BUTTON29, // 5D26
+ JS_BUTTON30, // 5D27
+ JS_BUTTON31, // 5D28
+
+ // Leader Key
+ KC_LEAD, // 5D29
+
+ // Bluetooth: output selection (continued)
+ OUT_BT, // 5D2A
+
+ // Lock Key
+ KC_LOCK, // 5D2B
+
+ // Terminal
+ TERM_ON, // 5D2C
+ TERM_OFF, // 5D2D
+
+ // Sequencer
+ SQ_ON, // 5D2E
+ SQ_OFF, // 5D2F
+ SQ_TOG, // 5D30
+
+ SQ_TMPD, // 5D31
+ SQ_TMPU, // 5D32
+
+ SQ_RESD, // 5D33
+ SQ_RESU, // 5D34
+
+ SQ_SALL, // 5D35
+ SQ_SCLR, // 5D36
+
+ SEQUENCER_STEP_MIN, // 5D37
+ SEQUENCER_STEP_MAX = SEQUENCER_STEP_MIN + SEQUENCER_STEPS,
SEQUENCER_RESOLUTION_MIN,
SEQUENCER_RESOLUTION_MAX = SEQUENCER_RESOLUTION_MIN + SEQUENCER_RESOLUTIONS,
- SQ_RESD, // Decrease resolution
- SQ_RESU, // Increase resolution
-
- SQ_SALL, // All steps on
- SQ_SCLR, // All steps off
- SEQUENCER_STEP_MIN,
- SEQUENCER_STEP_MAX = SEQUENCER_STEP_MIN + SEQUENCER_STEPS,
SEQUENCER_TRACK_MIN,
SEQUENCER_TRACK_MAX = SEQUENCER_TRACK_MIN + SEQUENCER_TRACKS,
-/**
- * Helpers to assign a keycode to a step, a resolution, or a track.
- * Falls back to NOOP if n is out of range.
- */
-# define SQ_S(n) (n < SEQUENCER_STEPS ? SEQUENCER_STEP_MIN + n : XXXXXXX)
-# define SQ_R(n) (n < SEQUENCER_RESOLUTIONS ? SEQUENCER_RESOLUTION_MIN + n : XXXXXXX)
-# define SQ_T(n) (n < SEQUENCER_TRACKS ? SEQUENCER_TRACK_MIN + n : XXXXXXX)
+#define SQ_S(n) (n < SEQUENCER_STEPS ? SEQUENCER_STEP_MIN + n : KC_NO)
+#define SQ_R(n) (n < SEQUENCER_RESOLUTIONS ? SEQUENCER_RESOLUTION_MIN + n : KC_NO)
+#define SQ_T(n) (n < SEQUENCER_TRACKS ? SEQUENCER_TRACK_MIN + n : KC_NO)
-#endif
+ // One Shot
+ ONESHOT_ENABLE,
+ ONESHOT_DISABLE,
+ ONESHOT_TOGGLE,
+
+ // RGB underglow/matrix (continued)
+ RGB_MODE_TWINKLE,
- // always leave at the end
+ // Start of custom keycode range for keyboards and keymaps - always leave at the end
SAFE_RANGE
};
-// Ability to use mods in layouts
+// Keycode modifiers & aliases
#define LCTL(kc) (QK_LCTL | (kc))
#define LSFT(kc) (QK_LSFT | (kc))
#define LALT(kc) (QK_LALT | (kc))
@@ -609,11 +550,7 @@ enum quantum_keycodes {
#define MOD_HYPR 0xF
#define MOD_MEH 0x7
-// Aliases for shifted symbols
-// Each key has a 4-letter code, and some have longer aliases too.
-// While the long aliases are descriptive, the 4-letter codes
-// make for nicer grid layouts (everything lines up), and are
-// the preferred style for Quantum.
+// US ANSI shifted keycode aliases
#define KC_TILD LSFT(KC_GRV) // ~
#define KC_TILDE KC_TILD
@@ -680,18 +617,15 @@ enum quantum_keycodes {
#define KC_DELT KC_DELETE // Del key (four letter code)
-// Alias for function layers than expand past FN31
-#define FUNC(kc) (QK_FUNCTION | (kc))
-
-// Aliases
+// Modified keycode aliases
#define C(kc) LCTL(kc)
#define S(kc) LSFT(kc)
#define A(kc) LALT(kc)
#define G(kc) LGUI(kc)
-#define F(kc) FUNC(kc)
+// Deprecated - do not use
+#define F(kc) (QK_FUNCTION | (kc))
#define M(kc) (QK_MACRO | (kc))
-
#define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc))
#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
@@ -699,19 +633,21 @@ enum quantum_keycodes {
#define EEP_RST EEPROM_RESET
+// Audio Clicky aliases
#define CK_TOGG CLICKY_TOGGLE
#define CK_RST CLICKY_RESET
#define CK_UP CLICKY_UP
#define CK_DOWN CLICKY_DOWN
#define CK_ON CLICKY_ENABLE
#define CK_OFF CLICKY_DISABLE
+// Fauxclicky (deprecated) redirects to Audio Clicky
#define FC_ON CLICKY_ENABLE
#define FC_OFF CLICKY_DISABLE
#define FC_TOGG CLICKY_TOGGLE
+// RGB aliases
#define RGB_MOD RGB_MODE_FORWARD
#define RGB_RMOD RGB_MODE_REVERSE
-
#define RGB_M_P RGB_MODE_PLAIN
#define RGB_M_B RGB_MODE_BREATHE
#define RGB_M_R RGB_MODE_RAINBOW
@@ -721,10 +657,9 @@ enum quantum_keycodes {
#define RGB_M_X RGB_MODE_XMAS
#define RGB_M_G RGB_MODE_GRADIENT
#define RGB_M_T RGB_MODE_RGBTEST
+#define RGB_M_TW RGB_MODE_TWINKLE
-// L-ayer, T-ap - 256 keycode max, 16 layer max
-#define LT(layer, kc) (QK_LAYER_TAP | (((layer)&0xF) << 8) | ((kc)&0xFF))
-
+// Magic aliases
#define CL_SWAP MAGIC_SWAP_CONTROL_CAPSLOCK
#define CL_NORM MAGIC_UNSWAP_CONTROL_CAPSLOCK
#define CL_CTRL MAGIC_CAPSLOCK_TO_CONTROL
@@ -793,6 +728,9 @@ enum quantum_keycodes {
// Layer tap-toggle
#define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer)&0xFF))
+// L-ayer, T-ap - 256 keycode max, 16 layer max
+#define LT(layer, kc) (QK_LAYER_TAP | (((layer)&0xF) << 8) | ((kc)&0xFF))
+
// M-od, T-ap - 256 keycode max
#define MT(mod, kc) (QK_MOD_TAP | (((mod)&0x1F) << 8) | ((kc)&0xFF))
@@ -822,12 +760,12 @@ enum quantum_keycodes {
#define CMD_T(kc) LCMD_T(kc)
#define WIN_T(kc) LWIN_T(kc)
-#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
-#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt
-#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
-#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
+#define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal
+#define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt
+#define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI
+#define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI
#define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
-#define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) // Left Shift + GUI
+#define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) // Left Shift + GUI
#define SCMD_T(kc) SGUI_T(kc)
#define SWIN_T(kc) SGUI_T(kc)
#define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt
@@ -842,6 +780,7 @@ enum quantum_keycodes {
#define KC_HYPR HYPR(KC_NO)
#define KC_MEH MEH(KC_NO)
+// Unicode aliases
// UNICODE_ENABLE - Allows Unicode input up to 0x7FFF
#define UC(c) (QK_UNICODE | (c))
// UNICODEMAP_ENABLE - Allows Unicode input up to 0x10FFFF, requires unicode_map
@@ -853,12 +792,13 @@ enum quantum_keycodes {
#define UC_M_MA UNICODE_MODE_MAC
#define UNICODE_MODE_OSX UNICODE_MODE_MAC // Deprecated alias
-#define UC_M_OS UNICODE_MODE_MAC // Deprecated alias
+#define UC_M_OS UNICODE_MODE_MAC // Deprecated alias
#define UC_M_LN UNICODE_MODE_LNX
#define UC_M_WI UNICODE_MODE_WIN
#define UC_M_BS UNICODE_MODE_BSD
#define UC_M_WC UNICODE_MODE_WINC
+// Swap Hands
#define SH_T(kc) (QK_SWAP_HANDS | (kc))
#define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE)
#define SH_TT (QK_SWAP_HANDS | OP_SH_TAP_TOGGLE)
@@ -868,9 +808,30 @@ enum quantum_keycodes {
#define SH_ON (QK_SWAP_HANDS | OP_SH_ON)
#define SH_OFF (QK_SWAP_HANDS | OP_SH_OFF)
+// MIDI aliases
+#define MIDI_TONE_MIN MI_C
+#define MIDI_TONE_MAX MI_B_5
+#define MIDI_OCTAVE_MIN MI_OCT_N2
+#define MIDI_OCTAVE_MAX MI_OCT_7
+#define MIDI_TRANSPOSE_MIN MI_TRNS_N6
+#define MIDI_TRANSPOSE_MAX MI_TRNS_6
+#define MIDI_VELOCITY_MIN MI_VEL_0
+#define MIDI_VELOCITY_MAX MI_VEL_10
+#define MIDI_CHANNEL_MIN MI_CH1
+#define MIDI_CHANNEL_MAX MI_CH16
+
// Dynamic Macros aliases
#define DM_REC1 DYN_REC_START1
#define DM_REC2 DYN_REC_START2
#define DM_RSTP DYN_REC_STOP
#define DM_PLY1 DYN_MACRO_PLAY1
#define DM_PLY2 DYN_MACRO_PLAY2
+
+// Joystick aliases
+#define JS_BUTTON_MIN JS_BUTTON0
+#define JS_BUTTON_MAX JS_BUTTON31
+
+// One Shot aliases
+#define OS_TOGG ONESHOT_TOGGLE
+#define OS_ON ONESHOT_ENABLE
+#define OS_OFF ONESHOT_DISABLE
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index ec17b4d72ca6..e716c6aad328 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -26,9 +26,9 @@
#include
#ifndef RGB_MATRIX_CENTER
-const point_t k_rgb_matrix_center = {112, 32};
+const led_point_t k_rgb_matrix_center = {112, 32};
#else
-const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
+const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
#endif
__attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); }
@@ -67,8 +67,8 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv
# define RGB_DISABLE_TIMEOUT 0
#endif
-#ifndef RGB_DISABLE_WHEN_USB_SUSPENDED
-# define RGB_DISABLE_WHEN_USB_SUSPENDED false
+#if RGB_DISABLE_WHEN_USB_SUSPENDED == false
+# undef RGB_DISABLE_WHEN_USB_SUSPENDED
#endif
#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
@@ -118,7 +118,6 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv
#endif
// globals
-bool g_suspend_state = false;
rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
uint32_t g_rgb_timer;
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
@@ -129,9 +128,10 @@ last_hit_t g_last_hit_tracker;
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
// internals
+static bool suspend_state = false;
static uint8_t rgb_last_enable = UINT8_MAX;
static uint8_t rgb_last_effect = UINT8_MAX;
-static effect_params_t rgb_effect_params = {0, 0xFF};
+static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
static rgb_task_states rgb_task_state = SYNCING;
#if RGB_DISABLE_TIMEOUT > 0
static uint32_t rgb_anykey_timer;
@@ -143,6 +143,11 @@ static uint32_t rgb_timer_buffer;
static last_hit_t last_hit_buffer;
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+// split rgb matrix
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
+#endif
+
void eeconfig_read_rgb_matrix(void) { eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); }
void eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); }
@@ -153,6 +158,7 @@ void eeconfig_update_rgb_matrix_default(void) {
rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE;
rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL};
rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD;
+ rgb_matrix_config.flags = LED_FLAG_ALL;
eeconfig_update_rgb_matrix();
}
@@ -164,6 +170,7 @@ void eeconfig_debug_rgb_matrix(void) {
dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s);
dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v);
dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed);
+ dprintf("rgb_matrix_config.flags = %d\n", rgb_matrix_config.flags);
}
__attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; }
@@ -180,9 +187,22 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l
void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); }
-void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); }
+void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ if (!is_keyboard_left() && index >= k_rgb_matrix_split[0])
+ rgb_matrix_driver.set_color(index - k_rgb_matrix_split[0], red, green, blue);
+ else if (is_keyboard_left() && index < k_rgb_matrix_split[0])
+#endif
+ rgb_matrix_driver.set_color(index, red, green, blue);
+}
-void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color_all(red, green, blue); }
+void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) rgb_matrix_set_color(i, red, green, blue);
+#else
+ rgb_matrix_driver.set_color_all(red, green, blue);
+#endif
+}
void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
#ifndef RGB_MATRIX_SPLIT
@@ -315,6 +335,10 @@ static void rgb_task_start(void) {
static void rgb_task_render(uint8_t effect) {
bool rendering = false;
rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable);
+ if (rgb_effect_params.flags != rgb_matrix_config.flags) {
+ rgb_effect_params.flags = rgb_matrix_config.flags;
+ rgb_matrix_set_color_all(0, 0, 0);
+ }
// each effect can opt to do calculations
// and/or request PWM buffer updates.
@@ -385,14 +409,11 @@ void rgb_matrix_task(void) {
// Ideally we would also stop sending zeros to the LED driver PWM buffers
// while suspended and just do a software shutdown. This is a cheap hack for now.
- bool suspend_backlight =
-#if RGB_DISABLE_WHEN_USB_SUSPENDED == true
- g_suspend_state ||
-#endif // RGB_DISABLE_WHEN_USB_SUSPENDED == true
+ bool suspend_backlight = suspend_state ||
#if RGB_DISABLE_TIMEOUT > 0
- (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) ||
+ (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) ||
#endif // RGB_DISABLE_TIMEOUT > 0
- false;
+ false;
uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
@@ -477,13 +498,15 @@ void rgb_matrix_init(void) {
}
void rgb_matrix_set_suspend_state(bool state) {
- if (RGB_DISABLE_WHEN_USB_SUSPENDED && state) {
+#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED
+ if (state) {
rgb_matrix_set_color_all(0, 0, 0); // turn off all LEDs when suspending
}
- g_suspend_state = state;
+ suspend_state = state;
+#endif
}
-bool rgb_matrix_get_suspend_state(void) { return g_suspend_state; }
+bool rgb_matrix_get_suspend_state(void) { return suspend_state; }
void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
rgb_matrix_config.enable ^= 1;
@@ -618,6 +641,6 @@ void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_spe
void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); }
void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); }
-led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; }
+led_flags_t rgb_matrix_get_flags(void) { return rgb_matrix_config.flags; }
-void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; }
+void rgb_matrix_set_flags(led_flags_t flags) { rgb_matrix_config.flags = flags; }
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
index bb8bcfab68ce..a615b8422c0a 100644
--- a/quantum/rgb_matrix.h
+++ b/quantum/rgb_matrix.h
@@ -216,7 +216,6 @@ extern const rgb_matrix_driver_t rgb_matrix_driver;
extern rgb_config_t rgb_matrix_config;
-extern bool g_suspend_state;
extern uint32_t g_rgb_timer;
extern led_config_t g_led_config;
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_drivers.c b/quantum/rgb_matrix_drivers.c
index 2978e7bed9ca..896fa6d0efd5 100644
--- a/quantum/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix_drivers.c
@@ -41,7 +41,28 @@ static void init(void) {
IS31FL3731_init(DRIVER_ADDR_4);
# endif
# elif defined(IS31FL3733)
- IS31FL3733_init(DRIVER_ADDR_1, 0);
+# ifndef DRIVER_SYNC_1
+# define DRIVER_SYNC_1 0
+# endif
+ IS31FL3733_init(DRIVER_ADDR_1, DRIVER_SYNC_1);
+# if defined DRIVER_ADDR_2 && (DRIVER_ADDR_1 != DRIVER_ADDR_2)
+# ifndef DRIVER_SYNC_2
+# define DRIVER_SYNC_2 0
+# endif
+ IS31FL3733_init(DRIVER_ADDR_2, DRIVER_SYNC_2);
+# endif
+# ifdef DRIVER_ADDR_3
+# ifndef DRIVER_SYNC_3
+# define DRIVER_SYNC_3 0
+# endif
+ IS31FL3733_init(DRIVER_ADDR_3, DRIVER_SYNC_3);
+# endif
+# ifdef DRIVER_ADDR_4
+# ifndef DRIVER_SYNC_4
+# define DRIVER_SYNC_4 0
+# endif
+ IS31FL3733_init(DRIVER_ADDR_4, DRIVER_SYNC_4);
+# endif
# elif defined(IS31FL3737)
IS31FL3737_init(DRIVER_ADDR_1);
# else
@@ -74,7 +95,15 @@ static void init(void) {
# endif
# elif defined(IS31FL3733)
IS31FL3733_update_led_control_registers(DRIVER_ADDR_1, 0);
+# ifdef DRIVER_ADDR_2
IS31FL3733_update_led_control_registers(DRIVER_ADDR_2, 1);
+# endif
+# ifdef DRIVER_ADDR_3
+ IS31FL3733_update_led_control_registers(DRIVER_ADDR_3, 2);
+# endif
+# ifdef DRIVER_ADDR_4
+ IS31FL3733_update_led_control_registers(DRIVER_ADDR_4, 3);
+# endif
# elif defined(IS31FL3737)
IS31FL3737_update_led_control_registers(DRIVER_ADDR_1, DRIVER_ADDR_2);
# else
@@ -105,7 +134,15 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
# elif defined(IS31FL3733)
static void flush(void) {
IS31FL3733_update_pwm_buffers(DRIVER_ADDR_1, 0);
+# ifdef DRIVER_ADDR_2
IS31FL3733_update_pwm_buffers(DRIVER_ADDR_2, 1);
+# endif
+# ifdef DRIVER_ADDR_3
+ IS31FL3733_update_pwm_buffers(DRIVER_ADDR_3, 2);
+# endif
+# ifdef DRIVER_ADDR_4
+ IS31FL3733_update_pwm_buffers(DRIVER_ADDR_4, 3);
+# endif
}
const rgb_matrix_driver_t rgb_matrix_driver = {
diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h
index 7b8171fb23a3..df575d6577c4 100644
--- a/quantum/rgb_matrix_types.h
+++ b/quantum/rgb_matrix_types.h
@@ -62,7 +62,7 @@ typedef struct PACKED {
typedef struct PACKED {
uint8_t x;
uint8_t y;
-} point_t;
+} led_point_t;
#define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
#define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00)
@@ -77,18 +77,19 @@ typedef struct PACKED {
#define NO_LED 255
typedef struct PACKED {
- uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
- point_t point[DRIVER_LED_TOTAL];
- uint8_t flags[DRIVER_LED_TOTAL];
+ uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
+ led_point_t point[DRIVER_LED_TOTAL];
+ uint8_t flags[DRIVER_LED_TOTAL];
} led_config_t;
typedef union {
uint32_t raw;
struct PACKED {
- uint8_t enable : 2;
- uint8_t mode : 6;
- HSV hsv;
- uint8_t speed; // EECONFIG needs to be increased to support this
+ uint8_t enable : 2;
+ uint8_t mode : 6;
+ HSV hsv;
+ uint8_t speed; // EECONFIG needs to be increased to support this
+ led_flags_t flags;
};
} rgb_config_t;
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 119d3eab2131..baa10ec416bb 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -722,23 +722,39 @@ static void rgblight_layers_write(void) {
}
# ifdef RGBLIGHT_LAYER_BLINK
-rgblight_layer_mask_t _blinked_layer_mask = 0;
-static uint16_t _blink_timer;
+rgblight_layer_mask_t _blinking_layer_mask = 0;
+static uint16_t _repeat_timer;
+static uint8_t _times_remaining;
+static uint16_t _dur;
+
+void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { rgblight_blink_layer_repeat(layer, duration_ms, 1); }
+
+void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times) {
+ _times_remaining = times * 2;
+ _dur = duration_ms;
-void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) {
rgblight_set_layer_state(layer, true);
- _blinked_layer_mask |= (rgblight_layer_mask_t)1 << layer;
- _blink_timer = sync_timer_read() + duration_ms;
+ _times_remaining--;
+ _blinking_layer_mask |= (rgblight_layer_mask_t)1 << layer;
+ _repeat_timer = sync_timer_read() + duration_ms;
}
-void rgblight_unblink_layers(void) {
- if (_blinked_layer_mask != 0 && timer_expired(sync_timer_read(), _blink_timer)) {
+void rgblight_blink_layer_repeat_helper(void) {
+ if (_blinking_layer_mask != 0 && timer_expired(sync_timer_read(), _repeat_timer)) {
for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) {
- if ((_blinked_layer_mask & (rgblight_layer_mask_t)1 << layer) != 0) {
- rgblight_set_layer_state(layer, false);
+ if ((_blinking_layer_mask & (rgblight_layer_mask_t)1 << layer) != 0 && _times_remaining > 0) {
+ if (_times_remaining % 2 == 1) {
+ rgblight_set_layer_state(layer, false);
+ } else {
+ rgblight_set_layer_state(layer, true);
+ }
+ _times_remaining--;
+ _repeat_timer = sync_timer_read() + _dur;
}
}
- _blinked_layer_mask = 0;
+ if (_times_remaining <= 0) {
+ _blinking_layer_mask = 0;
+ }
}
}
# endif
@@ -755,8 +771,8 @@ void rgblight_suspend(void) {
# ifdef RGBLIGHT_LAYER_BLINK
// make sure any layer blinks don't come back after suspend
- rgblight_status.enabled_layer_mask &= ~_blinked_layer_mask;
- _blinked_layer_mask = 0;
+ rgblight_status.enabled_layer_mask &= ~_blinking_layer_mask;
+ _blinking_layer_mask = 0;
# endif
rgblight_disable_noeeprom();
@@ -874,7 +890,7 @@ void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) {
animation_status.restart = true;
}
# endif /* RGBLIGHT_SPLIT_NO_ANIMATION_SYNC */
-# endif /* RGBLIGHT_USE_TIMER */
+# endif /* RGBLIGHT_USE_TIMER */
}
#endif /* RGBLIGHT_SPLIT */
@@ -1030,7 +1046,7 @@ void rgblight_task(void) {
}
# ifdef RGBLIGHT_LAYER_BLINK
- rgblight_unblink_layers();
+ rgblight_blink_layer_repeat_helper();
# endif
}
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 6fb3ab9380e5..bec2c66955df 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -222,6 +222,7 @@ extern const rgblight_segment_t *const *rgblight_layers;
# ifdef RGBLIGHT_LAYER_BLINK
# define RGBLIGHT_USE_TIMER
void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms);
+void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times);
# endif
# endif
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index d6636b886adf..039e7d977384 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -43,6 +43,7 @@ extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
uint8_t thisHand, thatHand;
// user-defined overridable functions
+__attribute__((weak)) void matrix_slave_scan_kb(void) { matrix_slave_scan_user(); }
__attribute__((weak)) void matrix_slave_scan_user(void) {}
static inline void setPinOutput_writeLow(pin_t pin) {
@@ -129,9 +130,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Unselect row
unselect_row(current_row);
- if (current_row + 1 < MATRIX_ROWS) {
- matrix_output_unselect_delay(); // wait for row signal to go HIGH
- }
+ matrix_output_unselect_delay(); // wait for all Col signals to go HIGH
// If the row has changed, store the row and return the changed flag.
if (current_matrix[current_row] != current_row_value) {
@@ -191,9 +190,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
// Unselect col
unselect_col(current_col);
- if (current_col + 1 < MATRIX_COLS) {
- matrix_output_unselect_delay(); // wait for col signal to go HIGH
- }
+ matrix_output_unselect_delay(); // wait for all Row signals to go HIGH
return matrix_changed;
}
@@ -284,7 +281,7 @@ bool matrix_post_scan(void) {
} else {
transport_slave(matrix + thatHand, matrix + thisHand);
- matrix_slave_scan_user();
+ matrix_slave_scan_kb();
}
return changed;
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index 2ae44e6e15f4..9e75e19ce0ea 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -1,3 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#include "split_util.h"
#include "matrix.h"
#include "keyboard.h"
@@ -6,14 +21,7 @@
#include "transport.h"
#include "quantum.h"
#include "wait.h"
-
-#ifdef PROTOCOL_LUFA
-# include
-#endif
-
-#ifdef PROTOCOL_VUSB
-# include
-#endif
+#include "usb_util.h"
#ifdef EE_HANDS
# include "eeconfig.h"
@@ -31,56 +39,21 @@
# define SPLIT_USB_TIMEOUT_POLL 10
#endif
-#ifdef PROTOCOL_CHIBIOS
-# define SPLIT_USB_DETECT // Force this on for now
-#endif
-
volatile bool isLeftHand = true;
#if defined(SPLIT_USB_DETECT)
-# if defined(PROTOCOL_LUFA)
-static inline bool usbHasActiveConnection(void) { return USB_Device_IsAddressSet(); }
-static inline void usbDisable(void) {
- USB_Disable();
- USB_DeviceState = DEVICE_STATE_Unattached;
-}
-# elif defined(PROTOCOL_CHIBIOS)
-static inline bool usbHasActiveConnection(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; }
-static inline void usbDisable(void) { usbStop(&USBD1); }
-# elif defined(PROTOCOL_VUSB)
-static inline bool usbHasActiveConnection(void) {
- usbPoll();
- return usbConfiguration;
-}
-static inline void usbDisable(void) { usbDeviceDisconnect(); }
-# else
-static inline bool usbHasActiveConnection(void) { return true; }
-static inline void usbDisable(void) {}
-# endif
-
-bool usbIsActive(void) {
+static bool usbIsActive(void) {
for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) {
// This will return true if a USB connection has been established
- if (usbHasActiveConnection()) {
+ if (usb_connected_state()) {
return true;
}
wait_ms(SPLIT_USB_TIMEOUT_POLL);
}
-
- // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow
- usbDisable();
-
return false;
}
-#elif defined(PROTOCOL_LUFA) && defined(OTGPADE)
-static inline bool usbIsActive(void) {
- USB_OTGPAD_On(); // enables VBUS pad
- wait_us(5);
-
- return USB_VBUS_GetStatus(); // checks state of VBUS
-}
#else
-static inline bool usbIsActive(void) { return true; }
+static inline bool usbIsActive(void) { return usb_vbus_state(); }
#endif
#ifdef SPLIT_HAND_MATRIX_GRID
@@ -126,6 +99,11 @@ __attribute__((weak)) bool is_keyboard_master(void) {
// only check once, as this is called often
if (usbstate == UNKNOWN) {
usbstate = usbIsActive() ? MASTER : SLAVE;
+
+ // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow
+ if (usbstate == SLAVE) {
+ usb_disable();
+ }
}
return (usbstate == MASTER);
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index 61b61ea08cfb..9ed0f7591b6c 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -22,6 +22,13 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A;
# define NUMBER_OF_ENCODERS (sizeof(encoders_pad) / sizeof(pin_t))
#endif
+#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+# include "led_matrix.h"
+#endif
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+# include "rgb_matrix.h"
+#endif
+
#if defined(USE_I2C)
# include "i2c_master.h"
@@ -54,6 +61,14 @@ typedef struct _I2C_slave_buffer_t {
# ifdef WPM_ENABLE
uint8_t current_wpm;
# endif
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_eeconfig_t led_matrix;
+ bool led_suspend_state;
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_config_t rgb_matrix;
+ bool rgb_suspend_state;
+# endif
} I2C_slave_buffer_t;
static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
@@ -68,6 +83,10 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
# define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state)
# define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm)
+# define I2C_LED_MATRIX_START offsetof(I2C_slave_buffer_t, led_matrix)
+# define I2C_LED_SUSPEND_START offsetof(I2C_slave_buffer_t, led_suspend_state)
+# define I2C_RGB_MATRIX_START offsetof(I2C_slave_buffer_t, rgb_matrix)
+# define I2C_RGB_SUSPEND_START offsetof(I2C_slave_buffer_t, rgb_suspend_state)
# define TIMEOUT 100
@@ -141,6 +160,17 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
# endif
# endif
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LED_MATRIX_START, (void *)led_matrix_eeconfig, sizeof(i2c_buffer->led_matrix), TIMEOUT);
+ bool suspend_state = led_matrix_get_suspend_state();
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LED_SUSPEND_START, (void *)suspend_state, sizeof(i2c_buffer->led_suspend_state), TIMEOUT);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_START, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix), TIMEOUT);
+ bool suspend_state = rgb_matrix_get_suspend_state();
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_SUSPEND_START, (void *)suspend_state, sizeof(i2c_buffer->rgb_suspend_state), TIMEOUT);
+# endif
+
# ifndef DISABLE_SYNC_TIMER
i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT);
@@ -186,6 +216,15 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
set_oneshot_mods(i2c_buffer->oneshot_mods);
# endif
# endif
+
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ memcpy((void *)i2c_buffer->led_matrix, (void *)led_matrix_eeconfig, sizeof(i2c_buffer->led_matrix));
+ led_matrix_set_suspend_state(i2c_buffer->led_suspend_state);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ memcpy((void *)i2c_buffer->rgb_matrix, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix));
+ rgb_matrix_set_suspend_state(i2c_buffer->rgb_suspend_state);
+# endif
}
void transport_master_init(void) { i2c_init(); }
@@ -201,30 +240,38 @@ typedef struct _Serial_s2m_buffer_t {
matrix_row_t smatrix[ROWS_PER_HAND];
# ifdef ENCODER_ENABLE
- uint8_t encoder_state[NUMBER_OF_ENCODERS];
+ uint8_t encoder_state[NUMBER_OF_ENCODERS];
# endif
} Serial_s2m_buffer_t;
typedef struct _Serial_m2s_buffer_t {
# ifdef SPLIT_MODS_ENABLE
- uint8_t real_mods;
- uint8_t weak_mods;
+ uint8_t real_mods;
+ uint8_t weak_mods;
# ifndef NO_ACTION_ONESHOT
- uint8_t oneshot_mods;
+ uint8_t oneshot_mods;
# endif
# endif
# ifndef DISABLE_SYNC_TIMER
- uint32_t sync_timer;
+ uint32_t sync_timer;
# endif
# ifdef SPLIT_TRANSPORT_MIRROR
matrix_row_t mmatrix[ROWS_PER_HAND];
# endif
# ifdef BACKLIGHT_ENABLE
- uint8_t backlight_level;
+ uint8_t backlight_level;
# endif
# ifdef WPM_ENABLE
- uint8_t current_wpm;
+ uint8_t current_wpm;
+# endif
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_eeconfig_t led_matrix;
+ bool led_suspend_state;
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_config_t rgb_matrix;
+ bool rgb_suspend_state;
# endif
} Serial_m2s_buffer_t;
@@ -316,7 +363,7 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
// TODO: if MATRIX_COLS > 8 change to unpack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
- slave_matrix[i] = serial_s2m_buffer.smatrix[i];
+ slave_matrix[i] = serial_s2m_buffer.smatrix[i];
# ifdef SPLIT_TRANSPORT_MIRROR
serial_m2s_buffer.mmatrix[i] = master_matrix[i];
# endif
@@ -333,18 +380,28 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
# ifdef WPM_ENABLE
// Write wpm to slave
- serial_m2s_buffer.current_wpm = get_current_wpm();
+ serial_m2s_buffer.current_wpm = get_current_wpm();
# endif
# ifdef SPLIT_MODS_ENABLE
- serial_m2s_buffer.real_mods = get_mods();
- serial_m2s_buffer.weak_mods = get_weak_mods();
+ serial_m2s_buffer.real_mods = get_mods();
+ serial_m2s_buffer.weak_mods = get_weak_mods();
# ifndef NO_ACTION_ONESHOT
serial_m2s_buffer.oneshot_mods = get_oneshot_mods();
# endif
# endif
+
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ serial_m2s_buffer.led_matrix = led_matrix_eeconfig;
+ serial_m2s_buffer.led_suspend_state = led_matrix_get_suspend_state();
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ serial_m2s_buffer.rgb_matrix = rgb_matrix_config;
+ serial_m2s_buffer.rgb_suspend_state = rgb_matrix_get_suspend_state();
+# endif
+
# ifndef DISABLE_SYNC_TIMER
- serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
+ serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
# endif
return true;
}
@@ -359,7 +416,7 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
for (int i = 0; i < ROWS_PER_HAND; ++i) {
serial_s2m_buffer.smatrix[i] = slave_matrix[i];
# ifdef SPLIT_TRANSPORT_MIRROR
- master_matrix[i] = serial_m2s_buffer.mmatrix[i];
+ master_matrix[i] = serial_m2s_buffer.mmatrix[i];
# endif
}
# ifdef BACKLIGHT_ENABLE
@@ -381,6 +438,15 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
set_oneshot_mods(serial_m2s_buffer.oneshot_mods);
# endif
# endif
+
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_matrix_eeconfig = serial_m2s_buffer.led_matrix;
+ led_matrix_set_suspend_state(serial_m2s_buffer.led_suspend_state);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_matrix_config = serial_m2s_buffer.rgb_matrix;
+ rgb_matrix_set_suspend_state(serial_m2s_buffer.rgb_suspend_state);
+# endif
}
#endif
diff --git a/quantum/wpm.c b/quantum/wpm.c
index da30bd252ce7..bec419a48e57 100644
--- a/quantum/wpm.c
+++ b/quantum/wpm.c
@@ -19,11 +19,10 @@
// WPM Stuff
static uint8_t current_wpm = 0;
-static uint8_t latest_wpm = 0;
static uint16_t wpm_timer = 0;
// This smoothing is 40 keystrokes
-static const float wpm_smoothing = 0.0487;
+static const float wpm_smoothing = WPM_SMOOTHING;
void set_current_wpm(uint8_t new_wpm) { current_wpm = new_wpm; }
@@ -46,19 +45,46 @@ __attribute__((weak)) bool wpm_keycode_user(uint16_t keycode) {
return false;
}
+#ifdef WPM_ALLOW_COUNT_REGRESSION
+__attribute__((weak)) uint8_t wpm_regress_count(uint16_t keycode) {
+ bool weak_modded = (keycode >= QK_LCTL && keycode < QK_LSFT) || (keycode >= QK_RCTL && keycode < QK_RSFT);
+
+ if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
+ keycode = keycode & 0xFF;
+ } else if (keycode > 0xFF) {
+ keycode = 0;
+ }
+ if (keycode == KC_DEL || keycode == KC_BSPC) {
+ if (((get_mods() | get_oneshot_mods()) & MOD_MASK_CTRL) || weak_modded) {
+ return WPM_ESTIMATED_WORD_SIZE;
+ } else {
+ return 1;
+ }
+ } else {
+ return 0;
+ }
+}
+#endif
+
void update_wpm(uint16_t keycode) {
if (wpm_keycode(keycode)) {
if (wpm_timer > 0) {
- latest_wpm = 60000 / timer_elapsed(wpm_timer) / 5;
- current_wpm = (latest_wpm - current_wpm) * wpm_smoothing + current_wpm;
+ current_wpm += ((60000 / timer_elapsed(wpm_timer) / WPM_ESTIMATED_WORD_SIZE) - current_wpm) * wpm_smoothing;
}
wpm_timer = timer_read();
}
+#ifdef WPM_ALLOW_COUNT_REGRESSION
+ uint8_t regress = wpm_regress_count(keycode);
+ if (regress) {
+ current_wpm -= regress;
+ wpm_timer = timer_read();
+ }
+#endif
}
void decay_wpm(void) {
if (timer_elapsed(wpm_timer) > 1000) {
- current_wpm = (0 - current_wpm) * wpm_smoothing + current_wpm;
- wpm_timer = timer_read();
+ current_wpm += (-current_wpm) * wpm_smoothing;
+ wpm_timer = timer_read();
}
}
diff --git a/quantum/wpm.h b/quantum/wpm.h
index 15ab4ffcd1b0..4af52d2b989d 100644
--- a/quantum/wpm.h
+++ b/quantum/wpm.h
@@ -19,10 +19,21 @@
#include "quantum.h"
+#ifndef WPM_ESTIMATED_WORD_SIZE
+# define WPM_ESTIMATED_WORD_SIZE 5
+#endif
+#ifndef WPM_SMOOTHING
+# define WPM_SMOOTHING 0.0487
+#endif
+
bool wpm_keycode(uint16_t keycode);
bool wpm_keycode_kb(uint16_t keycode);
bool wpm_keycode_user(uint16_t keycode);
+#ifdef WPM_ALLOW_COUNT_REGRESSION
+uint8_t wpm_regress_count(uint16_t keycode);
+#endif
+
void set_current_wpm(uint8_t);
uint8_t get_current_wpm(void);
void update_wpm(uint16_t);
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 1db3b6d73315..12d570e70c6b 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -4,5 +4,7 @@
# Python development requirements
nose2
flake8
+hid
pep8-naming
+pyusb
yapf
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index 2bc7cc95534c..521305f1b4f4 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -294,7 +294,7 @@ ifneq ($(strip $(BOOTLOADER)), qmk-dfu)
$(error Please set BOOTLOADER = qmk-dfu first!)
endif
make -C lib/lufa/Bootloaders/DFU/ clean
- bin/qmk generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
+ $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 40595a1e3b28..cdf9ba6495c0 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -190,6 +190,8 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld)","")
LDSCRIPT = $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld
else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld)","")
LDSCRIPT = $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld
+else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/ld/$(MCU_LDSCRIPT).ld)","")
+ LDSCRIPT = $(TOP_DIR)/platforms/chibios/$(BOARD)/ld/$(MCU_LDSCRIPT).ld
else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/common/ld/$(MCU_LDSCRIPT).ld)","")
LDSCRIPT = $(TOP_DIR)/platforms/chibios/common/ld/$(MCU_LDSCRIPT).ld
else ifneq ("$(wildcard $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld)","")
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index 238b3c69fd56..2f8f81126ab6 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -12,6 +12,7 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \
$(COMMON_DIR)/sendchar_null.c \
$(COMMON_DIR)/eeconfig.c \
$(COMMON_DIR)/report.c \
+ $(COMMON_DIR)/usb_util.c \
$(PLATFORM_COMMON_DIR)/suspend.c \
$(PLATFORM_COMMON_DIR)/timer.c \
$(COMMON_DIR)/sync_timer.c \
@@ -24,28 +25,6 @@ else
include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk
endif
-# Option modules
-BOOTMAGIC_ENABLE ?= no
-VALID_MAGIC_TYPES := yes full lite
-ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
- ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),)
- $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic)
- endif
- ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite)
- TMK_COMMON_DEFS += -DBOOTMAGIC_LITE
- TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic_lite.c
-
- TMK_COMMON_DEFS += -DMAGIC_ENABLE
- TMK_COMMON_SRC += $(COMMON_DIR)/magic.c
- else
- TMK_COMMON_DEFS += -DBOOTMAGIC_ENABLE
- TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic.c
- endif
-else
- TMK_COMMON_DEFS += -DMAGIC_ENABLE
- TMK_COMMON_SRC += $(COMMON_DIR)/magic.c
-endif
-
SHARED_EP_ENABLE = no
MOUSE_SHARED_EP ?= yes
ifeq ($(strip $(KEYBOARD_SHARED_EP)), yes)
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index aae5cbfa5feb..bd41d28b6679 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -133,7 +133,8 @@ void process_hand_swap(keyevent_t *event) {
bool do_swap = event->pressed ? swap_hands : swap_state[pos.row] & (col_bit);
if (do_swap) {
- event->key = hand_swap_config[pos.row][pos.col];
+ event->key.row = pgm_read_byte(&hand_swap_config[pos.row][pos.col].row);
+ event->key.col = pgm_read_byte(&hand_swap_config[pos.row][pos.col].col);
swap_state[pos.row] |= col_bit;
} else {
swap_state[pos.row] &= ~(col_bit);
@@ -772,10 +773,9 @@ void register_code(uint8_t code) {
}
#endif
- else if
- IS_KEY(code) {
- // TODO: should push command_proc out of this block?
- if (command_proc(code)) return;
+ else if IS_KEY (code) {
+ // TODO: should push command_proc out of this block?
+ if (command_proc(code)) return;
#ifndef NO_ACTION_ONESHOT
/* TODO: remove
@@ -792,35 +792,33 @@ void register_code(uint8_t code) {
} else
*/
#endif
- {
- // Force a new key press if the key is already pressed
- // without this, keys with the same keycode, but different
- // modifiers will be reported incorrectly, see issue #1708
- if (is_key_pressed(keyboard_report, code)) {
- del_key(code);
- send_keyboard_report();
- }
- add_key(code);
+ {
+ // Force a new key press if the key is already pressed
+ // without this, keys with the same keycode, but different
+ // modifiers will be reported incorrectly, see issue #1708
+ if (is_key_pressed(keyboard_report, code)) {
+ del_key(code);
send_keyboard_report();
}
- }
- else if
- IS_MOD(code) {
- add_mods(MOD_BIT(code));
+ add_key(code);
send_keyboard_report();
}
+ } else if IS_MOD (code) {
+ add_mods(MOD_BIT(code));
+ send_keyboard_report();
+ }
#ifdef EXTRAKEY_ENABLE
- else if
- IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); }
- else if
- IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); }
+ else if IS_SYSTEM (code) {
+ host_system_send(KEYCODE2SYSTEM(code));
+ } else if IS_CONSUMER (code) {
+ host_consumer_send(KEYCODE2CONSUMER(code));
+ }
#endif
#ifdef MOUSEKEY_ENABLE
- else if
- IS_MOUSEKEY(code) {
- mousekey_on(code);
- mousekey_send();
- }
+ else if IS_MOUSEKEY (code) {
+ mousekey_on(code);
+ mousekey_send();
+ }
#endif
}
@@ -865,26 +863,22 @@ void unregister_code(uint8_t code) {
}
#endif
- else if
- IS_KEY(code) {
- del_key(code);
- send_keyboard_report();
- }
- else if
- IS_MOD(code) {
- del_mods(MOD_BIT(code));
- send_keyboard_report();
- }
- else if
- IS_SYSTEM(code) { host_system_send(0); }
- else if
- IS_CONSUMER(code) { host_consumer_send(0); }
+ else if IS_KEY (code) {
+ del_key(code);
+ send_keyboard_report();
+ } else if IS_MOD (code) {
+ del_mods(MOD_BIT(code));
+ send_keyboard_report();
+ } else if IS_SYSTEM (code) {
+ host_system_send(0);
+ } else if IS_CONSUMER (code) {
+ host_consumer_send(0);
+ }
#ifdef MOUSEKEY_ENABLE
- else if
- IS_MOUSEKEY(code) {
- mousekey_off(code);
- mousekey_send();
- }
+ else if IS_MOUSEKEY (code) {
+ mousekey_off(code);
+ mousekey_send();
+ }
#endif
}
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h
index 9a991de1c2ba..8cb4722c6e7d 100644
--- a/tmk_core/common/action.h
+++ b/tmk_core/common/action.h
@@ -77,8 +77,8 @@ extern bool disable_action_cache;
/* Code for handling one-handed key modifiers. */
#ifdef SWAP_HANDS_ENABLE
-extern bool swap_hands;
-extern const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
+extern bool swap_hands;
+extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
# if (MATRIX_COLS <= 8)
typedef uint8_t swap_state_row_t;
# elif (MATRIX_COLS <= 16)
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c
index 000503b0821a..a57c8bf66a8e 100644
--- a/tmk_core/common/action_util.c
+++ b/tmk_core/common/action_util.c
@@ -147,12 +147,16 @@ void clear_oneshot_swaphands(void) {
* FIXME: needs doc
*/
void set_oneshot_layer(uint8_t layer, uint8_t state) {
- oneshot_layer_data = layer << 3 | state;
- layer_on(layer);
+ if (!keymap_config.oneshot_disable) {
+ oneshot_layer_data = layer << 3 | state;
+ layer_on(layer);
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
- oneshot_layer_time = timer_read();
+ oneshot_layer_time = timer_read();
# endif
- oneshot_layer_changed_kb(get_oneshot_layer());
+ oneshot_layer_changed_kb(get_oneshot_layer());
+ } else {
+ layer_on(layer);
+ }
}
/** \brief Reset oneshot layer
*
@@ -172,7 +176,7 @@ void reset_oneshot_layer(void) {
void clear_oneshot_layer_state(oneshot_fullfillment_t state) {
uint8_t start_state = oneshot_layer_data;
oneshot_layer_data &= ~state;
- if (!get_oneshot_layer_state() && start_state != oneshot_layer_data) {
+ if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) || keymap_config.oneshot_disable) {
layer_off(get_oneshot_layer());
reset_oneshot_layer();
}
@@ -182,6 +186,39 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state) {
* FIXME: needs doc
*/
bool is_oneshot_layer_active(void) { return get_oneshot_layer_state(); }
+
+/** \brief set oneshot
+ *
+ * FIXME: needs doc
+ */
+void oneshot_set(bool active) {
+ if (keymap_config.oneshot_disable != active) {
+ keymap_config.oneshot_disable = active;
+ eeconfig_update_keymap(keymap_config.raw);
+ dprintf("Oneshot: active: %d\n", active);
+ }
+}
+
+/** \brief toggle oneshot
+ *
+ * FIXME: needs doc
+ */
+void oneshot_toggle(void) { oneshot_set(!keymap_config.oneshot_disable); }
+
+/** \brief enable oneshot
+ *
+ * FIXME: needs doc
+ */
+void oneshot_enable(void) { oneshot_set(true); }
+
+/** \brief disable oneshot
+ *
+ * FIXME: needs doc
+ */
+void oneshot_disable(void) { oneshot_set(false); }
+
+bool is_oneshot_enabled(void) { return keymap_config.oneshot_disable; }
+
#endif
/** \brief Send keyboard report
@@ -321,14 +358,17 @@ void del_oneshot_mods(uint8_t mods) {
* FIXME: needs doc
*/
void set_oneshot_mods(uint8_t mods) {
- if (oneshot_mods != mods) {
+ if (!keymap_config.oneshot_disable) {
+ if (oneshot_mods != mods) {
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
- oneshot_time = timer_read();
+ oneshot_time = timer_read();
# endif
- oneshot_mods = mods;
- oneshot_mods_changed_kb(mods);
+ oneshot_mods = mods;
+ oneshot_mods_changed_kb(mods);
+ }
}
}
+
/** \brief clear oneshot mods
*
* FIXME: needs doc
diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h
index ff29f79b09d8..f2b3897ae501 100644
--- a/tmk_core/common/action_util.h
+++ b/tmk_core/common/action_util.h
@@ -85,6 +85,11 @@ void oneshot_mods_changed_kb(uint8_t mods);
void oneshot_layer_changed_user(uint8_t layer);
void oneshot_layer_changed_kb(uint8_t layer);
+void oneshot_toggle(void);
+void oneshot_enable(void);
+void oneshot_disable(void);
+bool is_oneshot_enabled(void);
+
/* inspect */
uint8_t has_anymod(void);
diff --git a/tmk_core/common/arm_atsam/_wait.h b/tmk_core/common/arm_atsam/_wait.h
new file mode 100644
index 000000000000..41b686b56c84
--- /dev/null
+++ b/tmk_core/common/arm_atsam/_wait.h
@@ -0,0 +1,22 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#include "clks.h"
+
+#define wait_ms(ms) CLK_delay_ms(ms)
+#define wait_us(us) CLK_delay_us(us)
+#define waitInputPinDelay()
diff --git a/tmk_core/common/avr/_wait.h b/tmk_core/common/avr/_wait.h
new file mode 100644
index 000000000000..56eb316faf63
--- /dev/null
+++ b/tmk_core/common/avr/_wait.h
@@ -0,0 +1,29 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#include
+
+#define wait_ms(ms) _delay_ms(ms)
+#define wait_us(us) _delay_us(us)
+
+/* The AVR series GPIOs have a one clock read delay for changes in the digital input signal.
+ * But here's more margin to make it two clocks. */
+#ifndef GPIO_INPUT_PIN_DELAY
+# define GPIO_INPUT_PIN_DELAY 2
+#endif
+
+#define waitInputPinDelay() __builtin_avr_delay_cycles(GPIO_INPUT_PIN_DELAY)
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c
index 47a82a2eecba..690d7f38caa2 100644
--- a/tmk_core/common/avr/suspend.c
+++ b/tmk_core/common/avr/suspend.c
@@ -28,6 +28,13 @@
# include "rgblight.h"
#endif
+#ifdef LED_MATRIX_ENABLE
+# include "led_matrix.h"
+#endif
+#ifdef RGB_MATRIX_ENABLE
+# include "rgb_matrix.h"
+#endif
+
/** \brief Suspend idle
*
* FIXME: needs doc
@@ -156,6 +163,13 @@ void suspend_power_down(void) {
rgblight_suspend();
# endif
+# if defined(LED_MATRIX_ENABLE)
+ led_matrix_set_suspend_state(true);
+# endif
+# if defined(RGB_MATRIX_ENABLE)
+ rgb_matrix_set_suspend_state(true);
+# endif
+
// Enter sleep state if possible (ie, the MCU has a watchdog timeout interrupt)
# if defined(WDT_vect)
power_down(WDTO_15MS);
@@ -208,6 +222,13 @@ void suspend_wakeup_init(void) {
rgblight_wakeup();
#endif
+#if defined(LED_MATRIX_ENABLE)
+ led_matrix_set_suspend_state(false);
+#endif
+#if defined(RGB_MATRIX_ENABLE)
+ rgb_matrix_set_suspend_state(false);
+#endif
+
suspend_wakeup_init_kb();
}
diff --git a/tmk_core/common/chibios/_wait.h b/tmk_core/common/chibios/_wait.h
new file mode 100644
index 000000000000..5bface53e1d0
--- /dev/null
+++ b/tmk_core/common/chibios/_wait.h
@@ -0,0 +1,55 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#include
+
+/* chThdSleepX of zero maps to infinite - so we map to a tiny delay to still yield */
+#define wait_ms(ms) \
+ do { \
+ if (ms != 0) { \
+ chThdSleepMilliseconds(ms); \
+ } else { \
+ chThdSleepMicroseconds(1); \
+ } \
+ } while (0)
+#define wait_us(us) \
+ do { \
+ if (us != 0) { \
+ chThdSleepMicroseconds(us); \
+ } else { \
+ chThdSleepMicroseconds(1); \
+ } \
+ } while (0)
+
+/* For GPIOs on ARM-based MCUs, the input pins are sampled by the clock of the bus
+ * to which the GPIO is connected.
+ * The connected buses differ depending on the various series of MCUs.
+ * And since the instruction execution clock of the CPU and the bus clock of GPIO are different,
+ * there is a delay of several clocks to read the change of the input signal.
+ *
+ * Define this delay with the GPIO_INPUT_PIN_DELAY macro.
+ * If the GPIO_INPUT_PIN_DELAY macro is not defined, the following default values will be used.
+ * (A fairly large value of 0.25 microseconds is set.)
+ */
+
+#include "wait.c"
+
+#ifndef GPIO_INPUT_PIN_DELAY
+# define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4)
+#endif
+
+#define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c
index 6cabcc4b81b5..11f7abf432a4 100644
--- a/tmk_core/common/chibios/bootloader.c
+++ b/tmk_core/common/chibios/bootloader.c
@@ -13,7 +13,23 @@
# define STM32_BOOTLOADER_DUAL_BANK FALSE
#endif
-#if STM32_BOOTLOADER_DUAL_BANK
+#ifdef BOOTLOADER_TINYUF2
+
+# define DBL_TAP_MAGIC 0xf01669ef // From tinyuf2's board_api.h
+
+// defined by linker script
+extern uint32_t _board_dfu_dbl_tap[];
+# define DBL_TAP_REG _board_dfu_dbl_tap[0]
+
+void bootloader_jump(void) {
+ DBL_TAP_REG = DBL_TAP_MAGIC;
+ NVIC_SystemReset();
+}
+
+void enter_bootloader_mode_if_requested(void) { /* not needed, no two-stage reset */
+}
+
+#elif STM32_BOOTLOADER_DUAL_BANK
// Need pin definitions
# include "config_common.h"
@@ -79,7 +95,7 @@ void enter_bootloader_mode_if_requested(void) {
}
}
-#elif defined(KL2x) || defined(K20x) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS
+#elif defined(KL2x) || defined(K20x) || defined(MK66F18) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS
/* Kinetis */
# if defined(BOOTLOADER_KIIBOHD)
diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h
index b4d96465d16c..1d8ace495565 100644
--- a/tmk_core/common/chibios/chibios_config.h
+++ b/tmk_core/common/chibios/chibios_config.h
@@ -15,6 +15,8 @@
*/
#pragma once
+#define SPLIT_USB_DETECT // Force this on for now
+
#if defined(STM32F1XX)
# define USE_GPIOV1
#endif
@@ -28,4 +30,9 @@
# define USE_I2CV1
# define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed
# define USE_GPIOV1
+# define STM32_SYSCLK KINETIS_SYSCLK_FREQUENCY
+#endif
+
+#if defined(MK66F18)
+# define STM32_SYSCLK KINETIS_SYSCLK_FREQUENCY
#endif
diff --git a/tmk_core/common/chibios/pin_defs.h b/tmk_core/common/chibios/pin_defs.h
index 86bc1076e88a..c03f8de0c253 100644
--- a/tmk_core/common/chibios/pin_defs.h
+++ b/tmk_core/common/chibios/pin_defs.h
@@ -70,6 +70,23 @@
# define A13 PAL_LINE(GPIOA, 13)
# define A14 PAL_LINE(GPIOA, 14)
# define A15 PAL_LINE(GPIOA, 15)
+# define A16 PAL_LINE(GPIOA, 16)
+# define A17 PAL_LINE(GPIOA, 17)
+# define A18 PAL_LINE(GPIOA, 18)
+# define A19 PAL_LINE(GPIOA, 19)
+# define A20 PAL_LINE(GPIOA, 20)
+# define A21 PAL_LINE(GPIOA, 21)
+# define A22 PAL_LINE(GPIOA, 22)
+# define A23 PAL_LINE(GPIOA, 23)
+# define A24 PAL_LINE(GPIOA, 24)
+# define A25 PAL_LINE(GPIOA, 25)
+# define A26 PAL_LINE(GPIOA, 26)
+# define A27 PAL_LINE(GPIOA, 27)
+# define A28 PAL_LINE(GPIOA, 28)
+# define A29 PAL_LINE(GPIOA, 29)
+# define A30 PAL_LINE(GPIOA, 30)
+# define A31 PAL_LINE(GPIOA, 31)
+# define A32 PAL_LINE(GPIOA, 32)
# define B0 PAL_LINE(GPIOB, 0)
# define B1 PAL_LINE(GPIOB, 1)
# define B2 PAL_LINE(GPIOB, 2)
@@ -90,6 +107,19 @@
# define B17 PAL_LINE(GPIOB, 17)
# define B18 PAL_LINE(GPIOB, 18)
# define B19 PAL_LINE(GPIOB, 19)
+# define B20 PAL_LINE(GPIOB, 20)
+# define B21 PAL_LINE(GPIOB, 21)
+# define B22 PAL_LINE(GPIOB, 22)
+# define B23 PAL_LINE(GPIOB, 23)
+# define B24 PAL_LINE(GPIOB, 24)
+# define B25 PAL_LINE(GPIOB, 25)
+# define B26 PAL_LINE(GPIOB, 26)
+# define B27 PAL_LINE(GPIOB, 27)
+# define B28 PAL_LINE(GPIOB, 28)
+# define B29 PAL_LINE(GPIOB, 29)
+# define B30 PAL_LINE(GPIOB, 30)
+# define B31 PAL_LINE(GPIOB, 31)
+# define B32 PAL_LINE(GPIOB, 32)
# define C0 PAL_LINE(GPIOC, 0)
# define C1 PAL_LINE(GPIOC, 1)
# define C2 PAL_LINE(GPIOC, 2)
@@ -106,6 +136,23 @@
# define C13 PAL_LINE(GPIOC, 13)
# define C14 PAL_LINE(GPIOC, 14)
# define C15 PAL_LINE(GPIOC, 15)
+# define C16 PAL_LINE(GPIOC, 16)
+# define C17 PAL_LINE(GPIOC, 17)
+# define C18 PAL_LINE(GPIOC, 18)
+# define C19 PAL_LINE(GPIOC, 19)
+# define C20 PAL_LINE(GPIOC, 20)
+# define C21 PAL_LINE(GPIOC, 21)
+# define C22 PAL_LINE(GPIOC, 22)
+# define C23 PAL_LINE(GPIOC, 23)
+# define C24 PAL_LINE(GPIOC, 24)
+# define C25 PAL_LINE(GPIOC, 25)
+# define C26 PAL_LINE(GPIOC, 26)
+# define C27 PAL_LINE(GPIOC, 27)
+# define C28 PAL_LINE(GPIOC, 28)
+# define C29 PAL_LINE(GPIOC, 29)
+# define C30 PAL_LINE(GPIOC, 30)
+# define C31 PAL_LINE(GPIOC, 31)
+# define C32 PAL_LINE(GPIOC, 32)
# define D0 PAL_LINE(GPIOD, 0)
# define D1 PAL_LINE(GPIOD, 1)
# define D2 PAL_LINE(GPIOD, 2)
@@ -122,6 +169,23 @@
# define D13 PAL_LINE(GPIOD, 13)
# define D14 PAL_LINE(GPIOD, 14)
# define D15 PAL_LINE(GPIOD, 15)
+# define D16 PAL_LINE(GPIOD, 16)
+# define D17 PAL_LINE(GPIOD, 17)
+# define D18 PAL_LINE(GPIOD, 18)
+# define D19 PAL_LINE(GPIOD, 19)
+# define D20 PAL_LINE(GPIOD, 20)
+# define D21 PAL_LINE(GPIOD, 21)
+# define D22 PAL_LINE(GPIOD, 22)
+# define D23 PAL_LINE(GPIOD, 23)
+# define D24 PAL_LINE(GPIOD, 24)
+# define D25 PAL_LINE(GPIOD, 25)
+# define D26 PAL_LINE(GPIOD, 26)
+# define D27 PAL_LINE(GPIOD, 27)
+# define D28 PAL_LINE(GPIOD, 28)
+# define D29 PAL_LINE(GPIOD, 29)
+# define D30 PAL_LINE(GPIOD, 30)
+# define D31 PAL_LINE(GPIOD, 31)
+# define D32 PAL_LINE(GPIOD, 32)
# define E0 PAL_LINE(GPIOE, 0)
# define E1 PAL_LINE(GPIOE, 1)
# define E2 PAL_LINE(GPIOE, 2)
@@ -138,6 +202,23 @@
# define E13 PAL_LINE(GPIOE, 13)
# define E14 PAL_LINE(GPIOE, 14)
# define E15 PAL_LINE(GPIOE, 15)
+# define E16 PAL_LINE(GPIOE, 16)
+# define E17 PAL_LINE(GPIOE, 17)
+# define E18 PAL_LINE(GPIOE, 18)
+# define E19 PAL_LINE(GPIOE, 19)
+# define E20 PAL_LINE(GPIOE, 20)
+# define E21 PAL_LINE(GPIOE, 21)
+# define E22 PAL_LINE(GPIOE, 22)
+# define E23 PAL_LINE(GPIOE, 23)
+# define E24 PAL_LINE(GPIOE, 24)
+# define E25 PAL_LINE(GPIOE, 25)
+# define E26 PAL_LINE(GPIOE, 26)
+# define E27 PAL_LINE(GPIOE, 27)
+# define E28 PAL_LINE(GPIOE, 28)
+# define E29 PAL_LINE(GPIOE, 29)
+# define E30 PAL_LINE(GPIOE, 30)
+# define E31 PAL_LINE(GPIOE, 31)
+# define E32 PAL_LINE(GPIOE, 32)
# define F0 PAL_LINE(GPIOF, 0)
# define F1 PAL_LINE(GPIOF, 1)
# define F2 PAL_LINE(GPIOF, 2)
diff --git a/tmk_core/common/chibios/sleep_led.c b/tmk_core/common/chibios/sleep_led.c
index 5595eec0e56c..1c65016a427e 100644
--- a/tmk_core/common/chibios/sleep_led.c
+++ b/tmk_core/common/chibios/sleep_led.c
@@ -9,21 +9,13 @@
* Use LP timer on Kinetises, TIM14 on STM32F0.
*/
-#if defined(KL2x) || defined(K20x)
-
-/* Use Low Power Timer (LPTMR) */
-# define TIMER_INTERRUPT_VECTOR KINETIS_LPTMR0_IRQ_VECTOR
-# define RESET_COUNTER LPTMR0->CSR |= LPTMRx_CSR_TCF
-
-#elif defined(STM32F0XX)
-
-/* Use TIM14 manually */
-# define TIMER_INTERRUPT_VECTOR STM32_TIM14_HANDLER
-# define RESET_COUNTER STM32_TIM14->SR &= ~STM32_TIM_SR_UIF
-
+#ifndef SLEEP_LED_GPT_DRIVER
+# if defined(STM32F0XX)
+# define SLEEP_LED_GPT_DRIVER GPTD14
+# endif
#endif
-#if defined(KL2x) || defined(K20x) || defined(STM32F0XX) /* common parts for timers/interrupts */
+#if defined(KL2x) || defined(K20x) || defined(SLEEP_LED_GPT_DRIVER) /* common parts for timers/interrupts */
/* Breathing Sleep LED brighness(PWM On period) table
* (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle
@@ -33,10 +25,7 @@
*/
static const uint8_t breathing_table[64] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, 15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, 255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, 15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-/* interrupt handler */
-OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) {
- OSAL_IRQ_PROLOGUE();
-
+void sleep_led_timer_callback(void) {
/* Software PWM
* timer:1111 1111 1111 1111
* \_____/\/ \_______/____ count(0-255)
@@ -64,20 +53,19 @@ OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) {
if (timer.pwm.count == breathing_table[timer.pwm.index]) {
led_set(0);
}
-
- /* Reset the counter */
- RESET_COUNTER;
-
- OSAL_IRQ_EPILOGUE();
}
#endif /* common parts for known platforms */
#if defined(KL2x) || defined(K20x) /* platform selection: familiar Kinetis chips */
+/* Use Low Power Timer (LPTMR) */
+# define TIMER_INTERRUPT_VECTOR KINETIS_LPTMR0_IRQ_VECTOR
+# define RESET_COUNTER LPTMR0->CSR |= LPTMRx_CSR_TCF
+
/* LPTMR clock options */
# define LPTMR_CLOCK_MCGIRCLK 0 /* 4MHz clock */
-# define LPTMR_CLOCK_LPO 1 /* 1kHz clock */
+# define LPTMR_CLOCK_LPO 1 /* 1kHz clock */
# define LPTMR_CLOCK_ERCLK32K 2 /* external 32kHz crystal */
# define LPTMR_CLOCK_OSCERCLK 3 /* output from OSC */
@@ -86,6 +74,18 @@ OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) {
# define SIM_SCGC5_LPTMR SIM_SCGC5_LPTIMER
# endif
+/* interrupt handler */
+OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) {
+ OSAL_IRQ_PROLOGUE();
+
+ sleep_led_timer_callback();
+
+ /* Reset the counter */
+ RESET_COUNTER;
+
+ OSAL_IRQ_EPILOGUE();
+}
+
/* Initialise the timer */
void sleep_led_init(void) {
/* Make sure the clock to the LPTMR is enabled */
@@ -121,7 +121,7 @@ void sleep_led_init(void) {
MCG->C2 |= MCG_C2_IRCS; // fast (4MHz) internal ref clock
# if defined(KL27) // divide the 8MHz IRC by 2, to have the same MCGIRCLK speed as others
MCG->MC |= MCG_MC_LIRC_DIV2_DIV2;
-# endif /* KL27 */
+# endif /* KL27 */
MCG->C1 |= MCG_C1_IRCLKEN; // enable internal ref clock
// to work in stop mode, also MCG_C1_IREFSTEN
// Divide 4MHz by 2^N (N=6) => 62500 irqs/sec =>
@@ -159,45 +159,23 @@ void sleep_led_toggle(void) {
LPTMR0->CSR ^= LPTMRx_CSR_TEN;
}
-#elif defined(STM32F0XX) /* platform selection: STM32F0XX */
-
-/* Initialise the timer */
-void sleep_led_init(void) {
- /* enable clock */
- rccEnableTIM14(FALSE); /* low power enable = FALSE */
- rccResetTIM14();
-
- /* prescale */
- /* Assuming 48MHz internal clock */
- /* getting cca 65484 irqs/sec */
- STM32_TIM14->PSC = 733;
+#elif defined(SLEEP_LED_GPT_DRIVER)
- /* auto-reload */
- /* 0 => interrupt every time */
- STM32_TIM14->ARR = 3;
+static void gptTimerCallback(GPTDriver *gptp) {
+ (void)gptp;
+ sleep_led_timer_callback();
+}
- /* enable counter update event interrupt */
- STM32_TIM14->DIER |= STM32_TIM_DIER_UIE;
+static const GPTConfig gptcfg = {1000000, gptTimerCallback, 0, 0};
- /* register interrupt vector */
- nvicEnableVector(STM32_TIM14_NUMBER, 2); /* vector, priority */
-}
+/* Initialise the timer */
+void sleep_led_init(void) { gptStart(&SLEEP_LED_GPT_DRIVER, &gptcfg); }
-void sleep_led_enable(void) {
- /* Enable the timer */
- STM32_TIM14->CR1 = STM32_TIM_CR1_CEN | STM32_TIM_CR1_URS;
- /* URS => update event only on overflow; setting UG bit disabled */
-}
+void sleep_led_enable(void) { gptStartContinuous(&SLEEP_LED_GPT_DRIVER, gptcfg.frequency / 0xFFFF); }
-void sleep_led_disable(void) {
- /* Disable the timer */
- STM32_TIM14->CR1 = 0;
-}
+void sleep_led_disable(void) { gptStopTimer(&SLEEP_LED_GPT_DRIVER); }
-void sleep_led_toggle(void) {
- /* Toggle the timer */
- STM32_TIM14->CR1 ^= STM32_TIM_CR1_CEN;
-}
+void sleep_led_toggle(void) { (SLEEP_LED_GPT_DRIVER.state == GPT_READY) ? sleep_led_enable() : sleep_led_disable(); }
#else /* platform selection: not on familiar chips */
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index 49e20641fb95..38517e06f0bf 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -24,6 +24,13 @@
# include "rgblight.h"
#endif
+#ifdef LED_MATRIX_ENABLE
+# include "led_matrix.h"
+#endif
+#ifdef RGB_MATRIX_ENABLE
+# include "rgb_matrix.h"
+#endif
+
/** \brief suspend idle
*
* FIXME: needs doc
@@ -53,6 +60,13 @@ void suspend_power_down(void) {
backlight_set(0);
#endif
+#ifdef LED_MATRIX_ENABLE
+ led_matrix_task();
+#endif
+#ifdef RGB_MATRIX_ENABLE
+ rgb_matrix_task();
+#endif
+
// Turn off LED indicators
uint8_t leds_off = 0;
#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
@@ -69,6 +83,13 @@ void suspend_power_down(void) {
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
rgblight_suspend();
#endif
+
+#if defined(LED_MATRIX_ENABLE)
+ led_matrix_set_suspend_state(true);
+#endif
+#if defined(RGB_MATRIX_ENABLE)
+ rgb_matrix_set_suspend_state(true);
+#endif
#ifdef AUDIO_ENABLE
stop_all_notes();
#endif /* AUDIO_ENABLE */
@@ -137,5 +158,12 @@ void suspend_wakeup_init(void) {
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
rgblight_wakeup();
#endif
+
+#if defined(LED_MATRIX_ENABLE)
+ led_matrix_set_suspend_state(false);
+#endif
+#if defined(RGB_MATRIX_ENABLE)
+ rgb_matrix_set_suspend_state(false);
+#endif
suspend_wakeup_init_kb();
}
diff --git a/tmk_core/common/chibios/wait.c b/tmk_core/common/chibios/wait.c
new file mode 100644
index 000000000000..c6270fd95ec2
--- /dev/null
+++ b/tmk_core/common/chibios/wait.c
@@ -0,0 +1,89 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef __OPTIMIZE__
+# pragma message "Compiler optimizations disabled; wait_cpuclock() won't work as designed"
+#endif
+
+#define CLOCK_DELAY_NOP8 "nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t"
+
+__attribute__((always_inline)) static inline void wait_cpuclock(unsigned int n) { /* n: 1..135 */
+ /* The argument n must be a constant expression.
+ * That way, compiler optimization will remove unnecessary code. */
+ if (n < 1) {
+ return;
+ }
+ if (n > 8) {
+ unsigned int n8 = n / 8;
+ n = n - n8 * 8;
+ switch (n8) {
+ case 16:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 15:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 14:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 13:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 12:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 11:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 10:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 9:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 8:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 7:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 6:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 5:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 4:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 3:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 2:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 1:
+ asm volatile(CLOCK_DELAY_NOP8::: "memory");
+ case 0:
+ break;
+ }
+ }
+ switch (n) {
+ case 8:
+ asm volatile("nop" ::: "memory");
+ case 7:
+ asm volatile("nop" ::: "memory");
+ case 6:
+ asm volatile("nop" ::: "memory");
+ case 5:
+ asm volatile("nop" ::: "memory");
+ case 4:
+ asm volatile("nop" ::: "memory");
+ case 3:
+ asm volatile("nop" ::: "memory");
+ case 2:
+ asm volatile("nop" ::: "memory");
+ case 1:
+ asm volatile("nop" ::: "memory");
+ case 0:
+ break;
+ }
+}
\ No newline at end of file
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index 5e3ebe6ee6fc..ffa56ab56dc6 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -57,7 +57,7 @@ void eeconfig_init_quantum(void) {
eeprom_update_dword(EECONFIG_HAPTIC, 0);
eeprom_update_byte(EECONFIG_VELOCIKEY, 0);
eeprom_update_dword(EECONFIG_RGB_MATRIX, 0);
- eeprom_update_byte(EECONFIG_RGB_MATRIX_SPEED, 0);
+ eeprom_update_word(EECONFIG_RGB_MATRIX_EXTENDED, 0);
// TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
// within the emulated eeprom via dfu-util or another tool
@@ -155,17 +155,6 @@ void eeconfig_update_keymap(uint16_t val) {
eeprom_update_byte(EECONFIG_KEYMAP_UPPER_BYTE, (val >> 8) & 0xFF);
}
-/** \brief eeconfig read backlight
- *
- * FIXME: needs doc
- */
-uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
-/** \brief eeconfig update backlight
- *
- * FIXME: needs doc
- */
-void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
-
/** \brief eeconfig read audio
*
* FIXME: needs doc
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index 86b9e6f99bf5..a88071729da6 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -21,7 +21,7 @@ along with this program. If not, see .
#include
#ifndef EECONFIG_MAGIC_NUMBER
-# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEEB // When changing, decrement this value to avoid future re-init issues
+# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEEA // When changing, decrement this value to avoid future re-init issues
#endif
#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF
@@ -43,12 +43,18 @@ along with this program. If not, see .
#define EECONFIG_VELOCIKEY (uint8_t *)23
#define EECONFIG_HAPTIC (uint32_t *)24
+
+// Mutually exclusive
+#define EECONFIG_LED_MATRIX (uint32_t *)28
#define EECONFIG_RGB_MATRIX (uint32_t *)28
-#define EECONFIG_RGB_MATRIX_SPEED (uint8_t *)32
+// Speed & Flags
+#define EECONFIG_LED_MATRIX_EXTENDED (uint16_t *)32
+#define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32
+
// TODO: Combine these into a single word and single block of EEPROM
-#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)33
+#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)34
// Size of EEPROM being used, other code can refer to this for available EEPROM
-#define EECONFIG_SIZE 34
+#define EECONFIG_SIZE 35
/* debug bit */
#define EECONFIG_DEBUG_ENABLE (1 << 0)
#define EECONFIG_DEBUG_MATRIX (1 << 1)
@@ -88,11 +94,6 @@ void eeconfig_update_default_layer(uint8_t val);
uint16_t eeconfig_read_keymap(void);
void eeconfig_update_keymap(uint16_t val);
-#ifdef BACKLIGHT_ENABLE
-uint8_t eeconfig_read_backlight(void);
-void eeconfig_update_backlight(uint8_t val);
-#endif
-
#ifdef AUDIO_ENABLE
uint8_t eeconfig_read_audio(void);
void eeconfig_update_audio(uint8_t val);
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index ce3255c06965..3d6092e71cfc 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -34,11 +34,6 @@ along with this program. If not, see .
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
#endif
-#ifdef BOOTMAGIC_ENABLE
-# include "bootmagic.h"
-#else
-# include "magic.h"
-#endif
#ifdef MOUSEKEY_ENABLE
# include "mousekey.h"
#endif
@@ -54,6 +49,9 @@ along with this program. If not, see .
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
#endif
+#ifdef LED_MATRIX_ENABLE
+# include "led_matrix.h"
+#endif
#ifdef RGB_MATRIX_ENABLE
# include "rgb_matrix.h"
#endif
@@ -96,6 +94,12 @@ along with this program. If not, see .
#ifdef DIP_SWITCH_ENABLE
# include "dip_switch.h"
#endif
+#ifdef STM32_EEPROM_ENABLE
+# include "eeprom_stm32.h"
+#endif
+#ifdef EEPROM_DRIVER
+# include "eeprom_driver.h"
+#endif
static uint32_t last_input_modification_time = 0;
uint32_t last_input_activity_time(void) { return last_input_modification_time; }
@@ -233,6 +237,12 @@ void keyboard_setup(void) {
disable_jtag();
#endif
print_set_sendchar(sendchar);
+#ifdef STM32_EEPROM_ENABLE
+ EEPROM_Init();
+#endif
+#ifdef EEPROM_DRIVER
+ eeprom_driver_init();
+#endif
matrix_setup();
keyboard_pre_init_kb();
}
@@ -270,6 +280,15 @@ __attribute__((weak)) void housekeeping_task_kb(void) {}
*/
__attribute__((weak)) void housekeeping_task_user(void) {}
+/** \brief housekeeping_task
+ *
+ * Invokes hooks for executing code after QMK is done after each loop iteration.
+ */
+void housekeeping_task(void) {
+ housekeeping_task_kb();
+ housekeeping_task_user();
+}
+
/** \brief keyboard_init
*
* FIXME: needs doc
@@ -296,11 +315,6 @@ void keyboard_init(void) {
#ifdef ADB_MOUSE_ENABLE
adb_mouse_init();
#endif
-#ifdef BOOTMAGIC_ENABLE
- bootmagic();
-#else
- magic();
-#endif
#ifdef BACKLIGHT_ENABLE
backlight_init();
#endif
@@ -337,6 +351,9 @@ void keyboard_init(void) {
* This is differnet than keycode events as no layer processing, or filtering occurs.
*/
void switch_events(uint8_t row, uint8_t col, bool pressed) {
+#if defined(LED_MATRIX_ENABLE)
+ process_led_matrix(row, col, pressed);
+#endif
#if defined(RGB_MATRIX_ENABLE)
process_rgb_matrix(row, col, pressed);
#endif
@@ -366,9 +383,6 @@ void keyboard_task(void) {
bool encoders_changed = false;
#endif
- housekeeping_task_kb();
- housekeeping_task_user();
-
uint8_t matrix_changed = matrix_scan();
if (matrix_changed) last_matrix_activity_trigger();
@@ -422,6 +436,9 @@ void keyboard_task(void) {
rgblight_task();
#endif
+#ifdef LED_MATRIX_ENABLE
+ led_matrix_task();
+#endif
#ifdef RGB_MATRIX_ENABLE
rgb_matrix_task();
#endif
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h
index eaf74bac5869..08f4e84f94a5 100644
--- a/tmk_core/common/keyboard.h
+++ b/tmk_core/common/keyboard.h
@@ -70,8 +70,9 @@ void keyboard_pre_init_user(void);
void keyboard_post_init_kb(void);
void keyboard_post_init_user(void);
-void housekeeping_task_kb(void);
-void housekeeping_task_user(void);
+void housekeeping_task(void); // To be executed by the main loop in each backend TMK protocol
+void housekeeping_task_kb(void); // To be overridden by keyboard-level code
+void housekeeping_task_user(void); // To be overridden by user/keymap-level code
uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder activity
uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder activity
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c
deleted file mode 100644
index e14994164e22..000000000000
--- a/tmk_core/common/magic.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include
-#include
-#if defined(__AVR__)
-# include
-#endif
-#include "matrix.h"
-#include "bootloader.h"
-#include "debug.h"
-#include "keymap.h"
-#include "host.h"
-#include "action_layer.h"
-#include "eeconfig.h"
-#include "magic.h"
-
-keymap_config_t keymap_config;
-
-/** \brief Magic
- *
- * FIXME: Needs doc
- */
-void magic(void) {
- /* check signature */
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
-
- /* debug enable */
- debug_config.raw = eeconfig_read_debug();
-
- /* keymap config */
- keymap_config.raw = eeconfig_read_keymap();
-
- uint8_t default_layer = 0;
- default_layer = eeconfig_read_default_layer();
- default_layer_set((layer_state_t)default_layer);
-
- /* Also initialize layer state to trigger callback functions for layer_state */
- layer_state_set_kb((layer_state_t)layer_state);
-}
diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h
deleted file mode 100644
index a6552c04dc2f..000000000000
--- a/tmk_core/common/magic.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-void magic(void);
diff --git a/tmk_core/common/test/_wait.h b/tmk_core/common/test/_wait.h
new file mode 100644
index 000000000000..4e22f593b737
--- /dev/null
+++ b/tmk_core/common/test/_wait.h
@@ -0,0 +1,22 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#include
+
+void wait_ms(uint32_t ms);
+#define wait_us(us) wait_ms(us / 1000)
+#define waitInputPinDelay()
diff --git a/tmk_core/common/usb_util.c b/tmk_core/common/usb_util.c
new file mode 100644
index 000000000000..e4c50fcb10a7
--- /dev/null
+++ b/tmk_core/common/usb_util.c
@@ -0,0 +1,29 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include "usb_util.h"
+#include "wait.h"
+
+__attribute__((weak)) void usb_disable(void) {}
+__attribute__((weak)) bool usb_connected_state(void) { return true; }
+__attribute__((weak)) bool usb_vbus_state(void) {
+#ifdef USB_VBUS_PIN
+ setPinInput(USB_VBUS_PIN);
+ wait_us(5);
+ return readPin(USB_VBUS_PIN);
+#else
+ return true;
+#endif
+}
diff --git a/tmk_core/common/usb_util.h b/tmk_core/common/usb_util.h
new file mode 100644
index 000000000000..4ebedb1e71f8
--- /dev/null
+++ b/tmk_core/common/usb_util.h
@@ -0,0 +1,22 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#include
+
+void usb_disable(void);
+bool usb_connected_state(void);
+bool usb_vbus_state(void);
diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h
index 28224fe3aa9a..cf7180fb0716 100644
--- a/tmk_core/common/wait.h
+++ b/tmk_core/common/wait.h
@@ -1,3 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#pragma once
#include
@@ -6,114 +21,8 @@
extern "C" {
#endif
-#if defined(__ARMEL__) || defined(__ARMEB__)
-# ifndef __OPTIMIZE__
-# pragma message "Compiler optimizations disabled; wait_cpuclock() won't work as designed"
-# endif
-
-# define wait_cpuclock(x) wait_cpuclock_allnop(x)
-
-# define CLOCK_DELAY_NOP8 "nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t"
-
-__attribute__((always_inline)) static inline void wait_cpuclock_allnop(unsigned int n) { /* n: 1..135 */
- /* The argument n must be a constant expression.
- * That way, compiler optimization will remove unnecessary code. */
- if (n < 1) {
- return;
- }
- if (n > 8) {
- unsigned int n8 = n / 8;
- n = n - n8 * 8;
- switch (n8) {
- case 16:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 15:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 14:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 13:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 12:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 11:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 10:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 9:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 8:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 7:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 6:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 5:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 4:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 3:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 2:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 1:
- asm volatile(CLOCK_DELAY_NOP8::: "memory");
- case 0:
- break;
- }
- }
- switch (n) {
- case 8:
- asm volatile("nop" ::: "memory");
- case 7:
- asm volatile("nop" ::: "memory");
- case 6:
- asm volatile("nop" ::: "memory");
- case 5:
- asm volatile("nop" ::: "memory");
- case 4:
- asm volatile("nop" ::: "memory");
- case 3:
- asm volatile("nop" ::: "memory");
- case 2:
- asm volatile("nop" ::: "memory");
- case 1:
- asm volatile("nop" ::: "memory");
- case 0:
- break;
- }
-}
-#endif
-
-#if defined(__AVR__)
-# include
-# define wait_ms(ms) _delay_ms(ms)
-# define wait_us(us) _delay_us(us)
-# define wait_cpuclock(x) __builtin_avr_delay_cycles(x)
-#elif defined PROTOCOL_CHIBIOS
-# include
-# define wait_ms(ms) \
- do { \
- if (ms != 0) { \
- chThdSleepMilliseconds(ms); \
- } else { \
- chThdSleepMicroseconds(1); \
- } \
- } while (0)
-# define wait_us(us) \
- do { \
- if (us != 0) { \
- chThdSleepMicroseconds(us); \
- } else { \
- chThdSleepMicroseconds(1); \
- } \
- } while (0)
-#elif defined PROTOCOL_ARM_ATSAM
-# include "clks.h"
-# define wait_ms(ms) CLK_delay_ms(ms)
-# define wait_us(us) CLK_delay_us(us)
-#else // Unit tests
-void wait_ms(uint32_t ms);
-# define wait_us(us) wait_ms(us / 1000)
+#if __has_include_next("_wait.h")
+# include_next "_wait.h" /* Include the platforms _wait.h */
#endif
#ifdef __cplusplus
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk
index 0c41642b9be8..cc87e8347839 100644
--- a/tmk_core/protocol.mk
+++ b/tmk_core/protocol.mk
@@ -54,5 +54,9 @@ ifeq ($(strip $(XT_ENABLE)), yes)
OPT_DEFS += -DXT_ENABLE
endif
+ifeq ($(strip $(USB_HID_ENABLE)), yes)
+ include $(TMK_DIR)/protocol/usb_hid.mk
+endif
+
# Search Path
VPATH += $(TMK_DIR)/protocol
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index e4e79d351044..ce0f54593cc9 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -305,6 +305,9 @@ int main(void) {
// dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired);
}
#endif // CONSOLE_ENABLE
+
+ // Run housekeeping
+ housekeeping_task();
}
return 1;
diff --git a/tmk_core/protocol/chibios.mk b/tmk_core/protocol/chibios.mk
index 80554abb3254..d01697835b0d 100644
--- a/tmk_core/protocol/chibios.mk
+++ b/tmk_core/protocol/chibios.mk
@@ -6,6 +6,7 @@ SRC += $(CHIBIOS_DIR)/usb_main.c
SRC += $(CHIBIOS_DIR)/main.c
SRC += usb_descriptor.c
SRC += $(CHIBIOS_DIR)/usb_driver.c
+SRC += $(CHIBIOS_DIR)/usb_util.c
SRC += $(LIBSRC)
VPATH += $(TMK_PATH)/$(PROTOCOL_DIR)
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c
index 63e4c99d21ac..199741594a5c 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/main.c
@@ -51,12 +51,6 @@
#ifdef MIDI_ENABLE
# include "qmk_midi.h"
#endif
-#ifdef STM32_EEPROM_ENABLE
-# include "eeprom_stm32.h"
-#endif
-#ifdef EEPROM_DRIVER
-# include "eeprom_driver.h"
-#endif
#include "suspend.h"
#include "wait.h"
@@ -150,13 +144,6 @@ int main(void) {
halInit();
chSysInit();
-#ifdef STM32_EEPROM_ENABLE
- EEPROM_Init();
-#endif
-#ifdef EEPROM_DRIVER
- eeprom_driver_init();
-#endif
-
// TESTING
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
@@ -270,7 +257,6 @@ int main(void) {
#endif
// Run housekeeping
- housekeeping_task_kb();
- housekeeping_task_user();
+ housekeeping_task();
}
}
diff --git a/tmk_core/protocol/chibios/usb_util.c b/tmk_core/protocol/chibios/usb_util.c
new file mode 100644
index 000000000000..5945e8a8de6f
--- /dev/null
+++ b/tmk_core/protocol/chibios/usb_util.c
@@ -0,0 +1,21 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include
+#include "usb_util.h"
+
+void usb_disable(void) { usbStop(&USBD1); }
+
+bool usb_connected_state(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; }
diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk
index 1cc1fa04e5fb..514d5fac418e 100644
--- a/tmk_core/protocol/lufa.mk
+++ b/tmk_core/protocol/lufa.mk
@@ -44,6 +44,7 @@ ifeq ($(strip $(VIRTSER_ENABLE)), yes)
endif
SRC += $(LUFA_SRC)
+SRC += $(LUFA_DIR)/usb_util.c
# Search Path
VPATH += $(TMK_PATH)/$(LUFA_DIR)
@@ -66,8 +67,8 @@ LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8
LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8
LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1
-# Remote wakeup fix for ATmega32U2 https://github.com/tmk/tmk_keyboard/issues/361
-ifeq ($(MCU),atmega32u2)
+# Remote wakeup fix for ATmega16/32U2 https://github.com/tmk/tmk_keyboard/issues/361
+ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2))
LUFA_OPTS += -DNO_LIMITED_CONTROLLER_CONNECT
endif
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 85d71d0835c0..63619fdb3b64 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -1107,8 +1107,7 @@ int main(void) {
#endif
// Run housekeeping
- housekeeping_task_kb();
- housekeeping_task_user();
+ housekeeping_task();
}
}
diff --git a/tmk_core/protocol/lufa/usb_util.c b/tmk_core/protocol/lufa/usb_util.c
new file mode 100644
index 000000000000..9e943a21b97c
--- /dev/null
+++ b/tmk_core/protocol/lufa/usb_util.c
@@ -0,0 +1,34 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include
+#include "usb_util.h"
+#include "wait.h"
+
+void usb_disable(void) {
+ USB_Disable();
+ USB_DeviceState = DEVICE_STATE_Unattached;
+}
+
+bool usb_connected_state(void) { return USB_Device_IsAddressSet(); }
+
+#if defined(OTGPADE)
+bool usb_vbus_state(void) {
+ USB_OTGPAD_On(); // enables VBUS pad
+ wait_us(5);
+
+ return USB_VBUS_GetStatus(); // checks state of VBUS
+}
+#endif
diff --git a/tmk_core/protocol/vusb.mk b/tmk_core/protocol/vusb.mk
index 1de60030899e..e4d013b38dfa 100644
--- a/tmk_core/protocol/vusb.mk
+++ b/tmk_core/protocol/vusb.mk
@@ -5,6 +5,7 @@ VUSB_PATH = $(LIB_PATH)/vusb
SRC += $(VUSB_DIR)/main.c \
$(VUSB_DIR)/vusb.c \
+ $(VUSB_DIR)/usb_util.c \
$(VUSB_PATH)/usbdrv/usbdrv.c \
$(VUSB_PATH)/usbdrv/usbdrvasm.S \
$(VUSB_PATH)/usbdrv/oddebug.c
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c
index 2de4f6a80a2a..53926a7493ce 100644
--- a/tmk_core/protocol/vusb/main.c
+++ b/tmk_core/protocol/vusb/main.c
@@ -173,8 +173,7 @@ int main(void) {
#endif
// Run housekeeping
- housekeeping_task_kb();
- housekeeping_task_user();
+ housekeeping_task();
}
}
}
diff --git a/tmk_core/protocol/vusb/usb_util.c b/tmk_core/protocol/vusb/usb_util.c
new file mode 100644
index 000000000000..602854dbe6f3
--- /dev/null
+++ b/tmk_core/protocol/vusb/usb_util.c
@@ -0,0 +1,24 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include
+#include "usb_util.h"
+
+void usb_disable(void) { usbDeviceDisconnect(); }
+
+bool usb_connected_state(void) {
+ usbPoll();
+ return usbConfiguration;
+}
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index bbcfc1e4d1dd..fc2dc68be224 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -223,6 +223,12 @@ ifneq ($(filter Darwin FreeBSD,$(shell uname -s)),)
MD5SUM = md5
endif
+# UF2 format settings
+# To produce a UF2 file in your build, add to your keyboard's rules.mk:
+# FIRMWARE_FORMAT = uf2
+UF2CONV = $(TOP_DIR)/util/uf2conv.py
+UF2_FAMILY ?= 0x0
+
# Compiler flags to generate dependency files.
#GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
GENDEPFLAGS = -MMD -MP -MF $(patsubst %.o,%.td,$@)
@@ -255,6 +261,7 @@ DFU_SUFFIX_ARGS ?=
elf: $(BUILD_DIR)/$(TARGET).elf
hex: $(BUILD_DIR)/$(TARGET).hex
+uf2: $(BUILD_DIR)/$(TARGET).uf2
cpfirmware: $(FIRMWARE_FORMAT)
$(SILENT) || printf "Copying $(TARGET).$(FIRMWARE_FORMAT) to qmk_firmware folder" | $(AWK_CMD)
$(COPY) $(BUILD_DIR)/$(TARGET).$(FIRMWARE_FORMAT) $(TARGET).$(FIRMWARE_FORMAT) && $(PRINT_OK)
@@ -283,34 +290,46 @@ gccversion :
# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
- @$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD)
$(eval CMD=$(HEX) $< $@)
+ #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
+ @$(SILENT) || printf "$(MSG_FLASH) $@" | $(AWK_CMD)
+ @$(BUILD_CMD)
+
+%.uf2: %.hex
+ $(eval CMD=$(UF2CONV) $(BUILD_DIR)/$(TARGET).hex -o $(BUILD_DIR)/$(TARGET).uf2 -c -f $(UF2_FAMILY) >/dev/null 2>&1)
+ #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
+ @$(SILENT) || printf "$(MSG_UF2) $@" | $(AWK_CMD)
@$(BUILD_CMD)
%.eep: %.elf
- @$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD)
$(eval CMD=$(EEP) $< $@ || exit 0)
+ #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
+ @$(SILENT) || printf "$(MSG_EEPROM) $@" | $(AWK_CMD)
@$(BUILD_CMD)
# Create extended listing file from ELF output file.
%.lss: %.elf
- @$(SILENT) || printf "$(MSG_EXTENDED_LISTING) $@" | $(AWK_CMD)
$(eval CMD=$(OBJDUMP) -h -S -z $< > $@)
+ #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
+ @$(SILENT) || printf "$(MSG_EXTENDED_LISTING) $@" | $(AWK_CMD)
@$(BUILD_CMD)
# Create a symbol table from ELF output file.
%.sym: %.elf
- @$(SILENT) || printf "$(MSG_SYMBOL_TABLE) $@" | $(AWK_CMD)
$(eval CMD=$(NM) -n $< > $@ )
+ #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
+ @$(SILENT) || printf "$(MSG_SYMBOL_TABLE) $@" | $(AWK_CMD)
@$(BUILD_CMD)
%.bin: %.elf
- @$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD)
$(eval CMD=$(BIN) $< $@ || exit 0)
+ #@$(SILENT) || printf "$(MSG_EXECUTING) '$(CMD)':\n"
+ @$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD)
@$(BUILD_CMD)
if [ ! -z "$(DFU_SUFFIX_ARGS)" ]; then \
$(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\
fi
+ #$(SILENT) || printf "$(MSG_EXECUTING) '$(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null':\n" ;\
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
BEGIN = gccversion sizebefore
@@ -476,7 +495,7 @@ $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null)))
# Listing of phony targets.
.PHONY : all dump_vars finish sizebefore sizeafter qmkversion \
-gccversion build elf hex eep lss sym coff extcoff \
+gccversion build elf hex uf2 eep lss sym coff extcoff \
clean clean_list debug gdb-config show_path \
program teensy dfu dfu-ee dfu-start \
flash dfu-split-left dfu-split-right \
diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c
index 564c234c3942..ea716ecdab8f 100644
--- a/users/arkag/arkag.c
+++ b/users/arkag/arkag.c
@@ -363,7 +363,7 @@ void matrix_scan_user(void) {
surround_type(4, KC_GRAVE, true);
}
SEQ_ONE_KEY(KC_C) {
- send_unicode_hex_string("00E7");
+ register_unicode(0x00E7); // ç
}
SEQ_TWO_KEYS(KC_A, KC_V) {
surround_type(2, KC_QUOT, true);
@@ -384,10 +384,10 @@ void matrix_scan_user(void) {
surround_type(6, KC_GRAVE, false);
}
SEQ_ONE_KEY(KC_E) {
- send_unicode_hex_string("00E8");
+ register_unicode(0x00E8); // è
}
SEQ_TWO_KEYS(KC_E, KC_E) {
- send_unicode_hex_string("00E9");
+ register_unicode(0x00E9); // é
}
// end format functions
@@ -407,8 +407,7 @@ void matrix_scan_user(void) {
// start typing functions
SEQ_TWO_KEYS(KC_T, KC_M) {
- // ™
- send_unicode_hex_string("2122");
+ register_unicode(0x2122); // ™
}
SEQ_TWO_KEYS(KC_D, KC_D) {
SEND_STRING(".\\Administrator");
@@ -420,27 +419,22 @@ void matrix_scan_user(void) {
tap_code(KC_ENTER);
}
SEQ_THREE_KEYS(KC_L, KC_O, KC_D) {
- // ಠ__ಠ
- send_unicode_hex_string("0CA0 005F 005F 0CA0");
+ send_unicode_string("ಠ__ಠ");
}
SEQ_THREE_KEYS(KC_M, KC_A, KC_P) {
SEND_STRING("https://github.com/qmk/qmk_firmware/tree/master/users/arkag");
}
SEQ_TWO_KEYS(KC_F, KC_F) {
- // (╯‵Д′)╯彡┻━┻
- send_unicode_hex_string("0028 256F 2035 0414 2032 0029 256F 5F61 253B 2501 253B");
+ send_unicode_string("(╯‵Д′)╯彡┻━┻");
}
SEQ_THREE_KEYS(KC_F, KC_F, KC_F) {
- // ┬─┬ノ( º _ º ノ)
- send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 0020 30CE 0029");
+ send_unicode_string("┬─┬ノ( º _ º ノ)");
}
SEQ_THREE_KEYS(KC_L, KC_O, KC_L) {
- // ( ͡° ͜ʖ ͡°)
- send_unicode_hex_string("0028 0020 0361 00B0 0020 035C 0296 0020 0361 00B0 0029");
+ send_unicode_string("( ͡° ͜ʖ ͡°)");
}
SEQ_THREE_KEYS(KC_S, KC_S, KC_S) {
- // ¯\_(ツ)_/¯
- send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF");
+ send_unicode_string("¯\\_(ツ)_/¯");
}
// end typing functions
@@ -513,7 +507,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case M_DASH:
if (record->event.pressed){
- send_unicode_hex_string("2014");
+ register_unicode(0x2014); // —
}
return false;
case M_LMHYP:
diff --git a/users/curry/process_records.c b/users/curry/process_records.c
index fd58ea181b04..3b5c0019260e 100644
--- a/users/curry/process_records.c
+++ b/users/curry/process_records.c
@@ -46,24 +46,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
break;
#if defined(UNICODE_ENABLE)
- case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻
+ case UC_FLIP:
if (record->event.pressed) {
- send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
+ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
}
break;
- case UC_TABL: // ┬─┬ノ( º _ ºノ)
+ case UC_TABL:
if (record->event.pressed) {
- send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029");
+ send_unicode_string("┬─┬ノ( º _ ºノ)");
}
break;
- case UC_SHRG: // ¯\_(ツ)_/¯
+ case UC_SHRG:
if (record->event.pressed) {
- send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF");
+ send_unicode_string("¯\\_(ツ)_/¯");
}
break;
- case UC_DISA: // ಠ_ಠ
+ case UC_DISA:
if (record->event.pressed) {
- send_unicode_hex_string("0CA0 005F 0CA0");
+ send_unicode_string("ಠ_ಠ");
}
break;
#endif
diff --git a/users/d4mation/macros.c b/users/d4mation/macros.c
index 3c115d7ead55..a8ca119b12a9 100644
--- a/users/d4mation/macros.c
+++ b/users/d4mation/macros.c
@@ -45,75 +45,75 @@ bool process_record_user( uint16_t keycode, keyrecord_t *record ) {
#ifdef UNICODE_ENABLE
- case AMENO: /* ༼ つ ◕_◕ ༽つ */
+ case AMENO:
if ( record->event.pressed ) {
- send_unicode_hex_string( "0F3C 0020 3064 0020 25D5 005F 25D5 0020 0F3D 3064" );
+ send_unicode_string( "༼ つ ◕_◕ ༽つ" );
}
return false;
break;
- case MAGIC: /* (∩ ͡° ͜ʖ ͡°)⊃━☆゚. * */
+ case MAGIC:
if ( record->event.pressed ) {
- send_unicode_hex_string( "0028 2229 0020 0361 00B0 0020 035C 0296 0020 0361 00B0 0029 2283 2501 2606 FF9F 002E 0020 002A" );
+ send_unicode_string( "(∩ ͡° ͜ʖ ͡°)⊃━☆゚. *" );
}
return false;
break;
- case LENNY: /* ( ͡° ͜ʖ ͡°) */
+ case LENNY:
if ( record->event.pressed ) {
- send_unicode_hex_string( "0028 0020 0361 00B0 0020 035C 0296 0020 0361 00b0 0029" );
+ send_unicode_string( "( ͡° ͜ʖ ͡°)" );
}
return false;
break;
- case DISFACE: /* ಠ_ಠ */
+ case DISFACE:
if ( record->event.pressed ) {
- send_unicode_hex_string( "0CA0 005F 0CA0" );
+ send_unicode_string( "ಠ_ಠ" );
}
return false;
break;
- case TFLIP: /* (╯°□°)╯ ︵ ┻━┻ */
+ case TFLIP:
if ( record->event.pressed ) {
- send_unicode_hex_string( "0028 256F 00b0 25A1 00B0 0029 256F FE35 253B 2501 253B" );
+ send_unicode_string( "(╯°□°)╯︵┻━┻" );
}
return false;
break;
- case TPUT: /* ┬──┬ ノ( ゜-゜ノ) */
+ case TPUT:
if ( record->event.pressed ) {
- send_unicode_hex_string( "252C 2500 2500 252C 0020 30CE 0028 0020 309C 002D 309C 30CE 0029" );
+ send_unicode_string( "┬──┬ ノ( ゜-゜ノ)" );
}
return false;
break;
- case SHRUG: /* ¯\_(ツ)_/¯ */
+ case SHRUG:
if ( record->event.pressed ) {
- send_unicode_hex_string( "00AF 005C 005F 0028 30C4 0029 005F 002F 00AF" );
+ send_unicode_string( "¯\\_(ツ)_/¯" );
}
diff --git a/users/drashna/config.h b/users/drashna/config.h
index 8081af9cc3d8..5f7c32ff35c9 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -24,7 +24,7 @@
#if defined(SPLIT_KEYBOARD)
# define SPLIT_MODS_ENABLE
-// # define SPLIT_TRANSPORT_MIRROR
+# define SPLIT_TRANSPORT_MIRROR
# define SERIAL_USE_MULTI_TRANSACTION
// # define SPLIT_NUM_TRANSACTIONS_KB 2
#endif
@@ -56,6 +56,8 @@
# else
# define RGBLIGHT_ANIMATIONS
# endif
+# define RGBLIGHT_EFFECT_TWINKLE_LIFE 250
+# define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1/24
#endif // RGBLIGHT_ENABLE
#ifdef RGB_MATRIX_ENABLE
@@ -115,6 +117,9 @@
# define OLED_UPDATE_INTERVAL 15
# endif
# define OLED_DISABLE_TIMEOUT
+# ifdef OLED_FONT_H
+# undef OLED_FONT_H
+# endif
# define OLED_FONT_H "drashna_font.h"
# define OLED_FONT_END 255
// # define OLED_FONT_5X5
@@ -149,7 +154,9 @@
#undef PERMISSIVE_HOLD
//#define TAPPING_FORCE_HOLD
//#define RETRO_TAPPING
-#define TAPPING_TERM_PER_KEY
+#ifndef KEYBOARD_kyria_rev1
+# define TAPPING_TERM_PER_KEY
+#endif
#define FORCE_NKRO
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 6a13f0d9b2e3..a49373726266 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -164,6 +164,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
return state;
}
+ state = layer_state_set_keymap(state);
state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
#if defined(RGBLIGHT_ENABLE)
state = layer_state_set_rgb_light(state);
@@ -179,7 +180,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
}
}
#endif
- return layer_state_set_keymap(state);
+ return state;
}
__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index 9a18a82965c8..e66f10657450 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -47,7 +47,6 @@ enum userspace_layers {
_MALTRON,
_EUCALYN,
_CARPLAX,
- _MODS, /* layer 8 */
_GAMEPAD,
_DIABLO,
_MACROS,
diff --git a/users/drashna/drashna_transport.c b/users/drashna/drashna_transport.c
index f0908b4900dd..9df11c9bdfd0 100644
--- a/users/drashna/drashna_transport.c
+++ b/users/drashna/drashna_transport.c
@@ -21,6 +21,7 @@
#include QMK_KEYBOARD_H
#define ROWS_PER_HAND (MATRIX_ROWS / 2)
+#define SYNC_TIMER_OFFSET 2
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
@@ -37,19 +38,33 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A;
#endif
#ifdef POINTING_DEVICE_ENABLE
-static int8_t split_mouse_x = 0, split_mouse_y = 0;
+static uint16_t device_cpi = 0;
+static int8_t split_mouse_x = 0, split_mouse_y = 0;
#endif
#ifdef OLED_DRIVER_ENABLE
# include "oled_driver.h"
#endif
+#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+# include "led_matrix.h"
+#endif
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+# include "rgb_matrix.h"
+#endif
+
#if defined(USE_I2C)
# include "i2c_master.h"
# include "i2c_slave.h"
typedef struct _I2C_slave_buffer_t {
+# ifndef DISABLE_SYNC_TIMER
+ uint32_t sync_timer;
+# endif
+# ifdef SPLIT_TRANSPORT_MIRROR
+ matrix_row_t mmatrix[ROWS_PER_HAND];
+# endif
matrix_row_t smatrix[ROWS_PER_HAND];
# ifdef SPLIT_MODS_ENABLE
uint8_t real_mods;
@@ -69,20 +84,30 @@ typedef struct _I2C_slave_buffer_t {
# endif
# ifdef WPM_ENABLE
uint8_t current_wpm;
+# endif
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_eeconfig_t led_matrix;
+ bool led_suspend_state;
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_config_t rgb_matrix;
+ bool rgb_suspend_state;
# endif
int8_t mouse_x;
int8_t mouse_y;
+ uint16_t device_cpi;
bool oled_on;
layer_state_t t_layer_state;
layer_state_t t_default_layer_state;
- bool is_rgb_matrix_suspended;
} __attribute__((packed)) I2C_slave_buffer_t;
static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
# define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level)
# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
-# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
+# define I2C_KEYMAP_MASTER_START offsetof(I2C_slave_buffer_t, mmatrix)
+# define I2C_KEYMAP_SLAVE_START offsetof(I2C_slave_buffer_t, smatrix)
+# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer)
# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods)
# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods)
# define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods)
@@ -90,10 +115,14 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm)
# define I2C_MOUSE_X_START offsetof(I2C_slave_buffer_t, mouse_x)
# define I2C_MOUSE_Y_START offsetof(I2C_slave_buffer_t, mouse_y)
+# define I2C_MOUSE_DPI_START offsetof(I2C_slave_buffer_t, device_cpi)
# define I2C_OLED_ON_START offsetof(I2C_slave_buffer_t, oled_on)
# define I2C_LAYER_STATE_START offsetof(I2C_slave_buffer_t, t_layer_state)
# define I2C_DEFAULT_LAYER_STATE_START offsetof(I2C_slave_buffer_t, t_default_layer_state)
-# define I2C_RGB_MATRIX_SUSPEND_START offsetof(I2C_slave_buffer_t, is_rgb_matrix_suspended)
+# define I2C_LED_MATRIX_START offsetof(I2C_slave_buffer_t, led_matrix)
+# define I2C_LED_SUSPEND_START offsetof(I2C_slave_buffer_t, led_suspend_state)
+# define I2C_RGB_MATRIX_START offsetof(I2C_slave_buffer_t, rgb_matrix)
+# define I2C_RGB_SUSPEND_START offsetof(I2C_slave_buffer_t, rgb_suspend_state)
# define TIMEOUT 100
@@ -102,9 +131,11 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# endif
// Get rows from other half over i2c
-bool transport_master(matrix_row_t matrix[]) {
- i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
-
+bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+ i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_SLAVE_START, (void *)slave_matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
+# ifdef SPLIT_TRANSPORT_MIRROR
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_MASTER_START, (void *)master_matrix, sizeof(i2c_buffer->mmatrix), TIMEOUT);
+# endif
// write backlight info
# ifdef BACKLIGHT_ENABLE
uint8_t level = is_backlight_enabled() ? get_backlight_level() : 0;
@@ -147,6 +178,12 @@ bool transport_master(matrix_row_t matrix[]) {
i2c_readReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_Y_START, (void *)&i2c_buffer->mouse_y, sizeof(i2c_buffer->mouse_y), TIMEOUT);
temp_report.y = i2c_buffer->mouse_y;
pointing_device_set_report(temp_report);
+
+ if (device_cpi != i2c_buffer->device_cpi) {
+ if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_DPI_START, (void *)&device_cpi, sizeof(device_cpi), TIMEOUT) >= 0) {
+ i2c_buffer->device_cpi = device_cpi
+ }
+ }
}
# endif
@@ -188,29 +225,42 @@ bool transport_master(matrix_row_t matrix[]) {
}
# ifdef OLED_DRIVER_ENABLE
- bool is_oled = is_oled_on();
- if (is_oled != i2c_buffer->oled_on) {
- if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LAYER_STATE_START, (void *)&is_oled, sizeof(is_oled), TIMEOUT) >= 0) {
- i2c_buffer->oled_on = is_oled;
+ bool is_oled_on = is_oled_on();
+ if (is_oled_on != i2c_buffer->oled_on) {
+ if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LAYER_STATE_START, (void *)&is_oled_on, sizeof(is_oled_on), TIMEOUT) >= 0) {
+ i2c_buffer->oled_on = is_oled_on;
}
}
# endif
-# ifdef RGB_MATRIX_ENABLE
- bool sus_state = rgb_matrix_get_suspend_state();
- if (sus_state != i2c_buffer->is_rgb_matrix_suspended) {
- if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_SUSPEND_START, (void *)&sus_state, sizeof(sus_state), TIMEOUT) >= 0) {
- i2c_buffer->is_rgb_matrix_suspended = sus_state;
- }
- }
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LED_MATRIX_START, (void *)led_matrix_eeconfig, sizeof(i2c_buffer->led_matrix), TIMEOUT);
+ bool suspend_state = led_matrix_get_suspend_state();
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LED_SUSPEND_START, (void *)suspend_state, sizeof(i2c_buffer->led_suspend_state), TIMEOUT);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_START, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix), TIMEOUT);
+ bool suspend_state = rgb_matrix_get_suspend_state();
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_SUSPEND_START, (void *)suspend_state, sizeof(i2c_buffer->rgb_suspend_state), TIMEOUT);
+# endif
+
+# ifndef DISABLE_SYNC_TIMER
+ i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT);
# endif
return true;
}
-void transport_slave(matrix_row_t matrix[]) {
+void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+# ifndef DISABLE_SYNC_TIMER
+ sync_timer_update(i2c_buffer->sync_timer);
+# endif
// Copy matrix to I2C buffer
- memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix));
+ memcpy((void *)i2c_buffer->smatrix, (void *)slave_matrix, sizeof(i2c_buffer->smatrix));
+# ifdef SPLIT_TRANSPORT_MIRROR
+ memcpy((void *)master_matrix, (void *)i2c_buffer->mmatrix, sizeof(i2c_buffer->mmatrix));
+# endif
// Read Backlight Info
# ifdef BACKLIGHT_ENABLE
@@ -235,6 +285,11 @@ void transport_slave(matrix_row_t matrix[]) {
# ifdef POINTING_DEVICE_ENABLE
if (!is_keyboard_left()) {
+ static uint16_t cpi;
+ if (cpi != i2c_buffer->device_cpi) {
+ cpi = i2c_buffer->device_cpi;
+ pmw_set_cpi(cpi);
+ }
i2c_buffer->mouse_x = split_mouse_x;
i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_MOUSE_X_START, (void *)&i2c_buffer->mouse_x, sizeof(i2c_buffer->mouse_x), TIMEOUT);
i2c_buffer->mouse_y = split_mouse_y;
@@ -266,8 +321,13 @@ void transport_slave(matrix_row_t matrix[]) {
}
# endif
-# ifdef RGB_MATRIX_ENABLE
- rgb_matrix_set_suspend_state(i2c_buffer->is_rgb_matrix_suspended);
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ memcpy((void *)i2c_buffer->led_matrix, (void *)led_matrix_eeconfig, sizeof(i2c_buffer->led_matrix));
+ led_matrix_set_suspend_state(i2c_buffer->led_suspend_state);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ memcpy((void *)i2c_buffer->rgb_matrix, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix));
+ rgb_matrix_set_suspend_state(i2c_buffer->rgb_suspend_state);
# endif
}
@@ -283,30 +343,44 @@ typedef struct _Serial_s2m_buffer_t {
// TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack
matrix_row_t smatrix[ROWS_PER_HAND];
# ifdef ENCODER_ENABLE
- uint8_t encoder_state[NUMBER_OF_ENCODERS];
+ uint8_t encoder_state[NUMBER_OF_ENCODERS];
# endif
- int8_t mouse_x;
- int8_t mouse_y;
+ int8_t mouse_x;
+ int8_t mouse_y;
} __attribute__((packed)) Serial_s2m_buffer_t;
typedef struct _Serial_m2s_buffer_t {
# ifdef SPLIT_MODS_ENABLE
- uint8_t real_mods;
- uint8_t weak_mods;
+ uint8_t real_mods;
+ uint8_t weak_mods;
# ifndef NO_ACTION_ONESHOT
- uint8_t oneshot_mods;
+ uint8_t oneshot_mods;
# endif
# endif
+# ifndef DISABLE_SYNC_TIMER
+ uint32_t sync_timer;
+# endif
+# ifdef SPLIT_TRANSPORT_MIRROR
+ matrix_row_t mmatrix[ROWS_PER_HAND];
+# endif
# ifdef BACKLIGHT_ENABLE
- uint8_t backlight_level;
+ uint8_t backlight_level;
# endif
# ifdef WPM_ENABLE
- uint8_t current_wpm;
+ uint8_t current_wpm;
# endif
+ uint16_t device_cpi;
bool oled_on;
layer_state_t t_layer_state;
layer_state_t t_default_layer_state;
- bool is_rgb_matrix_suspended;
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_eeconfig_t led_matrix;
+ bool led_suspend_state;
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_config_t rgb_matrix;
+ bool rgb_suspend_state;
+# endif
} __attribute__((packed)) Serial_m2s_buffer_t;
# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
@@ -383,7 +457,7 @@ void transport_rgblight_slave(void) {
# define transport_rgblight_slave()
# endif
-bool transport_master(matrix_row_t matrix[]) {
+bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
# ifndef SERIAL_USE_MULTI_TRANSACTION
if (soft_serial_transaction() != TRANSACTION_END) {
return false;
@@ -397,7 +471,10 @@ bool transport_master(matrix_row_t matrix[]) {
// TODO: if MATRIX_COLS > 8 change to unpack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
- matrix[i] = serial_s2m_buffer.smatrix[i];
+ slave_matrix[i] = serial_s2m_buffer.smatrix[i];
+# ifdef SPLIT_TRANSPORT_MIRROR
+ serial_m2s_buffer.mmatrix[i] = master_matrix[i];
+# endif
}
# ifdef BACKLIGHT_ENABLE
@@ -411,12 +488,12 @@ bool transport_master(matrix_row_t matrix[]) {
# ifdef WPM_ENABLE
// Write wpm to slave
- serial_m2s_buffer.current_wpm = get_current_wpm();
+ serial_m2s_buffer.current_wpm = get_current_wpm();
# endif
# ifdef SPLIT_MODS_ENABLE
- serial_m2s_buffer.real_mods = get_mods();
- serial_m2s_buffer.weak_mods = get_weak_mods();
+ serial_m2s_buffer.real_mods = get_mods();
+ serial_m2s_buffer.weak_mods = get_weak_mods();
# ifndef NO_ACTION_ONESHOT
serial_m2s_buffer.oneshot_mods = get_oneshot_mods();
# endif
@@ -428,28 +505,43 @@ bool transport_master(matrix_row_t matrix[]) {
temp_report.x = serial_s2m_buffer.mouse_x;
temp_report.y = serial_s2m_buffer.mouse_y;
pointing_device_set_report(temp_report);
+ serial_m2s_buffer.device_cpi = device_cpi;
}
# endif
- serial_m2s_buffer.t_layer_state = layer_state;
- serial_m2s_buffer.t_default_layer_state = default_layer_state;
+ serial_m2s_buffer.t_layer_state = layer_state;
+ serial_m2s_buffer.t_default_layer_state = default_layer_state;
# ifdef OLED_DRIVER_ENABLE
- serial_m2s_buffer.oled_on = is_oled_on();
+ serial_m2s_buffer.oled_on = is_oled_on();
# endif
-# ifdef RGB_MATRIX_ENABLE
- serial_m2s_buffer.is_rgb_matrix_suspended = rgb_matrix_get_suspend_state();
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ serial_m2s_buffer.led_matrix = led_matrix_eeconfig;
+ serial_m2s_buffer.led_suspend_state = led_matrix_get_suspend_state();
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ serial_m2s_buffer.rgb_matrix = rgb_matrix_config;
+ serial_m2s_buffer.rgb_suspend_state = rgb_matrix_get_suspend_state();
# endif
+# ifndef DISABLE_SYNC_TIMER
+ serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
+# endif
return true;
}
-void transport_slave(matrix_row_t matrix[]) {
+void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
transport_rgblight_slave();
+# ifndef DISABLE_SYNC_TIMER
+ sync_timer_update(serial_m2s_buffer.sync_timer);
+# endif
// TODO: if MATRIX_COLS > 8 change to pack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
- serial_s2m_buffer.smatrix[i] = matrix[i];
+ serial_s2m_buffer.smatrix[i] = slave_matrix[i];
+# ifdef SPLIT_TRANSPORT_MIRROR
+ master_matrix[i] = serial_m2s_buffer.mmatrix[i];
+# endif
}
# ifdef BACKLIGHT_ENABLE
@@ -474,6 +566,11 @@ void transport_slave(matrix_row_t matrix[]) {
# ifdef POINTING_DEVICE_ENABLE
if (!is_keyboard_left()) {
+ static uint16_t cpi;
+ if (cpi != serial_m2s_buffer.device_cpi) {
+ cpi = serial_m2s_buffer.device_cpi;
+ pmw_set_cpi(cpi);
+ }
serial_s2m_buffer.mouse_x = split_mouse_x;
serial_s2m_buffer.mouse_y = split_mouse_y;
}
@@ -493,16 +590,14 @@ void transport_slave(matrix_row_t matrix[]) {
}
# endif
-# ifdef RGB_MATRIX_ENABLE
- rgb_matrix_set_suspend_state(serial_m2s_buffer.is_rgb_matrix_suspended);
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_matrix_eeconfig = serial_m2s_buffer.led_matrix;
+ led_matrix_set_suspend_state(serial_m2s_buffer.led_suspend_state);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_matrix_config = serial_m2s_buffer.rgb_matrix;
+ rgb_matrix_set_suspend_state(serial_m2s_buffer.rgb_suspend_state);
# endif
}
#endif
-
-#ifdef POINTING_DEVICE_ENABLE
-void master_mouse_send(int8_t x, int8_t y) {
- split_mouse_x = x;
- split_mouse_y = y;
-}
-#endif
diff --git a/users/drashna/oled_stuff.c b/users/drashna/oled_stuff.c
index 4abf5f05f5bb..98e467d9303a 100644
--- a/users/drashna/oled_stuff.c
+++ b/users/drashna/oled_stuff.c
@@ -15,7 +15,6 @@
*/
#include "drashna.h"
-#include
#ifndef KEYLOGGER_LENGTH
// # ifdef OLED_DISPLAY_128X64
@@ -158,6 +157,19 @@ void render_keylock_status(uint8_t led_usb_state) {
oled_advance_page(true);
#endif
}
+void render_matrix_scan_rate(void) {
+#ifdef DEBUG_MATRIX_SCAN_RATE
+ char matrix_rate[5];
+ uint16_t n = get_matrix_scan_rate();
+ matrix_rate[4] = '\0';
+ matrix_rate[3] = '0' + n % 10;
+ matrix_rate[2] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
+ matrix_rate[1] = n / 10 ? '0' + n / 10 : ' ';
+ matrix_rate[0] = ' ';
+ oled_write_P(PSTR("MS:"), false);
+ oled_write(matrix_rate, false);
+#endif
+}
void render_mod_status(uint8_t modifiers) {
static const char PROGMEM mod_status[5][3] = {{0xE8, 0xE9, 0}, {0xE4, 0xE5, 0}, {0xE6, 0xE7, 0}, {0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
@@ -169,11 +181,17 @@ void render_mod_status(uint8_t modifiers) {
#endif
oled_write_P(mod_status[2], (modifiers & MOD_MASK_ALT));
oled_write_P(mod_status[1], (modifiers & MOD_MASK_CTRL));
+
+ render_matrix_scan_rate();
#if defined(OLED_DISPLAY_128X64)
oled_advance_page(true);
#endif
}
+#ifdef SWAP_HANDS_ENABLE
+extern bool swap_hands;
+#endif
+
void render_bootmagic_status(void) {
/* Show Ctrl-Gui Swap options */
static const char PROGMEM logo[][2][3] = {
@@ -209,7 +227,7 @@ void render_bootmagic_status(void) {
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NKRO), keymap_config.nkro);
oled_write_P(PSTR(" "), false);
- oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), !keymap_config.no_gui);
+ oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui);
#ifdef OLED_DISPLAY_128X64
oled_advance_page(true);
oled_write_P(PSTR("Magic"), false);
@@ -221,10 +239,11 @@ void render_bootmagic_status(void) {
}
#endif
oled_write_P(PSTR(" "), false);
- oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_GRV), keymap_config.swap_grave_esc);
+ oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_ONESHOT), !is_oneshot_enabled());
+#ifdef SWAP_HANDS_ENABLE
oled_write_P(PSTR(" "), false);
- oled_write_P(PSTR(" "), false);
- oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_CAPS), keymap_config.swap_control_capslock);
+ oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands);
+#endif
#ifdef OLED_DISPLAY_128X64
oled_advance_page(true);
#endif
@@ -282,12 +301,22 @@ __attribute__((weak)) void oled_driver_render_logo(void) {
void render_wpm(void) {
#ifdef WPM_ENABLE
+ uint8_t n = get_current_wpm();
# ifdef OLED_DISPLAY_128X64
char wpm_counter[4];
+ wpm_counter[3] = '\0';
+ wpm_counter[2] = '0' + n % 10;
+ wpm_counter[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
+ wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
# else
char wpm_counter[6];
-# endif
- snprintf(wpm_counter, sizeof(wpm_counter), "%3u", get_current_wpm());
+ wpm_counter[5] = '\0';
+ wpm_counter[4] = '0' + n % 10;
+ wpm_counter[3] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
+ wpm_counter[2] = n / 10 ? '0' + n / 10 : ' ';
+ wpm_counter[1] = ' ';
+ wpm_counter[0] = ' ';
+ # endif
oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
oled_write(wpm_counter, false);
#endif
@@ -299,7 +328,13 @@ extern uint16_t dpi_array[];
void render_pointing_dpi_status(void) {
char dpi_status[6];
- snprintf(dpi_status, sizeof(dpi_status), "%5u", dpi_array[keyboard_config.dpi_config]);
+ uint16_t n = dpi_array[keyboard_config.dpi_config];
+ dpi_status[5] = '\0';
+ dpi_status[4] = '0' + n % 10;
+ dpi_status[3] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
+ dpi_status[2] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
+ dpi_status[1] = n / 10 ? '0' + n / 10 : ' ';
+ dpi_status[0] = ' ';
oled_write_P(PSTR(" DPI: "), false);
oled_write(dpi_status, false);
}
@@ -320,7 +355,11 @@ void render_status_secondary(void) {
void render_status_main(void) {
#if defined(OLED_DISPLAY_128X64)
oled_driver_render_logo();
+# ifdef DEBUG_MATRIX_SCAN_RATE
+ render_matrix_scan_rate();
+# else
render_wpm();
+# endif
# ifdef KEYBOARD_handwired_dactyl_manuform_5x6_right_trackball
render_pointing_dpi_status();
# endif
diff --git a/users/drashna/oled_stuff.h b/users/drashna/oled_stuff.h
index 2224cd90ea7a..1f4440bd423f 100644
--- a/users/drashna/oled_stuff.h
+++ b/users/drashna/oled_stuff.h
@@ -57,6 +57,8 @@ extern uint32_t oled_timer;
# define OLED_RENDER_BOOTMAGIC_NKRO "NKRO"
# define OLED_RENDER_BOOTMAGIC_NOGUI "nGUI"
# define OLED_RENDER_BOOTMAGIC_GRV "GRV"
+# define OLED_RENDER_BOOTMAGIC_ONESHOT "1SHT"
+# define OLED_RENDER_BOOTMAGIC_SWAP "SWAP"
# define OLED_RENDER_BOOTMAGIC_CAPS "CAPS"
# define OLED_RENDER_USER_NAME "USER:"
@@ -99,6 +101,8 @@ extern uint32_t oled_timer;
# define OLED_RENDER_BOOTMAGIC_NKRO "NKRO"
# define OLED_RENDER_BOOTMAGIC_NOGUI "nGUI"
# define OLED_RENDER_BOOTMAGIC_GRV "GRV"
+# define OLED_RENDER_BOOTMAGIC_ONESHOT "1SHT"
+# define OLED_RENDER_BOOTMAGIC_SWAP "SWAP"
# define OLED_RENDER_BOOTMAGIC_CAPS "CAPS"
# define OLED_RENDER_USER_NAME "USER:"
diff --git a/users/drashna/pimoroni_trackball.c b/users/drashna/pimoroni_trackball.c
index 9ae094c05ab5..a6ca6c9966df 100644
--- a/users/drashna/pimoroni_trackball.c
+++ b/users/drashna/pimoroni_trackball.c
@@ -33,7 +33,7 @@ static float precisionSpeed = 1;
void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) {
uint8_t data[] = {0x00, red, green, blue, white};
- i2c_transmit(TRACKBALL_WRITE, data, sizeof(data), I2C_TIMEOUT);
+ i2c_transmit(TRACKBALL_ADDRESS << 1, data, sizeof(data), I2C_TIMEOUT);
}
int16_t mouse_offset(uint8_t positive, uint8_t negative, int16_t scale) {
@@ -94,7 +94,7 @@ void pointing_device_task(void) {
static bool debounce;
static uint16_t debounce_timer;
uint8_t state[5] = {};
- if (i2c_readReg(TRACKBALL_WRITE, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) {
+ if (i2c_readReg(TRACKBALL_ADDRESS << 1, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) {
if (!state[4] && !debounce) {
if (scrolling) {
#ifdef PIMORONI_TRACKBALL_INVERT_X
diff --git a/users/drashna/process_records.h b/users/drashna/process_records.h
index 2e246705015e..f60e6d7ebc58 100644
--- a/users/drashna/process_records.h
+++ b/users/drashna/process_records.h
@@ -53,7 +53,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
#define LOWER MO(_LOWER)
#define RAISE MO(_RAISE)
#define ADJUST MO(_ADJUST)
-#define TG_MODS TG(_MODS)
+#define TG_MODS OS_TOGG
#define TG_GAME TG(_GAMEPAD)
#define TG_DBLO TG(_DIABLO)
#define OS_LWR OSL(_LOWER)
diff --git a/users/drashna/rgb_matrix_stuff.c b/users/drashna/rgb_matrix_stuff.c
index 573cc7bc9d01..9e9e1e4279b4 100644
--- a/users/drashna/rgb_matrix_stuff.c
+++ b/users/drashna/rgb_matrix_stuff.c
@@ -62,7 +62,7 @@ __attribute__((weak)) void rgb_matrix_indicator_keymap(void) {}
void matrix_scan_rgb_matrix(void) {
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
- if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_TYPING_HEATMAP && timer_elapsed32(hypno_timer) > 15000) {
+ if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_TYPING_HEATMAP && sync_timer_elapsed32(hypno_timer) > 15000) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_REST_MODE);
}
#endif
@@ -79,7 +79,7 @@ void keyboard_post_init_rgb_matrix(void) {
bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
- hypno_timer = timer_read32();
+ hypno_timer = sync_timer_read32();
if (userspace_config.rgb_matrix_idle_anim && rgb_matrix_get_mode() == RGB_MATRIX_REST_MODE) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_TYPING_HEATMAP);
}
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index c8b2f4c726d4..6723ad4bf5ac 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -32,7 +32,7 @@ void scan_rgblight_fadeout(void) { // Don't effing change this function .... rg
bool litup = false;
for (uint8_t light_index = 0; light_index < RGBLED_NUM; ++light_index) {
- if (lights[light_index].enabled && timer_elapsed(lights[light_index].timer) > 10) {
+ if (lights[light_index].enabled && sync_timer_elapsed(lights[light_index].timer) > 10) {
rgblight_fadeout *light = &lights[light_index];
litup = true;
@@ -41,7 +41,7 @@ void scan_rgblight_fadeout(void) { // Don't effing change this function .... rg
if (get_highest_layer(layer_state) == 0) {
sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]);
}
- light->timer = timer_read();
+ light->timer = sync_timer_read();
} else {
if (light->enabled && get_highest_layer(layer_state) == 0) {
rgblight_sethsv_default_helper(light_index);
@@ -86,7 +86,7 @@ void start_rgb_light(void) {
rgblight_fadeout *light = &lights[light_index];
light->enabled = true;
- light->timer = timer_read();
+ light->timer = sync_timer_read();
light->life = 0xC0 + rand() % 0x40;
light->hue = rgblight_get_hue() + (rand() % 0xB4) - 0x54;
@@ -149,11 +149,11 @@ void matrix_scan_rgb_light(void) {
# if defined(RGBLIGHT_STARTUP_ANIMATION)
if (is_rgblight_startup && is_keyboard_master()) {
- if (timer_elapsed(rgblight_startup_loop_timer) > 10) {
+ if (sync_timer_elapsed(rgblight_startup_loop_timer) > 10) {
static uint8_t counter;
counter++;
rgblight_sethsv_noeeprom((counter + old_hue) % 255, 255, 255);
- rgblight_startup_loop_timer = timer_read();
+ rgblight_startup_loop_timer = sync_timer_read();
if (counter == 255) {
is_rgblight_startup = false;
if (!is_enabled) {
@@ -177,14 +177,11 @@ void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mo
layer_state_t layer_state_set_rgb_light(layer_state_t state) {
# ifdef RGBLIGHT_ENABLE
if (userspace_config.rgb_layer_change) {
- uint8_t mode = layer_state_cmp(state, _MODS) ? RGBLIGHT_MODE_BREATHING : RGBLIGHT_MODE_STATIC_LIGHT;
switch (get_highest_layer(state | default_layer_state)) {
- case _MACROS:
-# ifdef RGBLIGHT_EFFECT_TWINKLE
- rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_TWINKLE + 5);
-# else
- rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3);
-# endif
+ case _MACROS: // mouse
+ if (!layer_state_cmp(state, _GAMEPAD) && !layer_state_cmp(state, _DIABLO)) {
+ rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3);
+ }
break;
case _MEDIA:
rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_KNIGHT + 1);
@@ -205,28 +202,28 @@ layer_state_t layer_state_set_rgb_light(layer_state_t state) {
rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_KNIGHT + 2);
break;
case _COLEMAK:
- rgblight_set_hsv_and_mode(HSV_MAGENTA, mode);
+ rgblight_set_hsv_and_mode(HSV_MAGENTA, RGBLIGHT_MODE_STATIC_LIGHT);
break;
case _DVORAK:
- rgblight_set_hsv_and_mode(HSV_SPRINGGREEN, mode);
+ rgblight_set_hsv_and_mode(HSV_SPRINGGREEN, RGBLIGHT_MODE_STATIC_LIGHT);
break;
case _WORKMAN:
- rgblight_set_hsv_and_mode(HSV_GOLDENROD, mode);
+ rgblight_set_hsv_and_mode(HSV_GOLDENROD, RGBLIGHT_MODE_STATIC_LIGHT);
break;
case _NORMAN:
- rgblight_set_hsv_and_mode(HSV_CORAL, mode);
+ rgblight_set_hsv_and_mode(HSV_CORAL, RGBLIGHT_MODE_STATIC_LIGHT);
break;
case _MALTRON:
- rgblight_set_hsv_and_mode(HSV_YELLOW, mode);
+ rgblight_set_hsv_and_mode(HSV_YELLOW, RGBLIGHT_MODE_STATIC_LIGHT);
break;
case _EUCALYN:
- rgblight_set_hsv_and_mode(HSV_PINK, mode);
+ rgblight_set_hsv_and_mode(HSV_PINK, RGBLIGHT_MODE_STATIC_LIGHT);
break;
case _CARPLAX:
- rgblight_set_hsv_and_mode(HSV_BLUE, mode);
+ rgblight_set_hsv_and_mode(HSV_BLUE, RGBLIGHT_MODE_STATIC_LIGHT);
break;
default:
- rgblight_set_hsv_and_mode(HSV_CYAN, mode);
+ rgblight_set_hsv_and_mode(HSV_CYAN, RGBLIGHT_MODE_STATIC_LIGHT);
break;
}
}
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk
index 2ae01c62e55e..b79051508b44 100644
--- a/users/drashna/rules.mk
+++ b/users/drashna/rules.mk
@@ -16,29 +16,37 @@ ifneq ($(strip $(NO_SECRETS)), yes)
endif
endif
+CUSTOM_TAP_DANCE ?= yes
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
- SRC += tap_dances.c
+ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
+ SRC += tap_dances.c
+ endif
endif
+CUSTOM_RGBLIGHT ?= yes
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
- SRC += rgb_stuff.c
- ifeq ($(strip $(RGBLIGHT_TWINKLE)), yes)
- OPT_DEFS += -DRGBLIGHT_TWINKLE
- endif
- ifeq ($(strip $(RGBLIGHT_NOEEPROM)), yes)
- OPT_DEFS += -DRGBLIGHT_NOEEPROM
- endif
- ifeq ($(strip $(RGBLIGHT_STARTUP_ANIMATION)), yes)
- OPT_DEFS += -DRGBLIGHT_STARTUP_ANIMATION
+ ifeq ($(strip $(CUSTOM_RGBLIGHT)), yes)
+ SRC += rgb_stuff.c
+ ifeq ($(strip $(RGBLIGHT_TWINKLE)), yes)
+ OPT_DEFS += -DRGBLIGHT_TWINKLE
+ endif
+ ifeq ($(strip $(RGBLIGHT_NOEEPROM)), yes)
+ OPT_DEFS += -DRGBLIGHT_NOEEPROM
+ endif
+ ifeq ($(strip $(RGBLIGHT_STARTUP_ANIMATION)), yes)
+ OPT_DEFS += -DRGBLIGHT_STARTUP_ANIMATION
+ endif
endif
endif
-RGB_MATRIX_ENABLE ?= no
-ifneq ($(strip $(RGB_MATRIX_ENABLE)), no)
- SRC += rgb_matrix_stuff.c
+CUSTOM_RGB_MATRIX ?= yes
+ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
+ ifeq ($(strip $(CUSTOM_RGB_MATRIX)), yes)
+ SRC += rgb_matrix_stuff.c
+ endif
endif
-
+KEYLOGGER_ENABLE ?= no
ifdef CONSOLE_ENABLE
ifeq ($(strip $(KEYLOGGER_ENABLE)), yes)
OPT_DEFS += -DKEYLOGGER_ENABLE
@@ -56,8 +64,11 @@ ifeq ($(strip $(PROTOCOL)), VUSB)
NKRO_ENABLE = no
endif
+CUSTOM_OLED_DRIVER ?= yes
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
- SRC += oled_stuff.c
+ ifeq ($(strip $(CUSTOM_OLED_DRIVER)), yes)
+ SRC += oled_stuff.c
+ endif
endif
ifeq ($(strip $(PIMORONI_TRACKBALL_ENABLE)), yes)
@@ -67,26 +78,30 @@ ifeq ($(strip $(PIMORONI_TRACKBALL_ENABLE)), yes)
QUANTUM_LIB_SRC += i2c_master.c
endif
-
+CUSTOM_SPLIT_TRANSPORT ?= yes
ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
ifneq ($(strip $(SPLIT_TRANSPORT)), custom)
- SPLIT_TRANSPORT = custom
- QUANTUM_LIB_SRC += drashna_transport.c
- OPT_DEFS += -DDRASHNA_CUSTOM_TRANSPORT
- # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
- ifeq ($(PLATFORM),AVR)
- ifneq ($(NO_I2C),yes)
- QUANTUM_LIB_SRC += i2c_master.c \
- i2c_slave.c
+ ifeq ($(strip $(CUSTOM_SPLIT_TRANSPORT)), yes)
+ SPLIT_TRANSPORT = custom
+ QUANTUM_LIB_SRC += drashna_transport.c
+ OPT_DEFS += -DDRASHNA_CUSTOM_TRANSPORT
+ # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
+ ifeq ($(PLATFORM),AVR)
+ ifneq ($(NO_I2C),yes)
+ QUANTUM_LIB_SRC += i2c_master.c \
+ i2c_slave.c
+ endif
endif
- endif
- SERIAL_DRIVER ?= bitbang
- OPT_DEFS += -DSERIAL_DRIVER_$(strip $(shell echo $(SERIAL_DRIVER) | tr '[:lower:]' '[:upper:]'))
- ifeq ($(strip $(SERIAL_DRIVER)), bitbang)
- QUANTUM_LIB_SRC += serial.c
- else
- QUANTUM_LIB_SRC += serial_$(strip $(SERIAL_DRIVER)).c
+ SERIAL_DRIVER ?= bitbang
+ OPT_DEFS += -DSERIAL_DRIVER_$(strip $(shell echo $(SERIAL_DRIVER) | tr '[:lower:]' '[:upper:]'))
+ ifeq ($(strip $(SERIAL_DRIVER)), bitbang)
+ QUANTUM_LIB_SRC += serial.c
+ else
+ QUANTUM_LIB_SRC += serial_$(strip $(SERIAL_DRIVER)).c
+ endif
endif
endif
endif
+
+# DEBUG_MATRIX_SCAN_RATE_ENABLE = api
diff --git a/users/gordon/rules.mk b/users/gordon/rules.mk
index 19e77b01b1da..06e671a63598 100644
--- a/users/gordon/rules.mk
+++ b/users/gordon/rules.mk
@@ -1,4 +1,4 @@
TAP_DANCE_ENABLE = yes
SRC += gordon.c
-# BOOTMAGIC_ENABLE = yes
+# BOOTMAGIC_ENABLE = full
diff --git a/users/greatwizard/greatwizard.c b/users/greatwizard/greatwizard.c
index 46ee41436191..3ec856d72083 100644
--- a/users/greatwizard/greatwizard.c
+++ b/users/greatwizard/greatwizard.c
@@ -70,7 +70,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
#ifdef ENCODER_ENABLE
-void encoder_update_user(uint8_t index, bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
switch (get_highest_layer(layer_state)) {
case _QWERTY:
#ifdef LAYERS_PROGRAMMER
@@ -90,6 +90,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
}
break;
}
+ return true;
}
#endif
diff --git a/users/kuchosauronad0/encoder.c b/users/kuchosauronad0/encoder.c
index 06b7b51233b1..9284a041c227 100644
--- a/users/kuchosauronad0/encoder.c
+++ b/users/kuchosauronad0/encoder.c
@@ -1,5 +1,5 @@
#include "encoder.h"
-void encoder_update_user(uint8_t index, bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
static uint16_t kc;
uint8_t temp_mod = get_mods();
if (index == 0) { /* first encoder */
@@ -55,6 +55,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
tap_code(KC_1);
}
}
+ return true;
}
const uint16_t PROGMEM encoder_actions[][9] = { \
// None CTRL ALT SHIFT GUI CTRL+ALT CTRL+SHFT ALT+SHFT HYPER
diff --git a/users/kuchosauronad0/encoder.h b/users/kuchosauronad0/encoder.h
index 2610c9677aa0..7b05aa4911d8 100644
--- a/users/kuchosauronad0/encoder.h
+++ b/users/kuchosauronad0/encoder.h
@@ -1,4 +1,4 @@
#pragma once
#include "quantum.h"
const uint16_t PROGMEM encoder_actions[][9];
-void encoder_update_user(uint8_t index, bool clockwise);
+bool encoder_update_user(uint8_t index, bool clockwise);
diff --git a/users/kuchosauronad0/process_records.c b/users/kuchosauronad0/process_records.c
index bec6fa5ad079..5623c80f985d 100644
--- a/users/kuchosauronad0/process_records.c
+++ b/users/kuchosauronad0/process_records.c
@@ -214,24 +214,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// Unicode
#ifdef UNICODE_ENABLE
- case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻
+ case UC_FLIP:
if (record->event.pressed) {
- send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
+ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
}
break;
- case UC_TABL: // ┬┬ノ( º _ ºノ)
+ case UC_TABL:
if (record->event.pressed) {
- send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029");
+ send_unicode_string("┬─┬ノ( º _ ºノ)");
}
break;
- case UC_SHRG: // ¯\_(ツ)_/¯
+ case UC_SHRG:
if (record->event.pressed) {
- send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF");
+ send_unicode_string("¯\\_(ツ)_/¯");
}
break;
- case UC_DISA: // ಠ_ಠ
+ case UC_DISA:
if (record->event.pressed) {
- send_unicode_hex_string("0CA0 005F 0CA0");
+ send_unicode_string("ಠ_ಠ");
}
break;
#endif //!Unicode
diff --git a/users/kuchosauronad0/unicode.h b/users/kuchosauronad0/unicode.h
index cb550243eea7..9ff523baadf7 100644
--- a/users/kuchosauronad0/unicode.h
+++ b/users/kuchosauronad0/unicode.h
@@ -2,8 +2,6 @@
#include "quantum.h"
-void send_unicode_hex_string(const char* str);
-
/* use X(n) to call the */
#ifdef UNICODEMAP_ENABLE
enum unicode_name {
diff --git a/users/ninjonas/encoder.c b/users/ninjonas/encoder.c
index 3d56ff89eedd..f1b448b79b8f 100644
--- a/users/ninjonas/encoder.c
+++ b/users/ninjonas/encoder.c
@@ -15,7 +15,7 @@
*/
#include "ninjonas.h"
-#ifdef ENCODER_ENABLE
+#ifdef ENCODER_ENABLE
void left_encoder_cw(void) {
switch (get_highest_layer(layer_state)) {
case _LOWER:
@@ -81,7 +81,7 @@ void right_encoder_acw(void) {
}
}
-void encoder_update_user(uint8_t index, bool clockwise) {
+bool encoder_update_user(uint8_t index, bool clockwise) {
encoder_rotated_timer = timer_read();
if (index == 0) {
left_encoder_rotated = true;
@@ -99,6 +99,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
right_encoder_acw();
}
}
+ return true;
}
-#endif
\ No newline at end of file
+#endif
diff --git a/users/ridingqwerty/process_records.c b/users/ridingqwerty/process_records.c
index b0b0b48a2238..770af286e9b4 100644
--- a/users/ridingqwerty/process_records.c
+++ b/users/ridingqwerty/process_records.c
@@ -58,14 +58,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE)
case KC_A:
if (record->event.pressed) {
- send_unicode_hex_string("039B");
- tap_code(KC_SPC);
+ send_unicode_string("Λ ");
}
return false;
case KC_E:
if (record->event.pressed) {
- send_unicode_hex_string("039E");
- tap_code(KC_SPC);
+ send_unicode_string("Ξ ");
}
return false;
#else
@@ -175,154 +173,154 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// TRANSLATE
case KC_A:
if (record->event.pressed) {
- send_unicode_hex_string("0250");
+ register_unicode(0x0250); // ɐ
tap_code(KC_LEFT);
return false;
}
break;
case KC_C:
if (record->event.pressed) {
- send_unicode_hex_string("0254");
+ register_unicode(0x0254); // ɔ
tap_code(KC_LEFT);
return false;
}
break;
case KC_E:
if (record->event.pressed) {
- send_unicode_hex_string("01DD");
+ register_unicode(0x01DD); // ǝ
tap_code(KC_LEFT);
return false;
}
break;
case KC_F:
if (record->event.pressed) {
- send_unicode_hex_string("025F");
+ register_unicode(0x025F); // ɟ
tap_code(KC_LEFT);
return false;
}
break;
case KC_G:
if (record->event.pressed) {
- send_unicode_hex_string("0183");
+ register_unicode(0x0183); // ƃ
tap_code(KC_LEFT);
return false;
}
break;
case KC_H:
if (record->event.pressed) {
- send_unicode_hex_string("0265");
+ register_unicode(0x0265); // ɥ
tap_code(KC_LEFT);
return false;
}
break;
case KC_I:
if (record->event.pressed) {
- send_unicode_hex_string("1D09");
+ register_unicode(0x1D09); // ᴉ
tap_code(KC_LEFT);
return false;
}
break;
case KC_J:
if (record->event.pressed) {
- send_unicode_hex_string("027E");
+ register_unicode(0x027E); // ɾ
tap_code(KC_LEFT);
return false;
}
break;
case KC_K:
if (record->event.pressed) {
- send_unicode_hex_string("029E");
+ register_unicode(0x029E); // ʞ
tap_code(KC_LEFT);
return false;
}
break;
case KC_M:
if (record->event.pressed) {
- send_unicode_hex_string("026F");
+ register_unicode(0x026F); // ɯ
tap_code(KC_LEFT);
return false;
}
break;
case KC_R:
if (record->event.pressed) {
- send_unicode_hex_string("0279");
+ register_unicode(0x0279); // ɹ
tap_code(KC_LEFT);
return false;
}
break;
case KC_T:
if (record->event.pressed) {
- send_unicode_hex_string("0287");
+ register_unicode(0x0287); // ʇ
tap_code(KC_LEFT);
return false;
}
break;
case KC_V:
if (record->event.pressed) {
- send_unicode_hex_string("028C");
+ register_unicode(0x028C); // ʌ
tap_code(KC_LEFT);
return false;
}
break;
case KC_W:
if (record->event.pressed) {
- send_unicode_hex_string("028D");
+ register_unicode(0x028D); // ʍ
tap_code(KC_LEFT);
return false;
}
break;
case KC_X:
if (record->event.pressed) {
- send_unicode_hex_string("2717");
+ register_unicode(0x2717); // ✗
tap_code(KC_LEFT);
return false;
}
break;
case KC_Y:
if (record->event.pressed) {
- send_unicode_hex_string("028E");
+ register_unicode(0x028E); // ʎ
tap_code(KC_LEFT);
return false;
}
break;
case KC_1:
if (record->event.pressed) {
- send_unicode_hex_string("0269");
+ register_unicode(0x0269); // ɩ
tap_code(KC_LEFT);
return false;
}
break;
case KC_2:
if (record->event.pressed) {
- send_unicode_hex_string("3139");
+ register_unicode(0x3139); // ㄹ
tap_code(KC_LEFT);
return false;
}
break;
case KC_3:
if (record->event.pressed) {
- send_unicode_hex_string("0190");
+ register_unicode(0x0190); // Ɛ
tap_code(KC_LEFT);
return false;
}
break;
case KC_4:
if (record->event.pressed) {
- send_unicode_hex_string("3123");
+ register_unicode(0x3123); // ㄣ
tap_code(KC_LEFT);
return false;
}
break;
case KC_5:
if (record->event.pressed) {
- send_unicode_hex_string("03DB");
+ register_unicode(0x03DB); // ϛ
tap_code(KC_LEFT);
return false;
}
break;
case KC_7:
if (record->event.pressed) {
- send_unicode_hex_string("3125");
+ register_unicode(0x3125); // ㄥ
tap_code(KC_LEFT);
}
return false;
@@ -401,7 +399,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
user_mod_state = get_mods() & MOD_MASK_ALT;
if (user_mod_state) {
unregister_mods(MOD_BIT(KC_RALT));
- send_unicode_hex_string("00B0");
+ register_unicode(0x00B0); // °
set_mods(user_mod_state);
return false;
}
@@ -474,7 +472,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed && record->event.key.col == 4 && record->event.key.row == 1) {
if (get_mods() & MOD_BIT(KC_RALT)) {
unregister_mods(MOD_BIT(KC_RALT));
- //send_unicode_hex_string("262D");
+ //register_unicode(0x262D); // ☭
tap_code(KC_BSPC);
set_mods(MOD_BIT(KC_RALT));
return false;
diff --git a/users/rs/rs.h b/users/rs/rs.h
index 722d6ed19e3e..fde8c33558fc 100644
--- a/users/rs/rs.h
+++ b/users/rs/rs.h
@@ -18,8 +18,6 @@ enum custom_keycodes {
#endif
};
-#define KC_ KC_TRNS
-
#define KC_ESCC MT(MOD_LCTL, KC_ESC)
#define KC_ENTS MT(MOD_LSFT, KC_ENT)
#define KC_LTGT LTGT // > or < with shift
@@ -47,4 +45,4 @@ enum custom_keycodes {
#define KC_LVAI RGB_VAI
#define KC_LVAD RGB_VAD
#define KC_LMOD RGB_MOD
-#endif
\ No newline at end of file
+#endif
diff --git a/users/stanrc85/stanrc85.c b/users/stanrc85/stanrc85.c
index d5e56571d1bb..f8555d87bd6c 100644
--- a/users/stanrc85/stanrc85.c
+++ b/users/stanrc85/stanrc85.c
@@ -45,7 +45,7 @@ void ctl_copy_reset (qk_tap_dance_state_t *state, void *user_data) {
}
#if defined(HAS_ROTARY)
- void encoder_update_user(uint8_t index, bool clockwise) {
+ bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* First encoder */
if (clockwise) {
tap_code(KC_VOLD);
@@ -53,6 +53,7 @@ void ctl_copy_reset (qk_tap_dance_state_t *state, void *user_data) {
tap_code(KC_VOLU);
}
}
+ return true;
}
#endif
@@ -75,7 +76,7 @@ void lock_unlock (qk_tap_dance_state_t *state, void *user_data) {
writePin(INDICATOR_PIN_1, !led_user);
wait_ms(200);
writePin(INDICATOR_PIN_2, !led_user);
- #endif
+ #endif
break;
case SINGLE_HOLD:
break;
@@ -91,7 +92,7 @@ void lock_unlock (qk_tap_dance_state_t *state, void *user_data) {
writePin(INDICATOR_PIN_1, !led_user);
wait_ms(200);
writePin(INDICATOR_PIN_0, !led_user);
- #endif
+ #endif
break;
}
}
diff --git a/users/xulkal/custom_encoder.c b/users/xulkal/custom_encoder.c
index cd029944ff38..acd0275a8b3a 100644
--- a/users/xulkal/custom_encoder.c
+++ b/users/xulkal/custom_encoder.c
@@ -58,7 +58,7 @@ const uint16_t PROGMEM encoders[][2] = {
{ KC_VOLU, KC_VOLD }
};
-void encoder_update_user(uint8_t index, bool clockwise)
+bool encoder_update_user(uint8_t index, bool clockwise)
{
if (!is_keyboard_master())
return;
@@ -69,4 +69,5 @@ void encoder_update_user(uint8_t index, bool clockwise)
else
#endif // RGB_OLED_MENU
tap_code16(pgm_read_word(&encoders[index][clockwise]));
+ return true;
}
diff --git a/users/yet-another-developer/process_records.c b/users/yet-another-developer/process_records.c
index c7dbd704a0ae..7dba702bf5c7 100644
--- a/users/yet-another-developer/process_records.c
+++ b/users/yet-another-developer/process_records.c
@@ -162,24 +162,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
break;
#ifdef UNICODE_ENABLE
- case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻
+ case UC_FLIP:
if (record->event.pressed) {
- send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B");
+ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
}
break;
- case UC_TABL: // ┬─┬ノ( º _ ºノ)
+ case UC_TABL:
if (record->event.pressed) {
- send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029");
+ send_unicode_string("┬─┬ノ( º _ ºノ)");
}
break;
- case UC_SHRG: // ¯\_(ツ)_/¯
+ case UC_SHRG:
if (record->event.pressed) {
- send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF");
+ send_unicode_string("¯\\_(ツ)_/¯");
}
break;
- case UC_DISA: // ಠ_ಠ
+ case UC_DISA:
if (record->event.pressed) {
- send_unicode_hex_string("0CA0 005F 0CA0");
+ send_unicode_string("ಠ_ಠ");
}
break;
#endif // UNICODE_ENABLE
diff --git a/users/yet-another-developer/unicode.h b/users/yet-another-developer/unicode.h
index cb550243eea7..9ff523baadf7 100644
--- a/users/yet-another-developer/unicode.h
+++ b/users/yet-another-developer/unicode.h
@@ -2,8 +2,6 @@
#include "quantum.h"
-void send_unicode_hex_string(const char* str);
-
/* use X(n) to call the */
#ifdef UNICODEMAP_ENABLE
enum unicode_name {
diff --git a/util/install/arch.sh b/util/install/arch.sh
index 7442e2f136fb..eac4ad64eff0 100755
--- a/util/install/arch.sh
+++ b/util/install/arch.sh
@@ -4,13 +4,13 @@ _qmk_install() {
echo "Installing dependencies"
sudo pacman --needed --noconfirm -S \
- base-devel clang diffutils gcc git unzip wget zip \
- python-pip \
- avr-binutils \
- arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-newlib \
- avrdude dfu-programmer dfu-util
+ base-devel clang diffutils gcc git unzip wget zip python-pip \
+ avr-binutils arm-none-eabi-binutils arm-none-eabi-gcc \
+ arm-none-eabi-newlib avrdude dfu-programmer dfu-util
sudo pacman --needed --noconfirm -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz
sudo pacman --needed --noconfirm -S avr-libc # Must be installed after the above, or it will bring in the latest avr-gcc instead
+ sudo pacman --needed --noconfirm -S hidapi # This will fail if the community repo isn't enabled
+
python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}
diff --git a/util/install/debian.sh b/util/install/debian.sh
index 885df723d955..380348237ae9 100755
--- a/util/install/debian.sh
+++ b/util/install/debian.sh
@@ -13,10 +13,9 @@ _qmk_install() {
sudo apt-get -yq install \
build-essential clang-format diffutils gcc git unzip wget zip \
- python3-pip \
- binutils-avr gcc-avr avr-libc \
- binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi \
- avrdude dfu-programmer dfu-util teensy-loader-cli libusb-dev
+ python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \
+ gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \
+ dfu-util teensy-loader-cli libhidapi-hidraw0
python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}
diff --git a/util/install/fedora.sh b/util/install/fedora.sh
index d9452f68d546..3f9695356ca8 100755
--- a/util/install/fedora.sh
+++ b/util/install/fedora.sh
@@ -5,11 +5,10 @@ _qmk_install() {
# TODO: Check whether devel/headers packages are really needed
sudo dnf $SKIP_PROMPT install \
- clang diffutils git gcc glibc-headers kernel-devel kernel-headers make unzip wget zip \
- python3 \
- avr-binutils avr-gcc avr-libc \
+ clang diffutils git gcc glibc-headers kernel-devel kernel-headers \
+ make unzip wget zip python3 avr-binutils avr-gcc avr-libc \
arm-none-eabi-binutils-cs arm-none-eabi-gcc-cs arm-none-eabi-newlib \
- avrdude dfu-programmer dfu-util libusb-devel
+ avrdude dfu-programmer dfu-util hidapi
python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}
diff --git a/util/install/gentoo.sh b/util/install/gentoo.sh
index 97eb5df07f63..604d07bf84fd 100755
--- a/util/install/gentoo.sh
+++ b/util/install/gentoo.sh
@@ -22,9 +22,10 @@ _qmk_install() {
echo "sys-devel/gcc multilib" | sudo tee --append /etc/portage/package.use/qmkfirmware >/dev/null
sudo emerge -auN sys-devel/gcc
sudo emerge -au --noreplace \
- app-arch/unzip app-arch/zip net-misc/wget sys-devel/clang sys-devel/crossdev \
- \>=dev-lang/python-3.7 \
- dev-embedded/avrdude dev-embedded/dfu-programmer app-mobilephone/dfu-util
+ app-arch/unzip app-arch/zip net-misc/wget sys-devel/clang \
+ sys-devel/crossdev \>=dev-lang/python-3.7 dev-embedded/avrdude \
+ dev-embedded/dfu-programmer app-mobilephone/dfu-util sys-apps/hwloc \
+ dev-libs/hidapi
sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr
sudo crossdev -s4 --stable --g \<9 --portage --verbose --target arm-none-eabi
diff --git a/util/install/msys2.sh b/util/install/msys2.sh
index b1300a34d2df..b027ff53d217 100755
--- a/util/install/msys2.sh
+++ b/util/install/msys2.sh
@@ -9,11 +9,10 @@ _qmk_install() {
pacman --needed --noconfirm --disable-download-timeout -S pactoys-git
pacboy sync --needed --noconfirm --disable-download-timeout \
- base-devel: toolchain:x clang:x git: unzip: \
- python3-pip:x \
- avr-binutils:x avr-gcc:x avr-libc:x \
- arm-none-eabi-binutils:x arm-none-eabi-gcc:x arm-none-eabi-newlib:x \
- avrdude:x bootloadhid:x dfu-programmer:x dfu-util:x teensy-loader-cli:x
+ base-devel: toolchain:x clang:x git: unzip: python3-pip:x \
+ avr-binutils:x avr-gcc:x avr-libc:x arm-none-eabi-binutils:x \
+ arm-none-eabi-gcc:x arm-none-eabi-newlib:x avrdude:x bootloadhid:x \
+ dfu-programmer:x dfu-util:x teensy-loader-cli:x hidapi:x
_qmk_install_drivers
diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules
index acaa7dcc587c..679fe4ced38e 100644
--- a/util/udev/50-qmk.rules
+++ b/util/udev/50-qmk.rules
@@ -60,3 +60,6 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="239a", ATTRS{idProduct}=="000e", TAG+="uacc
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2a03", ATTRS{idProduct}=="0036", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1"
### Micro
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2a03", ATTRS{idProduct}=="0037", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1"
+
+# hid_listen
+KERNEL=="hidraw*", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
diff --git a/util/uf2conv.py b/util/uf2conv.py
new file mode 100755
index 000000000000..044a7f231890
--- /dev/null
+++ b/util/uf2conv.py
@@ -0,0 +1,319 @@
+#!/usr/bin/env python3
+import sys
+import struct
+import subprocess
+import re
+import os
+import os.path
+import argparse
+
+
+UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
+UF2_MAGIC_START1 = 0x9E5D5157 # Randomly selected
+UF2_MAGIC_END = 0x0AB16F30 # Ditto
+
+families = {
+ 'SAMD21': 0x68ed2b88,
+ 'SAML21': 0x1851780a,
+ 'SAMD51': 0x55114460,
+ 'NRF52': 0x1b57745f,
+ 'STM32F0': 0x647824b6,
+ 'STM32F1': 0x5ee21072,
+ 'STM32F2': 0x5d1a0a2e,
+ 'STM32F3': 0x6b846188,
+ 'STM32F4': 0x57755a57,
+ 'STM32F7': 0x53b80f00,
+ 'STM32G0': 0x300f5633,
+ 'STM32G4': 0x4c71240a,
+ 'STM32H7': 0x6db66082,
+ 'STM32L0': 0x202e3a91,
+ 'STM32L1': 0x1e1f432d,
+ 'STM32L4': 0x00ff6919,
+ 'STM32L5': 0x04240bdf,
+ 'STM32WB': 0x70d16653,
+ 'STM32WL': 0x21460ff0,
+ 'ATMEGA32': 0x16573617,
+ 'MIMXRT10XX': 0x4FB2D5BD,
+ 'LPC55': 0x2abc77ec,
+ 'GD32F350': 0x31D228C6,
+ 'ESP32S2': 0xbfdd4eee,
+ 'RP2040': 0xe48bff56
+}
+
+INFO_FILE = "/INFO_UF2.TXT"
+
+appstartaddr = 0x2000
+familyid = 0x0
+
+
+def is_uf2(buf):
+ w = struct.unpack(" 476:
+ assert False, "Invalid UF2 data size at " + ptr
+ newaddr = hd[3]
+ if curraddr == None:
+ appstartaddr = newaddr
+ curraddr = newaddr
+ padding = newaddr - curraddr
+ if padding < 0:
+ assert False, "Block out of order at " + ptr
+ if padding > 10*1024*1024:
+ assert False, "More than 10M of padding needed at " + ptr
+ if padding % 4 != 0:
+ assert False, "Non-word padding size at " + ptr
+ while padding > 0:
+ padding -= 4
+ outp += b"\x00\x00\x00\x00"
+ outp.append(block[32 : 32 + datalen])
+ curraddr = newaddr + datalen
+ return b"".join(outp)
+
+def convert_to_carray(file_content):
+ outp = "const unsigned long bindata_len = %d;\n" % len(file_content)
+ outp += "const unsigned char bindata[] __attribute__((aligned(16))) = {"
+ for i in range(len(file_content)):
+ if i % 16 == 0:
+ outp += "\n"
+ outp += "0x%02x, " % file_content[i]
+ outp += "\n};\n"
+ return bytes(outp, "utf-8")
+
+def convert_to_uf2(file_content):
+ global familyid
+ datapadding = b""
+ while len(datapadding) < 512 - 256 - 32 - 4:
+ datapadding += b"\x00\x00\x00\x00"
+ numblocks = (len(file_content) + 255) // 256
+ outp = []
+ for blockno in range(numblocks):
+ ptr = 256 * blockno
+ chunk = file_content[ptr:ptr + 256]
+ flags = 0x0
+ if familyid:
+ flags |= 0x2000
+ hd = struct.pack(b"= 3 and words[1] == "2" and words[2] == "FAT":
+ drives.append(words[0])
+ else:
+ rootpath = "/media"
+ if sys.platform == "darwin":
+ rootpath = "/Volumes"
+ elif sys.platform == "linux":
+ tmp = rootpath + "/" + os.environ["USER"]
+ if os.path.isdir(tmp):
+ rootpath = tmp
+ for d in os.listdir(rootpath):
+ drives.append(os.path.join(rootpath, d))
+
+
+ def has_info(d):
+ try:
+ return os.path.isfile(d + INFO_FILE)
+ except:
+ return False
+
+ return list(filter(has_info, drives))
+
+
+def board_id(path):
+ with open(path + INFO_FILE, mode='r') as file:
+ file_content = file.read()
+ return re.search("Board-ID: ([^\r\n]*)", file_content).group(1)
+
+
+def list_drives():
+ for d in get_drives():
+ print(d, board_id(d))
+
+
+def write_file(name, buf):
+ with open(name, "wb") as f:
+ f.write(buf)
+ print("Wrote %d bytes to %s" % (len(buf), name))
+
+
+def main():
+ global appstartaddr, familyid
+ def error(msg):
+ print(msg)
+ sys.exit(1)
+ parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
+ parser.add_argument('input', metavar='INPUT', type=str, nargs='?',
+ help='input file (HEX, BIN or UF2)')
+ parser.add_argument('-b' , '--base', dest='base', type=str,
+ default="0x2000",
+ help='set base address of application for BIN format (default: 0x2000)')
+ parser.add_argument('-o' , '--output', metavar="FILE", dest='output', type=str,
+ help='write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible')
+ parser.add_argument('-d' , '--device', dest="device_path",
+ help='select a device path to flash')
+ parser.add_argument('-l' , '--list', action='store_true',
+ help='list connected devices')
+ parser.add_argument('-c' , '--convert', action='store_true',
+ help='do not flash, just convert')
+ parser.add_argument('-D' , '--deploy', action='store_true',
+ help='just flash, do not convert')
+ parser.add_argument('-f' , '--family', dest='family', type=str,
+ default="0x0",
+ help='specify familyID - number or name (default: 0x0)')
+ parser.add_argument('-C' , '--carray', action='store_true',
+ help='convert binary file to a C array, not UF2')
+ args = parser.parse_args()
+ appstartaddr = int(args.base, 0)
+
+ if args.family.upper() in families:
+ familyid = families[args.family.upper()]
+ else:
+ try:
+ familyid = int(args.family, 0)
+ except ValueError:
+ error("Family ID needs to be a number or one of: " + ", ".join(families.keys()))
+
+ if args.list:
+ list_drives()
+ else:
+ if not args.input:
+ error("Need input file")
+ with open(args.input, mode='rb') as f:
+ inpbuf = f.read()
+ from_uf2 = is_uf2(inpbuf)
+ ext = "uf2"
+ if args.deploy:
+ outbuf = inpbuf
+ elif from_uf2:
+ outbuf = convert_from_uf2(inpbuf)
+ ext = "bin"
+ elif is_hex(inpbuf):
+ outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8"))
+ elif args.carray:
+ outbuf = convert_to_carray(inpbuf)
+ ext = "h"
+ else:
+ outbuf = convert_to_uf2(inpbuf)
+ print("Converting to %s, output size: %d, start address: 0x%x" %
+ (ext, len(outbuf), appstartaddr))
+ if args.convert or ext != "uf2":
+ drives = []
+ if args.output == None:
+ args.output = "flash." + ext
+ else:
+ drives = get_drives()
+
+ if args.output:
+ write_file(args.output, outbuf)
+ else:
+ if len(drives) == 0:
+ error("No drive to deploy.")
+ for d in drives:
+ print("Flashing %s (%s)" % (d, board_id(d)))
+ write_file(d + "/NEW.UF2", outbuf)
+
+
+if __name__ == "__main__":
+ main()