aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build_test.mk1
-rw-r--r--common_features.mk17
-rw-r--r--docs/_summary.md1
-rw-r--r--docs/breaking_changes.md4
-rw-r--r--docs/chibios_upgrade_instructions.md56
-rw-r--r--docs/config_options.md3
-rw-r--r--docs/custom_quantum_functions.md8
-rw-r--r--docs/feature_debounce_type.md4
-rw-r--r--docs/feature_rgb_matrix.md68
-rw-r--r--docs/feature_st7565.md270
-rw-r--r--drivers/awinic/aw20216.c166
-rw-r--r--drivers/awinic/aw20216.h251
-rw-r--r--drivers/chibios/spi_master.c70
-rw-r--r--drivers/chibios/spi_master.h19
-rw-r--r--drivers/lcd/st7565.c479
-rw-r--r--drivers/lcd/st7565.h215
-rw-r--r--keyboards/anavi/macropad8/keymaps/default/config.h19
-rw-r--r--keyboards/basekeys/trifecta/config.h4
-rwxr-xr-xkeyboards/bm40hsrgb/config.h2
-rw-r--r--keyboards/bm68rgb/keymaps/peepeetee/config.h2
-rw-r--r--keyboards/boardsource/the_mark/config.h2
-rw-r--r--keyboards/crkbd/keymaps/devdev/config.h14
-rw-r--r--keyboards/crkbd/keymaps/gotham/config.h2
-rw-r--r--keyboards/crkbd/keymaps/kidbrazil/config.h2
-rw-r--r--keyboards/crkbd/keymaps/rpbaptist/config.h2
-rw-r--r--keyboards/crkbd/keymaps/soundmonster/config.h4
-rw-r--r--keyboards/crkbd/readme.md2
-rw-r--r--keyboards/dztech/dz60rgb/v1/config.h2
-rw-r--r--keyboards/dztech/dz60rgb/v2/config.h2
-rw-r--r--keyboards/dztech/dz60rgb_ansi/v1/config.h2
-rw-r--r--keyboards/dztech/dz60rgb_ansi/v2/config.h2
-rw-r--r--keyboards/dztech/dz60rgb_wkl/v1/config.h2
-rw-r--r--keyboards/dztech/dz60rgb_wkl/v2/config.h2
-rw-r--r--keyboards/dztech/dz65rgb/v1/config.h4
-rw-r--r--keyboards/dztech/dz65rgb/v2/config.h2
-rw-r--r--keyboards/ergodox_ez/config.h2
-rw-r--r--keyboards/ergodox_ez/keymaps/hacker_dvorak/config.h2
-rw-r--r--keyboards/ergodox_infinity/config.h15
-rw-r--r--keyboards/ergodox_infinity/ergodox_infinity.c302
-rw-r--r--keyboards/ergodox_infinity/matrix.c18
-rw-r--r--keyboards/ergodox_infinity/rules.mk7
-rw-r--r--keyboards/geekboards/macropad_v2/config.h4
-rw-r--r--keyboards/geekboards/tester/config.h4
-rw-r--r--keyboards/gmmk/pro/config.h17
-rw-r--r--keyboards/gmmk/pro/halconf.h7
-rw-r--r--keyboards/gmmk/pro/mcuconf.h6
-rw-r--r--keyboards/gmmk/pro/pro.c222
-rw-r--r--keyboards/gmmk/pro/rules.mk2
-rw-r--r--keyboards/handwired/colorlice/config.h2
-rw-r--r--keyboards/handwired/frankie_macropad/keymaps/default/config.h19
-rw-r--r--keyboards/handwired/hnah40rgb/config.h2
-rw-r--r--keyboards/handwired/p65rgb/config.h2
-rw-r--r--keyboards/helix/rev3_4rows/config.h2
-rw-r--r--keyboards/helix/rev3_5rows/config.h2
-rw-r--r--keyboards/hs60/v1/config.h2
-rw-r--r--keyboards/kbdfans/bella/rgb/config.h2
-rw-r--r--keyboards/kbdfans/bella/rgb_iso/config.h2
-rw-r--r--keyboards/kbdfans/kbd67/mkiirgb/v1/config.h4
-rw-r--r--keyboards/kbdfans/kbd67/mkiirgb/v2/config.h4
-rw-r--r--keyboards/kbdfans/kbd67/rev1/keymaps/default/config.h2
-rw-r--r--keyboards/kbdfans/kbdmini/config.h2
-rwxr-xr-xkeyboards/kbdfans/maja/config.h4
-rw-r--r--keyboards/latin17rgb/config.h32
-rw-r--r--keyboards/latin60rgb/config.h31
-rw-r--r--keyboards/le_chiffre/config.h2
-rw-r--r--keyboards/marksard/rhymestone/rev1/config.h2
-rw-r--r--keyboards/massdrop/alt/keymaps/pregame/config.h4
-rw-r--r--keyboards/massdrop/alt/keymaps/urbanvanilla/config.h2
-rw-r--r--keyboards/massdrop/ctrl/keymaps/endgame/config.h2
-rw-r--r--keyboards/massdrop/ctrl/keymaps/matthewrobo/config.h2
-rw-r--r--keyboards/mechlovin/adelais/rgb_led/rev1/config.h4
-rw-r--r--keyboards/mechlovin/adelais/rgb_led/rev2/config.h6
-rw-r--r--keyboards/mechlovin/delphine/rgb_led/config.h4
-rw-r--r--keyboards/mechlovin/hannah60rgb/rev1/config.h4
-rw-r--r--keyboards/mechlovin/hannah60rgb/rev2/config.h4
-rw-r--r--keyboards/mechlovin/infinity87/rgb_rev1/config.h2
-rw-r--r--keyboards/melgeek/mj61/config.h2
-rw-r--r--keyboards/melgeek/mj63/config.h2
-rw-r--r--keyboards/melgeek/mj64/config.h2
-rw-r--r--keyboards/melgeek/mj65/config.h2
-rw-r--r--keyboards/melgeek/mojo75/config.h2
-rw-r--r--keyboards/melgeek/z70ultra/config.h2
-rw-r--r--keyboards/miller/gm862/config.h4
-rw-r--r--keyboards/monstargear/xo87/rgb/config.h2
-rw-r--r--keyboards/moonlander/config.h2
-rw-r--r--keyboards/mt84/keymaps/default/config.h19
-rw-r--r--keyboards/naked48/keymaps/salicylic/config.h3
-rw-r--r--keyboards/opendeck/32/rev1/config.h2
-rw-r--r--keyboards/percent/canoe_gen2/config.h2
-rw-r--r--keyboards/phase_studio/titan65/config.h2
-rw-r--r--keyboards/planck/ez/config.h2
-rw-r--r--keyboards/planck/rev6/config.h2
-rw-r--r--keyboards/setta21/keymaps/salicylic/config.h3
-rw-r--r--keyboards/sofle/keymaps/devdev/config.h44
-rw-r--r--keyboards/sofle/keymaps/killmaster/config.h64
-rw-r--r--keyboards/sofle/keymaps/killmaster/keymap.c403
-rw-r--r--keyboards/sofle/keymaps/killmaster/readme.md19
-rw-r--r--keyboards/sofle/keymaps/killmaster/rules.mk4
-rw-r--r--keyboards/sofle/keymaps/rgb_default/config.h44
-rw-r--r--keyboards/sofle/rev1/readme.md27
-rw-r--r--keyboards/sofle/rev1/rev1.c86
-rw-r--r--keyboards/terrazzo/config.h4
-rw-r--r--keyboards/tkc/portico/config.h2
-rw-r--r--keyboards/tokyokeyboard/tokyo60/config.h (renamed from keyboards/tokyo60/config.h)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/info.json (renamed from keyboards/tokyo60/info.json)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h (renamed from keyboards/tokyo60/keymaps/default/config.h)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/keymaps/default/keymap.c (renamed from keyboards/tokyo60/keymaps/default/keymap.c)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h (renamed from keyboards/tokyo60/keymaps/swappedBottomRow/config.h)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c (renamed from keyboards/tokyo60/keymaps/swappedBottomRow/keymap.c)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/keymaps/via/keymap.c (renamed from keyboards/tokyo60/keymaps/via/keymap.c)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/keymaps/via/rules.mk (renamed from keyboards/tokyo60/keymaps/via/rules.mk)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/readme.md (renamed from keyboards/tokyo60/readme.md)8
-rw-r--r--keyboards/tokyokeyboard/tokyo60/rules.mk (renamed from keyboards/tokyo60/rules.mk)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/tokyo60.c (renamed from keyboards/tokyo60/tokyo60.c)0
-rw-r--r--keyboards/tokyokeyboard/tokyo60/tokyo60.h (renamed from keyboards/tokyo60/tokyo60.h)0
-rw-r--r--keyboards/whitefox/config.h14
-rw-r--r--keyboards/whitefox/rules.mk8
-rw-r--r--keyboards/whitefox/whitefox.c76
-rw-r--r--keyboards/xbows/nature/config.h2
-rw-r--r--keyboards/xbows/woody/config.h6
-rw-r--r--keyboards/yncognito/batpad/config.h14
-rw-r--r--layouts/community/ortho_4x12/bocaj/config.h2
-rw-r--r--layouts/community/ortho_4x12/drashna/config.h2
-rw-r--r--layouts/community/split_3x6_3/drashna/config.h2
m---------lib/chibios0
m---------lib/chibios-contrib0
-rw-r--r--quantum/debounce.h2
-rw-r--r--quantum/debounce/asym_eager_defer_pk.c171
-rw-r--r--quantum/debounce/none.c31
-rw-r--r--quantum/debounce/sym_defer_g.c26
-rw-r--r--quantum/debounce/sym_defer_pk.c67
-rw-r--r--quantum/debounce/sym_eager_pk.c72
-rw-r--r--quantum/debounce/sym_eager_pr.c76
-rw-r--r--quantum/debounce/tests/asym_eager_defer_pk_tests.cpp374
-rw-r--r--quantum/debounce/tests/debounce_test_common.cpp229
-rw-r--r--quantum/debounce/tests/debounce_test_common.h83
-rw-r--r--quantum/debounce/tests/rules.mk44
-rw-r--r--quantum/debounce/tests/sym_defer_g_tests.cpp223
-rw-r--r--quantum/debounce/tests/sym_defer_pk_tests.cpp225
-rw-r--r--quantum/debounce/tests/sym_eager_pk_tests.cpp237
-rw-r--r--quantum/debounce/tests/sym_eager_pr_tests.cpp280
-rw-r--r--quantum/debounce/tests/testlist.mk6
-rw-r--r--quantum/led_matrix.c4
-rw-r--r--quantum/matrix.c79
-rw-r--r--quantum/quantum.h4
-rw-r--r--quantum/rgb_matrix.c4
-rw-r--r--quantum/rgb_matrix.h2
-rw-r--r--quantum/rgb_matrix_animations/jellybean_raindrops_anim.h2
-rw-r--r--quantum/rgb_matrix_drivers.c16
-rw-r--r--quantum/split_common/matrix.c77
-rw-r--r--testlist.mk1
-rw-r--r--tmk_core/avr.mk2
-rw-r--r--tmk_core/common/arm_atsam/_timer.h19
-rw-r--r--tmk_core/common/avr/_timer.h19
-rw-r--r--tmk_core/common/avr/gpio.h15
-rw-r--r--tmk_core/common/chibios/_timer.h19
-rw-r--r--tmk_core/common/chibios/bootloader.c2
-rw-r--r--tmk_core/common/chibios/gpio.h16
-rw-r--r--tmk_core/common/keyboard.c18
-rw-r--r--tmk_core/common/timer.h24
-rw-r--r--tmk_core/protocol/chibios/usb_main.c34
-rw-r--r--tmk_core/protocol/lufa/lufa.c34
-rw-r--r--tmk_core/protocol/usb_descriptor.c2
-rw-r--r--tmk_core/protocol/vusb/vusb.c3
-rw-r--r--tmk_core/rules.mk2
-rw-r--r--users/bcat/config.h2
-rw-r--r--users/bocaj/config.h2
-rw-r--r--users/curry/config.h2
-rw-r--r--users/drashna/config.h2
-rw-r--r--users/spidey3/config.h4
-rw-r--r--users/tominabox1/config.h2
171 files changed, 5389 insertions, 520 deletions
diff --git a/build_test.mk b/build_test.mk
index 77c4265f9..5171c58c3 100644
--- a/build_test.mk
+++ b/build_test.mk
@@ -49,6 +49,7 @@ endif
49 49
50include common_features.mk 50include common_features.mk
51include $(TMK_PATH)/common.mk 51include $(TMK_PATH)/common.mk
52include $(QUANTUM_PATH)/debounce/tests/rules.mk
52include $(QUANTUM_PATH)/sequencer/tests/rules.mk 53include $(QUANTUM_PATH)/sequencer/tests/rules.mk
53include $(QUANTUM_PATH)/serial_link/tests/rules.mk 54include $(QUANTUM_PATH)/serial_link/tests/rules.mk
54ifneq ($(filter $(FULL_TESTS),$(TEST)),) 55ifneq ($(filter $(FULL_TESTS),$(TEST)),)
diff --git a/common_features.mk b/common_features.mk
index 1a9fd46b5..b259af46c 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -244,7 +244,7 @@ endif
244endif 244endif
245 245
246RGB_MATRIX_ENABLE ?= no 246RGB_MATRIX_ENABLE ?= no
247VALID_RGB_MATRIX_TYPES := IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 custom 247VALID_RGB_MATRIX_TYPES := AW20216 IS31FL3731 IS31FL3733 IS31FL3737 IS31FL3741 WS2812 custom
248 248
249ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) 249ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
250 ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),) 250 ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),)
@@ -261,6 +261,13 @@ endif
261 CIE1931_CURVE := yes 261 CIE1931_CURVE := yes
262 RGB_KEYCODES_ENABLE := yes 262 RGB_KEYCODES_ENABLE := yes
263 263
264 ifeq ($(strip $(RGB_MATRIX_DRIVER)), AW20216)
265 OPT_DEFS += -DAW20216 -DSTM32_SPI -DHAL_USE_SPI=TRUE
266 COMMON_VPATH += $(DRIVER_PATH)/awinic
267 SRC += aw20216.c
268 QUANTUM_LIB_SRC += spi_master.c
269 endif
270
264 ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3731) 271 ifeq ($(strip $(RGB_MATRIX_DRIVER)), IS31FL3731)
265 OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE 272 OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
266 COMMON_VPATH += $(DRIVER_PATH)/issi 273 COMMON_VPATH += $(DRIVER_PATH)/issi
@@ -580,6 +587,14 @@ ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
580 SRC += oled_driver.c 587 SRC += oled_driver.c
581endif 588endif
582 589
590ifeq ($(strip $(ST7565_ENABLE)), yes)
591 OPT_DEFS += -DST7565_ENABLE
592 COMMON_VPATH += $(DRIVER_PATH)/oled # For glcdfont.h
593 COMMON_VPATH += $(DRIVER_PATH)/lcd
594 QUANTUM_LIB_SRC += spi_master.c
595 SRC += st7565.c
596endif
597
583include $(DRIVER_PATH)/qwiic/qwiic.mk 598include $(DRIVER_PATH)/qwiic/qwiic.mk
584 599
585ifeq ($(strip $(UCIS_ENABLE)), yes) 600ifeq ($(strip $(UCIS_ENABLE)), yes)
diff --git a/docs/_summary.md b/docs/_summary.md
index 9798ef512..4141e01e7 100644
--- a/docs/_summary.md
+++ b/docs/_summary.md
@@ -93,6 +93,7 @@
93 * Hardware Features 93 * Hardware Features
94 * Displays 94 * Displays
95 * [HD44780 LCD Controller](feature_hd44780.md) 95 * [HD44780 LCD Controller](feature_hd44780.md)
96 * [ST7565 LCD Driver](feature_st7565.md)
96 * [OLED Driver](feature_oled_driver.md) 97 * [OLED Driver](feature_oled_driver.md)
97 * Lighting 98 * Lighting
98 * [Backlight](feature_backlight.md) 99 * [Backlight](feature_backlight.md)
diff --git a/docs/breaking_changes.md b/docs/breaking_changes.md
index 3e85a7076..2ad8b5a14 100644
--- a/docs/breaking_changes.md
+++ b/docs/breaking_changes.md
@@ -96,3 +96,7 @@ This happens immediately after the previous `develop` branch is merged.
96 * [ ] Create a PR for `develop` 96 * [ ] Create a PR for `develop`
97 * [ ] Make sure travis comes back clean 97 * [ ] Make sure travis comes back clean
98 * [ ] Merge `develop` PR 98 * [ ] Merge `develop` PR
99
100## Post-merge operations
101
102* (Optional) [update ChibiOS + ChibiOS-Contrib on `develop`](chibios_upgrade_instructions.md) \ No newline at end of file
diff --git a/docs/chibios_upgrade_instructions.md b/docs/chibios_upgrade_instructions.md
new file mode 100644
index 000000000..40c2faafc
--- /dev/null
+++ b/docs/chibios_upgrade_instructions.md
@@ -0,0 +1,56 @@
1# ChibiOS Upgrade Procedure
2
3ChibiOS and ChibiOS-Contrib need to be updated in tandem -- the latter has a branch tied to the ChibiOS version in use and should not be mixed with different versions.
4
5## Getting ChibiOS
6
7* `svn` Initialisation:
8 * Only needed to be done once
9 * You might need to separately install `git-svn` package in your OS's package manager
10 * `git svn init --stdlayout --prefix='svn/' http://svn.osdn.net/svnroot/chibios/`
11 * `git remote add qmk git@github.com:qmk/ChibiOS.git`
12* Updating:
13 * `git svn fetch`
14 * First time around this will take several hours
15 * Subsequent updates will be incremental only
16* Tagging example (work out which version first!):
17 * `git tag -a ver20.3.3 -m ver20.3.3 svn/tags/ver20.3.3`
18 * `git push qmk ver20.3.3`
19 * `git tag -a breaking_YYYY_qN -m breaking_YYYY_qN svn/tags/ver20.3.3`
20 * `git push qmk breaking_YYYY_qN`
21
22## Getting ChibiOS-Contrib
23
24* `git` Initialisation:
25 * `git clone git@github.com:qmk/ChibiOS-Contrib`
26 * `git remote add upstream https://github.com/ChibiOS/ChibiOS-Contrib`
27 * `git checkout -b chibios-20.3.x upstream/chibios-20.3.x`
28* Updating:
29 * `git fetch --all --tags --prune`
30 * `git checkout chibios-20.3.x`
31 * `git pull --ff-only`
32 * `git push origin chibios-20.3.x`
33 * `git tag -a breaking_YYYY_qN -m breaking_YYYY_qN chibios-20.3.x`
34 * `git push origin breaking_YYYY_qN`
35
36## Updating submodules
37
38* Update the submodules
39 * `cd $QMK_FIRMWARE`
40 * `git checkout develop`
41 * `git pull --ff-only`
42 * `git checkout -b chibios-version-bump`
43 * `cd lib/chibios`
44 * `git fetch --all --tags --prune`
45 * `git checkout breaking_YYYY_qN`
46 * `cd ../chibios-contrib`
47 * `git fetch --all --tags --prune`
48 * `git checkout breaking_YYYY_qN`
49* Build everything
50 * `cd $QMK_FIRMWARE`
51 * `qmk multibuild -j4`
52 * Make sure there are no errors
53* Push to the repo
54 * `git commit -am 'Update ChibiOS to XXXXXXXXX'`
55 * `git push --set-upstream origin chibios-version-bump`
56* Make a PR to qmk_firmware with the new branch \ No newline at end of file
diff --git a/docs/config_options.md b/docs/config_options.md
index d0f0b316e..26fe8cea5 100644
--- a/docs/config_options.md
+++ b/docs/config_options.md
@@ -51,8 +51,10 @@ This is a C header file that is one of the first things included, and will persi
51 * the number of columns in your keyboard's matrix 51 * the number of columns in your keyboard's matrix
52* `#define MATRIX_ROW_PINS { D0, D5, B5, B6 }` 52* `#define MATRIX_ROW_PINS { D0, D5, B5, B6 }`
53 * pins of the rows, from top to bottom 53 * pins of the rows, from top to bottom
54 * may be omitted by the keyboard designer if matrix reads are handled in an alternate manner. See [low-level matrix overrides](custom_quantum_functions.md?id=low-level-matrix-overrides) for more information.
54* `#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 }` 55* `#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 }`
55 * pins of the columns, from left to right 56 * pins of the columns, from left to right
57 * may be omitted by the keyboard designer if matrix reads are handled in an alternate manner. See [low-level matrix overrides](custom_quantum_functions.md?id=low-level-matrix-overrides) for more information.
56* `#define MATRIX_IO_DELAY 30` 58* `#define MATRIX_IO_DELAY 30`
57 * the delay in microseconds when between changing matrix pin state and reading values 59 * the delay in microseconds when between changing matrix pin state and reading values
58* `#define UNUSED_PINS { D1, D2, D3, B1, B2, B3 }` 60* `#define UNUSED_PINS { D1, D2, D3, B1, B2, B3 }`
@@ -280,6 +282,7 @@ There are a few different ways to set handedness for split keyboards (listed in
280* `#define MATRIX_ROW_PINS_RIGHT { <row pins> }` 282* `#define MATRIX_ROW_PINS_RIGHT { <row pins> }`
281* `#define MATRIX_COL_PINS_RIGHT { <col pins> }` 283* `#define MATRIX_COL_PINS_RIGHT { <col pins> }`
282 * If you want to specify a different pinout for the right half than the left half, you can define `MATRIX_ROW_PINS_RIGHT`/`MATRIX_COL_PINS_RIGHT`. Currently, the size of `MATRIX_ROW_PINS` must be the same as `MATRIX_ROW_PINS_RIGHT` and likewise for the definition of columns. 284 * If you want to specify a different pinout for the right half than the left half, you can define `MATRIX_ROW_PINS_RIGHT`/`MATRIX_COL_PINS_RIGHT`. Currently, the size of `MATRIX_ROW_PINS` must be the same as `MATRIX_ROW_PINS_RIGHT` and likewise for the definition of columns.
285 * may be omitted by the keyboard designer if matrix reads are handled in an alternate manner. See [low-level matrix overrides](custom_quantum_functions.md?id=low-level-matrix-overrides) for more information.
283 286
284* `#define DIRECT_PINS_RIGHT { { F1, F0, B0, C7 }, { F4, F5, F6, F7 } }` 287* `#define DIRECT_PINS_RIGHT { { F1, F0, B0, C7 }, { F4, F5, F6, F7 } }`
285 * If you want to specify a different direct pinout for the right half than the left half, you can define `DIRECT_PINS_RIGHT`. Currently, the size of `DIRECT_PINS` must be the same as `DIRECT_PINS_RIGHT`. 288 * If you want to specify a different direct pinout for the right half than the left half, you can define `DIRECT_PINS_RIGHT`. Currently, the size of `DIRECT_PINS` must be the same as `DIRECT_PINS_RIGHT`.
diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md
index 694b421e7..30c637bb4 100644
--- a/docs/custom_quantum_functions.md
+++ b/docs/custom_quantum_functions.md
@@ -144,6 +144,14 @@ This is useful for setting up stuff that you may need elsewhere, but isn't hardw
144* Keyboard/Revision: `void matrix_init_kb(void)` 144* Keyboard/Revision: `void matrix_init_kb(void)`
145* Keymap: `void matrix_init_user(void)` 145* Keymap: `void matrix_init_user(void)`
146 146
147### Low-level Matrix Overrides Function Documentation :id=low-level-matrix-overrides
148
149* GPIO pin initialisation: `void matrix_init_pins(void)`
150 * This needs to perform the low-level initialisation of all row and column pins. By default this will initialise the input/output state of each of the GPIO pins listed in `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`, based on whether or not the keyboard is set up for `ROW2COL`, `COL2ROW`, or `DIRECT_PINS`. Should the keyboard designer override this function, no initialisation of pin state will occur within QMK itself, instead deferring to the keyboard's override.
151* `COL2ROW`-based row reads: `void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)`
152* `ROW2COL`-based column reads: `void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)`
153* `DIRECT_PINS`-based reads: `void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)`
154 * These three functions need to perform the low-level retrieval of matrix state of relevant input pins, based on the matrix type. Only one of the functions should be implemented, if needed. By default this will iterate through `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`, configuring the inputs and outputs based on whether or not the keyboard is set up for `ROW2COL`, `COL2ROW`, or `DIRECT_PINS`. Should the keyboard designer override this function, no manipulation of matrix GPIO pin state will occur within QMK itself, instead deferring to the keyboard's override.
147 155
148## Keyboard Post Initialization code 156## Keyboard Post Initialization code
149 157
diff --git a/docs/feature_debounce_type.md b/docs/feature_debounce_type.md
index 3ad74224c..306185fe8 100644
--- a/docs/feature_debounce_type.md
+++ b/docs/feature_debounce_type.md
@@ -121,16 +121,16 @@ DEBOUNCE_TYPE = <name of algorithm>
121Where name of algorithm is one of: 121Where name of algorithm is one of:
122* ```sym_defer_g``` - debouncing per keyboard. On any state change, a global timer is set. When ```DEBOUNCE``` milliseconds of no changes has occurred, all input changes are pushed. 122* ```sym_defer_g``` - debouncing per keyboard. On any state change, a global timer is set. When ```DEBOUNCE``` milliseconds of no changes has occurred, all input changes are pushed.
123 * This is the current default algorithm. This is the highest performance algorithm with lowest memory usage, and it's also noise-resistant. 123 * This is the current default algorithm. This is the highest performance algorithm with lowest memory usage, and it's also noise-resistant.
124* ```sym_eager_pr``` - debouncing per row. On any state change, response is immediate, followed by locking the row ```DEBOUNCE``` milliseconds of no further input for that row. 124* ```sym_eager_pr``` - debouncing per row. On any state change, response is immediate, followed by locking the row ```DEBOUNCE``` milliseconds of no further input for that row.
125For use in keyboards where refreshing ```NUM_KEYS``` 8-bit counters is computationally expensive / low scan rate, and fingers usually only hit one row at a time. This could be 125For use in keyboards where refreshing ```NUM_KEYS``` 8-bit counters is computationally expensive / low scan rate, and fingers usually only hit one row at a time. This could be
126appropriate for the ErgoDox models; the matrix is rotated 90°, and hence its "rows" are really columns, and each finger only hits a single "row" at a time in normal use. 126appropriate for the ErgoDox models; the matrix is rotated 90°, and hence its "rows" are really columns, and each finger only hits a single "row" at a time in normal use.
127* ```sym_eager_pk``` - debouncing per key. On any state change, response is immediate, followed by ```DEBOUNCE``` milliseconds of no further input for that key 127* ```sym_eager_pk``` - debouncing per key. On any state change, response is immediate, followed by ```DEBOUNCE``` milliseconds of no further input for that key
128* ```sym_defer_pk``` - debouncing per key. On any state change, a per-key timer is set. When ```DEBOUNCE``` milliseconds of no changes have occurred on that key, the key status change is pushed. 128* ```sym_defer_pk``` - debouncing per key. On any state change, a per-key timer is set. When ```DEBOUNCE``` milliseconds of no changes have occurred on that key, the key status change is pushed.
129* ```asym_eager_defer_pk``` - debouncing per key. On a key-down state change, response is immediate, followed by ```DEBOUNCE``` milliseconds of no further input for that key. On a key-up state change, a per-key timer is set. When ```DEBOUNCE``` milliseconds of no changes have occurred on that key, the key-up status change is pushed.
129 130
130### A couple algorithms that could be implemented in the future: 131### A couple algorithms that could be implemented in the future:
131* ```sym_defer_pr``` 132* ```sym_defer_pr```
132* ```sym_eager_g``` 133* ```sym_eager_g```
133* ```asym_eager_defer_pk```
134 134
135### Use your own debouncing code 135### Use your own debouncing code
136You have the option to implement you own debouncing algorithm. To do this: 136You have the option to implement you own debouncing algorithm. To do this:
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index bfb3688b6..25ba3ffe3 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -228,6 +228,74 @@ Configure the hardware via your `config.h`:
228``` 228```
229 229
230--- 230---
231### AW20216 :id=aw20216
232There is basic support for addressable RGB matrix lighting with the SPI AW20216 RGB controller. To enable it, add this to your `rules.mk`:
233
234```makefile
235RGB_MATRIX_ENABLE = yes
236RGB_MATRIX_DRIVER = AW20216
237```
238
239You can use up to 2 AW20216 IC's. Do not specify `DRIVER_<N>_xxx` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`:
240
241| Variable | Description | Default |
242|----------|-------------|---------|
243| `DRIVER_1_CS` | (Required) MCU pin connected to first RGB driver chip select line | B13 |
244| `DRIVER_2_CS` | (Optional) MCU pin connected to second RGB driver chip select line | |
245| `DRIVER_1_EN` | (Required) MCU pin connected to first RGB driver hardware enable line | C13 |
246| `DRIVER_2_EN` | (Optional) MCU pin connected to second RGB driver hardware enable line | |
247| `DRIVER_1_LED_TOTAL` | (Required) How many RGB lights are connected to first RGB driver | |
248| `DRIVER_2_LED_TOTAL` | (Optional) How many RGB lights are connected to second RGB driver | |
249| `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
250| `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
251| `AW_SCALING_MAX` | (Optional) LED current scaling value (0-255, higher values mean LED is brighter at full PWM) | 150 |
252| `AW_GLOBAL_CURRENT_MAX` | (Optional) Driver global current limit (0-255, higher values means the driver may consume more power) | 150 |
253
254Here is an example using 2 drivers.
255
256```c
257#define DRIVER_1_CS B13
258#define DRIVER_2_CS B14
259// Hardware enable lines may be connected to the same pin
260#define DRIVER_1_EN C13
261#define DRIVER_2_EN C13
262
263#define DRIVER_COUNT 2
264#define DRIVER_1_LED_TOTAL 66
265#define DRIVER_2_LED_TOTAL 32
266#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
267```
268
269!> 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`.
270
271Define these arrays listing all the LEDs in your `<keyboard>.c`:
272
273```c
274const aw_led g_aw_leds[DRIVER_LED_TOTAL] = {
275/* Each AW20216 channel is controlled by a register at some offset between 0x00
276 * and 0xD7 inclusive.
277 * See drivers/awinic/aw20216.h for the mapping between register offsets and
278 * driver pin locations.
279 * driver
280 * | R location
281 * | | G location
282 * | | | B location
283 * | | | | */
284 { 0, CS1_SW1, CS2_SW1, CS3_SW1 },
285 { 0, CS4_SW1, CS5_SW1, CS6_SW1 },
286 { 0, CS7_SW1, CS8_SW1, CS9_SW1 },
287 { 0, CS10_SW1, CS11_SW1, CS12_SW1 },
288 { 0, CS13_SW1, CS14_SW1, CS15_SW1 },
289 ...
290 { 1, CS1_SW1, CS2_SW1, CS3_SW1 },
291 { 1, CS13_SW1, CS14_SW1, CS15_SW1 },
292 { 1, CS16_SW1, CS17_SW1, CS18_SW1 },
293 { 1, CS4_SW2, CS5_SW2, CS6_SW2 },
294 ...
295};
296```
297
298---
231 299
232## Common Configuration :id=common-configuration 300## Common Configuration :id=common-configuration
233 301
diff --git a/docs/feature_st7565.md b/docs/feature_st7565.md
new file mode 100644
index 000000000..7db0f9ac4
--- /dev/null
+++ b/docs/feature_st7565.md
@@ -0,0 +1,270 @@
1# ST7565 LCD Driver
2
3## Supported Hardware
4
5LCD modules using ST7565 driver IC, communicating over SPI.
6
7|Module |IC |Size |Notes |
8|------------------------------|-------|------|----------------------------------------------------------|
9|Newhaven Display NHD-C12832A1Z|ST7565R|128x32|Used by Ergodox Infinity; primary consumer of this feature|
10|Zolentech ZLE12864B |ST7565P|128x64|Requires contrast adjustment |
11
12## Usage
13
14To enable the feature, there are three steps. First, when compiling your keyboard, you'll need to add the following to your `rules.mk`:
15
16```make
17ST7565_ENABLE = yes
18```
19
20Then in your `keymap.c` file, implement the ST7565 task call. This example assumes your keymap has three layers named `_QWERTY`, `_FN` and `_ADJ`:
21
22```c
23#ifdef ST7565_ENABLE
24void st7565_task_user(void) {
25 // Host Keyboard Layer Status
26 st7565_write_P(PSTR("Layer: "), false);
27
28 switch (get_highest_layer(layer_state)) {
29 case _QWERTY:
30 st7565_write_P(PSTR("Default\n"), false);
31 break;
32 case _FN:
33 st7565_write_P(PSTR("FN\n"), false);
34 break;
35 case _ADJ:
36 st7565_write_P(PSTR("ADJ\n"), false);
37 break;
38 default:
39 // Or use the write_ln shortcut over adding '\n' to the end of your string
40 st7565_write_ln_P(PSTR("Undefined"), false);
41 }
42
43 // Host Keyboard LED Status
44 led_t led_state = host_keyboard_led_state();
45 st7565_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false);
46 st7565_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false);
47 st7565_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
48}
49#endif
50```
51
52## Logo Example
53
54In the default font, certain ranges of characters are reserved for a QMK logo. To render this logo to the screen, use the following code example:
55
56```c
57static void render_logo(void) {
58 static const char PROGMEM qmk_logo[] = {
59 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
60 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
61 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
62 };
63
64 st7565_write_P(qmk_logo, false);
65}
66```
67
68## Buffer Read Example
69For some purposes, you may need to read the current state of the display buffer. The `st7565_read_raw` function can be used to safely read bytes from the buffer.
70
71In this example, calling `fade_display` in the `st7565_task_user` function will slowly fade away whatever is on the screen by turning random pixels off over time.
72```c
73//Setup some mask which can be or'd with bytes to turn off pixels
74const uint8_t single_bit_masks[8] = {127, 191, 223, 239, 247, 251, 253, 254};
75
76static void fade_display(void) {
77 //Define the reader structure
78 display_buffer_reader_t reader;
79 uint8_t buff_char;
80 if (random() % 30 == 0) {
81 srand(timer_read());
82 // Fetch a pointer for the buffer byte at index 0. The return structure
83 // will have the pointer and the number of bytes remaining from this
84 // index position if we want to perform a sequential read by
85 // incrementing the buffer pointer
86 reader = st7565_read_raw(0);
87 //Loop over the remaining buffer and erase pixels as we go
88 for (uint16_t i = 0; i < reader.remaining_element_count; i++) {
89 //Get the actual byte in the buffer by dereferencing the pointer
90 buff_char = *reader.current_element;
91 if (buff_char != 0) {
92 st7565_write_raw_byte(buff_char & single_bit_masks[rand() % 8], i);
93 }
94 //increment the pointer to fetch a new byte during the next loop
95 reader.current_element++;
96 }
97 }
98}
99```
100
101## Other Examples
102
103In split keyboards, it is very common to have two displays that each render different content and are oriented or flipped differently. You can do this by switching which content to render by using the return value from `is_keyboard_master()` or `is_keyboard_left()` found in `split_util.h`, e.g:
104
105```c
106#ifdef ST7565_ENABLE
107display_rotation_t st7565_init_user(display_rotation_t rotation) {
108 if (!is_keyboard_master()) {
109 return DISPLAY_ROTATION_180; // flips the display 180 degrees if offhand
110 }
111
112 return rotation;
113}
114
115void st7565_task_user(void) {
116 if (is_keyboard_master()) {
117 render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
118 } else {
119 render_logo(); // Renders a static logo
120 }
121}
122#endif
123```
124
125## Basic Configuration
126
127|Define |Default |Description |
128|------------------------|--------------|-----------------------------------------------------------------------------------------------------|
129|`ST7565_A0_PIN` |*Not defined* |(Required) The GPIO connected to the display's A0 (data/command) pin |
130|`ST7565_RST_PIN` |*Not defined* |(Required) The GPIO connected to the display's reset pin |
131|`ST7565_SS_PIN` |*Not defined* |(Required) The GPIO connected to the display's slave select pin |
132|`ST7565_SPI_CLK_DIVISOR`|`4` |The SPI clock divisor to use |
133|`ST7565_FONT_H` |`"glcdfont.c"`|The font code file to use for custom fonts |
134|`ST7565_FONT_START` |`0` |The starting character index for custom fonts |
135|`ST7565_FONT_END` |`223` |The ending character index for custom fonts |
136|`ST7565_FONT_WIDTH` |`6` |The font width |
137|`ST7565_FONT_HEIGHT` |`8` |The font height (untested) |
138|`ST7565_TIMEOUT` |`60000` |Turns off the screen after 60000ms of keyboard inactivity. Helps reduce burn-in. Set to 0 to disable.|
139|`ST7565_COLUMN_OFFSET` |`0` |Shift output to the right this many pixels. |
140|`ST7565_CONTRAST` |`32` |The default contrast level of the display, from 0 to 255. |
141|`ST7565_UPDATE_INTERVAL`|`0` |Set the time interval for updating the display in ms. This will improve the matrix scan rate. |
142
143## Custom sized displays
144
145The default display size for this feature is 128x32 and all necessary defines are precalculated with that in mind.
146
147|Define |Default |Description |
148|-----------------------|----------|-----------------------------------------------------------------------------------------------------------|
149|`ST7565_DISPLAY_WIDTH` |`128` |The width of the display. |
150|`ST7565_DISPLAY_HEIGHT`|`32` |The height of the display. |
151|`ST7565_MATRIX_SIZE` |`512` |The local buffer size to allocate.<br>`(ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH)`. |
152|`ST7565_BLOCK_TYPE` |`uint16_t`|The unsigned integer type to use for dirty rendering. |
153|`ST7565_BLOCK_COUNT` |`16` |The number of blocks the display is divided into for dirty rendering.<br>`(sizeof(ST7565_BLOCK_TYPE) * 8)`.|
154|`ST7565_BLOCK_SIZE` |`32` |The size of each block for dirty rendering<br>`(ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT)`. |
155
156## API
157
158```c
159// Rotation enum values are flags
160typedef enum {
161 DISPLAY_ROTATION_0,
162 DISPLAY_ROTATION_180
163} display_rotation_t;
164
165// Initialize the display, rotating the rendered output based on the define passed in.
166// Returns true if the was initialized successfully
167bool st7565_init(display_rotation_t rotation);
168
169// Called at the start of st7565_init, weak function overridable by the user
170// rotation - the value passed into st7565_init
171// Return new display_rotation_t if you want to override default rotation
172display_rotation_t st7565_init_user(display_rotation_t rotation);
173
174// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering
175void st7565_clear(void);
176
177// Renders the dirty chunks of the buffer to display
178void st7565_render(void);
179
180// Moves cursor to character position indicated by column and line, wraps if out of bounds
181// Max column denoted by 'st7565_max_chars()' and max lines by 'st7565_max_lines()' functions
182void st7565_set_cursor(uint8_t col, uint8_t line);
183
184// Advances the cursor to the next page, writing ' ' if true
185// Wraps to the begining when out of bounds
186void st7565_advance_page(bool clearPageRemainder);
187
188// Moves the cursor forward 1 character length
189// Advance page if there is not enough room for the next character
190// Wraps to the begining when out of bounds
191void st7565_advance_char(void);
192
193// Writes a single character to the buffer at current cursor position
194// Advances the cursor while writing, inverts the pixels if true
195// Main handler that writes character data to the display buffer
196void st7565_write_char(const char data, bool invert);
197
198// Writes a string to the buffer at current cursor position
199// Advances the cursor while writing, inverts the pixels if true
200void st7565_write(const char *data, bool invert);
201
202// Writes a string to the buffer at current cursor position
203// Advances the cursor while writing, inverts the pixels if true
204// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
205void st7565_write_ln(const char *data, bool invert);
206
207// Pans the buffer to the right (or left by passing true) by moving contents of the buffer
208// Useful for moving the screen in preparation for new drawing
209void st7565_pan(bool left);
210
211// Returns a pointer to the requested start index in the buffer plus remaining
212// buffer length as struct
213display_buffer_reader_t st7565_read_raw(uint16_t start_index);
214
215// Writes a string to the buffer at current cursor position
216void st7565_write_raw(const char *data, uint16_t size);
217
218// Writes a single byte into the buffer at the specified index
219void st7565_write_raw_byte(const char data, uint16_t index);
220
221// Sets a specific pixel on or off
222// Coordinates start at top-left and go right and down for positive x and y
223void st7565_write_pixel(uint8_t x, uint8_t y, bool on);
224
225// Writes a PROGMEM string to the buffer at current cursor position
226// Advances the cursor while writing, inverts the pixels if true
227// Remapped to call 'void st7565_write(const char *data, bool invert);' on ARM
228void st7565_write_P(const char *data, bool invert);
229
230// Writes a PROGMEM string to the buffer at current cursor position
231// Advances the cursor while writing, inverts the pixels if true
232// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
233// Remapped to call 'void st7565_write_ln(const char *data, bool invert);' on ARM
234void st7565_write_ln_P(const char *data, bool invert);
235
236// Writes a PROGMEM string to the buffer at current cursor position
237void st7565_write_raw_P(const char *data, uint16_t size);
238
239// Can be used to manually turn on the screen if it is off
240// Returns true if the screen was on or turns on
241bool st7565_on(void);
242
243// Called when st7565_on() turns on the screen, weak function overridable by the user
244// Not called if the screen is already on
245void st7565_on_user(void);
246
247// Can be used to manually turn off the screen if it is on
248// Returns true if the screen was off or turns off
249bool st7565_off(void);
250
251// Called when st7565_off() turns off the screen, weak function overridable by the user
252// Not called if the screen is already off
253void st7565_off_user(void);
254
255// Returns true if the screen is currently on, false if it is
256// not
257bool st7565_is_on(void);
258
259// Basically it's st7565_render, but with timeout management and st7565_task_user calling!
260void st7565_task(void);
261
262// Called at the start of st7565_task, weak function overridable by the user
263void st7565_task_user(void);
264
265// Returns the maximum number of characters that will fit on a line
266uint8_t st7565_max_chars(void);
267
268// Returns the maximum number of lines that will fit on the display
269uint8_t st7565_max_lines(void);
270```
diff --git a/drivers/awinic/aw20216.c b/drivers/awinic/aw20216.c
new file mode 100644
index 000000000..236c42a3c
--- /dev/null
+++ b/drivers/awinic/aw20216.c
@@ -0,0 +1,166 @@
1/* Copyright 2021 Jasper Chan
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "aw20216.h"
18#include "spi_master.h"
19
20/* The AW20216 appears to be somewhat similar to the IS31FL743, although quite
21 * a few things are different, such as the command byte format and page ordering.
22 * The LED addresses start from 0x00 instead of 0x01.
23 */
24#define AWINIC_ID 0b1010 << 4
25
26#define AW_PAGE_FUNCTION 0x00 << 1 // PG0, Function registers
27#define AW_PAGE_PWM 0x01 << 1 // PG1, LED PWM control
28#define AW_PAGE_SCALING 0x02 << 1 // PG2, LED current scaling control
29#define AW_PAGE_PATCHOICE 0x03 << 1 // PG3, Pattern choice?
30#define AW_PAGE_PWMSCALING 0x04 << 1 // PG4, LED PWM + Scaling control?
31
32#define AW_WRITE 0
33#define AW_READ 1
34
35#define AW_REG_CONFIGURATION 0x00 // PG0
36#define AW_REG_GLOBALCURRENT 0x01 // PG0
37
38// Default value of AW_REG_CONFIGURATION
39// D7:D4 = 1011, SWSEL (SW1~SW12 active)
40// D3 = 0?, reserved (apparently this should be 1 but it doesn't seem to matter)
41// D2:D1 = 00, OSDE (open/short detection enable)
42// D0 = 0, CHIPEN (write 1 to enable LEDs when hardware enable pulled high)
43#define AW_CONFIG_DEFAULT 0b10110000
44#define AW_CHIPEN 1
45
46#ifndef AW_SCALING_MAX
47# define AW_SCALING_MAX 150
48#endif
49
50#ifndef AW_GLOBAL_CURRENT_MAX
51# define AW_GLOBAL_CURRENT_MAX 150
52#endif
53
54#ifndef DRIVER_1_CS
55# define DRIVER_1_CS B13
56#endif
57
58#ifndef DRIVER_1_EN
59# define DRIVER_1_EN C13
60#endif
61
62uint8_t g_spi_transfer_buffer[20] = {0};
63aw_led g_pwm_buffer[DRIVER_LED_TOTAL];
64bool g_pwm_buffer_update_required[DRIVER_LED_TOTAL];
65
66bool AW20216_write_register(pin_t slave_pin, uint8_t page, uint8_t reg, uint8_t data) {
67 // Do we need to call spi_stop() if this fails?
68 if (!spi_start(slave_pin, false, 0, 16)) {
69 return false;
70 }
71
72 g_spi_transfer_buffer[0] = (AWINIC_ID | page | AW_WRITE);
73 g_spi_transfer_buffer[1] = reg;
74 g_spi_transfer_buffer[2] = data;
75
76 if (spi_transmit(g_spi_transfer_buffer, 3) != SPI_STATUS_SUCCESS) {
77 spi_stop();
78 return false;
79 }
80 spi_stop();
81 return true;
82}
83
84bool AW20216_init_scaling(void) {
85 // Set constant current to the max, control brightness with PWM
86 aw_led led;
87 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
88 led = g_aw_leds[i];
89 if (led.driver == 0) {
90 AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.r, AW_SCALING_MAX);
91 AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.g, AW_SCALING_MAX);
92 AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.b, AW_SCALING_MAX);
93 }
94#ifdef DRIVER_2_CS
95 else if (led.driver == 1) {
96 AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.r, AW_SCALING_MAX);
97 AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.g, AW_SCALING_MAX);
98 AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.b, AW_SCALING_MAX);
99 }
100#endif
101 }
102 return true;
103}
104
105bool AW20216_soft_enable(void) {
106 AW20216_write_register(DRIVER_1_CS, AW_PAGE_FUNCTION, AW_REG_CONFIGURATION, AW_CONFIG_DEFAULT | AW_CHIPEN);
107#ifdef DRIVER_2_CS
108 AW20216_write_register(DRIVER_2_CS, AW_PAGE_FUNCTION, AW_REG_CONFIGURATION, AW_CONFIG_DEFAULT | AW_CHIPEN);
109#endif
110 return true;
111}
112
113void AW20216_update_pwm(int index, uint8_t red, uint8_t green, uint8_t blue) {
114 aw_led led = g_aw_leds[index];
115 if (led.driver == 0) {
116 AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.r, red);
117 AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.g, green);
118 AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.b, blue);
119 }
120#ifdef DRIVER_2_CS
121 else if (led.driver == 1) {
122 AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.r, red);
123 AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.g, green);
124 AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.b, blue);
125 }
126#endif
127 return;
128}
129
130void AW20216_init(void) {
131 // All LEDs should start with all scaling and PWM registers as off
132 setPinOutput(DRIVER_1_EN);
133 writePinHigh(DRIVER_1_EN);
134 AW20216_write_register(DRIVER_1_CS, AW_PAGE_FUNCTION, AW_REG_GLOBALCURRENT, AW_GLOBAL_CURRENT_MAX);
135#ifdef DRIVER_2_EN
136 setPinOutput(DRIVER_2_EN);
137 writePinHigh(DRIVER_2_EN);
138 AW20216_write_register(DRIVER_2_CS, AW_PAGE_FUNCTION, AW_REG_GLOBALCURRENT, AW_GLOBAL_CURRENT_MAX);
139#endif
140 AW20216_init_scaling();
141 AW20216_soft_enable();
142 return;
143}
144
145void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
146 g_pwm_buffer[index].r = red;
147 g_pwm_buffer[index].g = green;
148 g_pwm_buffer[index].b = blue;
149 g_pwm_buffer_update_required[index] = true;
150 return;
151}
152void AW20216_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
153 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
154 AW20216_set_color(i, red, green, blue);
155 }
156 return;
157}
158void AW20216_update_pwm_buffers(void) {
159 for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
160 if (g_pwm_buffer_update_required[i]) {
161 AW20216_update_pwm(i, g_pwm_buffer[i].r, g_pwm_buffer[i].g, g_pwm_buffer[i].b);
162 g_pwm_buffer_update_required[i] = false;
163 }
164 }
165 return;
166}
diff --git a/drivers/awinic/aw20216.h b/drivers/awinic/aw20216.h
new file mode 100644
index 000000000..9c6865cc8
--- /dev/null
+++ b/drivers/awinic/aw20216.h
@@ -0,0 +1,251 @@
1/* Copyright 2021 Jasper Chan (Gigahawk)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include <stdint.h>
20#include <stdbool.h>
21
22typedef struct aw_led {
23 uint8_t driver : 2;
24 uint8_t r;
25 uint8_t g;
26 uint8_t b;
27} aw_led;
28
29extern const aw_led g_aw_leds[DRIVER_LED_TOTAL];
30
31void AW20216_init(void);
32void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
33void AW20216_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
34void AW20216_update_pwm_buffers(void);
35
36#define CS1_SW1 0x00
37#define CS2_SW1 0x01
38#define CS3_SW1 0x02
39#define CS4_SW1 0x03
40#define CS5_SW1 0x04
41#define CS6_SW1 0x05
42#define CS7_SW1 0x06
43#define CS8_SW1 0x07
44#define CS9_SW1 0x08
45#define CS10_SW1 0x09
46#define CS11_SW1 0x0A
47#define CS12_SW1 0x0B
48#define CS13_SW1 0x0C
49#define CS14_SW1 0x0D
50#define CS15_SW1 0x0E
51#define CS16_SW1 0x0F
52#define CS17_SW1 0x10
53#define CS18_SW1 0x11
54#define CS1_SW2 0x12
55#define CS2_SW2 0x13
56#define CS3_SW2 0x14
57#define CS4_SW2 0x15
58#define CS5_SW2 0x16
59#define CS6_SW2 0x17
60#define CS7_SW2 0x18
61#define CS8_SW2 0x19
62#define CS9_SW2 0x1A
63#define CS10_SW2 0x1B
64#define CS11_SW2 0x1C
65#define CS12_SW2 0x1D
66#define CS13_SW2 0x1E
67#define CS14_SW2 0x1F
68#define CS15_SW2 0x20
69#define CS16_SW2 0x21
70#define CS17_SW2 0x22
71#define CS18_SW2 0x23
72#define CS1_SW3 0x24
73#define CS2_SW3 0x25
74#define CS3_SW3 0x26
75#define CS4_SW3 0x27
76#define CS5_SW3 0x28
77#define CS6_SW3 0x29
78#define CS7_SW3 0x2A
79#define CS8_SW3 0x2B
80#define CS9_SW3 0x2C
81#define CS10_SW3 0x2D
82#define CS11_SW3 0x2E
83#define CS12_SW3 0x2F
84#define CS13_SW3 0x30
85#define CS14_SW3 0x31
86#define CS15_SW3 0x32
87#define CS16_SW3 0x33
88#define CS17_SW3 0x34
89#define CS18_SW3 0x35
90#define CS1_SW4 0x36
91#define CS2_SW4 0x37
92#define CS3_SW4 0x38
93#define CS4_SW4 0x39
94#define CS5_SW4 0x3A
95#define CS6_SW4 0x3B
96#define CS7_SW4 0x3C
97#define CS8_SW4 0x3D
98#define CS9_SW4 0x3E
99#define CS10_SW4 0x3F
100#define CS11_SW4 0x40
101#define CS12_SW4 0x41
102#define CS13_SW4 0x42
103#define CS14_SW4 0x43
104#define CS15_SW4 0x44
105#define CS16_SW4 0x45
106#define CS17_SW4 0x46
107#define CS18_SW4 0x47
108#define CS1_SW5 0x48
109#define CS2_SW5 0x49
110#define CS3_SW5 0x4A
111#define CS4_SW5 0x4B
112#define CS5_SW5 0x4C
113#define CS6_SW5 0x4D
114#define CS7_SW5 0x4E
115#define CS8_SW5 0x4F
116#define CS9_SW5 0x50
117#define CS10_SW5 0x51
118#define CS11_SW5 0x52
119#define CS12_SW5 0x53
120#define CS13_SW5 0x54
121#define CS14_SW5 0x55
122#define CS15_SW5 0x56
123#define CS16_SW5 0x57
124#define CS17_SW5 0x58
125#define CS18_SW5 0x59
126#define CS1_SW6 0x5A
127#define CS2_SW6 0x5B
128#define CS3_SW6 0x5C
129#define CS4_SW6 0x5D
130#define CS5_SW6 0x5E
131#define CS6_SW6 0x5F
132#define CS7_SW6 0x60
133#define CS8_SW6 0x61
134#define CS9_SW6 0x62
135#define CS10_SW6 0x63
136#define CS11_SW6 0x64
137#define CS12_SW6 0x65
138#define CS13_SW6 0x66
139#define CS14_SW6 0x67
140#define CS15_SW6 0x68
141#define CS16_SW6 0x69
142#define CS17_SW6 0x6A
143#define CS18_SW6 0x6B
144#define CS1_SW7 0x6C
145#define CS2_SW7 0x6D
146#define CS3_SW7 0x6E
147#define CS4_SW7 0x6F
148#define CS5_SW7 0x70
149#define CS6_SW7 0x71
150#define CS7_SW7 0x72
151#define CS8_SW7 0x73
152#define CS9_SW7 0x74
153#define CS10_SW7 0x75
154#define CS11_SW7 0x76
155#define CS12_SW7 0x77
156#define CS13_SW7 0x78
157#define CS14_SW7 0x79
158#define CS15_SW7 0x7A
159#define CS16_SW7 0x7B
160#define CS17_SW7 0x7C
161#define CS18_SW7 0x7D
162#define CS1_SW8 0x7E
163#define CS2_SW8 0x7F
164#define CS3_SW8 0x80
165#define CS4_SW8 0x81
166#define CS5_SW8 0x82
167#define CS6_SW8 0x83
168#define CS7_SW8 0x84
169#define CS8_SW8 0x85
170#define CS9_SW8 0x86
171#define CS10_SW8 0x87
172#define CS11_SW8 0x88
173#define CS12_SW8 0x89
174#define CS13_SW8 0x8A
175#define CS14_SW8 0x8B
176#define CS15_SW8 0x8C
177#define CS16_SW8 0x8D
178#define CS17_SW8 0x8E
179#define CS18_SW8 0x8F
180#define CS1_SW9 0x90
181#define CS2_SW9 0x91
182#define CS3_SW9 0x92
183#define CS4_SW9 0x93
184#define CS5_SW9 0x94
185#define CS6_SW9 0x95
186#define CS7_SW9 0x96
187#define CS8_SW9 0x97
188#define CS9_SW9 0x98
189#define CS10_SW9 0x99
190#define CS11_SW9 0x9A
191#define CS12_SW9 0x9B
192#define CS13_SW9 0x9C
193#define CS14_SW9 0x9D
194#define CS15_SW9 0x9E
195#define CS16_SW9 0x9F
196#define CS17_SW9 0xA0
197#define CS18_SW9 0xA1
198#define CS1_SW10 0xA2
199#define CS2_SW10 0xA3
200#define CS3_SW10 0xA4
201#define CS4_SW10 0xA5
202#define CS5_SW10 0xA6
203#define CS6_SW10 0xA7
204#define CS7_SW10 0xA8
205#define CS8_SW10 0xA9
206#define CS9_SW10 0xAA
207#define CS10_SW10 0xAB
208#define CS11_SW10 0xAC
209#define CS12_SW10 0xAD
210#define CS13_SW10 0xAE
211#define CS14_SW10 0xAF
212#define CS15_SW10 0xB0
213#define CS16_SW10 0xB1
214#define CS17_SW10 0xB2
215#define CS18_SW10 0xB3
216#define CS1_SW11 0xB4
217#define CS2_SW11 0xB5
218#define CS3_SW11 0xB6
219#define CS4_SW11 0xB7
220#define CS5_SW11 0xB8
221#define CS6_SW11 0xB9
222#define CS7_SW11 0xBA
223#define CS8_SW11 0xBB
224#define CS9_SW11 0xBC
225#define CS10_SW11 0xBD
226#define CS11_SW11 0xBE
227#define CS12_SW11 0xBF
228#define CS13_SW11 0xC0
229#define CS14_SW11 0xC1
230#define CS15_SW11 0xC2
231#define CS16_SW11 0xC3
232#define CS17_SW11 0xC4
233#define CS18_SW11 0xC5
234#define CS1_SW12 0xC6
235#define CS2_SW12 0xC7
236#define CS3_SW12 0xC8
237#define CS4_SW12 0xC9
238#define CS5_SW12 0xCA
239#define CS6_SW12 0xCB
240#define CS7_SW12 0xCC
241#define CS8_SW12 0xCD
242#define CS9_SW12 0xCE
243#define CS10_SW12 0xCF
244#define CS11_SW12 0xD0
245#define CS12_SW12 0xD1
246#define CS13_SW12 0xD2
247#define CS14_SW12 0xD3
248#define CS15_SW12 0xD4
249#define CS16_SW12 0xD5
250#define CS17_SW12 0xD6
251#define CS18_SW12 0xD7
diff --git a/drivers/chibios/spi_master.c b/drivers/chibios/spi_master.c
index 4852a6eba..28ddcbb2b 100644
--- a/drivers/chibios/spi_master.c
+++ b/drivers/chibios/spi_master.c
@@ -18,8 +18,13 @@
18 18
19#include "timer.h" 19#include "timer.h"
20 20
21static pin_t currentSlavePin = NO_PIN; 21static pin_t currentSlavePin = NO_PIN;
22static SPIConfig spiConfig = {false, NULL, 0, 0, 0, 0}; 22
23#if defined(K20x) || defined(KL2x)
24static SPIConfig spiConfig = {NULL, 0, 0, 0};
25#else
26static SPIConfig spiConfig = {false, NULL, 0, 0, 0, 0};
27#endif
23 28
24__attribute__((weak)) void spi_init(void) { 29__attribute__((weak)) void spi_init(void) {
25 static bool is_initialised = false; 30 static bool is_initialised = false;
@@ -27,15 +32,15 @@ __attribute__((weak)) void spi_init(void) {
27 is_initialised = true; 32 is_initialised = true;
28 33
29 // Try releasing special pins for a short time 34 // Try releasing special pins for a short time
30 palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_INPUT); 35 setPinInput(SPI_SCK_PIN);
31 palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_INPUT); 36 setPinInput(SPI_MOSI_PIN);
32 palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_INPUT); 37 setPinInput(SPI_MISO_PIN);
33 38
34 chThdSleepMilliseconds(10); 39 chThdSleepMilliseconds(10);
35#if defined(USE_GPIOV1) 40#if defined(USE_GPIOV1)
36 palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); 41 palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_PAL_MODE);
37 palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); 42 palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_PAL_MODE);
38 palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); 43 palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_PAL_MODE);
39#else 44#else
40 palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 45 palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
41 palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 46 palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
@@ -58,6 +63,54 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
58 return false; 63 return false;
59 } 64 }
60 65
66#if defined(K20x) || defined(KL2x)
67 spiConfig.tar0 = SPIx_CTARn_FMSZ(7) | SPIx_CTARn_ASC(1);
68
69 if (lsbFirst) {
70 spiConfig.tar0 |= SPIx_CTARn_LSBFE;
71 }
72
73 switch (mode) {
74 case 0:
75 break;
76 case 1:
77 spiConfig.tar0 |= SPIx_CTARn_CPHA;
78 break;
79 case 2:
80 spiConfig.tar0 |= SPIx_CTARn_CPOL;
81 break;
82 case 3:
83 spiConfig.tar0 |= SPIx_CTARn_CPHA | SPIx_CTARn_CPOL;
84 break;
85 }
86
87 switch (roundedDivisor) {
88 case 2:
89 spiConfig.tar0 |= SPIx_CTARn_BR(0);
90 break;
91 case 4:
92 spiConfig.tar0 |= SPIx_CTARn_BR(1);
93 break;
94 case 8:
95 spiConfig.tar0 |= SPIx_CTARn_BR(3);
96 break;
97 case 16:
98 spiConfig.tar0 |= SPIx_CTARn_BR(4);
99 break;
100 case 32:
101 spiConfig.tar0 |= SPIx_CTARn_BR(5);
102 break;
103 case 64:
104 spiConfig.tar0 |= SPIx_CTARn_BR(6);
105 break;
106 case 128:
107 spiConfig.tar0 |= SPIx_CTARn_BR(7);
108 break;
109 case 256:
110 spiConfig.tar0 |= SPIx_CTARn_BR(8);
111 break;
112 }
113#else
61 spiConfig.cr1 = 0; 114 spiConfig.cr1 = 0;
62 115
63 if (lsbFirst) { 116 if (lsbFirst) {
@@ -103,6 +156,7 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
103 spiConfig.cr1 |= SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0; 156 spiConfig.cr1 |= SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0;
104 break; 157 break;
105 } 158 }
159#endif
106 160
107 currentSlavePin = slavePin; 161 currentSlavePin = slavePin;
108 spiConfig.ssport = PAL_PORT(slavePin); 162 spiConfig.ssport = PAL_PORT(slavePin);
diff --git a/drivers/chibios/spi_master.h b/drivers/chibios/spi_master.h
index e93580e31..b5a6ef143 100644
--- a/drivers/chibios/spi_master.h
+++ b/drivers/chibios/spi_master.h
@@ -21,6 +21,7 @@
21#include <stdbool.h> 21#include <stdbool.h>
22 22
23#include "gpio.h" 23#include "gpio.h"
24#include "chibios_config.h"
24 25
25#ifndef SPI_DRIVER 26#ifndef SPI_DRIVER
26# define SPI_DRIVER SPID2 27# define SPI_DRIVER SPID2
@@ -31,7 +32,11 @@
31#endif 32#endif
32 33
33#ifndef SPI_SCK_PAL_MODE 34#ifndef SPI_SCK_PAL_MODE
34# define SPI_SCK_PAL_MODE 5 35# if defined(USE_GPIOV1)
36# define SPI_SCK_PAL_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL
37# else
38# define SPI_SCK_PAL_MODE 5
39# endif
35#endif 40#endif
36 41
37#ifndef SPI_MOSI_PIN 42#ifndef SPI_MOSI_PIN
@@ -39,7 +44,11 @@
39#endif 44#endif
40 45
41#ifndef SPI_MOSI_PAL_MODE 46#ifndef SPI_MOSI_PAL_MODE
42# define SPI_MOSI_PAL_MODE 5 47# if defined(USE_GPIOV1)
48# define SPI_MOSI_PAL_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL
49# else
50# define SPI_MOSI_PAL_MODE 5
51# endif
43#endif 52#endif
44 53
45#ifndef SPI_MISO_PIN 54#ifndef SPI_MISO_PIN
@@ -47,7 +56,11 @@
47#endif 56#endif
48 57
49#ifndef SPI_MISO_PAL_MODE 58#ifndef SPI_MISO_PAL_MODE
50# define SPI_MISO_PAL_MODE 5 59# if defined(USE_GPIOV1)
60# define SPI_MISO_PAL_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL
61# else
62# define SPI_MISO_PAL_MODE 5
63# endif
51#endif 64#endif
52 65
53typedef int16_t spi_status_t; 66typedef int16_t spi_status_t;
diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c
new file mode 100644
index 000000000..4b4891ce7
--- /dev/null
+++ b/drivers/lcd/st7565.c
@@ -0,0 +1,479 @@
1/*
2Copyright 2021
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "st7565.h"
19
20#include <string.h>
21
22#include "keyboard.h"
23#include "progmem.h"
24#include "timer.h"
25#include "wait.h"
26
27#include ST7565_FONT_H
28
29// Fundamental Commands
30#define CONTRAST 0x81
31#define DISPLAY_ALL_ON 0xA5
32#define DISPLAY_ALL_ON_RESUME 0xA4
33#define NORMAL_DISPLAY 0xA6
34#define DISPLAY_ON 0xAF
35#define DISPLAY_OFF 0xAE
36#define NOP 0xE3
37
38// Addressing Setting Commands
39#define PAM_SETCOLUMN_LSB 0x00
40#define PAM_SETCOLUMN_MSB 0x10
41#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
42
43// Hardware Configuration Commands
44#define DISPLAY_START_LINE 0x40
45#define SEGMENT_REMAP 0xA0
46#define SEGMENT_REMAP_INV 0xA1
47#define COM_SCAN_INC 0xC0
48#define COM_SCAN_DEC 0xC8
49#define LCD_BIAS_7 0xA3
50#define LCD_BIAS_9 0xA2
51#define RESISTOR_RATIO 0x20
52#define POWER_CONTROL 0x28
53
54// Misc defines
55#ifndef ST7565_BLOCK_COUNT
56# define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8)
57#endif
58#ifndef ST7565_BLOCK_SIZE
59# define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT)
60#endif
61
62#define ST7565_ALL_BLOCKS_MASK (((((ST7565_BLOCK_TYPE)1 << (ST7565_BLOCK_COUNT - 1)) - 1) << 1) | 1)
63
64#define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
65
66// Display buffer's is the same as the display memory layout
67// this is so we don't end up with rounding errors with
68// parts of the display unusable or don't get cleared correctly
69// and also allows for drawing & inverting
70uint8_t st7565_buffer[ST7565_MATRIX_SIZE];
71uint8_t * st7565_cursor;
72ST7565_BLOCK_TYPE st7565_dirty = 0;
73bool st7565_initialized = false;
74bool st7565_active = false;
75display_rotation_t st7565_rotation = DISPLAY_ROTATION_0;
76#if ST7565_TIMEOUT > 0
77uint32_t st7565_timeout;
78#endif
79#if ST7565_UPDATE_INTERVAL > 0
80uint16_t st7565_update_timeout;
81#endif
82
83// Flips the rendering bits for a character at the current cursor position
84static void InvertCharacter(uint8_t *cursor) {
85 const uint8_t *end = cursor + ST7565_FONT_WIDTH;
86 while (cursor < end) {
87 *cursor = ~(*cursor);
88 cursor++;
89 }
90}
91
92bool st7565_init(display_rotation_t rotation) {
93 setPinOutput(ST7565_A0_PIN);
94 writePinHigh(ST7565_A0_PIN);
95 setPinOutput(ST7565_RST_PIN);
96 writePinHigh(ST7565_RST_PIN);
97
98 st7565_rotation = st7565_init_user(rotation);
99
100 spi_init();
101 spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR);
102
103 st7565_reset();
104
105 st7565_send_cmd(LCD_BIAS_7);
106 if (!HAS_FLAGS(st7565_rotation, DISPLAY_ROTATION_180)) {
107 st7565_send_cmd(SEGMENT_REMAP);
108 st7565_send_cmd(COM_SCAN_DEC);
109 } else {
110 st7565_send_cmd(SEGMENT_REMAP_INV);
111 st7565_send_cmd(COM_SCAN_INC);
112 }
113 st7565_send_cmd(DISPLAY_START_LINE | 0x00);
114 st7565_send_cmd(CONTRAST);
115 st7565_send_cmd(ST7565_CONTRAST);
116 st7565_send_cmd(RESISTOR_RATIO | 0x01);
117 st7565_send_cmd(POWER_CONTROL | 0x04);
118 wait_ms(50);
119 st7565_send_cmd(POWER_CONTROL | 0x06);
120 wait_ms(50);
121 st7565_send_cmd(POWER_CONTROL | 0x07);
122 wait_ms(10);
123 st7565_send_cmd(DISPLAY_ON);
124 st7565_send_cmd(DISPLAY_ALL_ON_RESUME);
125 st7565_send_cmd(NORMAL_DISPLAY);
126
127 spi_stop();
128
129#if ST7565_TIMEOUT > 0
130 st7565_timeout = timer_read32() + ST7565_TIMEOUT;
131#endif
132
133 st7565_clear();
134 st7565_initialized = true;
135 st7565_active = true;
136 return true;
137}
138
139__attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) { return rotation; }
140
141void st7565_clear(void) {
142 memset(st7565_buffer, 0, sizeof(st7565_buffer));
143 st7565_cursor = &st7565_buffer[0];
144 st7565_dirty = ST7565_ALL_BLOCKS_MASK;
145}
146
147uint8_t crot(uint8_t a, int8_t n) {
148 const uint8_t mask = 0x7;
149 n &= mask;
150 return a << n | a >> (-n & mask);
151}
152
153void st7565_render(void) {
154 if (!st7565_initialized) {
155 return;
156 }
157
158 // Do we have work to do?
159 st7565_dirty &= ST7565_ALL_BLOCKS_MASK;
160 if (!st7565_dirty) {
161 return;
162 }
163
164 // Find first dirty block
165 uint8_t update_start = 0;
166 while (!(st7565_dirty & ((ST7565_BLOCK_TYPE)1 << update_start))) {
167 ++update_start;
168 }
169
170 // Calculate commands to set memory addressing bounds.
171 uint8_t start_page = ST7565_BLOCK_SIZE * update_start / ST7565_DISPLAY_WIDTH;
172 uint8_t start_column = ST7565_BLOCK_SIZE * update_start % ST7565_DISPLAY_WIDTH;
173 // IC has 132 segment drivers, for panels with less width we need to offset the starting column
174 if (HAS_FLAGS(st7565_rotation, DISPLAY_ROTATION_180)) {
175 start_column += (132 - ST7565_DISPLAY_WIDTH);
176 }
177
178 spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR);
179
180 st7565_send_cmd(PAM_PAGE_ADDR | start_page);
181 st7565_send_cmd(PAM_SETCOLUMN_LSB | ((ST7565_COLUMN_OFFSET + start_column) & 0x0f));
182 st7565_send_cmd(PAM_SETCOLUMN_MSB | ((ST7565_COLUMN_OFFSET + start_column) >> 4 & 0x0f));
183
184 st7565_send_data(&st7565_buffer[ST7565_BLOCK_SIZE * update_start], ST7565_BLOCK_SIZE);
185
186 // Turn on display if it is off
187 st7565_on();
188
189 // Clear dirty flag
190 st7565_dirty &= ~((ST7565_BLOCK_TYPE)1 << update_start);
191}
192
193void st7565_set_cursor(uint8_t col, uint8_t line) {
194 uint16_t index = line * ST7565_DISPLAY_WIDTH + col * ST7565_FONT_WIDTH;
195
196 // Out of bounds?
197 if (index >= ST7565_MATRIX_SIZE) {
198 index = 0;
199 }
200
201 st7565_cursor = &st7565_buffer[index];
202}
203
204void st7565_advance_page(bool clearPageRemainder) {
205 uint16_t index = st7565_cursor - &st7565_buffer[0];
206 uint8_t remaining = ST7565_DISPLAY_WIDTH - (index % ST7565_DISPLAY_WIDTH);
207
208 if (clearPageRemainder) {
209 // Remaining Char count
210 remaining = remaining / ST7565_FONT_WIDTH;
211
212 // Write empty character until next line
213 while (remaining--) st7565_write_char(' ', false);
214 } else {
215 // Next page index out of bounds?
216 if (index + remaining >= ST7565_MATRIX_SIZE) {
217 index = 0;
218 remaining = 0;
219 }
220
221 st7565_cursor = &st7565_buffer[index + remaining];
222 }
223}
224
225void st7565_advance_char(void) {
226 uint16_t nextIndex = st7565_cursor - &st7565_buffer[0] + ST7565_FONT_WIDTH;
227 uint8_t remainingSpace = ST7565_DISPLAY_WIDTH - (nextIndex % ST7565_DISPLAY_WIDTH);
228
229 // Do we have enough space on the current line for the next character
230 if (remainingSpace < ST7565_FONT_WIDTH) {
231 nextIndex += remainingSpace;
232 }
233
234 // Did we go out of bounds
235 if (nextIndex >= ST7565_MATRIX_SIZE) {
236 nextIndex = 0;
237 }
238
239 // Update cursor position
240 st7565_cursor = &st7565_buffer[nextIndex];
241}
242
243// Main handler that writes character data to the display buffer
244void st7565_write_char(const char data, bool invert) {
245 // Advance to the next line if newline
246 if (data == '\n') {
247 // Old source wrote ' ' until end of line...
248 st7565_advance_page(true);
249 return;
250 }
251
252 if (data == '\r') {
253 st7565_advance_page(false);
254 return;
255 }
256
257 // copy the current render buffer to check for dirty after
258 static uint8_t st7565_temp_buffer[ST7565_FONT_WIDTH];
259 memcpy(&st7565_temp_buffer, st7565_cursor, ST7565_FONT_WIDTH);
260
261 _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array");
262
263 // set the reder buffer data
264 uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
265 if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) {
266 memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH);
267 } else {
268 const uint8_t *glyph = &font[(cast_data - ST7565_FONT_START) * ST7565_FONT_WIDTH];
269 memcpy_P(st7565_cursor, glyph, ST7565_FONT_WIDTH);
270 }
271
272 // Invert if needed
273 if (invert) {
274 InvertCharacter(st7565_cursor);
275 }
276
277 // Dirty check
278 if (memcmp(&st7565_temp_buffer, st7565_cursor, ST7565_FONT_WIDTH)) {
279 uint16_t index = st7565_cursor - &st7565_buffer[0];
280 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (index / ST7565_BLOCK_SIZE));
281 // Edgecase check if the written data spans the 2 chunks
282 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << ((index + ST7565_FONT_WIDTH - 1) / ST7565_BLOCK_SIZE));
283 }
284
285 // Finally move to the next char
286 st7565_advance_char();
287}
288
289void st7565_write(const char *data, bool invert) {
290 const char *end = data + strlen(data);
291 while (data < end) {
292 st7565_write_char(*data, invert);
293 data++;
294 }
295}
296
297void st7565_write_ln(const char *data, bool invert) {
298 st7565_write(data, invert);
299 st7565_advance_page(true);
300}
301
302void st7565_pan(bool left) {
303 uint16_t i = 0;
304 for (uint16_t y = 0; y < ST7565_DISPLAY_HEIGHT / 8; y++) {
305 if (left) {
306 for (uint16_t x = 0; x < ST7565_DISPLAY_WIDTH - 1; x++) {
307 i = y * ST7565_DISPLAY_WIDTH + x;
308 st7565_buffer[i] = st7565_buffer[i + 1];
309 }
310 } else {
311 for (uint16_t x = ST7565_DISPLAY_WIDTH - 1; x > 0; x--) {
312 i = y * ST7565_DISPLAY_WIDTH + x;
313 st7565_buffer[i] = st7565_buffer[i - 1];
314 }
315 }
316 }
317 st7565_dirty = ST7565_ALL_BLOCKS_MASK;
318}
319
320display_buffer_reader_t st7565_read_raw(uint16_t start_index) {
321 if (start_index > ST7565_MATRIX_SIZE) start_index = ST7565_MATRIX_SIZE;
322 display_buffer_reader_t ret_reader;
323 ret_reader.current_element = &st7565_buffer[start_index];
324 ret_reader.remaining_element_count = ST7565_MATRIX_SIZE - start_index;
325 return ret_reader;
326}
327
328void st7565_write_raw_byte(const char data, uint16_t index) {
329 if (index > ST7565_MATRIX_SIZE) index = ST7565_MATRIX_SIZE;
330 if (st7565_buffer[index] == data) return;
331 st7565_buffer[index] = data;
332 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (index / ST7565_BLOCK_SIZE));
333}
334
335void st7565_write_raw(const char *data, uint16_t size) {
336 uint16_t cursor_start_index = st7565_cursor - &st7565_buffer[0];
337 if ((size + cursor_start_index) > ST7565_MATRIX_SIZE) size = ST7565_MATRIX_SIZE - cursor_start_index;
338 for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) {
339 if (st7565_buffer[i] == data[i]) continue;
340 st7565_buffer[i] = data[i];
341 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE));
342 }
343}
344
345void st7565_write_pixel(uint8_t x, uint8_t y, bool on) {
346 if (x >= ST7565_DISPLAY_WIDTH) {
347 return;
348 }
349 uint16_t index = x + (y / 8) * ST7565_DISPLAY_WIDTH;
350 if (index >= ST7565_MATRIX_SIZE) {
351 return;
352 }
353 uint8_t data = st7565_buffer[index];
354 if (on) {
355 data |= (1 << (y % 8));
356 } else {
357 data &= ~(1 << (y % 8));
358 }
359 if (st7565_buffer[index] != data) {
360 st7565_buffer[index] = data;
361 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (index / ST7565_BLOCK_SIZE));
362 }
363}
364
365#if defined(__AVR__)
366void st7565_write_P(const char *data, bool invert) {
367 uint8_t c = pgm_read_byte(data);
368 while (c != 0) {
369 st7565_write_char(c, invert);
370 c = pgm_read_byte(++data);
371 }
372}
373
374void st7565_write_ln_P(const char *data, bool invert) {
375 st7565_write_P(data, invert);
376 st7565_advance_page(true);
377}
378
379void st7565_write_raw_P(const char *data, uint16_t size) {
380 uint16_t cursor_start_index = st7565_cursor - &st7565_buffer[0];
381 if ((size + cursor_start_index) > ST7565_MATRIX_SIZE) size = ST7565_MATRIX_SIZE - cursor_start_index;
382 for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) {
383 uint8_t c = pgm_read_byte(data++);
384 if (st7565_buffer[i] == c) continue;
385 st7565_buffer[i] = c;
386 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE));
387 }
388}
389#endif // defined(__AVR__)
390
391bool st7565_on(void) {
392 if (!st7565_initialized) {
393 return st7565_active;
394 }
395
396#if ST7565_TIMEOUT > 0
397 st7565_timeout = timer_read32() + ST7565_TIMEOUT;
398#endif
399
400 if (!st7565_active) {
401 spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR);
402 st7565_send_cmd(DISPLAY_ON);
403 spi_stop();
404 st7565_active = true;
405 st7565_on_user();
406 }
407 return st7565_active;
408}
409
410__attribute__((weak)) void st7565_on_user(void) {}
411
412bool st7565_off(void) {
413 if (!st7565_initialized) {
414 return !st7565_active;
415 }
416
417 if (st7565_active) {
418 spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR);
419 st7565_send_cmd(DISPLAY_OFF);
420 spi_stop();
421 st7565_active = false;
422 st7565_off_user();
423 }
424 return !st7565_active;
425}
426
427__attribute__((weak)) void st7565_off_user(void) {}
428
429bool st7565_is_on(void) { return st7565_active; }
430
431uint8_t st7565_max_chars(void) { return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; }
432
433uint8_t st7565_max_lines(void) { return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; }
434
435void st7565_task(void) {
436 if (!st7565_initialized) {
437 return;
438 }
439
440#if ST7565_UPDATE_INTERVAL > 0
441 if (timer_elapsed(st7565_update_timeout) >= ST7565_UPDATE_INTERVAL) {
442 st7565_update_timeout = timer_read();
443 st7565_set_cursor(0, 0);
444 st7565_task_user();
445 }
446#else
447 st7565_set_cursor(0, 0);
448 st7565_task_user();
449#endif
450
451 // Smart render system, no need to check for dirty
452 st7565_render();
453
454 // Display timeout check
455#if ST7565_TIMEOUT > 0
456 if (st7565_active && timer_expired32(timer_read32(), st7565_timeout)) {
457 st7565_off();
458 }
459#endif
460}
461
462__attribute__((weak)) void st7565_task_user(void) {}
463
464void st7565_reset(void) {
465 writePinLow(ST7565_RST_PIN);
466 wait_ms(20);
467 writePinHigh(ST7565_RST_PIN);
468 wait_ms(20);
469}
470
471spi_status_t st7565_send_cmd(uint8_t cmd) {
472 writePinLow(ST7565_A0_PIN);
473 return spi_write(cmd);
474}
475
476spi_status_t st7565_send_data(uint8_t *data, uint16_t length) {
477 writePinHigh(ST7565_A0_PIN);
478 return spi_transmit(data, length);
479}
diff --git a/drivers/lcd/st7565.h b/drivers/lcd/st7565.h
new file mode 100644
index 000000000..53cfc9a81
--- /dev/null
+++ b/drivers/lcd/st7565.h
@@ -0,0 +1,215 @@
1/*
2Copyright 2021
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include <stdint.h>
21#include <stdbool.h>
22
23#include "spi_master.h"
24
25#ifndef ST7565_DISPLAY_WIDTH
26# define ST7565_DISPLAY_WIDTH 128
27#endif
28#ifndef ST7565_DISPLAY_HEIGHT
29# define ST7565_DISPLAY_HEIGHT 32
30#endif
31#ifndef ST7565_MATRIX_SIZE
32# define ST7565_MATRIX_SIZE (ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH) // 1024 (compile time mathed)
33#endif
34#ifndef ST7565_BLOCK_TYPE
35# define ST7565_BLOCK_TYPE uint16_t
36#endif
37#ifndef ST7565_BLOCK_COUNT
38# define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) // 32 (compile time mathed)
39#endif
40#ifndef ST7565_BLOCK_SIZE
41# define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) // 32 (compile time mathed)
42#endif
43
44// the column address corresponding to the first column in the display hardware
45#if !defined(ST7565_COLUMN_OFFSET)
46# define ST7565_COLUMN_OFFSET 0
47#endif
48
49// spi clock divisor
50#if !defined(ST7565_SPI_CLK_DIVISOR)
51# define ST7565_SPI_CLK_DIVISOR 4
52#endif
53
54// Custom font file to use
55#if !defined(ST7565_FONT_H)
56# define ST7565_FONT_H "glcdfont.c"
57#endif
58// unsigned char value of the first character in the font file
59#if !defined(ST7565_FONT_START)
60# define ST7565_FONT_START 0
61#endif
62// unsigned char value of the last character in the font file
63#if !defined(ST7565_FONT_END)
64# define ST7565_FONT_END 223
65#endif
66// Font render width
67#if !defined(ST7565_FONT_WIDTH)
68# define ST7565_FONT_WIDTH 6
69#endif
70// Font render height
71#if !defined(ST7565_FONT_HEIGHT)
72# define ST7565_FONT_HEIGHT 8
73#endif
74// Default contrast level
75#if !defined(ST7565_CONTRAST)
76# define ST7565_CONTRAST 32
77#endif
78
79#if !defined(ST7565_TIMEOUT)
80# if defined(ST7565_DISABLE_TIMEOUT)
81# define ST7565_TIMEOUT 0
82# else
83# define ST7565_TIMEOUT 60000
84# endif
85#endif
86
87#if !defined(ST7565_UPDATE_INTERVAL) && defined(SPLIT_KEYBOARD)
88# define ST7565_UPDATE_INTERVAL 50
89#endif
90
91typedef struct __attribute__((__packed__)) {
92 uint8_t *current_element;
93 uint16_t remaining_element_count;
94} display_buffer_reader_t;
95
96// Rotation enum values are flags
97typedef enum { DISPLAY_ROTATION_0, DISPLAY_ROTATION_180 } display_rotation_t;
98
99// Initialize the display, rotating the rendered output based on the define passed in.
100// Returns true if the display was initialized successfully
101bool st7565_init(display_rotation_t rotation);
102
103// Called at the start of st7565_init, weak function overridable by the user
104// rotation - the value passed into st7565_init
105// Return new display_rotation_t if you want to override default rotation
106display_rotation_t st7565_init_user(display_rotation_t rotation);
107
108// Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering
109void st7565_clear(void);
110
111// Renders the dirty chunks of the buffer to display
112void st7565_render(void);
113
114// Moves cursor to character position indicated by column and line, wraps if out of bounds
115// Max column denoted by 'st7565_max_chars()' and max lines by 'st7565_max_lines()' functions
116void st7565_set_cursor(uint8_t col, uint8_t line);
117
118// Advances the cursor to the next page, writing ' ' if true
119// Wraps to the begining when out of bounds
120void st7565_advance_page(bool clearPageRemainder);
121
122// Moves the cursor forward 1 character length
123// Advance page if there is not enough room for the next character
124// Wraps to the begining when out of bounds
125void st7565_advance_char(void);
126
127// Writes a single character to the buffer at current cursor position
128// Advances the cursor while writing, inverts the pixels if true
129// Main handler that writes character data to the display buffer
130void st7565_write_char(const char data, bool invert);
131
132// Writes a string to the buffer at current cursor position
133// Advances the cursor while writing, inverts the pixels if true
134void st7565_write(const char *data, bool invert);
135
136// Writes a string to the buffer at current cursor position
137// Advances the cursor while writing, inverts the pixels if true
138// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
139void st7565_write_ln(const char *data, bool invert);
140
141// Pans the buffer to the right (or left by passing true) by moving contents of the buffer
142// Useful for moving the screen in preparation for new drawing
143void st7565_pan(bool left);
144
145// Returns a pointer to the requested start index in the buffer plus remaining
146// buffer length as struct
147display_buffer_reader_t st7565_read_raw(uint16_t start_index);
148
149// Writes a string to the buffer at current cursor position
150void st7565_write_raw(const char *data, uint16_t size);
151
152// Writes a single byte into the buffer at the specified index
153void st7565_write_raw_byte(const char data, uint16_t index);
154
155// Sets a specific pixel on or off
156// Coordinates start at top-left and go right and down for positive x and y
157void st7565_write_pixel(uint8_t x, uint8_t y, bool on);
158
159#if defined(__AVR__)
160// Writes a PROGMEM string to the buffer at current cursor position
161// Advances the cursor while writing, inverts the pixels if true
162// Remapped to call 'void st7565_write(const char *data, bool invert);' on ARM
163void st7565_write_P(const char *data, bool invert);
164
165// Writes a PROGMEM string to the buffer at current cursor position
166// Advances the cursor while writing, inverts the pixels if true
167// Advances the cursor to the next page, wiring ' ' to the remainder of the current page
168// Remapped to call 'void st7565_write_ln(const char *data, bool invert);' on ARM
169void st7565_write_ln_P(const char *data, bool invert);
170
171// Writes a PROGMEM string to the buffer at current cursor position
172void st7565_write_raw_P(const char *data, uint16_t size);
173#else
174# define st7565_write_P(data, invert) st7565_write(data, invert)
175# define st7565_write_ln_P(data, invert) st7565_write_ln(data, invert)
176# define st7565_write_raw_P(data, size) st7565_write_raw(data, size)
177#endif // defined(__AVR__)
178
179// Can be used to manually turn on the screen if it is off
180// Returns true if the screen was on or turns on
181bool st7565_on(void);
182
183// Called when st7565_on() turns on the screen, weak function overridable by the user
184// Not called if the screen is already on
185void st7565_on_user(void);
186
187// Can be used to manually turn off the screen if it is on
188// Returns true if the screen was off or turns off
189bool st7565_off(void);
190
191// Called when st7565_off() turns off the screen, weak function overridable by the user
192// Not called if the screen is already off
193void st7565_off_user(void);
194
195// Returns true if the screen is currently on, false if it is
196// not
197bool st7565_is_on(void);
198
199// Basically it's st7565_render, but with timeout management and st7565_task_user calling!
200void st7565_task(void);
201
202// Called at the start of st7565_task, weak function overridable by the user
203void st7565_task_user(void);
204
205// Returns the maximum number of characters that will fit on a line
206uint8_t st7565_max_chars(void);
207
208// Returns the maximum number of lines that will fit on the display
209uint8_t st7565_max_lines(void);
210
211void st7565_reset(void);
212
213spi_status_t st7565_send_cmd(uint8_t cmd);
214
215spi_status_t st7565_send_data(uint8_t *data, uint16_t length);
diff --git a/keyboards/anavi/macropad8/keymaps/default/config.h b/keyboards/anavi/macropad8/keymaps/default/config.h
new file mode 100644
index 000000000..dd687cad5
--- /dev/null
+++ b/keyboards/anavi/macropad8/keymaps/default/config.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#define LAYER_STATE_8BIT
diff --git a/keyboards/basekeys/trifecta/config.h b/keyboards/basekeys/trifecta/config.h
index 8a9529126..28c9c18fb 100644
--- a/keyboards/basekeys/trifecta/config.h
+++ b/keyboards/basekeys/trifecta/config.h
@@ -80,11 +80,11 @@
80# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 80# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
81// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 81// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
82// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 82// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
83//# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 83//# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
84# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 84# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
85# 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) 85# 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)
86# 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) 86# 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)
87# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. 87# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
88# define RGB_MATRIX_HUE_STEP 8 88# define RGB_MATRIX_HUE_STEP 8
89# define RGB_MATRIX_SAT_STEP 8 89# define RGB_MATRIX_SAT_STEP 8
90# define RGB_MATRIX_VAL_STEP 8 90# define RGB_MATRIX_VAL_STEP 8
diff --git a/keyboards/bm40hsrgb/config.h b/keyboards/bm40hsrgb/config.h
index 84d0950d5..8ef9a78c7 100755
--- a/keyboards/bm40hsrgb/config.h
+++ b/keyboards/bm40hsrgb/config.h
@@ -51,5 +51,5 @@
51 #define RGB_MATRIX_KEYPRESSES // reacts to keypresses 51 #define RGB_MATRIX_KEYPRESSES // reacts to keypresses
52#endif 52#endif
53#ifdef RGB_MATRIX_ENABLE 53#ifdef RGB_MATRIX_ENABLE
54# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 54# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
55#endif 55#endif
diff --git a/keyboards/bm68rgb/keymaps/peepeetee/config.h b/keyboards/bm68rgb/keymaps/peepeetee/config.h
index 53eebce7f..aada255cd 100644
--- a/keyboards/bm68rgb/keymaps/peepeetee/config.h
+++ b/keyboards/bm68rgb/keymaps/peepeetee/config.h
@@ -64,7 +64,7 @@
64// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation 64// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation
65// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness) 65// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness)
66// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 66// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
67// #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 67// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
68// #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) 68// #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)
69// #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) 69// #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)
70// #define RGBLIGHT_ANIMATIONS // Run RGB animations 70// #define RGBLIGHT_ANIMATIONS // Run RGB animations
diff --git a/keyboards/boardsource/the_mark/config.h b/keyboards/boardsource/the_mark/config.h
index 5888452ce..9ca598b40 100644
--- a/keyboards/boardsource/the_mark/config.h
+++ b/keyboards/boardsource/the_mark/config.h
@@ -59,7 +59,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
59#define DRIVER_LED_TOTAL 24 // Number of LEDs 59#define DRIVER_LED_TOTAL 24 // Number of LEDs
60#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 60#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200
61# ifndef RGB_DISABLE_WHEN_USB_SUSPENDED 61# ifndef RGB_DISABLE_WHEN_USB_SUSPENDED
62# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 62# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
63# endif 63# endif
64#endif 64#endif
65 65
diff --git a/keyboards/crkbd/keymaps/devdev/config.h b/keyboards/crkbd/keymaps/devdev/config.h
index 793c7b020..c858f8f2d 100644
--- a/keyboards/crkbd/keymaps/devdev/config.h
+++ b/keyboards/crkbd/keymaps/devdev/config.h
@@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
32 32
33#define CUSTOM_FONT 33#define CUSTOM_FONT
34 34
35#define CUSTOM_LAYER_READ //if you remove this it causes issues - needs better guarding 35#define CUSTOM_LAYER_READ //if you remove this it causes issues - needs better guarding
36 36
37#define TAPPING_FORCE_HOLD 37#define TAPPING_FORCE_HOLD
38#define TAPPING_TERM 200 38#define TAPPING_TERM 200
@@ -43,7 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
43 43
44#ifdef RGBLIGHT_ENABLE 44#ifdef RGBLIGHT_ENABLE
45 #undef RGBLED_NUM 45 #undef RGBLED_NUM
46 46
47 //#define RGBLIGHT_ANIMATIONS 47 //#define RGBLIGHT_ANIMATIONS
48 #define RGBLIGHT_EFFECT_BREATHING 48 #define RGBLIGHT_EFFECT_BREATHING
49 #define RGBLIGHT_EFFECT_RAINBOW_MOOD 49 #define RGBLIGHT_EFFECT_RAINBOW_MOOD
@@ -55,11 +55,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
55 //#define RGBLIGHT_EFFECT_RGB_TEST 55 //#define RGBLIGHT_EFFECT_RGB_TEST
56 //#define RGBLIGHT_EFFECT_ALTERNATING 56 //#define RGBLIGHT_EFFECT_ALTERNATING
57 //#define RGBLIGHT_EFFECT_TWINKLE 57 //#define RGBLIGHT_EFFECT_TWINKLE
58 58
59 //#define RGBLED_NUM 54 59 //#define RGBLED_NUM 54
60 //#define RGBLED_SPLIT 27 60 //#define RGBLED_SPLIT 27
61 //#define RGBLED_SPLIT { 27, 27 } // haven't figured out how to use this yet 61 //#define RGBLED_SPLIT { 27, 27 } // haven't figured out how to use this yet
62 62
63 #define RGBLED_NUM 27 63 #define RGBLED_NUM 27
64 #define RGBLIGHT_LIMIT_VAL 120 64 #define RGBLIGHT_LIMIT_VAL 120
65 #define RGBLIGHT_HUE_STEP 10 65 #define RGBLIGHT_HUE_STEP 10
@@ -71,11 +71,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
71# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 71# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
72// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 72// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
73// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 73// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
74# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 74# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
75# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 75# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
76// # 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) 76// # 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)
77// # 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) 77// # 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)
78# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. 78# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
79 79
80#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_GRADIENT_LEFT_RIGHT 80#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_GRADIENT_LEFT_RIGHT
81 81
diff --git a/keyboards/crkbd/keymaps/gotham/config.h b/keyboards/crkbd/keymaps/gotham/config.h
index dd58a0fe0..05b04e0aa 100644
--- a/keyboards/crkbd/keymaps/gotham/config.h
+++ b/keyboards/crkbd/keymaps/gotham/config.h
@@ -39,7 +39,7 @@
39 39
40#ifdef RGB_MATRIX_ENABLE 40#ifdef RGB_MATRIX_ENABLE
41# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 41# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
42# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 42# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
43# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. 43# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
44# define RGB_MATRIX_HUE_STEP 32 44# define RGB_MATRIX_HUE_STEP 32
45# define RGB_MATRIX_SAT_STEP 64 45# define RGB_MATRIX_SAT_STEP 64
diff --git a/keyboards/crkbd/keymaps/kidbrazil/config.h b/keyboards/crkbd/keymaps/kidbrazil/config.h
index be1777e57..752ea862e 100644
--- a/keyboards/crkbd/keymaps/kidbrazil/config.h
+++ b/keyboards/crkbd/keymaps/kidbrazil/config.h
@@ -56,7 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56 //# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 56 //# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
57 // # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 57 // # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
58 // # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 58 // # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
59 #define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 59 #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
60 #define RGB_MATRIX_FRAMEBUFFER_EFFECTS 60 #define RGB_MATRIX_FRAMEBUFFER_EFFECTS
61 // # 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) 61 // # 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)
62 // # 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) 62 // # 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)
diff --git a/keyboards/crkbd/keymaps/rpbaptist/config.h b/keyboards/crkbd/keymaps/rpbaptist/config.h
index 6bd16725f..9e5f75c36 100644
--- a/keyboards/crkbd/keymaps/rpbaptist/config.h
+++ b/keyboards/crkbd/keymaps/rpbaptist/config.h
@@ -42,7 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
42#define NO_ACTION_ONESHOT 42#define NO_ACTION_ONESHOT
43 43
44#ifdef RGB_MATRIX_ENABLE 44#ifdef RGB_MATRIX_ENABLE
45# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 45# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
46# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 46# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150
47 47
48# define RGB_MATRIX_HUE_STEP 8 48# define RGB_MATRIX_HUE_STEP 8
diff --git a/keyboards/crkbd/keymaps/soundmonster/config.h b/keyboards/crkbd/keymaps/soundmonster/config.h
index 1e58af3ab..8235b4869 100644
--- a/keyboards/crkbd/keymaps/soundmonster/config.h
+++ b/keyboards/crkbd/keymaps/soundmonster/config.h
@@ -59,11 +59,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
59# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 59# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
60// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 60// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
61// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 61// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
62# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 62# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
63# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 63# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
64# 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) 64# 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)
65# 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) 65# 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)
66# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. 66# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
67# define RGB_MATRIX_HUE_STEP 8 67# define RGB_MATRIX_HUE_STEP 8
68# define RGB_MATRIX_SAT_STEP 8 68# define RGB_MATRIX_SAT_STEP 8
69# define RGB_MATRIX_VAL_STEP 8 69# define RGB_MATRIX_VAL_STEP 8
diff --git a/keyboards/crkbd/readme.md b/keyboards/crkbd/readme.md
index 1e5bfb39a..f0b5672cf 100644
--- a/keyboards/crkbd/readme.md
+++ b/keyboards/crkbd/readme.md
@@ -38,7 +38,7 @@ And in your `config.h` file, add the following:
38# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 38# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
39// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 39// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
40// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 40// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
41# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 41# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
42# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 42# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
43// # 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) 43// # 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)
44// # 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) 44// # 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)
diff --git a/keyboards/dztech/dz60rgb/v1/config.h b/keyboards/dztech/dz60rgb/v1/config.h
index 6e5b3da6f..f6ee7c4e2 100644
--- a/keyboards/dztech/dz60rgb/v1/config.h
+++ b/keyboards/dztech/dz60rgb/v1/config.h
@@ -37,7 +37,7 @@
37 37
38#ifdef RGB_MATRIX_ENABLE 38#ifdef RGB_MATRIX_ENABLE
39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41# define RGB_MATRIX_KEYPRESSES 41# define RGB_MATRIX_KEYPRESSES
42# define RGB_MATRIX_LED_PROCESS_LIMIT 4 42# define RGB_MATRIX_LED_PROCESS_LIMIT 4
43# define RGB_MATRIX_LED_FLUSH_LIMIT 26 43# define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/dztech/dz60rgb/v2/config.h b/keyboards/dztech/dz60rgb/v2/config.h
index df84fff59..6108e9903 100644
--- a/keyboards/dztech/dz60rgb/v2/config.h
+++ b/keyboards/dztech/dz60rgb/v2/config.h
@@ -37,7 +37,7 @@
37 37
38#ifdef RGB_MATRIX_ENABLE 38#ifdef RGB_MATRIX_ENABLE
39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41# define RGB_MATRIX_KEYPRESSES 41# define RGB_MATRIX_KEYPRESSES
42# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 42# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
43# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 43# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/keyboards/dztech/dz60rgb_ansi/v1/config.h b/keyboards/dztech/dz60rgb_ansi/v1/config.h
index 8710f8d07..dc2a6f4bc 100644
--- a/keyboards/dztech/dz60rgb_ansi/v1/config.h
+++ b/keyboards/dztech/dz60rgb_ansi/v1/config.h
@@ -37,7 +37,7 @@
37 37
38#ifdef RGB_MATRIX_ENABLE 38#ifdef RGB_MATRIX_ENABLE
39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41# define RGB_MATRIX_KEYPRESSES 41# define RGB_MATRIX_KEYPRESSES
42# define RGB_MATRIX_LED_PROCESS_LIMIT 4 42# define RGB_MATRIX_LED_PROCESS_LIMIT 4
43# define RGB_MATRIX_LED_FLUSH_LIMIT 26 43# define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/dztech/dz60rgb_ansi/v2/config.h b/keyboards/dztech/dz60rgb_ansi/v2/config.h
index f3c9b73fb..6c1e00682 100644
--- a/keyboards/dztech/dz60rgb_ansi/v2/config.h
+++ b/keyboards/dztech/dz60rgb_ansi/v2/config.h
@@ -37,7 +37,7 @@
37 37
38#ifdef RGB_MATRIX_ENABLE 38#ifdef RGB_MATRIX_ENABLE
39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41# define RGB_MATRIX_KEYPRESSES 41# define RGB_MATRIX_KEYPRESSES
42# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 42# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
43# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 43# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/keyboards/dztech/dz60rgb_wkl/v1/config.h b/keyboards/dztech/dz60rgb_wkl/v1/config.h
index 9c630c75b..12317c2d3 100644
--- a/keyboards/dztech/dz60rgb_wkl/v1/config.h
+++ b/keyboards/dztech/dz60rgb_wkl/v1/config.h
@@ -37,7 +37,7 @@
37 37
38#ifdef RGB_MATRIX_ENABLE 38#ifdef RGB_MATRIX_ENABLE
39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41# define RGB_MATRIX_KEYPRESSES 41# define RGB_MATRIX_KEYPRESSES
42# define RGB_MATRIX_LED_PROCESS_LIMIT 4 42# define RGB_MATRIX_LED_PROCESS_LIMIT 4
43# define RGB_MATRIX_LED_FLUSH_LIMIT 26 43# define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/dztech/dz60rgb_wkl/v2/config.h b/keyboards/dztech/dz60rgb_wkl/v2/config.h
index a6145c274..945b591ce 100644
--- a/keyboards/dztech/dz60rgb_wkl/v2/config.h
+++ b/keyboards/dztech/dz60rgb_wkl/v2/config.h
@@ -37,7 +37,7 @@
37 37
38#ifdef RGB_MATRIX_ENABLE 38#ifdef RGB_MATRIX_ENABLE
39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41# define RGB_MATRIX_KEYPRESSES 41# define RGB_MATRIX_KEYPRESSES
42# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 42# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
43# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 43# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/keyboards/dztech/dz65rgb/v1/config.h b/keyboards/dztech/dz65rgb/v1/config.h
index cd4747716..1b0aa5205 100644
--- a/keyboards/dztech/dz65rgb/v1/config.h
+++ b/keyboards/dztech/dz65rgb/v1/config.h
@@ -36,9 +36,9 @@
36# define RGB_MATRIX_LED_FLUSH_LIMIT 26 36# define RGB_MATRIX_LED_FLUSH_LIMIT 26
37# define DEBOUNCE 3 37# define DEBOUNCE 3
38# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 38# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
39# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 39# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
40# define RGB_MATRIX_KEYPRESSES 40# define RGB_MATRIX_KEYPRESSES
41# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 41# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
42# define DISABLE_RGB_MATRIX_BAND_SAT 42# define DISABLE_RGB_MATRIX_BAND_SAT
43# define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT 43# define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
44# define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT 44# define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT
diff --git a/keyboards/dztech/dz65rgb/v2/config.h b/keyboards/dztech/dz65rgb/v2/config.h
index ccd74275a..117fb1e3e 100644
--- a/keyboards/dztech/dz65rgb/v2/config.h
+++ b/keyboards/dztech/dz65rgb/v2/config.h
@@ -36,7 +36,7 @@
36# define RGB_MATRIX_LED_FLUSH_LIMIT 26 36# define RGB_MATRIX_LED_FLUSH_LIMIT 26
37# define DEBOUNCE 3 37# define DEBOUNCE 3
38# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 38# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
39# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 39# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
40# define RGB_MATRIX_KEYPRESSES 40# define RGB_MATRIX_KEYPRESSES
41# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 41# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
42# define DISABLE_RGB_MATRIX_BAND_SAT 42# define DISABLE_RGB_MATRIX_BAND_SAT
diff --git a/keyboards/ergodox_ez/config.h b/keyboards/ergodox_ez/config.h
index bc63f6108..9dcfc341e 100644
--- a/keyboards/ergodox_ez/config.h
+++ b/keyboards/ergodox_ez/config.h
@@ -129,7 +129,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
129#define RGB_MATRIX_LED_PROCESS_LIMIT 5 129#define RGB_MATRIX_LED_PROCESS_LIMIT 5
130#define RGB_MATRIX_LED_FLUSH_LIMIT 26 130#define RGB_MATRIX_LED_FLUSH_LIMIT 26
131 131
132#define RGB_DISABLE_WHEN_USB_SUSPENDED true 132#define RGB_DISABLE_WHEN_USB_SUSPENDED
133 133
134// #define RGBLIGHT_COLOR_LAYER_0 0x00, 0x00, 0xFF 134// #define RGBLIGHT_COLOR_LAYER_0 0x00, 0x00, 0xFF
135/* #define RGBLIGHT_COLOR_LAYER_1 0x00, 0x00, 0xFF */ 135/* #define RGBLIGHT_COLOR_LAYER_1 0x00, 0x00, 0xFF */
diff --git a/keyboards/ergodox_ez/keymaps/hacker_dvorak/config.h b/keyboards/ergodox_ez/keymaps/hacker_dvorak/config.h
index a0ba655ed..da2082078 100644
--- a/keyboards/ergodox_ez/keymaps/hacker_dvorak/config.h
+++ b/keyboards/ergodox_ez/keymaps/hacker_dvorak/config.h
@@ -14,7 +14,7 @@
14#undef IGNORE_MOD_TAP_INTERRUPT 14#undef IGNORE_MOD_TAP_INTERRUPT
15#define IGNORE_MOD_TAP_INTERRUPT 15#define IGNORE_MOD_TAP_INTERRUPT
16 16
17#define RGB_DISABLE_WHEN_USB_SUSPENDED true 17#define RGB_DISABLE_WHEN_USB_SUSPENDED
18 18
19#undef FORCE_NKRO 19#undef FORCE_NKRO
20#define FORCE_NKRO 20#define FORCE_NKRO
diff --git a/keyboards/ergodox_infinity/config.h b/keyboards/ergodox_infinity/config.h
index a64f3f4a1..a00c593ee 100644
--- a/keyboards/ergodox_infinity/config.h
+++ b/keyboards/ergodox_infinity/config.h
@@ -62,6 +62,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
62#define LED_BRIGHTNESS_LO 100 62#define LED_BRIGHTNESS_LO 100
63#define LED_BRIGHTNESS_HI 255 63#define LED_BRIGHTNESS_HI 255
64 64
65/* LED matrix driver */
66#define LED_DRIVER_ADDR_1 0x74
67#define LED_DRIVER_COUNT 1
68#define DRIVER_LED_TOTAL 76
69#define LED_MATRIX_SPLIT { 38, 38 }
70#define LED_DISABLE_WHEN_USB_SUSPENDED
71
72/* i2c (for LED matrix) */
73#define I2C1_CLOCK_SPEED 400000
74#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
75#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
76#define I2C1_BANK GPIOB
77#define I2C1_SCL 0
78#define I2C1_SDA 1
79
65/* define if matrix has ghost */ 80/* define if matrix has ghost */
66//#define MATRIX_HAS_GHOST 81//#define MATRIX_HAS_GHOST
67 82
diff --git a/keyboards/ergodox_infinity/ergodox_infinity.c b/keyboards/ergodox_infinity/ergodox_infinity.c
index 97b628470..da8ea311a 100644
--- a/keyboards/ergodox_infinity/ergodox_infinity.c
+++ b/keyboards/ergodox_infinity/ergodox_infinity.c
@@ -1,20 +1,45 @@
1#include QMK_KEYBOARD_H 1#include QMK_KEYBOARD_H
2#include <ch.h> 2#include <ch.h>
3#include <hal.h> 3#include <hal.h>
4#include <string.h>
5#include "eeconfig.h"
4#include "serial_link/system/serial_link.h" 6#include "serial_link/system/serial_link.h"
5#ifdef VISUALIZER_ENABLE 7#ifdef VISUALIZER_ENABLE
6#include "lcd_backlight.h" 8# include "lcd_backlight.h"
7#endif 9#endif
8 10
9#ifdef WPM_ENABLE 11#if (defined(LED_MATRIX_ENABLE) || defined(WPM_ENABLE))
10# include "serial_link/protocol/transport.h" 12# include "serial_link/protocol/transport.h"
11# include "wpm.h" 13
14# ifdef LED_MATRIX_ENABLE
15MASTER_TO_ALL_SLAVES_OBJECT(led_matrix, led_eeconfig_t);
16MASTER_TO_ALL_SLAVES_OBJECT(led_suspend_state, bool);
17static led_eeconfig_t last_sent_led_matrix;
18static uint16_t led_matrix_sent_timer = 0;
19
20void send_led_suspend_state(void) {
21 if (is_serial_link_master()) {
22 *begin_write_led_suspend_state() = led_matrix_get_suspend_state();
23 end_write_led_suspend_state();
24 }
25}
26# endif
12 27
28# ifdef WPM_ENABLE
29# include "wpm.h"
13MASTER_TO_ALL_SLAVES_OBJECT(current_wpm, uint8_t); 30MASTER_TO_ALL_SLAVES_OBJECT(current_wpm, uint8_t);
14static remote_object_t* remote_objects[] = { 31static uint8_t last_sent_wpm = 0;
32# endif
33
34static remote_object_t *remote_objects[] = {
35# ifdef LED_MATRIX_ENABLE
36 REMOTE_OBJECT(led_matrix),
37 REMOTE_OBJECT(led_suspend_state),
38# endif
39# ifdef WPM_ENABLE
15 REMOTE_OBJECT(current_wpm), 40 REMOTE_OBJECT(current_wpm),
41# endif
16}; 42};
17static uint8_t last_sent_wpm = 0;
18#endif 43#endif
19 44
20void init_serial_link_hal(void) { 45void init_serial_link_hal(void) {
@@ -52,7 +77,7 @@ void init_serial_link_hal(void) {
52void lcd_backlight_hal_init(void) { 77void lcd_backlight_hal_init(void) {
53 // Setup Backlight 78 // Setup Backlight
54 SIM->SCGC6 |= SIM_SCGC6_FTM0; 79 SIM->SCGC6 |= SIM_SCGC6_FTM0;
55 FTM0->CNT = 0; // Reset counter 80 FTM0->CNT = 0; // Reset counter
56 81
57 // PWM Period 82 // PWM Period
58 // 16-bit maximum 83 // 16-bit maximum
@@ -60,25 +85,25 @@ void lcd_backlight_hal_init(void) {
60 85
61 // Set FTM to PWM output - Edge Aligned, Low-true pulses 86 // Set FTM to PWM output - Edge Aligned, Low-true pulses
62#define CNSC_MODE FTM_SC_CPWMS | FTM_SC_PS(4) | FTM_SC_CLKS(0) 87#define CNSC_MODE FTM_SC_CPWMS | FTM_SC_PS(4) | FTM_SC_CLKS(0)
63 CHANNEL_RED.CnSC = CNSC_MODE; 88 CHANNEL_RED.CnSC = CNSC_MODE;
64 CHANNEL_GREEN.CnSC = CNSC_MODE; 89 CHANNEL_GREEN.CnSC = CNSC_MODE;
65 CHANNEL_BLUE.CnSC = CNSC_MODE; 90 CHANNEL_BLUE.CnSC = CNSC_MODE;
66 91
67 // System clock, /w prescalar setting 92 // System clock, /w prescalar setting
68 FTM0->SC = FTM_SC_CLKS(1) | FTM_SC_PS(PRESCALAR_DEFINE); 93 FTM0->SC = FTM_SC_CLKS(1) | FTM_SC_PS(PRESCALAR_DEFINE);
69 94
70 CHANNEL_RED.CnV = 0; 95 CHANNEL_RED.CnV = 0;
71 CHANNEL_GREEN.CnV = 0; 96 CHANNEL_GREEN.CnV = 0;
72 CHANNEL_BLUE.CnV = 0; 97 CHANNEL_BLUE.CnV = 0;
73 98
74 RGB_PORT_GPIO->PDDR |= (1 << RED_PIN); 99 RGB_PORT_GPIO->PDDR |= (1 << RED_PIN);
75 RGB_PORT_GPIO->PDDR |= (1 << GREEN_PIN); 100 RGB_PORT_GPIO->PDDR |= (1 << GREEN_PIN);
76 RGB_PORT_GPIO->PDDR |= (1 << BLUE_PIN); 101 RGB_PORT_GPIO->PDDR |= (1 << BLUE_PIN);
77 102
78#define RGB_MODE PORTx_PCRn_SRE | PORTx_PCRn_DSE | PORTx_PCRn_MUX(4) 103#define RGB_MODE PORTx_PCRn_SRE | PORTx_PCRn_DSE | PORTx_PCRn_MUX(4)
79 RGB_PORT->PCR[RED_PIN] = RGB_MODE; 104 RGB_PORT->PCR[RED_PIN] = RGB_MODE;
80 RGB_PORT->PCR[GREEN_PIN] = RGB_MODE; 105 RGB_PORT->PCR[GREEN_PIN] = RGB_MODE;
81 RGB_PORT->PCR[BLUE_PIN] = RGB_MODE; 106 RGB_PORT->PCR[BLUE_PIN] = RGB_MODE;
82} 107}
83 108
84static uint16_t cie_lightness(uint16_t v) { 109static uint16_t cie_lightness(uint16_t v) {
@@ -89,12 +114,11 @@ static uint16_t cie_lightness(uint16_t v) {
89 // Y = (L* / 902.3) if L* <= 8 114 // Y = (L* / 902.3) if L* <= 8
90 // Y = ((L* + 16) / 116)^3 if L* > 8 115 // Y = ((L* + 16) / 116)^3 if L* > 8
91 116
92 float l = 100.0f * (v / 65535.0f); 117 float l = 100.0f * (v / 65535.0f);
93 float y = 0.0f; 118 float y = 0.0f;
94 if (l <= 8.0f) { 119 if (l <= 8.0f) {
95 y = l / 902.3; 120 y = l / 902.3;
96 } 121 } else {
97 else {
98 y = ((l + 16.0f) / 116.0f); 122 y = ((l + 16.0f) / 116.0f);
99 y = y * y * y; 123 y = y * y * y;
100 if (y > 1.0f) { 124 if (y > 1.0f) {
@@ -105,31 +129,48 @@ static uint16_t cie_lightness(uint16_t v) {
105} 129}
106 130
107void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) { 131void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) {
108 CHANNEL_RED.CnV = cie_lightness(r); 132 CHANNEL_RED.CnV = cie_lightness(r);
109 CHANNEL_GREEN.CnV = cie_lightness(g); 133 CHANNEL_GREEN.CnV = cie_lightness(g);
110 CHANNEL_BLUE.CnV = cie_lightness(b); 134 CHANNEL_BLUE.CnV = cie_lightness(b);
111} 135}
112 136
113__attribute__ ((weak)) 137__attribute__ ((weak)) void matrix_init_user(void) {}
114void matrix_init_user(void) { 138
115} 139__attribute__ ((weak)) void matrix_scan_user(void) {}
116 140
117__attribute__ ((weak))
118void matrix_scan_user(void) {
119}
120 141
142void keyboard_pre_init_kb() {
143#ifdef LED_MATRIX_ENABLE
144 // Turn on LED controller
145 setPinOutput(B16);
146 writePinHigh(B16);
147#endif
148 keyboard_pre_init_user();
149}
121 150
122void matrix_init_kb(void) { 151void matrix_init_kb(void) {
123 // put your keyboard start-up code here 152 // put your keyboard start-up code here
124 // runs once when the firmware starts up 153 // runs once when the firmware starts up
125 154
155#ifdef LED_MATRIX_ENABLE
156 /*
157 * Since K20x is stuck with a 32 byte EEPROM (see tmk_core/common/chibios/eeprom_teensy.c),
158 * and neither led_matrix_eeconfig.speed or .flags fit in this boundary, just force their values to default on boot.
159 */
160# if !defined(LED_MATRIX_STARTUP_SPD)
161# define LED_MATRIX_STARTUP_SPD UINT8_MAX / 2
162# endif
163 led_matrix_set_speed(LED_MATRIX_STARTUP_SPD);
164 led_matrix_set_flags(LED_FLAG_ALL);
165#endif
166
126 matrix_init_user(); 167 matrix_init_user();
127 // The backlight always has to be initialized, otherwise it will stay lit 168 // The backlight always has to be initialized, otherwise it will stay lit
128#ifndef VISUALIZER_ENABLE 169#ifndef VISUALIZER_ENABLE
129 lcd_backlight_hal_init(); 170 lcd_backlight_hal_init();
130#endif 171#endif
131#ifdef WPM_ENABLE 172#if (defined(LED_MATRIX_ENABLE) || defined(WPM_ENABLE))
132 add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*)); 173 add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t *));
133#endif 174#endif
134} 175}
135 176
@@ -137,6 +178,30 @@ void matrix_scan_kb(void) {
137 // put your looping keyboard code here 178 // put your looping keyboard code here
138 // runs every cycle (a lot) 179 // runs every cycle (a lot)
139 180
181#ifdef LED_MATRIX_ENABLE
182 if (is_serial_link_master()) {
183 if (!led_matrix_get_suspend_state()) {
184 if (timer_elapsed(led_matrix_sent_timer) >= 5000 || memcmp((void *)&last_sent_led_matrix, (void *)&led_matrix_eeconfig, sizeof(last_sent_led_matrix))) {
185 led_matrix_sent_timer = timer_read();
186 memcpy((void *)&last_sent_led_matrix, (void *)&led_matrix_eeconfig, sizeof(last_sent_led_matrix));
187 *begin_write_led_matrix() = last_sent_led_matrix;
188 end_write_led_matrix();
189 }
190 }
191 } else if (is_serial_link_connected()) {
192 bool *new_led_suspend_state = read_led_suspend_state();
193 if (new_led_suspend_state) {
194 led_matrix_set_suspend_state(*new_led_suspend_state);
195 }
196 if (!led_matrix_get_suspend_state()) {
197 led_eeconfig_t *new_led_matrix = read_led_matrix();
198 if (new_led_matrix) {
199 memcpy((void *)&led_matrix_eeconfig, (void *)new_led_matrix, sizeof(last_sent_led_matrix));
200 }
201 }
202 }
203#endif
204
140#ifdef WPM_ENABLE 205#ifdef WPM_ENABLE
141 if (is_serial_link_master()) { 206 if (is_serial_link_master()) {
142 uint8_t current_wpm = get_current_wpm(); 207 uint8_t current_wpm = get_current_wpm();
@@ -146,67 +211,68 @@ void matrix_scan_kb(void) {
146 last_sent_wpm = current_wpm; 211 last_sent_wpm = current_wpm;
147 } 212 }
148 } else if (is_serial_link_connected()) { 213 } else if (is_serial_link_connected()) {
149 uint8_t* new_wpm = read_current_wpm(); 214 uint8_t *new_wpm = read_current_wpm();
150 if (new_wpm) { 215 if (new_wpm) {
151 set_current_wpm(*new_wpm); 216 set_current_wpm(*new_wpm);
152 } 217 }
153 } 218 }
154#endif 219#endif
220
155 matrix_scan_user(); 221 matrix_scan_user();
156} 222}
157 223
158bool is_keyboard_master(void) { 224bool is_keyboard_master(void) { return is_serial_link_master(); }
159 return is_serial_link_master();
160}
161 225
162__attribute__ ((weak)) 226bool is_keyboard_left(void) {
163void ergodox_board_led_on(void){ 227#if defined(EE_HANDS)
228 return eeconfig_read_handedness();
229#elif defined(MASTER_IS_ON_RIGHT)
230 return !is_keyboard_master();
231#else
232 return is_keyboard_master();
233#endif
164} 234}
165 235
166__attribute__ ((weak)) 236__attribute__ ((weak)) void ergodox_board_led_on(void) {}
167void ergodox_right_led_1_on(void){
168}
169 237
170__attribute__ ((weak)) 238__attribute__ ((weak)) void ergodox_right_led_1_on(void) {}
171void ergodox_right_led_2_on(void){
172}
173 239
174__attribute__ ((weak)) 240__attribute__ ((weak)) void ergodox_right_led_2_on(void) {}
175void ergodox_right_led_3_on(void){
176}
177 241
178__attribute__ ((weak)) 242__attribute__ ((weak)) void ergodox_right_led_3_on(void) {}
179void ergodox_board_led_off(void){
180}
181 243
182__attribute__ ((weak)) 244__attribute__ ((weak)) void ergodox_board_led_off(void) {}
183void ergodox_right_led_1_off(void){
184}
185 245
186__attribute__ ((weak)) 246__attribute__ ((weak)) void ergodox_right_led_1_off(void) {}
187void ergodox_right_led_2_off(void){
188}
189 247
190__attribute__ ((weak)) 248__attribute__ ((weak)) void ergodox_right_led_2_off(void) {}
191void ergodox_right_led_3_off(void){
192}
193 249
194__attribute__ ((weak)) 250__attribute__ ((weak)) void ergodox_right_led_3_off(void) {}
195void ergodox_right_led_1_set(uint8_t n) {
196}
197 251
198__attribute__ ((weak)) 252__attribute__ ((weak)) void ergodox_right_led_1_set(uint8_t n) {}
199void ergodox_right_led_2_set(uint8_t n) { 253
254__attribute__ ((weak)) void ergodox_right_led_2_set(uint8_t n) {}
255
256__attribute__ ((weak)) void ergodox_right_led_3_set(uint8_t n) {}
257
258void suspend_power_down_kb(void) {
259#ifdef LED_MATRIX_ENABLE
260 send_led_suspend_state();
261#endif
262 suspend_power_down_user();
200} 263}
201 264
202__attribute__ ((weak)) 265void suspend_wakeup_init_kb(void) {
203void ergodox_right_led_3_set(uint8_t n) { 266#ifdef LED_MATRIX_ENABLE
267 send_led_suspend_state();
268#endif
269 suspend_wakeup_init_user();
204} 270}
205 271
206#ifdef SWAP_HANDS_ENABLE 272#ifdef SWAP_HANDS_ENABLE
207__attribute__ ((weak)) 273__attribute__ ((weak))
208const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { 274const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
209 {{0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 9}}, 275 {{0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 9}},
210 {{0, 10}, {1, 10}, {2, 10}, {3, 10}, {4, 10}}, 276 {{0, 10}, {1, 10}, {2, 10}, {3, 10}, {4, 10}},
211 {{0, 11}, {1, 11}, {2, 11}, {3, 11}, {4, 11}}, 277 {{0, 11}, {1, 11}, {2, 11}, {3, 11}, {4, 11}},
212 {{0, 12}, {1, 12}, {2, 12}, {3, 12}, {4, 12}}, 278 {{0, 12}, {1, 12}, {2, 12}, {3, 12}, {4, 12}},
@@ -226,3 +292,115 @@ const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
226 {{0, 8}, {1, 8}, {2, 8}, {3, 8}, {4, 8}}, 292 {{0, 8}, {1, 8}, {2, 8}, {3, 8}, {4, 8}},
227}; 293};
228#endif 294#endif
295
296#ifdef LED_MATRIX_ENABLE
297const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
298// The numbers in the comments are the led numbers DXX on the PCB
299/* Refer to IS31 manual for these locations
300 * driver
301 * | LED address
302 * | | */
303// Left half
304// 45 44 43 42 41 40 39
305 { 0, C2_2 }, { 0, C1_2 }, { 0, C5_1 }, { 0, C4_1 }, { 0, C3_1 }, { 0, C2_1 }, { 0, C1_1 },
306// 52 51 50 49 48 47 46
307 { 0, C4_3 }, { 0, C3_3 }, { 0, C2_3 }, { 0, C1_3 }, { 0, C5_2 }, { 0, C4_2 }, { 0, C3_2 },
308// 58 57 56 55 54 53
309 { 0, C5_4 }, { 0, C4_4 }, { 0, C3_4 }, { 0, C2_4 }, { 0, C1_4 }, { 0, C5_3 },
310// 67 66 65 64 63 62 61
311 { 0, C4_6 }, { 0, C3_6 }, { 0, C2_6 }, { 0, C1_6 }, { 0, C5_5 }, { 0, C4_5 }, { 0, C3_5 },
312// 76 75 74 73 72
313 { 0, C4_8 }, { 0, C3_8 }, { 0, C2_8 }, { 0, C1_8 }, { 0, C4_7 },
314// 60 59
315 { 0, C2_5 }, { 0, C1_5 },
316// 68
317 { 0, C5_6 },
318// 71 70 69
319 { 0, C3_7 }, { 0, C2_7 }, { 0, C1_7 },
320// Right half (mirrored)
321// Due to how LED_MATRIX_SPLIT is implemented, only the first half of g_is31_leds is actually used.
322// Luckily, the right half has the same LED pinouts, just mirrored.
323// 45 44 43 42 41 40 39
324 { 0, C2_2 }, { 0, C1_2 }, { 0, C5_1 }, { 0, C4_1 }, { 0, C3_1 }, { 0, C2_1 }, { 0, C1_1 },
325// 52 51 50 49 48 47 46
326 { 0, C4_3 }, { 0, C3_3 }, { 0, C2_3 }, { 0, C1_3 }, { 0, C5_2 }, { 0, C4_2 }, { 0, C3_2 },
327// 58 57 56 55 54 53
328 { 0, C5_4 }, { 0, C4_4 }, { 0, C3_4 }, { 0, C2_4 }, { 0, C1_4 }, { 0, C5_3 },
329// 67 66 65 64 63 62 61
330 { 0, C4_6 }, { 0, C3_6 }, { 0, C2_6 }, { 0, C1_6 }, { 0, C5_5 }, { 0, C4_5 }, { 0, C3_5 },
331// 76 75 74 73 72
332 { 0, C4_8 }, { 0, C3_8 }, { 0, C2_8 }, { 0, C1_8 }, { 0, C4_7 },
333// 60 59
334 { 0, C2_5 }, { 0, C1_5 },
335// 68
336 { 0, C5_6 },
337// 71 70 69
338 { 0, C3_7 }, { 0, C2_7 }, { 0, C1_7 },
339};
340
341led_config_t g_led_config = {
342 {
343 // Key Matrix to LED Index
344 // Left half
345 { NO_LED, NO_LED, NO_LED, 33, 34 },
346 { NO_LED, NO_LED, NO_LED, 32, 37 },
347 { 6, 13, NO_LED, 26, 36 },
348 { 5, 12, 19, 25, 35 },
349 { 4, 11, 18, 24, 31 },
350 { 3, 10, 17, 23, 30 },
351 { 2, 9, 16, 22, 29 },
352 { 1, 8, 15, 21, 28 },
353 { 0, 7, 14, 20, 27 },
354 // Right half
355 { NO_LED, NO_LED, NO_LED, 71, 72 },
356 { NO_LED, NO_LED, NO_LED, 70, 75 },
357 { 44, 51, NO_LED, 64, 74 },
358 { 43, 50, 57, 63, 73 },
359 { 42, 49, 56, 62, 69 },
360 { 41, 48, 55, 61, 68 },
361 { 40, 47, 54, 60, 67 },
362 { 39, 46, 53, 59, 66 },
363 { 38, 45, 52, 58, 65 },
364 }, {
365 // LED Index to Physical Position (assumes a reasonable gap between halves)
366 // Left half
367 { 0, 3 }, { 15, 3 }, { 27, 1 }, { 39, 0 }, { 51, 1 }, { 63, 2 }, { 75, 2 },
368 { 0, 13 }, { 15, 13 }, { 27, 11 }, { 39, 10 }, { 51, 11 }, { 63, 12 }, { 78, 17 },
369 { 0, 23 }, { 15, 23 }, { 27, 21 }, { 39, 20 }, { 51, 21 }, { 63, 22 },
370 { 0, 33 }, { 15, 33 }, { 27, 31 }, { 39, 30 }, { 51, 31 }, { 63, 32 }, { 78, 32 },
371 { 4, 43 }, { 15, 43 }, { 27, 41 }, { 39, 40 }, { 51, 41 },
372 { 89, 41 }, { 100, 46 },
373 { 95, 55 },
374 { 72, 54 }, { 83, 59 }, { 90, 64 },
375 // Right half (mirrored)
376 { 224, 3 }, { 209, 3 }, { 197, 1 }, { 185, 0 }, { 173, 1 }, { 161, 2 }, { 149, 2 },
377 { 224, 13 }, { 209, 13 }, { 197, 11 }, { 185, 10 }, { 173, 11 }, { 161, 12 }, { 146, 17 },
378 { 224, 23 }, { 209, 23 }, { 197, 21 }, { 185, 20 }, { 173, 21 }, { 161, 22 },
379 { 224, 33 }, { 209, 33 }, { 197, 31 }, { 185, 30 }, { 173, 31 }, { 161, 32 }, { 146, 32 },
380 { 220, 43 }, { 209, 43 }, { 197, 41 }, { 185, 40 }, { 173, 41 },
381 { 135, 41 }, { 124, 46 },
382 { 129, 55 },
383 { 152, 54 }, { 141, 59 }, { 134, 64 },
384 }, {
385 // LED Index to Flag
386 // Left half
387 1, 4, 4, 4, 4, 4, 1,
388 1, 4, 4, 4, 4, 4, 1,
389 1, 4, 4, 4, 4, 4,
390 1, 4, 4, 4, 4, 4, 1,
391 1, 1, 1, 1, 1,
392 1, 1,
393 1,
394 1, 1, 1,
395 // Right half (mirrored)
396 1, 4, 4, 4, 4, 4, 1,
397 1, 4, 4, 4, 4, 4, 1,
398 1, 4, 4, 4, 4, 4,
399 1, 4, 4, 4, 4, 4, 1,
400 1, 1, 1, 1, 1,
401 1, 1,
402 1,
403 1, 1, 1,
404 }
405};
406#endif
diff --git a/keyboards/ergodox_infinity/matrix.c b/keyboards/ergodox_infinity/matrix.c
index 7baacd24d..0fca56a97 100644
--- a/keyboards/ergodox_infinity/matrix.c
+++ b/keyboards/ergodox_infinity/matrix.c
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#include "print.h" 24#include "print.h"
25#include "debug.h" 25#include "debug.h"
26#include "matrix.h" 26#include "matrix.h"
27#include "eeconfig.h" 27#include "keyboard.h"
28#include "serial_link/system/serial_link.h" 28#include "serial_link/system/serial_link.h"
29 29
30 30
@@ -119,15 +119,9 @@ uint8_t matrix_scan(void)
119 } 119 }
120 120
121 uint8_t offset = 0; 121 uint8_t offset = 0;
122#if (defined(EE_HANDS) || defined(MASTER_IS_ON_RIGHT)) 122 if (is_serial_link_master() && !is_keyboard_left()) {
123#ifdef EE_HANDS
124 if (is_serial_link_master() && !eeconfig_read_handedness()) {
125#else
126 if (is_serial_link_master()) {
127#endif
128 offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS; 123 offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS;
129 } 124 }
130#endif
131 125
132 if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) { 126 if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
133 for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) { 127 for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) {
@@ -167,17 +161,11 @@ void matrix_print(void)
167 161
168void matrix_set_remote(matrix_row_t* rows, uint8_t index) { 162void matrix_set_remote(matrix_row_t* rows, uint8_t index) {
169 uint8_t offset = 0; 163 uint8_t offset = 0;
170#ifdef EE_HANDS 164 if (is_keyboard_left()) {
171 if (eeconfig_read_handedness()) {
172 offset = LOCAL_MATRIX_ROWS * (index + 1); 165 offset = LOCAL_MATRIX_ROWS * (index + 1);
173 } else { 166 } else {
174 offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS * (index + 2); 167 offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS * (index + 2);
175 } 168 }
176#elif defined(MASTER_IS_ON_RIGHT)
177 offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS * (index + 2);
178#else
179 offset = LOCAL_MATRIX_ROWS * (index + 1);
180#endif
181 for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) { 169 for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) {
182 matrix[offset + row] = rows[row]; 170 matrix[offset + row] = rows[row];
183 } 171 }
diff --git a/keyboards/ergodox_infinity/rules.mk b/keyboards/ergodox_infinity/rules.mk
index b9ead9e87..70bcabe80 100644
--- a/keyboards/ergodox_infinity/rules.mk
+++ b/keyboards/ergodox_infinity/rules.mk
@@ -22,8 +22,6 @@ CUSTOM_MATRIX = yes # Custom matrix file
22SERIAL_LINK_ENABLE = yes 22SERIAL_LINK_ENABLE = yes
23VISUALIZER_ENABLE = yes 23VISUALIZER_ENABLE = yes
24LCD_ENABLE = yes 24LCD_ENABLE = yes
25BACKLIGHT_ENABLE = yes
26BACKLIGHT_DRIVER = custom
27LCD_BACKLIGHT_ENABLE = yes 25LCD_BACKLIGHT_ENABLE = yes
28MIDI_ENABLE = no 26MIDI_ENABLE = no
29RGBLIGHT_ENABLE = no 27RGBLIGHT_ENABLE = no
@@ -32,9 +30,8 @@ LCD_DRIVER = st7565
32LCD_WIDTH = 128 30LCD_WIDTH = 128
33LCD_HEIGHT = 32 31LCD_HEIGHT = 32
34 32
35LED_DRIVER = is31fl3731c 33LED_MATRIX_ENABLE = yes
36LED_WIDTH = 7 34LED_MATRIX_DRIVER = IS31FL3731
37LED_HEIGHT = 7
38 35
39# project specific files 36# project specific files
40SRC = matrix.c \ 37SRC = matrix.c \
diff --git a/keyboards/geekboards/macropad_v2/config.h b/keyboards/geekboards/macropad_v2/config.h
index 5f11cdddb..d0e208f9b 100644
--- a/keyboards/geekboards/macropad_v2/config.h
+++ b/keyboards/geekboards/macropad_v2/config.h
@@ -41,7 +41,7 @@
41#define WS2812_DMA_CHANNEL 3 41#define WS2812_DMA_CHANNEL 3
42 42
43#ifdef RGB_MATRIX_ENABLE 43#ifdef RGB_MATRIX_ENABLE
44#define RGB_MATRIX_KEYPRESSES 44#define RGB_MATRIX_KEYPRESSES
45#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 45#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
46#define DISABLE_RGB_MATRIX_ALPHAS_MODS 46#define DISABLE_RGB_MATRIX_ALPHAS_MODS
47#define DISABLE_RGB_MATRIX_BAND_SAT 47#define DISABLE_RGB_MATRIX_BAND_SAT
@@ -67,7 +67,7 @@
67#define RGB_MATRIX_STARTUP_SPD 30 67#define RGB_MATRIX_STARTUP_SPD 30
68#endif //RGB_MATRIX_ENABLE 68#endif //RGB_MATRIX_ENABLE
69 69
70#define RGB_DISABLE_WHEN_USB_SUSPENDED true 70#define RGB_DISABLE_WHEN_USB_SUSPENDED
71#define WAIT_FOR_USB 71#define WAIT_FOR_USB
72 72
73/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ 73/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
diff --git a/keyboards/geekboards/tester/config.h b/keyboards/geekboards/tester/config.h
index 4f072c0ee..3e3daccd5 100644
--- a/keyboards/geekboards/tester/config.h
+++ b/keyboards/geekboards/tester/config.h
@@ -24,7 +24,7 @@
24#define DEBOUNCE 3 24#define DEBOUNCE 3
25#ifdef RGB_MATRIX_ENABLE 25#ifdef RGB_MATRIX_ENABLE
26#define RGB_DISABLE_AFTER_TIMEOUT 0 26#define RGB_DISABLE_AFTER_TIMEOUT 0
27#define RGB_DISABLE_WHEN_USB_SUSPENDED true 27#define RGB_DISABLE_WHEN_USB_SUSPENDED
28#define RGB_MATRIX_KEYPRESSES 28#define RGB_MATRIX_KEYPRESSES
29#define DISABLE_RGB_MATRIX_SPLASH 29#define DISABLE_RGB_MATRIX_SPLASH
30#define DISABLE_RGB_MATRIX_MULTISPLASH 30#define DISABLE_RGB_MATRIX_MULTISPLASH
@@ -36,4 +36,4 @@
36#define DRIVER_1_LED_TOTAL 8 36#define DRIVER_1_LED_TOTAL 8
37#define DRIVER_2_LED_TOTAL 0 37#define DRIVER_2_LED_TOTAL 0
38#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) 38#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
39#endif \ No newline at end of file 39#endif
diff --git a/keyboards/gmmk/pro/config.h b/keyboards/gmmk/pro/config.h
index ab3c7a7a2..64062bece 100644
--- a/keyboards/gmmk/pro/config.h
+++ b/keyboards/gmmk/pro/config.h
@@ -46,3 +46,20 @@
46#define LOCKING_SUPPORT_ENABLE 46#define LOCKING_SUPPORT_ENABLE
47/* Locking resynchronize hack */ 47/* Locking resynchronize hack */
48#define LOCKING_RESYNC_ENABLE 48#define LOCKING_RESYNC_ENABLE
49
50/* SPI Config for LED Driver */
51#define SPI_DRIVER SPID1
52#define SPI_SCK_PIN A5
53#define SPI_MOSI_PIN A6
54#define SPI_MISO_PIN A7
55
56#define DRIVER_1_CS B13
57#define DRIVER_2_CS B14
58#define DRIVER_1_EN C13
59#define DRIVER_2_EN C13
60
61#define DRIVER_COUNT 2
62#define DRIVER_1_LED_TOTAL 66
63#define DRIVER_2_LED_TOTAL 32
64#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
65
diff --git a/keyboards/gmmk/pro/halconf.h b/keyboards/gmmk/pro/halconf.h
new file mode 100644
index 000000000..23ecb202a
--- /dev/null
+++ b/keyboards/gmmk/pro/halconf.h
@@ -0,0 +1,7 @@
1#pragma once
2
3#define HAL_USE_SPI TRUE
4#define SPI_USE_WAIT TRUE
5#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
6
7#include_next <halconf.h>
diff --git a/keyboards/gmmk/pro/mcuconf.h b/keyboards/gmmk/pro/mcuconf.h
new file mode 100644
index 000000000..bb1c0acde
--- /dev/null
+++ b/keyboards/gmmk/pro/mcuconf.h
@@ -0,0 +1,6 @@
1#pragma once
2
3#include_next <mcuconf.h>
4
5#undef STM32_SPI_USE_SPI1
6#define STM32_SPI_USE_SPI1 TRUE
diff --git a/keyboards/gmmk/pro/pro.c b/keyboards/gmmk/pro/pro.c
index 816d089a5..9ed7ac886 100644
--- a/keyboards/gmmk/pro/pro.c
+++ b/keyboards/gmmk/pro/pro.c
@@ -14,3 +14,225 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16#include "pro.h" 16#include "pro.h"
17
18#ifdef RGB_MATRIX_ENABLE
19led_config_t g_led_config = { {
20 { 4, NO_LED, NO_LED, 95, 65, 79, 5, 28 },
21 { 8, 2, 9, 0, 10, 75, 1, 7 },
22 { 14, 3, 15, NO_LED, 16, 86, 6, 13 },
23 { 20, 18, 21, 23, 22, 94, 12, 19 },
24 { 25, 30, 26, 31, 27, 32, 29, 24 },
25 { 41, 36, 42, 37, 43, 38, 35, 40 },
26 { 46, 89, 47, 34, 48, 72, 78, 45 },
27 { 52, 39, 53, 97, 54, 82, 44, 51 },
28 { 58, 63, 59, 64, NO_LED, 60, 62, 57 },
29 { 11, 90, 55, 17, 33, 49, NO_LED, 69 },
30 { NO_LED, 85, 93, 61, 96, 66, 50, 56 }
31}, {
32 { 0, 0 }, // 0, ESC, k13
33 { 0, 15 }, // 1, ~, k16
34 { 4, 26 }, // 2, Tab, k11
35 { 5, 38 }, // 3, Caps, k21
36 { 9, 49 }, // 4, Sh_L, k00
37 { 2, 61 }, // 5, Ct_L, k06
38 { 18, 0 }, // 6, F1, k26
39 { 14, 15 }, // 7, 1, k17
40 { 22, 26 }, // 8, Q, k10
41 { 25, 38 }, // 9, A, k12
42 { 33, 49 }, // 10, Z, k14
43 { 20, 61 }, // 11, Win_L, k90
44 { 33, 0 }, // 12, F2, k36
45 { 29, 15 }, // 13, 2, k27
46 { 36, 26 }, // 14, W, k20
47 { 40, 38 }, // 15, S, k22
48 { 47, 49 }, // 16, X, k24
49 { 38, 61 }, // 17, Alt_L, k93
50 { 47, 0 }, // 18, F3, k31
51 { 43, 15 }, // 19, 3, k37
52 { 51, 26 }, // 20, E, k30
53 { 54, 38 }, // 21, D, k32
54 { 61, 49 }, // 22, C, k34
55 { 61, 0 }, // 23, F4, k33
56 { 58, 15 }, // 24, 4, k47
57 { 65, 26 }, // 25, R, k40
58 { 69, 38 }, // 26, F, k42
59 { 76, 49 }, // 27, V, k44
60 { 79, 0 }, // 28, F5, k07
61 { 72, 15 }, // 29, 5, k46
62 { 79, 26 }, // 30, T, k41
63 { 83, 38 }, // 31, G, k43
64 { 90, 49 }, // 32, B, k45
65 { 92, 61 }, // 33, SPACE, k94
66 { 94, 0 }, // 34, F6, k63
67 { 87, 15 }, // 35, 6, k56
68 { 94, 26 }, // 36, Y, k51
69 { 98, 38 }, // 37, H, k53
70 { 105, 49 }, // 38, N, k55
71 { 108, 0 }, // 39, F7, k71
72 { 101, 15 }, // 40, 7, k57
73 { 108, 26 }, // 41, U, k50
74 { 112, 38 }, // 42, J, k52
75 { 119, 49 }, // 43, M, k54
76 { 123, 0 }, // 44, F8, k76
77 { 116, 15 }, // 45, 8, k67
78 { 123, 26 }, // 46, I, k60
79 { 126, 38 }, // 47, K, k62
80 { 134, 49 }, // 48, ,, k64
81 { 145, 61 }, // 49, Alt_R, k95
82 { 141, 0 }, // 50, F9, ka6
83 { 130, 15 }, // 51, 9, k77
84 { 137, 26 }, // 52, O, k70
85 { 141, 38 }, // 53, L, k72
86 { 148, 49 }, // 54, ., k74
87 { 159, 61 }, // 55, FN, k92
88 { 155, 0 }, // 56, F10, ka7
89 { 145, 15 }, // 57, 0, k87
90 { 152, 26 }, // 58, P, k80
91 { 155, 38 }, // 59, ;, k82
92 { 163, 49 }, // 60, ?, k85
93 { 170, 0 }, // 61, F11, ka3
94 { 159, 15 }, // 62, -, k86
95 { 166, 26 }, // 63, [, k81
96 { 170, 38 }, // 64, ", k83
97 { 173, 61 }, // 65, Ct_R, k04
98 { 184, 0 }, // 66, F12, ka5
99 { 0, 8 }, // 67, LED, l01
100 { 224, 8 }, // 68, LED, l11
101 { 202, 0 }, // 69, Prt, k97
102 { 0, 15 }, // 70, LED, l02
103 { 224, 15 }, // 71, LED, l12
104 { 224, 15 }, // 72, Del, k65
105 { 0, 21 }, // 73, LED, l03
106 { 224, 21 }, // 74, LED, l13
107 { 224, 26 }, // 75, PgUp, k15
108 { 0, 28 }, // 76, LED, l04
109 { 224, 28 }, // 77, LED, l14
110 { 173, 15 }, // 78, =, k66
111 { 220, 64 }, // 79, Right, k05
112 { 0, 35 }, // 80, LED, l05
113 { 224, 35 }, // 81, LED, l15
114 { 224, 49 }, // 82, End, k75
115 { 0, 42 }, // 83, LED, l06
116 { 224, 42 }, // 84, LED, l16
117 { 195, 15 }, // 85, BSpc, ka1
118 { 224, 38 }, // 86, PgDn, k25
119 { 0, 48 }, // 87, LED, l07
120 { 224, 48 }, // 88, LED, l17
121 { 181, 26 }, // 89, ], k61
122 { 182, 49 }, // 90, Sh_R, k91
123 { 0, 55 }, // 91, LED, l08
124 { 224, 55 }, // 92, LED, l18
125 { 199, 26 }, // 93, \, ka2
126 { 206, 52 }, // 94, Up, k35
127 { 191, 64 }, // 95, Left, k03
128 { 193, 38 }, // 96, Enter, ka4
129 { 206, 64 } // 97, Down, k73
130}, {
131 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
132 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
133 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 2, 2, 4, 2, 2,
134 4, 2, 2, 4, 4, 2, 2, 4, 2, 2, 4, 4, 2, 2, 4, 4, 2, 2, 4, 4, 4, 4, 4
135} };
136
137const aw_led g_aw_leds[DRIVER_LED_TOTAL] = {
138 { 0, CS1_SW1, CS2_SW1, CS3_SW1 }, // 0, ESC, k13
139 { 0, CS4_SW1, CS5_SW1, CS6_SW1 }, // 1, ~, k16
140 { 0, CS7_SW1, CS8_SW1, CS9_SW1 }, // 2, Tab, k11
141 { 0, CS10_SW1, CS11_SW1, CS12_SW1 }, // 3, Caps, k21
142 { 0, CS13_SW1, CS14_SW1, CS15_SW1 }, // 4, Sh_L, k00
143 { 0, CS16_SW1, CS17_SW1, CS18_SW1 }, // 5, Ct_L, k06
144 { 0, CS1_SW2, CS2_SW2, CS3_SW2 }, // 6, F1, k26
145 { 0, CS4_SW2, CS5_SW2, CS6_SW2 }, // 7, 1, k17
146 { 0, CS7_SW2, CS8_SW2, CS9_SW2 }, // 8, Q, k10
147 { 0, CS10_SW2, CS11_SW2, CS12_SW2 }, // 9, A, k12
148 { 0, CS13_SW2, CS14_SW2, CS15_SW2 }, // 10, Z, k14
149 { 0, CS16_SW2, CS17_SW2, CS18_SW2 }, // 11, Win_L, k90
150 { 0, CS1_SW3, CS2_SW3, CS3_SW3 }, // 12, F2, k36
151 { 0, CS4_SW3, CS5_SW3, CS6_SW3 }, // 13, 2, k27
152 { 0, CS7_SW3, CS8_SW3, CS9_SW3 }, // 14, W, k20
153 { 0, CS10_SW3, CS11_SW3, CS12_SW3 }, // 15, S, k22
154 { 0, CS13_SW3, CS14_SW3, CS15_SW3 }, // 16, X, k24
155 { 0, CS16_SW3, CS17_SW3, CS18_SW3 }, // 17, Alt_L, k93
156 { 0, CS1_SW4, CS2_SW4, CS3_SW4 }, // 18, F3, k31
157 { 0, CS4_SW4, CS5_SW4, CS6_SW4 }, // 19, 3, k37
158 { 0, CS7_SW4, CS8_SW4, CS9_SW4 }, // 20, E, k30
159 { 0, CS10_SW4, CS11_SW4, CS12_SW4 }, // 21, D, k32
160 { 0, CS13_SW4, CS14_SW4, CS15_SW4 }, // 22, C, k34
161 { 0, CS1_SW5, CS2_SW5, CS3_SW5 }, // 23, F4, k33
162 { 0, CS4_SW5, CS5_SW5, CS6_SW5 }, // 24, 4, k47
163 { 0, CS7_SW5, CS8_SW5, CS9_SW5 }, // 25, R, k40
164 { 0, CS10_SW5, CS11_SW5, CS12_SW5 }, // 26, F, k42
165 { 0, CS13_SW5, CS14_SW5, CS15_SW5 }, // 27, V, k44
166 { 0, CS1_SW6, CS2_SW6, CS3_SW6 }, // 28, F5, k07
167 { 0, CS4_SW6, CS5_SW6, CS6_SW6 }, // 29, 5, k46
168 { 0, CS7_SW6, CS8_SW6, CS9_SW6 }, // 30, T, k41
169 { 0, CS10_SW6, CS11_SW6, CS12_SW6 }, // 31, G, k43
170 { 0, CS13_SW6, CS14_SW6, CS15_SW6 }, // 32, B, k45
171 { 0, CS16_SW6, CS17_SW6, CS18_SW6 }, // 33, SPACE, k94
172 { 0, CS1_SW7, CS2_SW7, CS3_SW7 }, // 34, F6, k63
173 { 0, CS4_SW7, CS5_SW7, CS6_SW7 }, // 35, 6, k56
174 { 0, CS7_SW7, CS8_SW7, CS9_SW7 }, // 36, Y, k51
175 { 0, CS10_SW7, CS11_SW7, CS12_SW7 }, // 37, H, k53
176 { 0, CS13_SW7, CS14_SW7, CS15_SW7 }, // 38, N, k55
177 { 0, CS1_SW8, CS2_SW8, CS3_SW8 }, // 39, F7, k71
178 { 0, CS4_SW8, CS5_SW8, CS6_SW8 }, // 40, 7, k57
179 { 0, CS7_SW8, CS8_SW8, CS9_SW8 }, // 41, U, k50
180 { 0, CS10_SW8, CS11_SW8, CS12_SW8 }, // 42, J, k52
181 { 0, CS13_SW8, CS14_SW8, CS15_SW8 }, // 43, M, k54
182 { 0, CS1_SW9, CS2_SW9, CS3_SW9 }, // 44, F8, k76
183 { 0, CS4_SW9, CS5_SW9, CS6_SW9 }, // 45, 8, k67
184 { 0, CS7_SW9, CS8_SW9, CS9_SW9 }, // 46, I, k60
185 { 0, CS10_SW9, CS11_SW9, CS12_SW9 }, // 47, K, k62
186 { 0, CS13_SW9, CS14_SW9, CS15_SW9 }, // 48, ,, k64
187 { 0, CS16_SW9, CS17_SW9, CS18_SW9 }, // 49, Alt_R, k95
188 { 0, CS1_SW10, CS2_SW10, CS3_SW10 }, // 50, F9, ka6
189 { 0, CS4_SW10, CS5_SW10, CS6_SW10 }, // 51, 9, k77
190 { 0, CS7_SW10, CS8_SW10, CS9_SW10 }, // 52, O, k70
191 { 0, CS10_SW10, CS11_SW10, CS12_SW10 }, // 53, L, k72
192 { 0, CS13_SW10, CS14_SW10, CS15_SW10 }, // 54, ., k74
193 { 0, CS16_SW10, CS17_SW10, CS18_SW10 }, // 55, FN, k92
194 { 0, CS1_SW11, CS2_SW11, CS3_SW11 }, // 56, F10, ka7
195 { 0, CS4_SW11, CS5_SW11, CS6_SW11 }, // 57, 0, k87
196 { 0, CS7_SW11, CS8_SW11, CS9_SW11 }, // 58, P, k80
197 { 0, CS10_SW11, CS11_SW11, CS12_SW11 }, // 59, ;, k82
198 { 0, CS13_SW11, CS14_SW11, CS15_SW11 }, // 60, ?, k85
199 { 0, CS1_SW12, CS2_SW12, CS3_SW12 }, // 61, F11, ka3
200 { 0, CS4_SW12, CS5_SW12, CS6_SW12 }, // 62, -, k86
201 { 0, CS7_SW12, CS8_SW12, CS9_SW12 }, // 63, [, k81
202 { 0, CS10_SW12, CS11_SW12, CS12_SW12 }, // 64, ", k83
203 { 0, CS16_SW12, CS17_SW12, CS18_SW12 }, // 65, Ct_R, k04
204
205 { 1, CS1_SW1, CS2_SW1, CS3_SW1 }, // 66, F12, ka5
206 { 1, CS13_SW1, CS14_SW1, CS15_SW1 }, // 67, LED, l01
207 { 1, CS16_SW1, CS17_SW1, CS18_SW1 }, // 68, LED, l11
208 { 1, CS4_SW2, CS5_SW2, CS6_SW2 }, // 69, Prt, k97
209 { 1, CS13_SW2, CS14_SW2, CS15_SW2 }, // 70, LED, l02
210 { 1, CS16_SW2, CS17_SW2, CS18_SW2 }, // 71, LED, l12
211 { 1, CS4_SW3, CS5_SW3, CS6_SW3 }, // 72, Del, k65
212 { 1, CS13_SW3, CS14_SW3, CS15_SW3 }, // 73, LED, l03
213 { 1, CS16_SW3, CS17_SW3, CS18_SW3 }, // 74, LED, l13
214 { 1, CS4_SW4, CS5_SW4, CS6_SW4 }, // 75, PgUp, k15
215 { 1, CS13_SW4, CS14_SW4, CS15_SW4 }, // 76, LED, l04
216 { 1, CS16_SW4, CS17_SW4, CS18_SW4 }, // 77, LED, l14
217 { 1, CS1_SW5, CS2_SW5, CS3_SW5 }, // 78, =, k66
218 { 1, CS10_SW5, CS11_SW5, CS12_SW5 }, // 79, Right, k05
219 { 1, CS13_SW5, CS14_SW5, CS15_SW5 }, // 80, LED, l05
220 { 1, CS16_SW5, CS17_SW5, CS18_SW5 }, // 81, LED, l15
221 { 1, CS4_SW6, CS5_SW6, CS6_SW6 }, // 82, End, k75
222 { 1, CS13_SW6, CS14_SW6, CS15_SW6 }, // 83, LED, l06
223 { 1, CS16_SW6, CS17_SW6, CS18_SW6 }, // 84, LED, l16
224 { 1, CS1_SW7, CS2_SW7, CS3_SW7 }, // 85, BSpc, ka1
225 { 1, CS4_SW7, CS5_SW7, CS6_SW7 }, // 86, PgDn, k25
226 { 1, CS13_SW7, CS14_SW7, CS15_SW7 }, // 87, LED, l07
227 { 1, CS16_SW7, CS17_SW7, CS18_SW7 }, // 88, LED, l17
228 { 1, CS1_SW8, CS2_SW8, CS3_SW8 }, // 89, ], k61
229 { 1, CS4_SW8, CS5_SW8, CS6_SW8 }, // 90, Sh_R, k91
230 { 1, CS13_SW8, CS14_SW8, CS15_SW8 }, // 91, LED, l08
231 { 1, CS16_SW8, CS17_SW8, CS18_SW8 }, // 92, LED, l18
232 { 1, CS1_SW9, CS2_SW9, CS3_SW9 }, // 93, \, ka2
233 { 1, CS4_SW9, CS5_SW9, CS6_SW9 }, // 94, Up, k35
234 { 1, CS4_SW10, CS5_SW10, CS6_SW10 }, // 95, Left, k03
235 { 1, CS1_SW11, CS2_SW11, CS3_SW11 }, // 96, Enter, ka4
236 { 1, CS4_SW11, CS5_SW11, CS6_SW11 }, // 97, Down, k73
237};
238#endif
diff --git a/keyboards/gmmk/pro/rules.mk b/keyboards/gmmk/pro/rules.mk
index b12d055a3..6221d6408 100644
--- a/keyboards/gmmk/pro/rules.mk
+++ b/keyboards/gmmk/pro/rules.mk
@@ -21,3 +21,5 @@ RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
21BLUETOOTH_ENABLE = no # Enable Bluetooth 21BLUETOOTH_ENABLE = no # Enable Bluetooth
22AUDIO_ENABLE = no # Audio output 22AUDIO_ENABLE = no # Audio output
23ENCODER_ENABLE = yes 23ENCODER_ENABLE = yes
24RGB_MATRIX_ENABLE = yes
25RGB_MATRIX_DRIVER = AW20216
diff --git a/keyboards/handwired/colorlice/config.h b/keyboards/handwired/colorlice/config.h
index 206a4004e..0148817f3 100644
--- a/keyboards/handwired/colorlice/config.h
+++ b/keyboards/handwired/colorlice/config.h
@@ -49,7 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
49/* RGB LEDs */ 49/* RGB LEDs */
50#define RGB_DI_PIN B1 50#define RGB_DI_PIN B1
51#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 51#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
52#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 52#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
53#define RGB_MATRIX_KEYPRESSES 53#define RGB_MATRIX_KEYPRESSES
54#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 54#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
55#define RGB_MATRIX_LED_PROCESS_LIMIT 4 55#define RGB_MATRIX_LED_PROCESS_LIMIT 4
diff --git a/keyboards/handwired/frankie_macropad/keymaps/default/config.h b/keyboards/handwired/frankie_macropad/keymaps/default/config.h
new file mode 100644
index 000000000..dd687cad5
--- /dev/null
+++ b/keyboards/handwired/frankie_macropad/keymaps/default/config.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#define LAYER_STATE_8BIT
diff --git a/keyboards/handwired/hnah40rgb/config.h b/keyboards/handwired/hnah40rgb/config.h
index e6271738c..3d558f97f 100644
--- a/keyboards/handwired/hnah40rgb/config.h
+++ b/keyboards/handwired/hnah40rgb/config.h
@@ -60,7 +60,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 60#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
61#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 61#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
62#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 62#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
63#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 63// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
64#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) 64#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)
65#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 65#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
66#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set 66#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set
diff --git a/keyboards/handwired/p65rgb/config.h b/keyboards/handwired/p65rgb/config.h
index c50fc2826..142d3c03e 100644
--- a/keyboards/handwired/p65rgb/config.h
+++ b/keyboards/handwired/p65rgb/config.h
@@ -40,7 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
40 40
41#define RGB_DI_PIN B4 41#define RGB_DI_PIN B4
42#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 42#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
43#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 43#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
44#define RGB_MATRIX_KEYPRESSES 44#define RGB_MATRIX_KEYPRESSES
45#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 45#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
46#define RGB_MATRIX_LED_PROCESS_LIMIT 4 46#define RGB_MATRIX_LED_PROCESS_LIMIT 4
diff --git a/keyboards/helix/rev3_4rows/config.h b/keyboards/helix/rev3_4rows/config.h
index 9102104bf..95eb8bf0c 100644
--- a/keyboards/helix/rev3_4rows/config.h
+++ b/keyboards/helix/rev3_4rows/config.h
@@ -68,7 +68,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
68# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 68# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
69// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 69// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
70// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 70// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
71# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 71# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
72# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 72# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
73// # 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) 73// # 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)
74// # 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) 74// # 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)
diff --git a/keyboards/helix/rev3_5rows/config.h b/keyboards/helix/rev3_5rows/config.h
index 4dda76206..a373de7d1 100644
--- a/keyboards/helix/rev3_5rows/config.h
+++ b/keyboards/helix/rev3_5rows/config.h
@@ -68,7 +68,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
68# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 68# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
69// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 69// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
70// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 70// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
71# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 71# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
72# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 72# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
73// # 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) 73// # 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)
74// # 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) 74// # 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)
diff --git a/keyboards/hs60/v1/config.h b/keyboards/hs60/v1/config.h
index 68c75b2af..41246b6ee 100644
--- a/keyboards/hs60/v1/config.h
+++ b/keyboards/hs60/v1/config.h
@@ -118,7 +118,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
118//#define RGB_MATRIX_KEYPRESSES // reacts to keypresses (will slow down matrix scan by a lot) 118//#define RGB_MATRIX_KEYPRESSES // reacts to keypresses (will slow down matrix scan by a lot)
119 119
120#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 120#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
121#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 121// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
122#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 215 122#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 215
123 123
124#define DRIVER_ADDR_1 0b1110100 124#define DRIVER_ADDR_1 0b1110100
diff --git a/keyboards/kbdfans/bella/rgb/config.h b/keyboards/kbdfans/bella/rgb/config.h
index f56049690..07594a34a 100644
--- a/keyboards/kbdfans/bella/rgb/config.h
+++ b/keyboards/kbdfans/bella/rgb/config.h
@@ -37,7 +37,7 @@
37/* disable these deprecated features by default */ 37/* disable these deprecated features by default */
38#ifdef RGB_MATRIX_ENABLE 38#ifdef RGB_MATRIX_ENABLE
39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41#define RGB_MATRIX_KEYPRESSES 41#define RGB_MATRIX_KEYPRESSES
42#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 42#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
43#define RGB_MATRIX_LED_PROCESS_LIMIT 4 43#define RGB_MATRIX_LED_PROCESS_LIMIT 4
diff --git a/keyboards/kbdfans/bella/rgb_iso/config.h b/keyboards/kbdfans/bella/rgb_iso/config.h
index fc7a9d7c0..4fda99867 100644
--- a/keyboards/kbdfans/bella/rgb_iso/config.h
+++ b/keyboards/kbdfans/bella/rgb_iso/config.h
@@ -37,7 +37,7 @@
37/* disable these deprecated features by default */ 37/* disable these deprecated features by default */
38#ifdef RGB_MATRIX_ENABLE 38#ifdef RGB_MATRIX_ENABLE
39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41#define RGB_MATRIX_KEYPRESSES 41#define RGB_MATRIX_KEYPRESSES
42#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 42#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
43#define RGB_MATRIX_LED_PROCESS_LIMIT 4 43#define RGB_MATRIX_LED_PROCESS_LIMIT 4
diff --git a/keyboards/kbdfans/kbd67/mkiirgb/v1/config.h b/keyboards/kbdfans/kbd67/mkiirgb/v1/config.h
index a832110d3..b0b7e1dad 100644
--- a/keyboards/kbdfans/kbd67/mkiirgb/v1/config.h
+++ b/keyboards/kbdfans/kbd67/mkiirgb/v1/config.h
@@ -16,9 +16,9 @@
16#define RGB_MATRIX_LED_FLUSH_LIMIT 26 16#define RGB_MATRIX_LED_FLUSH_LIMIT 26
17#define DEBOUNCE 3 17#define DEBOUNCE 3
18#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 18#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
19#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 19#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
20#define RGB_MATRIX_KEYPRESSES 20#define RGB_MATRIX_KEYPRESSES
21#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 21#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
22#define DISABLE_RGB_MATRIX_BAND_SAT 22#define DISABLE_RGB_MATRIX_BAND_SAT
23#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT 23#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
24#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT 24#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT
diff --git a/keyboards/kbdfans/kbd67/mkiirgb/v2/config.h b/keyboards/kbdfans/kbd67/mkiirgb/v2/config.h
index 1ac9c770d..51e732f10 100644
--- a/keyboards/kbdfans/kbd67/mkiirgb/v2/config.h
+++ b/keyboards/kbdfans/kbd67/mkiirgb/v2/config.h
@@ -16,10 +16,10 @@
16#define RGB_MATRIX_LED_FLUSH_LIMIT 26 16#define RGB_MATRIX_LED_FLUSH_LIMIT 26
17#define DEBOUNCE 3 17#define DEBOUNCE 3
18#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 18#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
19#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 19#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
20#define RGB_MATRIX_KEYPRESSES 20#define RGB_MATRIX_KEYPRESSES
21#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_ALL 21#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_ALL
22#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 22#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
23#define DISABLE_RGB_MATRIX_BAND_SAT 23#define DISABLE_RGB_MATRIX_BAND_SAT
24#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT 24#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
25#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT 25#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT
diff --git a/keyboards/kbdfans/kbd67/rev1/keymaps/default/config.h b/keyboards/kbdfans/kbd67/rev1/keymaps/default/config.h
index a3ed4f762..90fb10ebb 100644
--- a/keyboards/kbdfans/kbd67/rev1/keymaps/default/config.h
+++ b/keyboards/kbdfans/kbd67/rev1/keymaps/default/config.h
@@ -16,4 +16,4 @@
16 16
17#pragma once 17#pragma once
18 18
19// place overrides here 19#define LAYER_STATE_8BIT
diff --git a/keyboards/kbdfans/kbdmini/config.h b/keyboards/kbdfans/kbdmini/config.h
index 5a36e983d..fc65f4341 100644
--- a/keyboards/kbdfans/kbdmini/config.h
+++ b/keyboards/kbdfans/kbdmini/config.h
@@ -35,7 +35,7 @@
35 35
36#ifdef RGB_MATRIX_ENABLE 36#ifdef RGB_MATRIX_ENABLE
37#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 37#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
38#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 38#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
39#define RGB_MATRIX_KEYPRESSES 39#define RGB_MATRIX_KEYPRESSES
40#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 40#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
41#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 41#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/keyboards/kbdfans/maja/config.h b/keyboards/kbdfans/maja/config.h
index d8553766b..3722c8381 100755
--- a/keyboards/kbdfans/maja/config.h
+++ b/keyboards/kbdfans/maja/config.h
@@ -18,9 +18,9 @@
18#define RGB_MATRIX_LED_FLUSH_LIMIT 26 18#define RGB_MATRIX_LED_FLUSH_LIMIT 26
19#define DEBOUNCE 3 19#define DEBOUNCE 3
20#define RGB_DISABLE_AFTER_TIMEOUT 0 20#define RGB_DISABLE_AFTER_TIMEOUT 0
21#define RGB_DISABLE_WHEN_USB_SUSPENDED true 21#define RGB_DISABLE_WHEN_USB_SUSPENDED
22#define RGB_MATRIX_KEYPRESSES 22#define RGB_MATRIX_KEYPRESSES
23#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 23#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
24#define DISABLE_RGB_MATRIX_BAND_SAT 24#define DISABLE_RGB_MATRIX_BAND_SAT
25#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT 25#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
26#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT 26#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT
diff --git a/keyboards/latin17rgb/config.h b/keyboards/latin17rgb/config.h
index 013899f60..6a7ea8e78 100644
--- a/keyboards/latin17rgb/config.h
+++ b/keyboards/latin17rgb/config.h
@@ -1,18 +1,18 @@
1 /* Copyright 2021 18438880 1 /* Copyright 2021 18438880
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#pragma once 17#pragma once
18 18
@@ -56,7 +56,7 @@
56 56
57#ifdef RGB_MATRIX_ENABLE 57#ifdef RGB_MATRIX_ENABLE
58# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 58# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
59# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 59# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
60# define RGB_MATRIX_KEYPRESSES 60# define RGB_MATRIX_KEYPRESSES
61# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 61# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
62# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 62# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
@@ -100,5 +100,3 @@
100#define RGBLIGHT_VAL_STEP 5 100#define RGBLIGHT_VAL_STEP 5
101#define RGBLIGHT_SLEEP 101#define RGBLIGHT_SLEEP
102#endif 102#endif
103
104
diff --git a/keyboards/latin60rgb/config.h b/keyboards/latin60rgb/config.h
index bbe502054..97b481291 100644
--- a/keyboards/latin60rgb/config.h
+++ b/keyboards/latin60rgb/config.h
@@ -1,18 +1,18 @@
1 /* Copyright 2021 latincompass 1 /* Copyright 2021 latincompass
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16#pragma once 16#pragma once
17 17
18/* USB Device descriptor parameter */ 18/* USB Device descriptor parameter */
@@ -53,7 +53,7 @@
53 53
54#ifdef RGB_MATRIX_ENABLE 54#ifdef RGB_MATRIX_ENABLE
55# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 55# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
56# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 56# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
57# define RGB_MATRIX_KEYPRESSES 57# define RGB_MATRIX_KEYPRESSES
58# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 58# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
59# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 59# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
@@ -77,4 +77,3 @@
77# define DRIVER_1_LED_TOTAL 60 77# define DRIVER_1_LED_TOTAL 60
78# define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL 78# define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL
79#endif 79#endif
80
diff --git a/keyboards/le_chiffre/config.h b/keyboards/le_chiffre/config.h
index e14b4665f..af4d1e49c 100644
--- a/keyboards/le_chiffre/config.h
+++ b/keyboards/le_chiffre/config.h
@@ -69,7 +69,7 @@
69 69
70#ifdef RGB_MATRIX_ENABLE 70#ifdef RGB_MATRIX_ENABLE
71#define RGB_MATRIX_KEYPRESSES // reacts to keypresses 71#define RGB_MATRIX_KEYPRESSES // reacts to keypresses
72#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 72#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
73#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 73#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
74#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. 74#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
75#define RGB_MATRIX_HUE_STEP 8 75#define RGB_MATRIX_HUE_STEP 8
diff --git a/keyboards/marksard/rhymestone/rev1/config.h b/keyboards/marksard/rhymestone/rev1/config.h
index 9a1bf0a1d..983392511 100644
--- a/keyboards/marksard/rhymestone/rev1/config.h
+++ b/keyboards/marksard/rhymestone/rev1/config.h
@@ -93,7 +93,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
93 #define RGB_MATRIX_KEYPRESSES // reacts to keypresses 93 #define RGB_MATRIX_KEYPRESSES // reacts to keypresses
94 // #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 94 // #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
95 // #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 95 // #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
96 #define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 96 #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
97 // #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) 97 // #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)
98 // #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) 98 // #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)
99 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 99 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
diff --git a/keyboards/massdrop/alt/keymaps/pregame/config.h b/keyboards/massdrop/alt/keymaps/pregame/config.h
index acd041ce1..32dee56d3 100644
--- a/keyboards/massdrop/alt/keymaps/pregame/config.h
+++ b/keyboards/massdrop/alt/keymaps/pregame/config.h
@@ -89,7 +89,7 @@
89// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation 89// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation
90// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness) 90// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness)
91// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 91// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
92// #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 92// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
93// #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) 93// #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)
94// #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) 94// #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)
95#define RGBLIGHT_ANIMATIONS // Run RGB animations 95#define RGBLIGHT_ANIMATIONS // Run RGB animations
@@ -103,7 +103,7 @@
103// #define RGBLIGHT_EFFECT_RGB_TEST // Enable RGB test animation mode. 103// #define RGBLIGHT_EFFECT_RGB_TEST // Enable RGB test animation mode.
104// #define RGBLIGHT_EFFECT_SNAKE // Enable snake animation mode. 104// #define RGBLIGHT_EFFECT_SNAKE // Enable snake animation mode.
105// #define RGBLIGHT_EFFECT_STATIC_GRADIENT // Enable static gradient mode. 105// #define RGBLIGHT_EFFECT_STATIC_GRADIENT // Enable static gradient mode.
106 106
107// #define RGBLIGHT_EFFECT_BREATHE_CENTER // If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 107// #define RGBLIGHT_EFFECT_BREATHE_CENTER // If defined, used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7
108// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // The maximum brightness for the breathing mode. Valid values are 1 to 255 108// #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // The maximum brightness for the breathing mode. Valid values are 1 to 255
109// #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 // How long to wait between light changes for the "Christmas" animation, in milliseconds 109// #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 // How long to wait between light changes for the "Christmas" animation, in milliseconds
diff --git a/keyboards/massdrop/alt/keymaps/urbanvanilla/config.h b/keyboards/massdrop/alt/keymaps/urbanvanilla/config.h
index 0f2740013..f2a7e5038 100644
--- a/keyboards/massdrop/alt/keymaps/urbanvanilla/config.h
+++ b/keyboards/massdrop/alt/keymaps/urbanvanilla/config.h
@@ -24,4 +24,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#define RGB_MATRIX_LED_PROCESS_LIMIT 15 24#define RGB_MATRIX_LED_PROCESS_LIMIT 15
25#define RGB_MATRIX_LED_FLUSH_LIMIT 10 25#define RGB_MATRIX_LED_FLUSH_LIMIT 10
26 26
27#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 27// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
diff --git a/keyboards/massdrop/ctrl/keymaps/endgame/config.h b/keyboards/massdrop/ctrl/keymaps/endgame/config.h
index 0ef485591..ad738347a 100644
--- a/keyboards/massdrop/ctrl/keymaps/endgame/config.h
+++ b/keyboards/massdrop/ctrl/keymaps/endgame/config.h
@@ -49,7 +49,7 @@
49// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation 49// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation
50// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness) 50// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness)
51// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 51// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
52// #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 52// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
53// #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) 53// #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)
54// #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) 54// #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)
55// #define RGBLIGHT_ANIMATIONS // Run RGB animations 55// #define RGBLIGHT_ANIMATIONS // Run RGB animations
diff --git a/keyboards/massdrop/ctrl/keymaps/matthewrobo/config.h b/keyboards/massdrop/ctrl/keymaps/matthewrobo/config.h
index 6e16c3a5f..89c129c58 100644
--- a/keyboards/massdrop/ctrl/keymaps/matthewrobo/config.h
+++ b/keyboards/massdrop/ctrl/keymaps/matthewrobo/config.h
@@ -67,7 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
67// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation 67// #define RGBLIGHT_SAT_STEP 25 // Units to step when in/decreasing saturation
68// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness) 68// #define RGBLIGHT_VAL_STEP 12 // Units to step when in/decreasing value (brightness)
69// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 69// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
70// #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 70// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
71// #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) 71// #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)
72// #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) 72// #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)
73// #define RGBLIGHT_ANIMATIONS // Run RGB animations 73// #define RGBLIGHT_ANIMATIONS // Run RGB animations
diff --git a/keyboards/mechlovin/adelais/rgb_led/rev1/config.h b/keyboards/mechlovin/adelais/rgb_led/rev1/config.h
index 1ba7d27df..d75cbd3f2 100644
--- a/keyboards/mechlovin/adelais/rgb_led/rev1/config.h
+++ b/keyboards/mechlovin/adelais/rgb_led/rev1/config.h
@@ -13,7 +13,7 @@
13#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 13#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
14#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 14#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
15#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 15#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
16#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 16// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
17#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) 17#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)
18#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 220 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 18#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 220 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
19#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set \ No newline at end of file 19#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set
diff --git a/keyboards/mechlovin/adelais/rgb_led/rev2/config.h b/keyboards/mechlovin/adelais/rgb_led/rev2/config.h
index 38ffdd40a..c830edce2 100644
--- a/keyboards/mechlovin/adelais/rgb_led/rev2/config.h
+++ b/keyboards/mechlovin/adelais/rgb_led/rev2/config.h
@@ -1,7 +1,7 @@
1#pragma once 1#pragma once
2 2
3#define PRODUCT_ID 0xAEC2 3#define PRODUCT_ID 0xAEC2
4#define PRODUCT Adelais En Ciel Rev2 4#define PRODUCT Adelais En Ciel Rev2
5 5
6#define MATRIX_ROW_PINS { B1, A0, C13, A1, A2} 6#define MATRIX_ROW_PINS { B1, A0, C13, A1, A2}
7#define MATRIX_COL_PINS { A10, A9, A8, B15, B14, B13, B12, B11, B10, B8, B4, B5, B3, C14, A7 } 7#define MATRIX_COL_PINS { A10, A9, A8, B15, B14, B13, B12, B11, B10, B8, B4, B5, B3, C14, A7 }
@@ -31,7 +31,7 @@
31#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 31#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
32#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 32#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
33#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 33#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
34#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 34// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
35#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) 35#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)
36#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 36#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
37#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set 37#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set
@@ -42,4 +42,4 @@
42#define ENCODERS_PAD_B { A3 } 42#define ENCODERS_PAD_B { A3 }
43#define ENCODER_RESOLUTION 4 43#define ENCODER_RESOLUTION 4
44 44
45#define TAP_CODE_DELAY 10 \ No newline at end of file 45#define TAP_CODE_DELAY 10
diff --git a/keyboards/mechlovin/delphine/rgb_led/config.h b/keyboards/mechlovin/delphine/rgb_led/config.h
index 4d5c853d0..9a653d759 100644
--- a/keyboards/mechlovin/delphine/rgb_led/config.h
+++ b/keyboards/mechlovin/delphine/rgb_led/config.h
@@ -24,7 +24,7 @@
24// #define RGBLIGHT_EFFECT_RGB_TEST 24// #define RGBLIGHT_EFFECT_RGB_TEST
25// #define RGBLIGHT_EFFECT_ALTERNATING 25// #define RGBLIGHT_EFFECT_ALTERNATING
26#endif 26#endif
27 27
28//rgb matrix setting// This is a 7-bit address, that gets left-shifted and bit 0 28//rgb matrix setting// This is a 7-bit address, that gets left-shifted and bit 0
29// set to 0 for write, 1 for read (as per I2C protocol) 29// set to 0 for write, 1 for read (as per I2C protocol)
30// The address will vary depending on your wiring: 30// The address will vary depending on your wiring:
@@ -41,7 +41,7 @@
41#define RGB_MATRIX_KEYPRESSES // reacts to keypresses 41#define RGB_MATRIX_KEYPRESSES // reacts to keypresses
42#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 42#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
43#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 43#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
44#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 44// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
45#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) 45#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)
46#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 46#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
47#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set 47#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set
diff --git a/keyboards/mechlovin/hannah60rgb/rev1/config.h b/keyboards/mechlovin/hannah60rgb/rev1/config.h
index 20873e716..fd45ecca6 100644
--- a/keyboards/mechlovin/hannah60rgb/rev1/config.h
+++ b/keyboards/mechlovin/hannah60rgb/rev1/config.h
@@ -11,8 +11,8 @@
11# define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 11# define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
12# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 12# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
13# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 13# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
14# define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 14// # define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
15# 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) 15# 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)
16# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 16# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
17# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set 17# define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set
18#endif \ No newline at end of file 18#endif
diff --git a/keyboards/mechlovin/hannah60rgb/rev2/config.h b/keyboards/mechlovin/hannah60rgb/rev2/config.h
index 2bcffbc85..5e57f985d 100644
--- a/keyboards/mechlovin/hannah60rgb/rev2/config.h
+++ b/keyboards/mechlovin/hannah60rgb/rev2/config.h
@@ -30,11 +30,11 @@
30#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 30#define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
31#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 31#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
32#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 32#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
33#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 33// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
34#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) 34#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)
35#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 35#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
36#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set 36#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_PINWHEEL // Sets the default mode, if none has been set
37 37
38#if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE) 38#if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE)
39# define RGB_MATRIX_DISABLE_KEYCODES 39# define RGB_MATRIX_DISABLE_KEYCODES
40#endif \ No newline at end of file 40#endif
diff --git a/keyboards/mechlovin/infinity87/rgb_rev1/config.h b/keyboards/mechlovin/infinity87/rgb_rev1/config.h
index 0c16c684c..76c6e0db7 100644
--- a/keyboards/mechlovin/infinity87/rgb_rev1/config.h
+++ b/keyboards/mechlovin/infinity87/rgb_rev1/config.h
@@ -35,7 +35,7 @@
35// 0b0110001 AD <-> SCL 35// 0b0110001 AD <-> SCL
36// 0b0110010 AD <-> SDA 36// 0b0110010 AD <-> SDA
37#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 37#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
38#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 38#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
39#define RGB_MATRIX_KEYPRESSES 39#define RGB_MATRIX_KEYPRESSES
40#define DISABLE_RGB_MATRIX_SPLASH 40#define DISABLE_RGB_MATRIX_SPLASH
41#define DISABLE_RGB_MATRIX_MULTISPLASH 41#define DISABLE_RGB_MATRIX_MULTISPLASH
diff --git a/keyboards/melgeek/mj61/config.h b/keyboards/melgeek/mj61/config.h
index 164c04fb5..6ba19dd75 100644
--- a/keyboards/melgeek/mj61/config.h
+++ b/keyboards/melgeek/mj61/config.h
@@ -37,7 +37,7 @@
37#define NO_ACTION_FUNCTION 37#define NO_ACTION_FUNCTION
38 38
39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41#define RGB_MATRIX_KEYPRESSES 41#define RGB_MATRIX_KEYPRESSES
42#define RGB_MATRIX_LED_PROCESS_LIMIT 4 42#define RGB_MATRIX_LED_PROCESS_LIMIT 4
43#define RGB_MATRIX_LED_FLUSH_LIMIT 26 43#define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/melgeek/mj63/config.h b/keyboards/melgeek/mj63/config.h
index 47ad2f96c..46d3b0fb7 100644
--- a/keyboards/melgeek/mj63/config.h
+++ b/keyboards/melgeek/mj63/config.h
@@ -37,7 +37,7 @@
37#define NO_ACTION_FUNCTION 37#define NO_ACTION_FUNCTION
38 38
39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41#define RGB_MATRIX_KEYPRESSES 41#define RGB_MATRIX_KEYPRESSES
42#define RGB_MATRIX_LED_PROCESS_LIMIT 4 42#define RGB_MATRIX_LED_PROCESS_LIMIT 4
43#define RGB_MATRIX_LED_FLUSH_LIMIT 26 43#define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/melgeek/mj64/config.h b/keyboards/melgeek/mj64/config.h
index 29cb95f17..920d34acd 100644
--- a/keyboards/melgeek/mj64/config.h
+++ b/keyboards/melgeek/mj64/config.h
@@ -37,7 +37,7 @@
37#define NO_ACTION_FUNCTION 37#define NO_ACTION_FUNCTION
38 38
39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41#define RGB_MATRIX_KEYPRESSES 41#define RGB_MATRIX_KEYPRESSES
42#define RGB_MATRIX_LED_PROCESS_LIMIT 4 42#define RGB_MATRIX_LED_PROCESS_LIMIT 4
43#define RGB_MATRIX_LED_FLUSH_LIMIT 26 43#define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/melgeek/mj65/config.h b/keyboards/melgeek/mj65/config.h
index 12a7c7ce1..399c243ac 100644
--- a/keyboards/melgeek/mj65/config.h
+++ b/keyboards/melgeek/mj65/config.h
@@ -37,7 +37,7 @@
37#define NO_ACTION_FUNCTION 37#define NO_ACTION_FUNCTION
38 38
39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41#define RGB_MATRIX_KEYPRESSES 41#define RGB_MATRIX_KEYPRESSES
42#define RGB_MATRIX_LED_PROCESS_LIMIT 4 42#define RGB_MATRIX_LED_PROCESS_LIMIT 4
43#define RGB_MATRIX_LED_FLUSH_LIMIT 26 43#define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/melgeek/mojo75/config.h b/keyboards/melgeek/mojo75/config.h
index c1a8083f1..d5bb4b454 100644
--- a/keyboards/melgeek/mojo75/config.h
+++ b/keyboards/melgeek/mojo75/config.h
@@ -37,7 +37,7 @@
37#define NO_ACTION_FUNCTION 37#define NO_ACTION_FUNCTION
38 38
39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 39#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
40#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41#define RGB_MATRIX_KEYPRESSES 41#define RGB_MATRIX_KEYPRESSES
42#define RGB_MATRIX_LED_PROCESS_LIMIT 4 42#define RGB_MATRIX_LED_PROCESS_LIMIT 4
43#define RGB_MATRIX_LED_FLUSH_LIMIT 26 43#define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/melgeek/z70ultra/config.h b/keyboards/melgeek/z70ultra/config.h
index d5a9d0a89..e4530e2ea 100644
--- a/keyboards/melgeek/z70ultra/config.h
+++ b/keyboards/melgeek/z70ultra/config.h
@@ -36,7 +36,7 @@
36#define NO_ACTION_FUNCTION 36#define NO_ACTION_FUNCTION
37 37
38#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 38#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
39#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 39#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
40#define RGB_MATRIX_KEYPRESSES 40#define RGB_MATRIX_KEYPRESSES
41#define RGB_MATRIX_LED_PROCESS_LIMIT 4 41#define RGB_MATRIX_LED_PROCESS_LIMIT 4
42#define RGB_MATRIX_LED_FLUSH_LIMIT 26 42#define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/miller/gm862/config.h b/keyboards/miller/gm862/config.h
index 2b084efc2..e6e1b4c1d 100644
--- a/keyboards/miller/gm862/config.h
+++ b/keyboards/miller/gm862/config.h
@@ -36,10 +36,10 @@
36#define DEBOUNCE 3 36#define DEBOUNCE 3
37#ifdef RGB_MATRIX_ENABLE 37#ifdef RGB_MATRIX_ENABLE
38# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 38# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
39# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 39# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
40# define RGB_MATRIX_KEYPRESSES 40# define RGB_MATRIX_KEYPRESSES
41# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 41# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
42# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 42# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
43# define DISABLE_RGB_MATRIX_BAND_SAT 43# define DISABLE_RGB_MATRIX_BAND_SAT
44# define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT 44# define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
45# define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT 45# define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT
diff --git a/keyboards/monstargear/xo87/rgb/config.h b/keyboards/monstargear/xo87/rgb/config.h
index 83eee8349..5ed0ed445 100644
--- a/keyboards/monstargear/xo87/rgb/config.h
+++ b/keyboards/monstargear/xo87/rgb/config.h
@@ -36,7 +36,7 @@
36#define DIODE_DIRECTION ROW2COL 36#define DIODE_DIRECTION ROW2COL
37#define RGB_DI_PIN D7 37#define RGB_DI_PIN D7
38#define DRIVER_LED_TOTAL 110 38#define DRIVER_LED_TOTAL 110
39#define RGB_DISABLE_WHEN_USB_SUSPENDED true 39#define RGB_DISABLE_WHEN_USB_SUSPENDED
40 40
41#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 100 // limits maximum brightness of LEDs to 100 out of 255. 41#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 100 // limits maximum brightness of LEDs to 100 out of 255.
42#define RGBLIGHT_LIMIT_VAL 100 // limits maximum brightness of LEDs to 100 out of 255. 42#define RGBLIGHT_LIMIT_VAL 100 // limits maximum brightness of LEDs to 100 out of 255.
diff --git a/keyboards/moonlander/config.h b/keyboards/moonlander/config.h
index c88feea3d..c1a139dc7 100644
--- a/keyboards/moonlander/config.h
+++ b/keyboards/moonlander/config.h
@@ -91,7 +91,7 @@
91#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175 91#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 175
92#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 92#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
93#define RGB_MATRIX_KEYPRESSES 93#define RGB_MATRIX_KEYPRESSES
94#define RGB_DISABLE_WHEN_USB_SUSPENDED true 94#define RGB_DISABLE_WHEN_USB_SUSPENDED
95 95
96#define MUSIC_MAP 96#define MUSIC_MAP
97 97
diff --git a/keyboards/mt84/keymaps/default/config.h b/keyboards/mt84/keymaps/default/config.h
new file mode 100644
index 000000000..dd687cad5
--- /dev/null
+++ b/keyboards/mt84/keymaps/default/config.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#define LAYER_STATE_8BIT
diff --git a/keyboards/naked48/keymaps/salicylic/config.h b/keyboards/naked48/keymaps/salicylic/config.h
index b6372db3b..71a43e208 100644
--- a/keyboards/naked48/keymaps/salicylic/config.h
+++ b/keyboards/naked48/keymaps/salicylic/config.h
@@ -31,7 +31,7 @@
31# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 31# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
32// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 32// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
33// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 33// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
34# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 34# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
35// # 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) 35// # 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)
36// # 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) 36// # 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)
37// # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 37// # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
@@ -41,4 +41,3 @@
41# define RGB_MATRIX_VAL_STEP 5 41# define RGB_MATRIX_VAL_STEP 5
42# define RGB_MATRIX_SPD_STEP 10 42# define RGB_MATRIX_SPD_STEP 10
43#endif 43#endif
44
diff --git a/keyboards/opendeck/32/rev1/config.h b/keyboards/opendeck/32/rev1/config.h
index 9f8ed7427..8b25ab256 100644
--- a/keyboards/opendeck/32/rev1/config.h
+++ b/keyboards/opendeck/32/rev1/config.h
@@ -38,7 +38,7 @@
38#define DRIVER_COUNT 1 38#define DRIVER_COUNT 1
39#define DRIVER_1_LED_TOTAL (4 * 8 * 3) 39#define DRIVER_1_LED_TOTAL (4 * 8 * 3)
40#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL) 40#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL)
41#define RGB_DISABLE_WHEN_USB_SUSPENDED true 41#define RGB_DISABLE_WHEN_USB_SUSPENDED
42#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_SPIRAL 42#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_SPIRAL
43#define RGB_MATRIX_DISABLE_KEYCODES 43#define RGB_MATRIX_DISABLE_KEYCODES
44 44
diff --git a/keyboards/percent/canoe_gen2/config.h b/keyboards/percent/canoe_gen2/config.h
index bac5ebb3f..6409371d4 100644
--- a/keyboards/percent/canoe_gen2/config.h
+++ b/keyboards/percent/canoe_gen2/config.h
@@ -64,4 +64,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
64#define RGB_MATRIX_STARTUP_SAT 255 64#define RGB_MATRIX_STARTUP_SAT 255
65#define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS 65#define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS
66#define RGB_MATRIX_STARTUP_SPD 127 66#define RGB_MATRIX_STARTUP_SPD 127
67#define RGB_DISABLE_WHEN_USB_SUSPENDED true 67#define RGB_DISABLE_WHEN_USB_SUSPENDED
diff --git a/keyboards/phase_studio/titan65/config.h b/keyboards/phase_studio/titan65/config.h
index 4104c2ec2..66ae4f20b 100644
--- a/keyboards/phase_studio/titan65/config.h
+++ b/keyboards/phase_studio/titan65/config.h
@@ -47,5 +47,5 @@
47#define RGB_DI_PIN E6 47#define RGB_DI_PIN E6
48#define DRIVER_LED_TOTAL 67 48#define DRIVER_LED_TOTAL 67
49#define RGB_MATRIX_KEYPRESSES // reacts to keypresses 49#define RGB_MATRIX_KEYPRESSES // reacts to keypresses
50#define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended 50// #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
51#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 51#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
diff --git a/keyboards/planck/ez/config.h b/keyboards/planck/ez/config.h
index 7f8876496..5317a5156 100644
--- a/keyboards/planck/ez/config.h
+++ b/keyboards/planck/ez/config.h
@@ -147,7 +147,7 @@
147 147
148#define RGB_MATRIX_KEYPRESSES 148#define RGB_MATRIX_KEYPRESSES
149#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 149#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
150#define RGB_DISABLE_WHEN_USB_SUSPENDED true 150#define RGB_DISABLE_WHEN_USB_SUSPENDED
151 151
152#define RGB_MATRIX_LED_PROCESS_LIMIT 5 152#define RGB_MATRIX_LED_PROCESS_LIMIT 5
153#define RGB_MATRIX_LED_FLUSH_LIMIT 26 153#define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/planck/rev6/config.h b/keyboards/planck/rev6/config.h
index 4bc8a509f..18bb74096 100644
--- a/keyboards/planck/rev6/config.h
+++ b/keyboards/planck/rev6/config.h
@@ -141,7 +141,7 @@
141#define WS2812_DMA_CHANNEL 2 141#define WS2812_DMA_CHANNEL 2
142 142
143#ifndef RGB_DISABLE_WHEN_USB_SUSPENDED 143#ifndef RGB_DISABLE_WHEN_USB_SUSPENDED
144# define RGB_DISABLE_WHEN_USB_SUSPENDED true 144# define RGB_DISABLE_WHEN_USB_SUSPENDED
145#endif 145#endif
146 146
147#endif 147#endif
diff --git a/keyboards/setta21/keymaps/salicylic/config.h b/keyboards/setta21/keymaps/salicylic/config.h
index 44b34aa2f..06e23ba7a 100644
--- a/keyboards/setta21/keymaps/salicylic/config.h
+++ b/keyboards/setta21/keymaps/salicylic/config.h
@@ -27,7 +27,7 @@
27# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 27# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
28// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 28// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
29// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 29// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
30# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 30# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
31// # 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) 31// # 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)
32// # 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) 32// # 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)
33// # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 33// # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
@@ -37,4 +37,3 @@
37# define RGB_MATRIX_VAL_STEP 5 37# define RGB_MATRIX_VAL_STEP 5
38# define RGB_MATRIX_SPD_STEP 10 38# define RGB_MATRIX_SPD_STEP 10
39#endif 39#endif
40
diff --git a/keyboards/sofle/keymaps/devdev/config.h b/keyboards/sofle/keymaps/devdev/config.h
index 7d597d991..32d071735 100644
--- a/keyboards/sofle/keymaps/devdev/config.h
+++ b/keyboards/sofle/keymaps/devdev/config.h
@@ -1,18 +1,18 @@
1 /* Copyright 2021 Dane Evans 1 /* Copyright 2021 Dane Evans
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15*/ 15*/
16 #pragma once 16 #pragma once
17 17
18 18
@@ -29,7 +29,7 @@
29 29
30#define CUSTOM_FONT 30#define CUSTOM_FONT
31 31
32#define CUSTOM_LAYER_READ //if you remove this it causes issues - needs better guarding 32#define CUSTOM_LAYER_READ //if you remove this it causes issues - needs better guarding
33 33
34 34
35#define TAPPING_FORCE_HOLD 35#define TAPPING_FORCE_HOLD
@@ -56,7 +56,7 @@
56 56
57#ifdef RGBLIGHT_ENABLE 57#ifdef RGBLIGHT_ENABLE
58 #undef RGBLED_NUM 58 #undef RGBLED_NUM
59 59
60 //#define RGBLIGHT_ANIMATIONS 60 //#define RGBLIGHT_ANIMATIONS
61 //#define RGBLIGHT_EFFECT_BREATHING 61 //#define RGBLIGHT_EFFECT_BREATHING
62 #define RGBLIGHT_EFFECT_RAINBOW_MOOD 62 #define RGBLIGHT_EFFECT_RAINBOW_MOOD
@@ -68,11 +68,11 @@
68 //#define RGBLIGHT_EFFECT_RGB_TEST 68 //#define RGBLIGHT_EFFECT_RGB_TEST
69 //#define RGBLIGHT_EFFECT_ALTERNATING 69 //#define RGBLIGHT_EFFECT_ALTERNATING
70 //#define RGBLIGHT_EFFECT_TWINKLE 70 //#define RGBLIGHT_EFFECT_TWINKLE
71 71
72 #define RGBLED_NUM 70 72 #define RGBLED_NUM 70
73 //#define RGBLED_SPLIT 73 //#define RGBLED_SPLIT
74 #define RGBLED_SPLIT { 35, 35 } // haven't figured out how to use this yet 74 #define RGBLED_SPLIT { 35, 35 } // haven't figured out how to use this yet
75 75
76 //#define RGBLED_NUM 30 76 //#define RGBLED_NUM 30
77 #define RGBLIGHT_LIMIT_VAL 120 77 #define RGBLIGHT_LIMIT_VAL 120
78 #define RGBLIGHT_HUE_STEP 10 78 #define RGBLIGHT_HUE_STEP 10
@@ -84,11 +84,11 @@
84# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 84# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
85// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 85// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
86// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 86// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
87# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 87# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
88# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 88# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
89// # 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) 89// # 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)
90// # 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) 90// # 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)
91# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. 91# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
92 92
93#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_GRADIENT_LEFT_RIGHT 93#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_GRADIENT_LEFT_RIGHT
94 94
@@ -127,4 +127,4 @@
127// # define DISABLE_RGB_MATRIX_MULTISPLASH 127// # define DISABLE_RGB_MATRIX_MULTISPLASH
128// # define DISABLE_RGB_MATRIX_SOLID_SPLASH 128// # define DISABLE_RGB_MATRIX_SOLID_SPLASH
129// # define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH 129// # define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
130#endif \ No newline at end of file 130#endif
diff --git a/keyboards/sofle/keymaps/killmaster/config.h b/keyboards/sofle/keymaps/killmaster/config.h
new file mode 100644
index 000000000..2e6abe84e
--- /dev/null
+++ b/keyboards/sofle/keymaps/killmaster/config.h
@@ -0,0 +1,64 @@
1/* Copyright 2021 Carlos Martins
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18/* The way how "handedness" is decided (which half is which),
19see https://docs.qmk.fm/#/feature_split_keyboard?id=setting-handedness
20for more options.
21*/
22
23#define RGB_DI_PIN D3
24
25#ifdef RGB_MATRIX_ENABLE
26
27#define RGBLED_NUM 72
28#define DRIVER_LED_TOTAL RGBLED_NUM
29#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
30#define RGB_MATRIX_HUE_STEP 8
31#define RGB_MATRIX_SAT_STEP 8
32#define RGB_MATRIX_VAL_STEP 8
33#define RGB_MATRIX_SPD_STEP 10
34#define RGB_MATRIX_KEYPRESSES
35#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
36#define RGB_MATRIX_SPLIT {36,36}
37#define SPLIT_TRANSPORT_MIRROR
38
39#endif
40
41#ifdef RGBLIGHT_ENABLE
42#define RGBLIGHT_SPLIT
43#define RGBLED_NUM 70
44#define RGB_SPLIT {36,36}
45#define RGBLIGHT_LIMIT_VAL 120
46// #define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
47// /*== all animations enable ==*/
48// #define RGBLIGHT_ANIMATIONS
49// /*== or choose animations ==*/
50// #define RGBLIGHT_EFFECT_BREATHING
51 //#define RGBLIGHT_EFFECT_RAINBOW_MOOD
52 //#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
53// #define RGBLIGHT_EFFECT_SNAKE
54// #define RGBLIGHT_EFFECT_KNIGHT
55// #define RGBLIGHT_EFFECT_CHRISTMAS
56 #define RGBLIGHT_EFFECT_STATIC_GRADIENT
57 #define RGBLIGHT_EFFECT_RGB_TEST
58// #define RGBLIGHT_EFFECT_ALTERNATING
59#endif
60
61#define MEDIA_KEY_DELAY 2
62
63#define USB_POLLING_INTERVAL_MS 1
64#define QMK_KEYS_PER_SCAN 12
diff --git a/keyboards/sofle/keymaps/killmaster/keymap.c b/keyboards/sofle/keymaps/killmaster/keymap.c
new file mode 100644
index 000000000..950dee36b
--- /dev/null
+++ b/keyboards/sofle/keymaps/killmaster/keymap.c
@@ -0,0 +1,403 @@
1/* Copyright 2021 Carlos Martins
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include QMK_KEYBOARD_H
18#include <stdio.h>
19
20enum sofle_layers {
21 /* _M_XYZ = Mac Os, _W_XYZ = Win/Linux */
22 _QWERTY,
23 _LOWER,
24 _RAISE,
25 _ADJUST,
26};
27
28enum custom_keycodes {
29 KC_QWERTY = SAFE_RANGE,
30 KC_LOWER,
31 KC_RAISE,
32 KC_ADJUST,
33 KC_PRVWD,
34 KC_NXTWD,
35 KC_LSTRT,
36 KC_LEND,
37 KC_DLINE
38};
39
40
41const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
42/*
43 * QWERTY
44 * ,-----------------------------------------. ,-----------------------------------------.
45 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | ` |
46 * |------+------+------+------+------+------| |------+------+------+------+------+------|
47 * | ESC | Q | W | E | R | T | | Y | U | I | O | P | Bspc |
48 * |------+------+------+------+------+------| |------+------+------+------+------+------|
49 * | Tab | A | S | D | F | G |-------. ,-------| H | J | K | L | ; | ' |
50 * |------+------+------+------+------+------| | | |------+------+------+------+------+------|
51 * |LShift| Z | X | C | V | B |-------| |-------| N | M | , | . | / |RShift|
52 * `-----------------------------------------/ / \ \-----------------------------------------'
53 * | LGUI | LAlt | LCTR |LOWER | /Space / \Enter \ |RAISE | RCTR | RAlt | RGUI |
54 * | | | | |/ / \ \ | | | | |
55 * `----------------------------------' '------''---------------------------'
56 */
57
58[_QWERTY] = LAYOUT(
59 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
60 KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
61 KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
62 KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_MUTE, KC_MPLY,KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC,
63 KC_LGUI,KC_LALT,KC_LCTRL, KC_LOWER, KC_SPC, KC_ENT, KC_RAISE, KC_RCTRL, KC_RALT, KC_RGUI
64),
65/* LOWER
66 * ,-----------------------------------------. ,-----------------------------------------.
67 * | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 |
68 * |------+------+------+------+------+------| |------+------+------+------+------+------|
69 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | F12 |
70 * |------+------+------+------+------+------| |------+------+------+------+------+------|
71 * | Tab | ! | @ | # | $ | % |-------. ,-------| ^ | & | * | ( | ) | | |
72 * |------+------+------+------+------+------| MUTE | | |------+------+------+------+------+------|
73 * | Shift| = | - | + | { | } |-------| |-------| [ | ] | ; | : | \ | Shift|
74 * `-----------------------------------------/ / \ \-----------------------------------------'
75 * | LGUI | LAlt | LCTR |LOWER | /Enter / \Space \ |RAISE | RCTR | RAlt | RGUI |
76 * | | | | |/ / \ \ | | | | |
77 * `----------------------------------' '------''---------------------------'
78 */
79[_LOWER] = LAYOUT(
80 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
81 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_F12,
82 _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE,
83 _______, KC_EQL, KC_MINS, KC_PLUS, KC_LCBR, KC_RCBR, _______, _______, KC_LBRC, KC_RBRC, KC_SCLN, KC_COLN, KC_BSLS, _______,
84 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
85),
86/* RAISE
87 * ,----------------------------------------. ,-----------------------------------------.
88 * | | | | | | | | | | | | | |
89 * |------+------+------+------+------+------| |------+------+------+------+------+------|
90 * | Esc | Ins | Pscr | Menu | |RGBTog| | | PWrd | Up | NWrd | DLine| Bspc |
91 * |------+------+------+------+------+------| |------+------+------+------+------+------|
92 * | Tab | LAt | LCtl |LShift| | Caps |-------. ,-------| | Left | Down | Rigth| Del | Bspc |
93 * |------+------+------+------+------+------| MUTE | | |------+------+------+------+------+------|
94 * |Shift | Undo | Cut | Copy | Paste| |-------| |-------| | LStr | | LEnd | | Shift|
95 * `-----------------------------------------/ / \ \-----------------------------------------'
96 * | LGUI | LAlt | LCTR |LOWER | /Enter / \Space \ |RAISE | RCTR | RAlt | RGUI |
97 * | | | | |/ / \ \ | | | | |
98 * `----------------------------------' '------''---------------------------'
99 */
100[_RAISE] = LAYOUT(
101 _______, _______ , _______ , _______ , RGB_RMOD , RGB_MOD, _______, _______ , _______, _______ , _______ ,_______,
102 _______, KC_INS, KC_PSCR, KC_APP, XXXXXXX, RGB_TOG, KC_PGUP, KC_PRVWD, KC_UP, KC_NXTWD,KC_DLINE, KC_BSPC,
103 _______, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX, KC_CAPS, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, KC_DEL, KC_BSPC,
104 _______,XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, _______, XXXXXXX, KC_LSTRT, XXXXXXX, KC_LEND, XXXXXXX, _______,
105 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
106),
107/* ADJUST
108 * ,-----------------------------------------. ,-----------------------------------------.
109 * | | | | | | | | | | | | | |
110 * |------+------+------+------+------+------| |------+------+------+------+------+------|
111 * | RESET| |QWERTY|COLEMAK| | | | | | | | | |
112 * |------+------+------+------+------+------| |------+------+------+------+------+------|
113 * | | |MACWIN| | | |-------. ,-------| | VOLDO| MUTE | VOLUP| | |
114 * |------+------+------+------+------+------| MUTE | | |------+------+------+------+------+------|
115 * | | | | | | |-------| |-------| | PREV | PLAY | NEXT | | |
116 * `-----------------------------------------/ / \ \-----------------------------------------'
117 * | LGUI | LAlt | LCTR |LOWER | /Enter / \Space \ |RAISE | RCTR | RAlt | RGUI |
118 * | | | | |/ / \ \ | | | | |
119 * `----------------------------------' '------''---------------------------'
120 */
121 [_ADJUST] = LAYOUT(
122 XXXXXXX , XXXXXXX, XXXXXXX , XXXXXXX , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
123 RESET , XXXXXXX, KC_QWERTY, XXXXXXX , CG_TOGG,XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
124 XXXXXXX , XXXXXXX,CG_TOGG, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_VOLD, KC_MUTE, KC_VOLU, XXXXXXX, XXXXXXX,
125 XXXXXXX , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MPRV, KC_MPLY, KC_MNXT, XXXXXXX, XXXXXXX,
126 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
127 )
128};
129
130#ifdef OLED_DRIVER_ENABLE
131
132static void render_logo(void) {
133 static const char PROGMEM bananas_logo[] = {
134 // 'killmaster_bananas', 128x32px
135 0x00, 0x00, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xe0, 0x02, 0x0e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
138 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
143 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
145 0x00, 0x00, 0x80, 0xc0, 0x40, 0x00, 0x00, 0x00, 0x40, 0x40, 0xd8, 0xc8, 0x00, 0x00, 0x00, 0x00,
146 0x08, 0x08, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0xf8, 0xf8, 0x00, 0x00, 0x00,
147 0x00, 0x00, 0xc0, 0x40, 0x40, 0xc0, 0x80, 0x40, 0xc0, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40,
148 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0xc0, 0x40, 0x00, 0x00, 0x40, 0x40, 0xf0,
149 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0xc0, 0x80, 0x00, 0x00, 0x00,
150 0x40, 0xc0, 0x80, 0x40, 0x40, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151 0x00, 0x01, 0x0f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xf0,
152 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
153 0x02, 0x07, 0x0d, 0x10, 0x20, 0x20, 0x00, 0x00, 0x20, 0x20, 0x3f, 0x3f, 0x20, 0x20, 0x00, 0x00,
154 0x00, 0x00, 0x1f, 0x3f, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x3f, 0x20, 0x20, 0x20,
155 0x00, 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x1c, 0x36, 0x22, 0x22, 0x22,
156 0x1f, 0x20, 0x00, 0x00, 0x10, 0x23, 0x22, 0x22, 0x26, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x1f,
157 0x30, 0x20, 0x20, 0x20, 0x00, 0x00, 0x0f, 0x1f, 0x32, 0x22, 0x22, 0x32, 0x23, 0x00, 0x00, 0x00,
158 0x20, 0x3f, 0x21, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07, 0x07, 0x0f, 0x0f, 0x0f, 0x1f, 0x1f,
160 0x1f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3e, 0x3e, 0x1c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
162 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
164 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
166 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
167 };
168 oled_write_raw_P(bananas_logo, sizeof(bananas_logo));
169}
170
171static void print_status_narrow(void) {
172 // Print current mode
173 oled_write_P(PSTR("Sofle"), false);
174 oled_write_P(PSTR("\n\n\n"), false);
175 switch (get_highest_layer(default_layer_state)) {
176 case _QWERTY:
177 oled_write_ln_P(PSTR("QWERT"), false);
178 break;
179 default:
180 oled_write_P(PSTR("Undef"), false);
181 }
182 oled_write_P(PSTR("\n\n"), false);
183 // Print current layer
184 oled_write_ln_P(PSTR("Layer"), false);
185 switch (get_highest_layer(layer_state)) {
186 case _QWERTY:
187 oled_write_P(PSTR("Base\n"), false);
188 break;
189 case _RAISE:
190 oled_write_P(PSTR("Raise"), false);
191 break;
192 case _LOWER:
193 oled_write_P(PSTR("Lower"), false);
194 break;
195 case _ADJUST:
196 oled_write_P(PSTR("Adj\n"), false);
197 break;
198 default:
199 oled_write_ln_P(PSTR("Undef"), false);
200 }
201 oled_write_P(PSTR("\n\n"), false);
202}
203
204oled_rotation_t oled_init_user(oled_rotation_t rotation) {
205 if (is_keyboard_master()) {
206 return OLED_ROTATION_270;
207 }
208 else {
209 return OLED_ROTATION_180;
210 }
211 return rotation;
212}
213
214void oled_task_user(void) {
215 if (is_keyboard_master()) {
216 print_status_narrow();
217 } else {
218 render_logo();
219 }
220}
221
222
223
224#endif // OLED_DRIVER_ENABLE
225
226bool process_record_user(uint16_t keycode, keyrecord_t *record) {
227 switch (keycode) {
228 case KC_QWERTY:
229 if (record->event.pressed) {
230 set_single_persistent_default_layer(_QWERTY);
231 }
232 return false;
233 case KC_LOWER:
234 if (record->event.pressed) {
235 layer_on(_LOWER);
236 update_tri_layer(_LOWER, _RAISE, _ADJUST);
237 } else {
238 layer_off(_LOWER);
239 update_tri_layer(_LOWER, _RAISE, _ADJUST);
240 }
241 return false;
242 case KC_RAISE:
243 if (record->event.pressed) {
244 layer_on(_RAISE);
245 update_tri_layer(_LOWER, _RAISE, _ADJUST);
246 } else {
247 layer_off(_RAISE);
248 update_tri_layer(_LOWER, _RAISE, _ADJUST);
249 }
250 return false;
251 case KC_ADJUST:
252 if (record->event.pressed) {
253 layer_on(_ADJUST);
254 } else {
255 layer_off(_ADJUST);
256 }
257 return false;
258 case KC_PRVWD:
259 if (record->event.pressed) {
260 if (keymap_config.swap_lctl_lgui) {
261 register_mods(mod_config(MOD_LALT));
262 register_code(KC_LEFT);
263 } else {
264 register_mods(mod_config(MOD_LCTL));
265 register_code(KC_LEFT);
266 }
267 } else {
268 if (keymap_config.swap_lctl_lgui) {
269 unregister_mods(mod_config(MOD_LALT));
270 unregister_code(KC_LEFT);
271 } else {
272 unregister_mods(mod_config(MOD_LCTL));
273 unregister_code(KC_LEFT);
274 }
275 }
276 break;
277 case KC_NXTWD:
278 if (record->event.pressed) {
279 if (keymap_config.swap_lctl_lgui) {
280 register_mods(mod_config(MOD_LALT));
281 register_code(KC_RIGHT);
282 } else {
283 register_mods(mod_config(MOD_LCTL));
284 register_code(KC_RIGHT);
285 }
286 } else {
287 if (keymap_config.swap_lctl_lgui) {
288 unregister_mods(mod_config(MOD_LALT));
289 unregister_code(KC_RIGHT);
290 } else {
291 unregister_mods(mod_config(MOD_LCTL));
292 unregister_code(KC_RIGHT);
293 }
294 }
295 break;
296 case KC_LSTRT:
297 if (record->event.pressed) {
298 if (keymap_config.swap_lctl_lgui) {
299 //CMD-arrow on Mac, but we have CTL and GUI swapped
300 register_mods(mod_config(MOD_LCTL));
301 register_code(KC_LEFT);
302 } else {
303 register_code(KC_HOME);
304 }
305 } else {
306 if (keymap_config.swap_lctl_lgui) {
307 unregister_mods(mod_config(MOD_LCTL));
308 unregister_code(KC_LEFT);
309 } else {
310 unregister_code(KC_HOME);
311 }
312 }
313 break;
314 case KC_LEND:
315 if (record->event.pressed) {
316 if (keymap_config.swap_lctl_lgui) {
317 //CMD-arrow on Mac, but we have CTL and GUI swapped
318 register_mods(mod_config(MOD_LCTL));
319 register_code(KC_RIGHT);
320 } else {
321 register_code(KC_END);
322 }
323 } else {
324 if (keymap_config.swap_lctl_lgui) {
325 unregister_mods(mod_config(MOD_LCTL));
326 unregister_code(KC_RIGHT);
327 } else {
328 unregister_code(KC_END);
329 }
330 }
331 break;
332 case KC_DLINE:
333 if (record->event.pressed) {
334 register_mods(mod_config(MOD_LCTL));
335 register_code(KC_BSPC);
336 } else {
337 unregister_mods(mod_config(MOD_LCTL));
338 unregister_code(KC_BSPC);
339 }
340 break;
341 }
342 return true;
343}
344
345#ifdef ENCODER_ENABLE
346
347bool encoder_update_user(uint8_t index, bool clockwise) {
348 uint8_t temp_mod = get_mods();
349 uint8_t temp_osm = get_oneshot_mods();
350 bool is_ctrl = (temp_mod | temp_osm) & MOD_MASK_CTRL;
351 bool is_shift = (temp_mod | temp_osm) & MOD_MASK_SHIFT;
352
353 if (is_shift) {
354 if (index == 0) { /* First encoder */
355 if (clockwise) {
356 rgb_matrix_increase_hue();
357 } else {
358 rgb_matrix_decrease_hue();
359 }
360 } else if (index == 1) { /* Second encoder */
361 if (clockwise) {
362 rgb_matrix_decrease_sat();
363 } else {
364 rgb_matrix_increase_sat();
365 }
366 }
367 } else if (is_ctrl) {
368 if (index == 0) { /* First encoder */
369 if (clockwise) {
370 rgb_matrix_increase_val();
371 } else {
372 rgb_matrix_decrease_val();
373 }
374 } else if (index == 1) { /* Second encoder */
375 if (clockwise) {
376 rgb_matrix_increase_speed();
377 } else {
378 rgb_matrix_decrease_speed();
379 }
380 }
381 } else {
382 if (index == 1) { /* First encoder */
383 if (clockwise) {
384 tap_code(KC_PGUP);
385 // tap_code(KC_MS_WH_UP);
386 } else {
387 tap_code(KC_PGDOWN);
388 // tap_code(KC_MS_WH_DOWN);
389 }
390 } else if (index == 0) { /* Second encoder */
391 uint16_t mapped_code = 0;
392 if (clockwise) {
393 mapped_code = KC_VOLD;
394 } else {
395 mapped_code = KC_VOLU;
396 }
397 tap_code_delay(mapped_code, MEDIA_KEY_DELAY);
398 }
399 }
400 return true;
401}
402
403#endif
diff --git a/keyboards/sofle/keymaps/killmaster/readme.md b/keyboards/sofle/keymaps/killmaster/readme.md
new file mode 100644
index 000000000..6d6dea228
--- /dev/null
+++ b/keyboards/sofle/keymaps/killmaster/readme.md
@@ -0,0 +1,19 @@
1![SofleKeyboard default keymap](https://github.com/josefadamcik/SofleKeyboard/raw/master/Images/soflekeyboard.png)
2![SofleKeyboard adjust layer](https://github.com/josefadamcik/SofleKeyboard/raw/master/Images/soflekeyboard_layout_adjust.png)
3
4
5# Default keymap for Sofle Keyboard
6
7Layout in [Keyboard Layout Editor](http://www.keyboard-layout-editor.com/#/gists/76efb423a46cbbea75465cb468eef7ff) and [adjust layer](http://www.keyboard-layout-editor.com/#/gists/4bcf66f922cfd54da20ba04905d56bd4)
8
9
10Features:
11
12- Symmetric modifiers (CMD/Super, Alt/Opt, Ctrl, Shift)
13- Various modes, can be switched (using Adjust layer and the selected one is stored in EEPROM.
14- Modes for Qwerty and Colemak support
15- Modes for Mac vs Linux/Win support -> different order of modifiers and different action shortcuts on the "UPPER" layer (the red one in the image). Designed to simplify transtions when switching between operating systems often.
16- The OLED on master half shows selected mode and caps lock state and is rotated.
17- Left encoder controls volume up/down/mute. Right encoder PGUP/PGDOWN.
18
19
diff --git a/keyboards/sofle/keymaps/killmaster/rules.mk b/keyboards/sofle/keymaps/killmaster/rules.mk
new file mode 100644
index 000000000..38d611450
--- /dev/null
+++ b/keyboards/sofle/keymaps/killmaster/rules.mk
@@ -0,0 +1,4 @@
1EXTRAKEY_ENABLE = yes
2LTO_ENABLE = yes
3RGB_MATRIX_ENABLE = yes
4RGB_MATRIX_DRIVER = WS2812
diff --git a/keyboards/sofle/keymaps/rgb_default/config.h b/keyboards/sofle/keymaps/rgb_default/config.h
index 7d597d991..32d071735 100644
--- a/keyboards/sofle/keymaps/rgb_default/config.h
+++ b/keyboards/sofle/keymaps/rgb_default/config.h
@@ -1,18 +1,18 @@
1 /* Copyright 2021 Dane Evans 1 /* Copyright 2021 Dane Evans
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15*/ 15*/
16 #pragma once 16 #pragma once
17 17
18 18
@@ -29,7 +29,7 @@
29 29
30#define CUSTOM_FONT 30#define CUSTOM_FONT
31 31
32#define CUSTOM_LAYER_READ //if you remove this it causes issues - needs better guarding 32#define CUSTOM_LAYER_READ //if you remove this it causes issues - needs better guarding
33 33
34 34
35#define TAPPING_FORCE_HOLD 35#define TAPPING_FORCE_HOLD
@@ -56,7 +56,7 @@
56 56
57#ifdef RGBLIGHT_ENABLE 57#ifdef RGBLIGHT_ENABLE
58 #undef RGBLED_NUM 58 #undef RGBLED_NUM
59 59
60 //#define RGBLIGHT_ANIMATIONS 60 //#define RGBLIGHT_ANIMATIONS
61 //#define RGBLIGHT_EFFECT_BREATHING 61 //#define RGBLIGHT_EFFECT_BREATHING
62 #define RGBLIGHT_EFFECT_RAINBOW_MOOD 62 #define RGBLIGHT_EFFECT_RAINBOW_MOOD
@@ -68,11 +68,11 @@
68 //#define RGBLIGHT_EFFECT_RGB_TEST 68 //#define RGBLIGHT_EFFECT_RGB_TEST
69 //#define RGBLIGHT_EFFECT_ALTERNATING 69 //#define RGBLIGHT_EFFECT_ALTERNATING
70 //#define RGBLIGHT_EFFECT_TWINKLE 70 //#define RGBLIGHT_EFFECT_TWINKLE
71 71
72 #define RGBLED_NUM 70 72 #define RGBLED_NUM 70
73 //#define RGBLED_SPLIT 73 //#define RGBLED_SPLIT
74 #define RGBLED_SPLIT { 35, 35 } // haven't figured out how to use this yet 74 #define RGBLED_SPLIT { 35, 35 } // haven't figured out how to use this yet
75 75
76 //#define RGBLED_NUM 30 76 //#define RGBLED_NUM 30
77 #define RGBLIGHT_LIMIT_VAL 120 77 #define RGBLIGHT_LIMIT_VAL 120
78 #define RGBLIGHT_HUE_STEP 10 78 #define RGBLIGHT_HUE_STEP 10
@@ -84,11 +84,11 @@
84# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 84# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
85// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 85// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
86// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 86// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
87# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 87# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
88# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 88# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
89// # 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) 89// # 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)
90// # 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) 90// # 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)
91# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. 91# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
92 92
93#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_GRADIENT_LEFT_RIGHT 93#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_GRADIENT_LEFT_RIGHT
94 94
@@ -127,4 +127,4 @@
127// # define DISABLE_RGB_MATRIX_MULTISPLASH 127// # define DISABLE_RGB_MATRIX_MULTISPLASH
128// # define DISABLE_RGB_MATRIX_SOLID_SPLASH 128// # define DISABLE_RGB_MATRIX_SOLID_SPLASH
129// # define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH 129// # define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
130#endif \ No newline at end of file 130#endif
diff --git a/keyboards/sofle/rev1/readme.md b/keyboards/sofle/rev1/readme.md
new file mode 100644
index 000000000..629d568e6
--- /dev/null
+++ b/keyboards/sofle/rev1/readme.md
@@ -0,0 +1,27 @@
1# Sofle Keyboard
2
3![SofleKeyboard version 1](https://raw.githubusercontent.com/josefadamcik/SofleKeyboard/master/Images/IMG_20200126_114622.jpg)
4
5Sofle is 6×4+5 keys column-staggered split keyboard. Based on Lily58, Corne and Helix keyboards.
6
7More details about the keyboard on my blog: [Let me introduce you SofleKeyboard - a split keyboard based on Lily58 and Crkbd](https://josef-adamcik.cz/electronics/let-me-introduce-you-sofle-keyboard-split-keyboard-based-on-lily58.html)
8
9The current (temporary) build guide and a build log is available here: [SofleKeyboard build log/guide](https://josef-adamcik.cz/electronics/soflekeyboard-build-log-and-build-guide.html)
10
11* Keyboard Maintainer: [Josef Adamcik](https://josef-adamcik.cz) [Twitter:@josefadamcik](https://twitter.com/josefadamcik)
12* Hardware Supported: SofleKeyboard PCB, ProMicro
13* Hardware Availability: [PCB & Case Data](https://github.com/josefadamcik/SofleKeyboard)
14
15Make example for this keyboard (after setting up your build environment):
16
17 make sofle:default
18
19Flashing example for this keyboard:
20
21 make sofle:default:flash
22
23Press reset button on he keyboard when asked.
24
25Disconnect the first half, connect the second one and repeat the process.
26
27See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/keyboards/sofle/rev1/rev1.c b/keyboards/sofle/rev1/rev1.c
index bbb014c4d..88a28e6a4 100644
--- a/keyboards/sofle/rev1/rev1.c
+++ b/keyboards/sofle/rev1/rev1.c
@@ -1 +1,87 @@
1/* Copyright 2021 Carlos Martins
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
1#include "sofle.h" 17#include "sofle.h"
18
19#ifdef RGB_MATRIX_ENABLE
20 // Physical Layout
21 // Columns
22 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13
23 // ROWS
24 // 12 13 22 23 32 33 33 32 23 22 13 12 0
25 // 02 03 04 04 03 02
26 // 11 14 21 24 31 34 34 31 24 21 14 11 1
27 // 01 01
28 // 10 15 20 25 30 35 35 30 25 20 15 10 2
29 //
30 // 09 16 19 26 29 36 36 29 26 19 16 09 3
31 //
32 // 08 17 18 27 28 28 27 18 17 08 4
33 // 07 06 05 05 06 07
34
35led_config_t g_led_config = {
36 {
37 { 11, 12, 21, 22, 31, 32 },
38 { 10, 13, 20, 23, 30, 33 },
39 { 9, 14, 19, 24, 29, 34},
40 { 8, 15, 18, 25, 28, 35},
41 { 7, 16, 17, 26, 27, NO_LED },
42 { 47, 48, 57, 58, 67, 68},
43 { 46, 49, 56, 59, 66, 69},
44 { 45, 50, 55, 60, 65, 70},
45 { 44, 51, 54, 61, 64, 71},
46 { 43, 52, 53, 62, 63, NO_LED }
47 },
48 {
49 // Left side underglow
50 {96, 40}, {16, 20}, {48, 10}, {80, 18}, {88, 60}, {56, 57}, {24,60},
51 // Left side Matrix
52 {32, 57}, { 0, 48}, { 0, 36}, { 0, 24}, { 0, 12},
53 {16, 12}, {16, 24}, {16, 36}, {16, 48}, {48, 55},
54 {64, 57}, {32, 45}, {32, 33}, {32, 21}, {32, 9},
55 {48, 7}, {48, 19}, {48, 31}, {48, 43}, {80, 59},
56 {96, 64}, {64, 45}, {64, 33}, {64, 21}, {64, 9},
57 {80, 10}, {80, 22}, {80, 34}, {80, 47},
58
59
60 // Right side underglow
61 {128, 40}, {208, 20}, {176, 10}, {144, 18}, {136, 60}, {168, 57}, {200,60},
62 // Right side Matrix
63 {192, 57}, {224, 48}, {224, 36}, {224, 24}, {224, 12},
64 {208, 12}, {208, 24}, {208, 36}, {208, 48}, {176, 55},
65 {160, 57}, {192, 45}, {192, 33}, {192, 21}, {192, 9},
66 {176, 7}, {176, 19}, {176, 31}, {176, 43}, {144, 59},
67 {128, 64}, {160, 45}, {160, 33}, {160, 21}, {160, 9},
68 {144, 10}, {144, 22}, {144, 34}, {144, 47},
69 },
70 {
71 LED_FLAG_NONE, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW,
72 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
73 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
74 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
75 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
76 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
77 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
78 LED_FLAG_NONE, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW, LED_FLAG_UNDERGLOW,
79 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
80 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
81 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
82 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
83 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT,
84 LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT, LED_FLAG_KEYLIGHT
85 }
86};
87#endif
diff --git a/keyboards/terrazzo/config.h b/keyboards/terrazzo/config.h
index 985110d16..907c94ff5 100644
--- a/keyboards/terrazzo/config.h
+++ b/keyboards/terrazzo/config.h
@@ -83,13 +83,13 @@ so there is only one configuration. */
83 83
84#ifdef LED_MATRIX_ENABLE 84#ifdef LED_MATRIX_ENABLE
85 85
86#define LED_DRIVER_ADDR_1 0x74 86#define LED_DRIVER_ADDR_1 0x74
87#define LED_DRIVER_COUNT 1 87#define LED_DRIVER_COUNT 1
88#define DRIVER_LED_TOTAL 105 88#define DRIVER_LED_TOTAL 105
89#define LED_MATRIX_ROWS 15 89#define LED_MATRIX_ROWS 15
90#define LED_MATRIX_COLS 7 90#define LED_MATRIX_COLS 7
91#define LED_MATRIX_MAXIMUM_BRIGHTNESS 20 91#define LED_MATRIX_MAXIMUM_BRIGHTNESS 20
92#define LED_DISABLE_WHEN_USB_SUSPENDED true 92#define LED_DISABLE_WHEN_USB_SUSPENDED
93 93
94#define DISABLE_LED_MATRIX_ALPHAS_MODS 94#define DISABLE_LED_MATRIX_ALPHAS_MODS
95#define DISABLE_LED_MATRIX_BREATHING 95#define DISABLE_LED_MATRIX_BREATHING
diff --git a/keyboards/tkc/portico/config.h b/keyboards/tkc/portico/config.h
index 4a7da833f..ef6e46658 100644
--- a/keyboards/tkc/portico/config.h
+++ b/keyboards/tkc/portico/config.h
@@ -45,7 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
45# define RGB_MATRIX_LED_FLUSH_LIMIT 26 45# define RGB_MATRIX_LED_FLUSH_LIMIT 26
46# define DEBOUNCE 3 46# define DEBOUNCE 3
47# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 47# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
48# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 48# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
49# define RGB_MATRIX_KEYPRESSES 49# define RGB_MATRIX_KEYPRESSES
50# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 50# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
51# define DISABLE_RGB_MATRIX_BAND_SAT 51# define DISABLE_RGB_MATRIX_BAND_SAT
diff --git a/keyboards/tokyo60/config.h b/keyboards/tokyokeyboard/tokyo60/config.h
index 03dee74e9..03dee74e9 100644
--- a/keyboards/tokyo60/config.h
+++ b/keyboards/tokyokeyboard/tokyo60/config.h
diff --git a/keyboards/tokyo60/info.json b/keyboards/tokyokeyboard/tokyo60/info.json
index 10d1bf093..10d1bf093 100644
--- a/keyboards/tokyo60/info.json
+++ b/keyboards/tokyokeyboard/tokyo60/info.json
diff --git a/keyboards/tokyo60/keymaps/default/config.h b/keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h
index 271f48d00..271f48d00 100644
--- a/keyboards/tokyo60/keymaps/default/config.h
+++ b/keyboards/tokyokeyboard/tokyo60/keymaps/default/config.h
diff --git a/keyboards/tokyo60/keymaps/default/keymap.c b/keyboards/tokyokeyboard/tokyo60/keymaps/default/keymap.c
index 9139d15bc..9139d15bc 100644
--- a/keyboards/tokyo60/keymaps/default/keymap.c
+++ b/keyboards/tokyokeyboard/tokyo60/keymaps/default/keymap.c
diff --git a/keyboards/tokyo60/keymaps/swappedBottomRow/config.h b/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h
index 271f48d00..271f48d00 100644
--- a/keyboards/tokyo60/keymaps/swappedBottomRow/config.h
+++ b/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/config.h
diff --git a/keyboards/tokyo60/keymaps/swappedBottomRow/keymap.c b/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c
index 54b68f582..54b68f582 100644
--- a/keyboards/tokyo60/keymaps/swappedBottomRow/keymap.c
+++ b/keyboards/tokyokeyboard/tokyo60/keymaps/swappedBottomRow/keymap.c
diff --git a/keyboards/tokyo60/keymaps/via/keymap.c b/keyboards/tokyokeyboard/tokyo60/keymaps/via/keymap.c
index ffef9af79..ffef9af79 100644
--- a/keyboards/tokyo60/keymaps/via/keymap.c
+++ b/keyboards/tokyokeyboard/tokyo60/keymaps/via/keymap.c
diff --git a/keyboards/tokyo60/keymaps/via/rules.mk b/keyboards/tokyokeyboard/tokyo60/keymaps/via/rules.mk
index 1e5b99807..1e5b99807 100644
--- a/keyboards/tokyo60/keymaps/via/rules.mk
+++ b/keyboards/tokyokeyboard/tokyo60/keymaps/via/rules.mk
diff --git a/keyboards/tokyo60/readme.md b/keyboards/tokyokeyboard/tokyo60/readme.md
index 74f4e07cc..56c31efad 100644
--- a/keyboards/tokyo60/readme.md
+++ b/keyboards/tokyokeyboard/tokyo60/readme.md
@@ -1,15 +1,15 @@
1# Tokyo60 1# Tokyo60
2​ 2​
3![Tokyo60](http://tokyokeyboard.com/wp-content/uploads/2018/02/AI7B4543_copy_page_20180215141449-1200x800.jpg) 3![Tokyo60](https://i2.wp.com/tokyokeyboard.com/wp-content/uploads/2018/02/AI7B4543_copy_page_20180215141449-1200x800.jpg)
4​ 4​
5Minimal hacker style mechanical keyboard designed in Tokyo. Full aluminum hi-pro construction with integrated top-plate. Cherry MX compatible. More Info at [Tokyo Keyboard](http://tokyokeyboard.com). 5Minimal hacker style mechanical keyboard designed in Tokyo. Full aluminum hi-pro construction with integrated top-plate. Cherry MX compatible. More Info at [Tokyo Keyboard](http://tokyokeyboard.com).
6​ 6​
7* Keyboard Maintainer: [Tokyo Keyboard](http://tokyokeyboard.com) 7* Keyboard Maintainer: [Tokyo Keyboard](https://tokyokeyboard.com)
8* Hardware Supported: Tokyo60 Rev.1 8* Hardware Supported: Tokyo60 Rev.1 - 4
9* Hardware Availability: [Drop](https://drop.com/buy/massdrop-x-tokyo-keyboard-tokyo60-keyboard-kit?mode=guest_open) 9* Hardware Availability: [Drop](https://drop.com/buy/massdrop-x-tokyo-keyboard-tokyo60-keyboard-kit?mode=guest_open)
10​ 10​
11Make example for this keyboard (after setting up your build environment): 11Make example for this keyboard (after setting up your build environment):
12​ 12​
13 make tokyo60:default 13 make tokyokeyboard/tokyo60:default
14​ 14​
15See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). 15See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/keyboards/tokyo60/rules.mk b/keyboards/tokyokeyboard/tokyo60/rules.mk
index fa639b1ca..fa639b1ca 100644
--- a/keyboards/tokyo60/rules.mk
+++ b/keyboards/tokyokeyboard/tokyo60/rules.mk
diff --git a/keyboards/tokyo60/tokyo60.c b/keyboards/tokyokeyboard/tokyo60/tokyo60.c
index 2126bb612..2126bb612 100644
--- a/keyboards/tokyo60/tokyo60.c
+++ b/keyboards/tokyokeyboard/tokyo60/tokyo60.c
diff --git a/keyboards/tokyo60/tokyo60.h b/keyboards/tokyokeyboard/tokyo60/tokyo60.h
index 9eb5f3e62..9eb5f3e62 100644
--- a/keyboards/tokyo60/tokyo60.h
+++ b/keyboards/tokyokeyboard/tokyo60/tokyo60.h
diff --git a/keyboards/whitefox/config.h b/keyboards/whitefox/config.h
index 4d7a460d2..1cdac01d0 100644
--- a/keyboards/whitefox/config.h
+++ b/keyboards/whitefox/config.h
@@ -62,6 +62,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
62#define LED_BRIGHTNESS_LO 100 62#define LED_BRIGHTNESS_LO 100
63#define LED_BRIGHTNESS_HI 255 63#define LED_BRIGHTNESS_HI 255
64 64
65/* LED matrix driver */
66#define LED_DRIVER_ADDR_1 0x74
67#define LED_DRIVER_COUNT 1
68#define DRIVER_LED_TOTAL 71
69#define LED_DISABLE_WHEN_USB_SUSPENDED
70
71/* i2c (for LED matrix) */
72#define I2C1_CLOCK_SPEED 400000
73#define I2C1_SCL_PAL_MODE PAL_MODE_ALTERNATIVE_2
74#define I2C1_SDA_PAL_MODE PAL_MODE_ALTERNATIVE_2
75#define I2C1_BANK GPIOB
76#define I2C1_SCL 0
77#define I2C1_SDA 1
78
65/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. 79/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
66 * This is useful for the Windows task manager shortcut (ctrl+shift+esc). 80 * This is useful for the Windows task manager shortcut (ctrl+shift+esc).
67 */ 81 */
diff --git a/keyboards/whitefox/rules.mk b/keyboards/whitefox/rules.mk
index 771804369..7c1d0c3de 100644
--- a/keyboards/whitefox/rules.mk
+++ b/keyboards/whitefox/rules.mk
@@ -25,16 +25,12 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
25SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 25SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
26# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 26# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
27NKRO_ENABLE = yes # USB Nkey Rollover 27NKRO_ENABLE = yes # USB Nkey Rollover
28BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
29RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow 28RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
30BLUETOOTH_ENABLE = no # Enable Bluetooth 29BLUETOOTH_ENABLE = no # Enable Bluetooth
31AUDIO_ENABLE = no # Audio output 30AUDIO_ENABLE = no # Audio output
32BACKLIGHT_DRIVER = custom
33VISUALIZER_ENABLE = yes
34 31
35LED_DRIVER = is31fl3731c 32LED_MATRIX_ENABLE = yes
36LED_WIDTH = 16 33LED_MATRIX_DRIVER = IS31FL3731
37LED_HEIGHT = 5
38 34
39LAYOUTS = 65_ansi 65_ansi_blocker 65_ansi_blocker_split_bs 65_iso 65_iso_blocker 65_iso_blocker_split_bs 35LAYOUTS = 65_ansi 65_ansi_blocker 65_ansi_blocker_split_bs 65_iso 65_iso_blocker 65_iso_blocker_split_bs
40 36
diff --git a/keyboards/whitefox/whitefox.c b/keyboards/whitefox/whitefox.c
index ea083c6e0..f10f0fd5c 100644
--- a/keyboards/whitefox/whitefox.c
+++ b/keyboards/whitefox/whitefox.c
@@ -16,3 +16,79 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include "whitefox.h" 18#include "whitefox.h"
19
20#ifdef LED_MATRIX_ENABLE
21const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
22// The numbers in the comments are the led numbers DXX on the PCB
23/* Refer to IS31 manual for these locations
24 * driver
25 * | LED address
26 * | | */
27// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
28 { 0, C1_1 }, { 0, C1_2 }, { 0, C1_3 }, { 0, C1_4 }, { 0, C1_5 }, { 0, C1_6 }, { 0, C1_7 }, { 0, C1_8 }, { 0, C2_1 }, { 0, C2_2 }, { 0, C2_3 }, { 0, C2_4 }, { 0, C2_5 }, { 0, C2_6 }, { 0, C2_7 }, { 0, C2_8 },
29// 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
30 { 0, C3_1 }, { 0, C3_2 }, { 0, C3_3 }, { 0, C3_4 }, { 0, C3_5 }, { 0, C3_6 }, { 0, C3_7 }, { 0, C3_8 }, { 0, C4_1 }, { 0, C4_2 }, { 0, C4_3 }, { 0, C4_4 }, { 0, C4_5 }, { 0, C4_6 }, { 0, C4_7 },
31// 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
32 { 0, C4_8 }, { 0, C5_1 }, { 0, C5_2 }, { 0, C5_3 }, { 0, C5_4 }, { 0, C5_5 }, { 0, C5_6 }, { 0, C5_7 }, { 0, C5_8 }, { 0, C6_1 }, { 0, C6_2 }, { 0, C6_3 }, { 0, C6_4 }, { 0, C6_5 }, { 0, C6_6 },
33// 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
34 { 0, C6_7 }, { 0, C6_8 }, { 0, C7_1 }, { 0, C7_2 }, { 0, C7_3 }, { 0, C7_4 }, { 0, C7_5 }, { 0, C7_6 }, { 0, C7_7 }, { 0, C7_8 }, { 0, C8_1 }, { 0, C8_2 }, { 0, C8_3 }, { 0, C8_4 }, { 0, C8_5 },
35// 62 63 64 65 66 67 68 69 70 71
36 { 0, C8_6 }, { 0, C8_7 }, { 0, C8_8 }, { 0, C9_1 }, { 0, C9_2 }, { 0, C9_3 }, { 0, C9_4 }, { 0, C9_5 }, { 0, C9_6 }, { 0, C9_7 },
37};
38
39led_config_t g_led_config = {
40 {
41 // Key Matrix to LED Index
42 { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
43 { 9, 10, 11, 12, 13, 14, 15, 16, 17 },
44 { 18, 19, 20, 21, 22, 23, 24, 25, 26 },
45 { 27, 28, 29, 30, 31, 32, 33, 34, 35 },
46 { 36, 37, 38, 39, 40, 41, 42, 43, 44 },
47 { 45, 46, 47, 48, 49, 50, 51, 52, 53 },
48 { 54, 55, 56, 57, 58, 59, 60, 61, 62 },
49 { 63, 64, 65, 66, 67, 68, 69, 70, NO_LED },
50 }, {
51 // LED Index to Physical Position
52 { 0, 0 }, { 15, 0 }, { 30, 0 }, { 45, 0 }, { 60, 0 }, { 75, 0 }, { 90, 0 }, { 105, 0 }, { 119, 0 }, { 134, 0 }, { 149, 0 }, { 164, 0 }, { 179, 0 }, { 194, 0 }, { 209, 0 }, { 224, 0 },
53 { 4, 16 }, { 22, 16 }, { 37, 16 }, { 52, 16 }, { 67, 16 }, { 82, 16 }, { 97, 16 }, { 112, 16 }, { 127, 16 }, { 142, 16 }, { 157, 16 }, { 172, 16 }, { 187, 16 }, { 205, 16 }, { 224, 16 },
54 { 6, 32 }, { 26, 32 }, { 41, 32 }, { 56, 32 }, { 71, 32 }, { 86, 32 }, { 101, 32 }, { 116, 32 }, { 131, 32 }, { 146, 32 }, { 161, 32 }, { 175, 32 }, { 190, 32 }, { 207, 32 }, { 224, 32 },
55 { 2, 48 }, { 19, 48 }, { 34, 48 }, { 49, 48 }, { 63, 48 }, { 78, 48 }, { 93, 48 }, { 108, 48 }, { 123, 48 }, { 138, 48 }, { 153, 48 }, { 168, 48 }, { 189, 48 }, { 209, 48 }, { 224, 48 },
56 { 2, 64 }, { 21, 64 }, { 39, 64 }, { 95, 64 }, { 149, 64 }, { 164, 64 }, { 179, 64 }, { 194, 64 }, { 209, 64 }, { 224, 64 }
57 }, {
58 // LED Index to Flag
59 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
60 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
61 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1,
62 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1,
63 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
64 }
65};
66#endif
67
68void keyboard_pre_init_kb(void) {
69#ifdef LED_MATRIX_ENABLE
70 // Turn on LED controller
71 setPinOutput(B16);
72 writePinHigh(B16);
73#endif
74 keyboard_pre_init_user();
75}
76
77void matrix_init_kb(void) {
78 // put your keyboard start-up code here
79 // runs once when the firmware starts up
80
81#ifdef LED_MATRIX_ENABLE
82 /*
83 * Since K20x is stuck with a 32 byte EEPROM (see tmk_core/common/chibios/eeprom_teensy.c),
84 * and neither led_matrix_eeconfig.speed or .flags fit in this boundary, just force their values to default on boot.
85 */
86# if !defined(LED_MATRIX_STARTUP_SPD)
87# define LED_MATRIX_STARTUP_SPD UINT8_MAX / 2
88# endif
89 led_matrix_set_speed(LED_MATRIX_STARTUP_SPD),
90 led_matrix_set_flags(LED_FLAG_ALL);
91#endif
92
93 matrix_init_user();
94}
diff --git a/keyboards/xbows/nature/config.h b/keyboards/xbows/nature/config.h
index c1ff79335..e321f7ee1 100644
--- a/keyboards/xbows/nature/config.h
+++ b/keyboards/xbows/nature/config.h
@@ -35,7 +35,7 @@
35# define RGB_MATRIX_LED_PROCESS_LIMIT 18 35# define RGB_MATRIX_LED_PROCESS_LIMIT 18
36# define RGB_MATRIX_LED_FLUSH_LIMIT 16 36# define RGB_MATRIX_LED_FLUSH_LIMIT 16
37# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 37# define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
38# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 38# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
39# define RGB_MATRIX_KEYPRESSES 39# define RGB_MATRIX_KEYPRESSES
40# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 40# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200
41# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 41# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/keyboards/xbows/woody/config.h b/keyboards/xbows/woody/config.h
index 7f396d000..ea27508da 100644
--- a/keyboards/xbows/woody/config.h
+++ b/keyboards/xbows/woody/config.h
@@ -16,10 +16,10 @@
16#define RGB_MATRIX_LED_FLUSH_LIMIT 26 16#define RGB_MATRIX_LED_FLUSH_LIMIT 26
17#define DEBOUNCE 3 17#define DEBOUNCE 3
18#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 18#define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
19#define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 19#define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
20#define RGB_MATRIX_KEYPRESSES 20#define RGB_MATRIX_KEYPRESSES
21#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 21#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200
22#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 22#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
23#define DISABLE_RGB_MATRIX_BAND_SAT 23#define DISABLE_RGB_MATRIX_BAND_SAT
24#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT 24#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
25#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT 25#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT
@@ -40,4 +40,4 @@
40#define DRIVER_1_LED_TOTAL 35 40#define DRIVER_1_LED_TOTAL 35
41#define DRIVER_2_LED_TOTAL 32 41#define DRIVER_2_LED_TOTAL 32
42#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL) 42#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
43#endif \ No newline at end of file 43#endif
diff --git a/keyboards/yncognito/batpad/config.h b/keyboards/yncognito/batpad/config.h
index 02c84a514..7ca4072e0 100644
--- a/keyboards/yncognito/batpad/config.h
+++ b/keyboards/yncognito/batpad/config.h
@@ -47,13 +47,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
47 47
48#define RGB_DI_PIN B5 48#define RGB_DI_PIN B5
49#define DRIVER_LED_TOTAL 8 49#define DRIVER_LED_TOTAL 8
50#define RGB_MATRIX_KEYPRESSES 50#define RGB_MATRIX_KEYPRESSES
51#define RGB_MATRIX_KEYRELEASES 51#define RGB_MATRIX_KEYRELEASES
52#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 52#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
53#define RGB_DISABLE_AFTER_TIMEOUT 0 53#define RGB_DISABLE_AFTER_TIMEOUT 0
54#define RGB_DISABLE_WHEN_USB_SUSPENDED false 54// #define RGB_DISABLE_WHEN_USB_SUSPENDED
55#define RGB_MATRIX_LED_FLUSH_LIMIT 16 55#define RGB_MATRIX_LED_FLUSH_LIMIT 16
56#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255 56#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 255
57#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_ALL 57#define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_ALL
58
59
diff --git a/layouts/community/ortho_4x12/bocaj/config.h b/layouts/community/ortho_4x12/bocaj/config.h
index 9a65684f3..c9d297f92 100644
--- a/layouts/community/ortho_4x12/bocaj/config.h
+++ b/layouts/community/ortho_4x12/bocaj/config.h
@@ -24,7 +24,7 @@
24# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 24# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
25// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 25// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
26// #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 26// #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
27# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 27# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
28# undef RGB_MATRIX_LED_PROCESS_LIMIT 28# undef RGB_MATRIX_LED_PROCESS_LIMIT
29# undef RGB_MATRIX_LED_FLUSH_LIMIT 29# undef RGB_MATRIX_LED_FLUSH_LIMIT
30#endif 30#endif
diff --git a/layouts/community/ortho_4x12/drashna/config.h b/layouts/community/ortho_4x12/drashna/config.h
index f4abd64f5..43143c3a3 100644
--- a/layouts/community/ortho_4x12/drashna/config.h
+++ b/layouts/community/ortho_4x12/drashna/config.h
@@ -37,7 +37,7 @@
37# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 37# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
38// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 38// #define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
39// #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 39// #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
40# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 40# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
41# undef RGB_MATRIX_LED_PROCESS_LIMIT 41# undef RGB_MATRIX_LED_PROCESS_LIMIT
42# undef RGB_MATRIX_LED_FLUSH_LIMIT 42# undef RGB_MATRIX_LED_FLUSH_LIMIT
43# ifdef KEYBOARD_planck_rev6 43# ifdef KEYBOARD_planck_rev6
diff --git a/layouts/community/split_3x6_3/drashna/config.h b/layouts/community/split_3x6_3/drashna/config.h
index dd950ce7b..cc53d4c36 100644
--- a/layouts/community/split_3x6_3/drashna/config.h
+++ b/layouts/community/split_3x6_3/drashna/config.h
@@ -47,7 +47,7 @@
47# define RGB_MATRIX_KEYPRESSES // reacts to keypresses 47# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
48// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses) 48// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
49// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 49// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
50# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 50# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
51// # 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) 51// # 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)
52// # 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) 52// # 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)
53# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 53# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 120 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
diff --git a/lib/chibios b/lib/chibios
Subproject ffe54d63cb10a355add318f8e922e39f1c3d4bf Subproject 413e39c5681d181720440f2a8b7391f581788d7
diff --git a/lib/chibios-contrib b/lib/chibios-contrib
Subproject 61baa6b036138c155f7cfc5646d833d9423f324 Subproject 9c2bfa6aeba993345f5425d82807c101f8e25e6
diff --git a/quantum/debounce.h b/quantum/debounce.h
index 9ca05c682..504386828 100644
--- a/quantum/debounce.h
+++ b/quantum/debounce.h
@@ -9,3 +9,5 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
9bool debounce_active(void); 9bool debounce_active(void);
10 10
11void debounce_init(uint8_t num_rows); 11void debounce_init(uint8_t num_rows);
12
13void debounce_free(void);
diff --git a/quantum/debounce/asym_eager_defer_pk.c b/quantum/debounce/asym_eager_defer_pk.c
new file mode 100644
index 000000000..24380dc5e
--- /dev/null
+++ b/quantum/debounce/asym_eager_defer_pk.c
@@ -0,0 +1,171 @@
1/*
2 * Copyright 2017 Alex Ong <the.onga@gmail.com>
3 * Copyright 2020 Andrei Purdea <andrei@purdea.ro>
4 * Copyright 2021 Simon Arlott
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21Basic symmetric per-key algorithm. Uses an 8-bit counter per key.
22When no state changes have occured for DEBOUNCE milliseconds, we push the state.
23*/
24
25#include "matrix.h"
26#include "timer.h"
27#include "quantum.h"
28#include <stdlib.h>
29
30#ifdef PROTOCOL_CHIBIOS
31# if CH_CFG_USE_MEMCORE == FALSE
32# error ChibiOS is configured without a memory allocator. Your keyboard may have set `#define CH_CFG_USE_MEMCORE FALSE`, which is incompatible with this debounce algorithm.
33# endif
34#endif
35
36#ifndef DEBOUNCE
37# define DEBOUNCE 5
38#endif
39
40// Maximum debounce: 127ms
41#if DEBOUNCE > 127
42# undef DEBOUNCE
43# define DEBOUNCE 127
44#endif
45
46#define ROW_SHIFTER ((matrix_row_t)1)
47
48typedef struct {
49 bool pressed : 1;
50 uint8_t time : 7;
51} debounce_counter_t;
52
53#if DEBOUNCE > 0
54static debounce_counter_t *debounce_counters;
55static fast_timer_t last_time;
56static bool counters_need_update;
57static bool matrix_need_update;
58
59#define DEBOUNCE_ELAPSED 0
60
61static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time);
62static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
63
64// we use num_rows rather than MATRIX_ROWS to support split keyboards
65void debounce_init(uint8_t num_rows) {
66 debounce_counters = malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
67 int i = 0;
68 for (uint8_t r = 0; r < num_rows; r++) {
69 for (uint8_t c = 0; c < MATRIX_COLS; c++) {
70 debounce_counters[i++].time = DEBOUNCE_ELAPSED;
71 }
72 }
73}
74
75void debounce_free(void) {
76 free(debounce_counters);
77 debounce_counters = NULL;
78}
79
80void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
81 bool updated_last = false;
82
83 if (counters_need_update) {
84 fast_timer_t now = timer_read_fast();
85 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
86
87 last_time = now;
88 updated_last = true;
89 if (elapsed_time > UINT8_MAX) {
90 elapsed_time = UINT8_MAX;
91 }
92
93 if (elapsed_time > 0) {
94 update_debounce_counters_and_transfer_if_expired(raw, cooked, num_rows, elapsed_time);
95 }
96 }
97
98 if (changed || matrix_need_update) {
99 if (!updated_last) {
100 last_time = timer_read_fast();
101 }
102
103 transfer_matrix_values(raw, cooked, num_rows);
104 }
105}
106
107static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time) {
108 debounce_counter_t *debounce_pointer = debounce_counters;
109
110 counters_need_update = false;
111 matrix_need_update = false;
112
113 for (uint8_t row = 0; row < num_rows; row++) {
114 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
115 matrix_row_t col_mask = (ROW_SHIFTER << col);
116
117 if (debounce_pointer->time != DEBOUNCE_ELAPSED) {
118 if (debounce_pointer->time <= elapsed_time) {
119 debounce_pointer->time = DEBOUNCE_ELAPSED;
120
121 if (debounce_pointer->pressed) {
122 // key-down: eager
123 matrix_need_update = true;
124 } else {
125 // key-up: defer
126 cooked[row] = (cooked[row] & ~col_mask) | (raw[row] & col_mask);
127 }
128 } else {
129 debounce_pointer->time -= elapsed_time;
130 counters_need_update = true;
131 }
132 }
133 debounce_pointer++;
134 }
135 }
136}
137
138static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) {
139 debounce_counter_t *debounce_pointer = debounce_counters;
140
141 for (uint8_t row = 0; row < num_rows; row++) {
142 matrix_row_t delta = raw[row] ^ cooked[row];
143 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
144 matrix_row_t col_mask = (ROW_SHIFTER << col);
145
146 if (delta & col_mask) {
147 if (debounce_pointer->time == DEBOUNCE_ELAPSED) {
148 debounce_pointer->pressed = (raw[row] & col_mask);
149 debounce_pointer->time = DEBOUNCE;
150 counters_need_update = true;
151
152 if (debounce_pointer->pressed) {
153 // key-down: eager
154 cooked[row] ^= col_mask;
155 }
156 }
157 } else if (debounce_pointer->time != DEBOUNCE_ELAPSED) {
158 if (!debounce_pointer->pressed) {
159 // key-up: defer
160 debounce_pointer->time = DEBOUNCE_ELAPSED;
161 }
162 }
163 debounce_pointer++;
164 }
165 }
166}
167
168bool debounce_active(void) { return true; }
169#else
170# include "none.c"
171#endif
diff --git a/quantum/debounce/none.c b/quantum/debounce/none.c
new file mode 100644
index 000000000..b03892bc5
--- /dev/null
+++ b/quantum/debounce/none.c
@@ -0,0 +1,31 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "matrix.h"
18#include "quantum.h"
19#include <stdlib.h>
20
21void debounce_init(uint8_t num_rows) {}
22
23void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
24 for (int i = 0; i < num_rows; i++) {
25 cooked[i] = raw[i];
26 }
27}
28
29bool debounce_active(void) { return false; }
30
31void debounce_free(void) {}
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c
index 3ed9055d2..fbefd55ed 100644
--- a/quantum/debounce/sym_defer_g.c
+++ b/quantum/debounce/sym_defer_g.c
@@ -1,5 +1,6 @@
1/* 1/*
2Copyright 2017 Alex Ong<the.onga@gmail.com> 2Copyright 2017 Alex Ong<the.onga@gmail.com>
3Copyright 2021 Simon Arlott
3This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
5the Free Software Foundation, either version 2 of the License, or 6the Free Software Foundation, either version 2 of the License, or
@@ -23,30 +24,29 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
23# define DEBOUNCE 5 24# define DEBOUNCE 5
24#endif 25#endif
25 26
26void debounce_init(uint8_t num_rows) {} 27#if DEBOUNCE > 0
27static bool debouncing = false; 28static bool debouncing = false;
29static fast_timer_t debouncing_time;
28 30
29#if DEBOUNCE > 0 31void debounce_init(uint8_t num_rows) {}
30static uint16_t debouncing_time; 32
31void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { 33void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
32 if (changed) { 34 if (changed) {
33 debouncing = true; 35 debouncing = true;
34 debouncing_time = timer_read(); 36 debouncing_time = timer_read_fast();
35 } 37 }
36 38
37 if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) { 39 if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
38 for (int i = 0; i < num_rows; i++) { 40 for (int i = 0; i < num_rows; i++) {
39 cooked[i] = raw[i]; 41 cooked[i] = raw[i];
40 } 42 }
41 debouncing = false; 43 debouncing = false;
42 } 44 }
43} 45}
44#else // no debouncing.
45void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
46 for (int i = 0; i < num_rows; i++) {
47 cooked[i] = raw[i];
48 }
49}
50#endif
51 46
52bool debounce_active(void) { return debouncing; } 47bool debounce_active(void) { return debouncing; }
48
49void debounce_free(void) {}
50#else // no debouncing.
51# include "none.c"
52#endif
diff --git a/quantum/debounce/sym_defer_pk.c b/quantum/debounce/sym_defer_pk.c
index 60513f98e..626a9be84 100644
--- a/quantum/debounce/sym_defer_pk.c
+++ b/quantum/debounce/sym_defer_pk.c
@@ -1,6 +1,7 @@
1/* 1/*
2Copyright 2017 Alex Ong<the.onga@gmail.com> 2Copyright 2017 Alex Ong<the.onga@gmail.com>
3Copyright 2020 Andrei Purdea<andrei@purdea.ro> 3Copyright 2020 Andrei Purdea<andrei@purdea.ro>
4Copyright 2021 Simon Arlott
4This program is free software: you can redistribute it and/or modify 5This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 6it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or 7the Free Software Foundation, either version 2 of the License, or
@@ -33,28 +34,25 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
33# define DEBOUNCE 5 34# define DEBOUNCE 5
34#endif 35#endif
35 36
37// Maximum debounce: 255ms
38#if DEBOUNCE > UINT8_MAX
39# undef DEBOUNCE
40# define DEBOUNCE UINT8_MAX
41#endif
42
36#define ROW_SHIFTER ((matrix_row_t)1) 43#define ROW_SHIFTER ((matrix_row_t)1)
37 44
38#define debounce_counter_t uint8_t 45typedef uint8_t debounce_counter_t;
39 46
47#if DEBOUNCE > 0
40static debounce_counter_t *debounce_counters; 48static debounce_counter_t *debounce_counters;
49static fast_timer_t last_time;
41static bool counters_need_update; 50static bool counters_need_update;
42 51
43#define DEBOUNCE_ELAPSED 251 52#define DEBOUNCE_ELAPSED 0
44#define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1)
45
46static uint8_t wrapping_timer_read(void) {
47 static uint16_t time = 0;
48 static uint8_t last_result = 0;
49 uint16_t new_time = timer_read();
50 uint16_t diff = new_time - time;
51 time = new_time;
52 last_result = (last_result + diff) % (MAX_DEBOUNCE + 1);
53 return last_result;
54}
55 53
56void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time); 54static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time);
57void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time); 55static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
58 56
59// we use num_rows rather than MATRIX_ROWS to support split keyboards 57// we use num_rows rather than MATRIX_ROWS to support split keyboards
60void debounce_init(uint8_t num_rows) { 58void debounce_init(uint8_t num_rows) {
@@ -67,27 +65,49 @@ void debounce_init(uint8_t num_rows) {
67 } 65 }
68} 66}
69 67
68void debounce_free(void) {
69 free(debounce_counters);
70 debounce_counters = NULL;
71}
72
70void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { 73void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
71 uint8_t current_time = wrapping_timer_read(); 74 bool updated_last = false;
75
72 if (counters_need_update) { 76 if (counters_need_update) {
73 update_debounce_counters_and_transfer_if_expired(raw, cooked, num_rows, current_time); 77 fast_timer_t now = timer_read_fast();
78 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
79
80 last_time = now;
81 updated_last = true;
82 if (elapsed_time > UINT8_MAX) {
83 elapsed_time = UINT8_MAX;
84 }
85
86 if (elapsed_time > 0) {
87 update_debounce_counters_and_transfer_if_expired(raw, cooked, num_rows, elapsed_time);
88 }
74 } 89 }
75 90
76 if (changed) { 91 if (changed) {
77 start_debounce_counters(raw, cooked, num_rows, current_time); 92 if (!updated_last) {
93 last_time = timer_read_fast();
94 }
95
96 start_debounce_counters(raw, cooked, num_rows);
78 } 97 }
79} 98}
80 99
81void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) { 100static void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t elapsed_time) {
82 counters_need_update = false; 101 counters_need_update = false;
83 debounce_counter_t *debounce_pointer = debounce_counters; 102 debounce_counter_t *debounce_pointer = debounce_counters;
84 for (uint8_t row = 0; row < num_rows; row++) { 103 for (uint8_t row = 0; row < num_rows; row++) {
85 for (uint8_t col = 0; col < MATRIX_COLS; col++) { 104 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
86 if (*debounce_pointer != DEBOUNCE_ELAPSED) { 105 if (*debounce_pointer != DEBOUNCE_ELAPSED) {
87 if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) { 106 if (*debounce_pointer <= elapsed_time) {
88 *debounce_pointer = DEBOUNCE_ELAPSED; 107 *debounce_pointer = DEBOUNCE_ELAPSED;
89 cooked[row] = (cooked[row] & ~(ROW_SHIFTER << col)) | (raw[row] & (ROW_SHIFTER << col)); 108 cooked[row] = (cooked[row] & ~(ROW_SHIFTER << col)) | (raw[row] & (ROW_SHIFTER << col));
90 } else { 109 } else {
110 *debounce_pointer -= elapsed_time;
91 counters_need_update = true; 111 counters_need_update = true;
92 } 112 }
93 } 113 }
@@ -96,14 +116,14 @@ void update_debounce_counters_and_transfer_if_expired(matrix_row_t raw[], matrix
96 } 116 }
97} 117}
98 118
99void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) { 119static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) {
100 debounce_counter_t *debounce_pointer = debounce_counters; 120 debounce_counter_t *debounce_pointer = debounce_counters;
101 for (uint8_t row = 0; row < num_rows; row++) { 121 for (uint8_t row = 0; row < num_rows; row++) {
102 matrix_row_t delta = raw[row] ^ cooked[row]; 122 matrix_row_t delta = raw[row] ^ cooked[row];
103 for (uint8_t col = 0; col < MATRIX_COLS; col++) { 123 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
104 if (delta & (ROW_SHIFTER << col)) { 124 if (delta & (ROW_SHIFTER << col)) {
105 if (*debounce_pointer == DEBOUNCE_ELAPSED) { 125 if (*debounce_pointer == DEBOUNCE_ELAPSED) {
106 *debounce_pointer = current_time; 126 *debounce_pointer = DEBOUNCE;
107 counters_need_update = true; 127 counters_need_update = true;
108 } 128 }
109 } else { 129 } else {
@@ -115,3 +135,6 @@ void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], uint8_t
115} 135}
116 136
117bool debounce_active(void) { return true; } 137bool debounce_active(void) { return true; }
138#else
139# include "none.c"
140#endif
diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c
index e66cf92d7..15a3242e6 100644
--- a/quantum/debounce/sym_eager_pk.c
+++ b/quantum/debounce/sym_eager_pk.c
@@ -1,5 +1,6 @@
1/* 1/*
2Copyright 2017 Alex Ong<the.onga@gmail.com> 2Copyright 2017 Alex Ong<the.onga@gmail.com>
3Copyright 2021 Simon Arlott
3This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
5the Free Software Foundation, either version 2 of the License, or 6the Free Software Foundation, either version 2 of the License, or
@@ -33,29 +34,26 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
33# define DEBOUNCE 5 34# define DEBOUNCE 5
34#endif 35#endif
35 36
37// Maximum debounce: 255ms
38#if DEBOUNCE > UINT8_MAX
39# undef DEBOUNCE
40# define DEBOUNCE UINT8_MAX
41#endif
42
36#define ROW_SHIFTER ((matrix_row_t)1) 43#define ROW_SHIFTER ((matrix_row_t)1)
37 44
38#define debounce_counter_t uint8_t 45typedef uint8_t debounce_counter_t;
39 46
47#if DEBOUNCE > 0
40static debounce_counter_t *debounce_counters; 48static debounce_counter_t *debounce_counters;
49static fast_timer_t last_time;
41static bool counters_need_update; 50static bool counters_need_update;
42static bool matrix_need_update; 51static bool matrix_need_update;
43 52
44#define DEBOUNCE_ELAPSED 251 53#define DEBOUNCE_ELAPSED 0
45#define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1)
46
47static uint8_t wrapping_timer_read(void) {
48 static uint16_t time = 0;
49 static uint8_t last_result = 0;
50 uint16_t new_time = timer_read();
51 uint16_t diff = new_time - time;
52 time = new_time;
53 last_result = (last_result + diff) % (MAX_DEBOUNCE + 1);
54 return last_result;
55}
56 54
57void update_debounce_counters(uint8_t num_rows, uint8_t current_time); 55static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time);
58void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time); 56static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
59 57
60// we use num_rows rather than MATRIX_ROWS to support split keyboards 58// we use num_rows rather than MATRIX_ROWS to support split keyboards
61void debounce_init(uint8_t num_rows) { 59void debounce_init(uint8_t num_rows) {
@@ -68,27 +66,51 @@ void debounce_init(uint8_t num_rows) {
68 } 66 }
69} 67}
70 68
69void debounce_free(void) {
70 free(debounce_counters);
71 debounce_counters = NULL;
72}
73
71void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { 74void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
72 uint8_t current_time = wrapping_timer_read(); 75 bool updated_last = false;
76
73 if (counters_need_update) { 77 if (counters_need_update) {
74 update_debounce_counters(num_rows, current_time); 78 fast_timer_t now = timer_read_fast();
79 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
80
81 last_time = now;
82 updated_last = true;
83 if (elapsed_time > UINT8_MAX) {
84 elapsed_time = UINT8_MAX;
85 }
86
87 if (elapsed_time > 0) {
88 update_debounce_counters(num_rows, elapsed_time);
89 }
75 } 90 }
76 91
77 if (changed || matrix_need_update) { 92 if (changed || matrix_need_update) {
78 transfer_matrix_values(raw, cooked, num_rows, current_time); 93 if (!updated_last) {
94 last_time = timer_read_fast();
95 }
96
97 transfer_matrix_values(raw, cooked, num_rows);
79 } 98 }
80} 99}
81 100
82// If the current time is > debounce counter, set the counter to enable input. 101// If the current time is > debounce counter, set the counter to enable input.
83void update_debounce_counters(uint8_t num_rows, uint8_t current_time) { 102static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) {
84 counters_need_update = false; 103 counters_need_update = false;
104 matrix_need_update = false;
85 debounce_counter_t *debounce_pointer = debounce_counters; 105 debounce_counter_t *debounce_pointer = debounce_counters;
86 for (uint8_t row = 0; row < num_rows; row++) { 106 for (uint8_t row = 0; row < num_rows; row++) {
87 for (uint8_t col = 0; col < MATRIX_COLS; col++) { 107 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
88 if (*debounce_pointer != DEBOUNCE_ELAPSED) { 108 if (*debounce_pointer != DEBOUNCE_ELAPSED) {
89 if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) { 109 if (*debounce_pointer <= elapsed_time) {
90 *debounce_pointer = DEBOUNCE_ELAPSED; 110 *debounce_pointer = DEBOUNCE_ELAPSED;
111 matrix_need_update = true;
91 } else { 112 } else {
113 *debounce_pointer -= elapsed_time;
92 counters_need_update = true; 114 counters_need_update = true;
93 } 115 }
94 } 116 }
@@ -98,8 +120,7 @@ void update_debounce_counters(uint8_t num_rows, uint8_t current_time) {
98} 120}
99 121
100// upload from raw_matrix to final matrix; 122// upload from raw_matrix to final matrix;
101void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) { 123static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) {
102 matrix_need_update = false;
103 debounce_counter_t *debounce_pointer = debounce_counters; 124 debounce_counter_t *debounce_pointer = debounce_counters;
104 for (uint8_t row = 0; row < num_rows; row++) { 125 for (uint8_t row = 0; row < num_rows; row++) {
105 matrix_row_t delta = raw[row] ^ cooked[row]; 126 matrix_row_t delta = raw[row] ^ cooked[row];
@@ -108,11 +129,9 @@ void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t n
108 matrix_row_t col_mask = (ROW_SHIFTER << col); 129 matrix_row_t col_mask = (ROW_SHIFTER << col);
109 if (delta & col_mask) { 130 if (delta & col_mask) {
110 if (*debounce_pointer == DEBOUNCE_ELAPSED) { 131 if (*debounce_pointer == DEBOUNCE_ELAPSED) {
111 *debounce_pointer = current_time; 132 *debounce_pointer = DEBOUNCE;
112 counters_need_update = true; 133 counters_need_update = true;
113 existing_row ^= col_mask; // flip the bit. 134 existing_row ^= col_mask; // flip the bit.
114 } else {
115 matrix_need_update = true;
116 } 135 }
117 } 136 }
118 debounce_pointer++; 137 debounce_pointer++;
@@ -122,3 +141,6 @@ void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t n
122} 141}
123 142
124bool debounce_active(void) { return true; } 143bool debounce_active(void) { return true; }
144#else
145# include "none.c"
146#endif
diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c
index 20ccb46f1..2ad592c5a 100644
--- a/quantum/debounce/sym_eager_pr.c
+++ b/quantum/debounce/sym_eager_pr.c
@@ -1,5 +1,6 @@
1/* 1/*
2Copyright 2019 Alex Ong<the.onga@gmail.com> 2Copyright 2019 Alex Ong<the.onga@gmail.com>
3Copyright 2021 Simon Arlott
3This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
5the Free Software Foundation, either version 2 of the License, or 6the Free Software Foundation, either version 2 of the License, or
@@ -33,27 +34,25 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
33# define DEBOUNCE 5 34# define DEBOUNCE 5
34#endif 35#endif
35 36
36#define debounce_counter_t uint8_t 37// Maximum debounce: 255ms
38#if DEBOUNCE > UINT8_MAX
39# undef DEBOUNCE
40# define DEBOUNCE UINT8_MAX
41#endif
42
43typedef uint8_t debounce_counter_t;
44
45#if DEBOUNCE > 0
37static bool matrix_need_update; 46static bool matrix_need_update;
38 47
39static debounce_counter_t *debounce_counters; 48static debounce_counter_t *debounce_counters;
49static fast_timer_t last_time;
40static bool counters_need_update; 50static bool counters_need_update;
41 51
42#define DEBOUNCE_ELAPSED 251 52#define DEBOUNCE_ELAPSED 0
43#define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1)
44
45static uint8_t wrapping_timer_read(void) {
46 static uint16_t time = 0;
47 static uint8_t last_result = 0;
48 uint16_t new_time = timer_read();
49 uint16_t diff = new_time - time;
50 time = new_time;
51 last_result = (last_result + diff) % (MAX_DEBOUNCE + 1);
52 return last_result;
53}
54 53
55void update_debounce_counters(uint8_t num_rows, uint8_t current_time); 54static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time);
56void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time); 55static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows);
57 56
58// we use num_rows rather than MATRIX_ROWS to support split keyboards 57// we use num_rows rather than MATRIX_ROWS to support split keyboards
59void debounce_init(uint8_t num_rows) { 58void debounce_init(uint8_t num_rows) {
@@ -63,27 +62,50 @@ void debounce_init(uint8_t num_rows) {
63 } 62 }
64} 63}
65 64
65void debounce_free(void) {
66 free(debounce_counters);
67 debounce_counters = NULL;
68}
69
66void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { 70void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
67 uint8_t current_time = wrapping_timer_read(); 71 bool updated_last = false;
68 bool needed_update = counters_need_update; 72
69 if (counters_need_update) { 73 if (counters_need_update) {
70 update_debounce_counters(num_rows, current_time); 74 fast_timer_t now = timer_read_fast();
75 fast_timer_t elapsed_time = TIMER_DIFF_FAST(now, last_time);
76
77 last_time = now;
78 updated_last = true;
79 if (elapsed_time > UINT8_MAX) {
80 elapsed_time = UINT8_MAX;
81 }
82
83 if (elapsed_time > 0) {
84 update_debounce_counters(num_rows, elapsed_time);
85 }
71 } 86 }
72 87
73 if (changed || (needed_update && !counters_need_update) || matrix_need_update) { 88 if (changed || matrix_need_update) {
74 transfer_matrix_values(raw, cooked, num_rows, current_time); 89 if (!updated_last) {
90 last_time = timer_read_fast();
91 }
92
93 transfer_matrix_values(raw, cooked, num_rows);
75 } 94 }
76} 95}
77 96
78// If the current time is > debounce counter, set the counter to enable input. 97// If the current time is > debounce counter, set the counter to enable input.
79void update_debounce_counters(uint8_t num_rows, uint8_t current_time) { 98static void update_debounce_counters(uint8_t num_rows, uint8_t elapsed_time) {
80 counters_need_update = false; 99 counters_need_update = false;
100 matrix_need_update = false;
81 debounce_counter_t *debounce_pointer = debounce_counters; 101 debounce_counter_t *debounce_pointer = debounce_counters;
82 for (uint8_t row = 0; row < num_rows; row++) { 102 for (uint8_t row = 0; row < num_rows; row++) {
83 if (*debounce_pointer != DEBOUNCE_ELAPSED) { 103 if (*debounce_pointer != DEBOUNCE_ELAPSED) {
84 if (TIMER_DIFF(current_time, *debounce_pointer, MAX_DEBOUNCE) >= DEBOUNCE) { 104 if (*debounce_pointer <= elapsed_time) {
85 *debounce_pointer = DEBOUNCE_ELAPSED; 105 *debounce_pointer = DEBOUNCE_ELAPSED;
106 matrix_need_update = true;
86 } else { 107 } else {
108 *debounce_pointer -= elapsed_time;
87 counters_need_update = true; 109 counters_need_update = true;
88 } 110 }
89 } 111 }
@@ -92,8 +114,7 @@ void update_debounce_counters(uint8_t num_rows, uint8_t current_time) {
92} 114}
93 115
94// upload from raw_matrix to final matrix; 116// upload from raw_matrix to final matrix;
95void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) { 117static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows) {
96 matrix_need_update = false;
97 debounce_counter_t *debounce_pointer = debounce_counters; 118 debounce_counter_t *debounce_pointer = debounce_counters;
98 for (uint8_t row = 0; row < num_rows; row++) { 119 for (uint8_t row = 0; row < num_rows; row++) {
99 matrix_row_t existing_row = cooked[row]; 120 matrix_row_t existing_row = cooked[row];
@@ -102,11 +123,9 @@ void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t n
102 // determine new value basd on debounce pointer + raw value 123 // determine new value basd on debounce pointer + raw value
103 if (existing_row != raw_row) { 124 if (existing_row != raw_row) {
104 if (*debounce_pointer == DEBOUNCE_ELAPSED) { 125 if (*debounce_pointer == DEBOUNCE_ELAPSED) {
105 *debounce_pointer = current_time; 126 *debounce_pointer = DEBOUNCE;
106 cooked[row] = raw_row; 127 cooked[row] = raw_row;
107 counters_need_update = true; 128 counters_need_update = true;
108 } else {
109 matrix_need_update = true;
110 } 129 }
111 } 130 }
112 debounce_pointer++; 131 debounce_pointer++;
@@ -114,3 +133,6 @@ void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t n
114} 133}
115 134
116bool debounce_active(void) { return true; } 135bool debounce_active(void) { return true; }
136#else
137# include "none.c"
138#endif
diff --git a/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
new file mode 100644
index 000000000..fe374c3df
--- /dev/null
+++ b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
@@ -0,0 +1,374 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "gtest/gtest.h"
18
19#include "debounce_test_common.h"
20
21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
24 /* Release key after 1ms delay */
25 {1, {{0, 1, UP}}, {}},
26
27 /*
28 * Until the eager timer on DOWN is observed to finish, the defer timer
29 * on UP can't start. There's no workaround for this because it's not
30 * possible to debounce an event that isn't being tracked.
31 *
32 * sym_defer_pk has the same problem but the test has to track that the
33 * key changed state so the DOWN timer is always allowed to finish
34 * before starting the UP timer.
35 */
36 {5, {}, {}},
37
38 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
39 /* Press key again after 1ms delay */
40 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
41 });
42 runEvents();
43}
44
45TEST_F(DebounceTest, OneKeyShort2) {
46 addEvents({ /* Time, Inputs, Outputs */
47 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
48 /* Release key after 2ms delay */
49 {2, {{0, 1, UP}}, {}},
50
51 {5, {}, {}}, /* See OneKeyShort1 */
52
53 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
54 /* Press key again after 1ms delay */
55 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
56 });
57 runEvents();
58}
59
60TEST_F(DebounceTest, OneKeyShort3) {
61 addEvents({ /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
63 /* Release key after 3ms delay */
64 {3, {{0, 1, UP}}, {}},
65
66 {5, {}, {}}, /* See OneKeyShort1 */
67
68 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
69 /* Press key again after 1ms delay */
70 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
71 });
72 runEvents();
73}
74
75TEST_F(DebounceTest, OneKeyShort4) {
76 addEvents({ /* Time, Inputs, Outputs */
77 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
78 /* Release key after 4ms delay */
79 {4, {{0, 1, UP}}, {}},
80
81 {5, {}, {}}, /* See OneKeyShort1 */
82
83 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
84 /* Press key again after 1ms delay */
85 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
86 });
87 runEvents();
88}
89
90TEST_F(DebounceTest, OneKeyShort5) {
91 addEvents({ /* Time, Inputs, Outputs */
92 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
93
94 /* Release key after 5ms delay */
95 {5, {{0, 1, UP}}, {}},
96
97 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
98 /* Press key again after 1ms delay */
99 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
100 });
101 runEvents();
102}
103
104TEST_F(DebounceTest, OneKeyShort6) {
105 addEvents({ /* Time, Inputs, Outputs */
106 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
107
108 /* Release key after 6ms delay */
109 {6, {{0, 1, UP}}, {}},
110
111 {11, {}, {{0, 1, UP}}}, /* 5ms after UP at time 6 */
112 /* Press key again after 1ms delay */
113 {12, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
114 });
115 runEvents();
116}
117
118TEST_F(DebounceTest, OneKeyShort7) {
119 addEvents({ /* Time, Inputs, Outputs */
120 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
121
122 /* Release key after 7ms delay */
123 {7, {{0, 1, UP}}, {}},
124
125 {12, {}, {{0, 1, UP}}}, /* 5ms after UP at time 7 */
126 /* Press key again after 1ms delay */
127 {13, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
128 });
129 runEvents();
130}
131
132TEST_F(DebounceTest, OneKeyShort8) {
133 addEvents({ /* Time, Inputs, Outputs */
134 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
135 /* Release key after 1ms delay */
136 {1, {{0, 1, UP}}, {}},
137
138 {5, {}, {}}, /* See OneKeyShort1 */
139
140 {10, {}, {{0, 1, UP}}}, /* 5ms after UP at time 7 */
141 /* Press key again after 0ms delay (scan 2) */
142 {10, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
143 });
144 runEvents();
145}
146
147TEST_F(DebounceTest, OneKeyShort9) {
148 addEvents({ /* Time, Inputs, Outputs */
149 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
150 /* Release key after 1ms delay */
151 {1, {{0, 1, UP}}, {}},
152
153 {5, {}, {}}, /* See OneKeyShort1 */
154
155 /* Press key again after 0ms delay (same scan) before debounce finishes */
156 {10, {{0, 1, DOWN}}, {}},
157 });
158 runEvents();
159}
160
161TEST_F(DebounceTest, OneKeyBouncing1) {
162 addEvents({ /* Time, Inputs, Outputs */
163 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
164 {1, {{0, 1, UP}}, {}},
165 {2, {{0, 1, DOWN}}, {}},
166 {3, {{0, 1, UP}}, {}},
167 {4, {{0, 1, DOWN}}, {}},
168 {5, {{0, 1, UP}}, {}},
169 {6, {{0, 1, DOWN}}, {}},
170 {7, {{0, 1, UP}}, {}},
171 {8, {{0, 1, DOWN}}, {}},
172 {9, {{0, 1, UP}}, {}},
173 {10, {{0, 1, DOWN}}, {}},
174 {11, {{0, 1, UP}}, {}},
175 {12, {{0, 1, DOWN}}, {}},
176 {13, {{0, 1, UP}}, {}},
177 {14, {{0, 1, DOWN}}, {}},
178 {15, {{0, 1, UP}}, {}},
179
180 {20, {}, {{0, 1, UP}}},
181 /* Press key again after 1ms delay */
182 {21, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
183 });
184 runEvents();
185}
186
187TEST_F(DebounceTest, OneKeyBouncing2) {
188 addEvents({ /* Time, Inputs, Outputs */
189 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
190 /* Change twice in the same time period */
191 {1, {{0, 1, UP}}, {}},
192 {1, {{0, 1, DOWN}}, {}},
193 /* Change three times in the same time period */
194 {2, {{0, 1, UP}}, {}},
195 {2, {{0, 1, DOWN}}, {}},
196 {2, {{0, 1, UP}}, {}},
197 /* Change twice in the same time period */
198 {6, {{0, 1, DOWN}}, {}},
199 {6, {{0, 1, UP}}, {}},
200 /* Change three times in the same time period */
201 {7, {{0, 1, DOWN}}, {}},
202 {7, {{0, 1, UP}}, {}},
203 {7, {{0, 1, DOWN}}, {}},
204 /* Change twice in the same time period */
205 {8, {{0, 1, UP}}, {}},
206 {8, {{0, 1, DOWN}}, {}},
207 /* Change three times in the same time period */
208 {9, {{0, 1, UP}}, {}},
209 {9, {{0, 1, DOWN}}, {}},
210 {9, {{0, 1, UP}}, {}},
211
212 {14, {}, {{0, 1, UP}}},
213 /* Press key again after 1ms delay */
214 {15, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
215 });
216 runEvents();
217}
218
219TEST_F(DebounceTest, OneKeyLong) {
220 addEvents({ /* Time, Inputs, Outputs */
221 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
222
223 {25, {{0, 1, UP}}, {}},
224
225 {30, {}, {{0, 1, UP}}},
226
227 {50, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
228
229 {75, {{0, 1, UP}}, {}},
230
231 {80, {}, {{0, 1, UP}}},
232
233 {100, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
234 });
235 runEvents();
236}
237
238TEST_F(DebounceTest, TwoKeysShort) {
239 addEvents({ /* Time, Inputs, Outputs */
240 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
241 {1, {{0, 2, DOWN}}, {{0, 2, DOWN}}},
242 /* Release key after 2ms delay */
243 {2, {{0, 1, UP}}, {}},
244 {3, {{0, 2, UP}}, {}},
245
246 {5, {}, {}}, /* See OneKeyShort1 */
247 {6, {}, {}}, /* See OneKeyShort1 */
248
249 {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
250 /* Press key again after 1ms delay */
251 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}, {0, 2, UP}}}, /* 5ms+5ms after DOWN at time 0 */
252 {12, {{0, 2, DOWN}}, {{0, 2, DOWN}}}, /* 5ms+5ms after DOWN at time 0 */
253 });
254 runEvents();
255}
256
257
258TEST_F(DebounceTest, OneKeyDelayedScan1) {
259 addEvents({ /* Time, Inputs, Outputs */
260 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
261
262 /* Processing is very late, immediately release key */
263 {300, {{0, 1, UP}}, {}},
264
265 {305, {}, {{0, 1, UP}}},
266 });
267 time_jumps_ = true;
268 runEvents();
269}
270
271TEST_F(DebounceTest, OneKeyDelayedScan2) {
272 addEvents({ /* Time, Inputs, Outputs */
273 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
274
275 /* Processing is very late, immediately release key */
276 {300, {{0, 1, UP}}, {}},
277
278 /* Processing is very late again */
279 {600, {}, {{0, 1, UP}}},
280 });
281 time_jumps_ = true;
282 runEvents();
283}
284
285TEST_F(DebounceTest, OneKeyDelayedScan3) {
286 addEvents({ /* Time, Inputs, Outputs */
287 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
288
289 /* Processing is very late */
290 {300, {}, {}},
291 /* Release key after 1ms */
292 {301, {{0, 1, UP}}, {}},
293
294 {306, {}, {{0, 1, UP}}},
295 });
296 time_jumps_ = true;
297 runEvents();
298}
299
300TEST_F(DebounceTest, OneKeyDelayedScan4) {
301 addEvents({ /* Time, Inputs, Outputs */
302 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
303
304 /* Processing is very late */
305 {300, {}, {}},
306 /* Release key after 1ms */
307 {301, {{0, 1, UP}}, {}},
308
309 /* Processing is very late again */
310 {600, {}, {{0, 1, UP}}},
311 });
312 time_jumps_ = true;
313 runEvents();
314}
315
316TEST_F(DebounceTest, OneKeyDelayedScan5) {
317 addEvents({ /* Time, Inputs, Outputs */
318 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
319
320 {5, {{0, 1, UP}}, {}},
321
322 /* Processing is very late */
323 {300, {}, {{0, 1, UP}}},
324 /* Immediately press key again */
325 {300, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
326 });
327 time_jumps_ = true;
328 runEvents();
329}
330
331TEST_F(DebounceTest, OneKeyDelayedScan6) {
332 addEvents({ /* Time, Inputs, Outputs */
333 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
334
335 {5, {{0, 1, UP}}, {}},
336
337 /* Processing is very late */
338 {300, {}, {{0, 1, UP}}},
339
340 /* Press key again after 1ms */
341 {301, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
342 });
343 time_jumps_ = true;
344 runEvents();
345}
346
347TEST_F(DebounceTest, OneKeyDelayedScan7) {
348 addEvents({ /* Time, Inputs, Outputs */
349 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
350
351 {5, {{0, 1, UP}}, {}},
352
353 /* Press key again before debounce expires */
354 {300, {{0, 1, DOWN}}, {}},
355 });
356 time_jumps_ = true;
357 runEvents();
358}
359
360TEST_F(DebounceTest, OneKeyDelayedScan8) {
361 addEvents({ /* Time, Inputs, Outputs */
362 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
363
364 /* Processing is a bit late */
365 {50, {}, {}},
366 /* Release key after 1ms */
367 {51, {{0, 1, UP}}, {}},
368
369 /* Processing is a bit late again */
370 {100, {}, {{0, 1, UP}}},
371 });
372 time_jumps_ = true;
373 runEvents();
374}
diff --git a/quantum/debounce/tests/debounce_test_common.cpp b/quantum/debounce/tests/debounce_test_common.cpp
new file mode 100644
index 000000000..1c5e7c9f4
--- /dev/null
+++ b/quantum/debounce/tests/debounce_test_common.cpp
@@ -0,0 +1,229 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "gtest/gtest.h"
18
19#include "debounce_test_common.h"
20
21#include <algorithm>
22#include <iomanip>
23#include <sstream>
24
25extern "C" {
26#include "quantum.h"
27#include "timer.h"
28#include "debounce.h"
29
30void set_time(uint32_t t);
31void advance_time(uint32_t ms);
32}
33
34void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) {
35 events_.insert(events_.end(), events.begin(), events.end());
36}
37
38void DebounceTest::runEvents() {
39 /* Run the test multiple times, from 1kHz to 10kHz scan rate */
40 for (extra_iterations_ = 0; extra_iterations_ < 10; extra_iterations_++) {
41 if (time_jumps_) {
42 /* Don't advance time smoothly, jump to the next event (some tests require this) */
43 auto_advance_time_ = false;
44 runEventsInternal();
45 } else {
46 /* Run the test with both smooth and irregular time; it must produce the same result */
47 auto_advance_time_ = true;
48 runEventsInternal();
49 auto_advance_time_ = false;
50 runEventsInternal();
51 }
52 }
53}
54
55void DebounceTest::runEventsInternal() {
56 fast_timer_t previous = 0;
57 bool first = true;
58
59 /* Initialise keyboard with start time (offset to avoid testing at 0) and all keys UP */
60 debounce_init(MATRIX_ROWS);
61 set_time(time_offset_);
62 std::fill(std::begin(input_matrix_), std::end(input_matrix_), 0);
63 std::fill(std::begin(output_matrix_), std::end(output_matrix_), 0);
64
65 for (auto &event : events_) {
66 if (!auto_advance_time_) {
67 /* Jump to the next event */
68 set_time(time_offset_ + event.time_);
69 } else if (!first && event.time_ == previous + 1) {
70 /* This event immediately follows the previous one, don't make extra debounce() calls */
71 advance_time(1);
72 } else {
73 /* Fast forward to the time for this event, calling debounce() with no changes */
74 ASSERT_LT((time_offset_ + event.time_) - timer_read_fast(), 60000) << "Test tries to advance more than 1 minute of time";
75
76 while (timer_read_fast() != time_offset_ + event.time_) {
77 runDebounce(false);
78 checkCookedMatrix(false, "debounce() modified cooked matrix");
79 advance_time(1);
80 }
81 }
82
83 first = false;
84 previous = event.time_;
85
86 /* Prepare input matrix */
87 for (auto &input : event.inputs_) {
88 matrixUpdate(input_matrix_, "input", input);
89 }
90
91 /* Call debounce */
92 runDebounce(!event.inputs_.empty());
93
94 /* Prepare output matrix */
95 for (auto &output : event.outputs_) {
96 matrixUpdate(output_matrix_, "output", output);
97 }
98
99 /* Check output matrix has expected change events */
100 for (auto &output : event.outputs_) {
101 EXPECT_EQ(!!(cooked_matrix_[output.row_] & (1U << output.col_)), directionValue(output.direction_))
102 << "Missing event at " << strTime()
103 << " expected key " << output.row_ << "," << output.col_ << " " << directionLabel(output.direction_)
104 << "\ninput_matrix: changed=" << !event.inputs_.empty() << "\n" << strMatrix(input_matrix_)
105 << "\nexpected_matrix:\n" << strMatrix(output_matrix_)
106 << "\nactual_matrix:\n" << strMatrix(cooked_matrix_);
107 }
108
109 /* Check output matrix has no other changes */
110 checkCookedMatrix(!event.inputs_.empty(), "debounce() cooked matrix does not match expected output matrix");
111
112 /* Perform some extra iterations of the matrix scan with no changes */
113 for (int i = 0; i < extra_iterations_; i++) {
114 runDebounce(false);
115 checkCookedMatrix(false, "debounce() modified cooked matrix");
116 }
117 }
118
119 /* Check that no further changes happen for 1 minute */
120 for (int i = 0; i < 60000; i++) {
121 runDebounce(false);
122 checkCookedMatrix(false, "debounce() modified cooked matrix");
123 advance_time(1);
124 }
125
126 debounce_free();
127}
128
129void DebounceTest::runDebounce(bool changed) {
130 std::copy(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_));
131 std::copy(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_));
132
133 debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed);
134
135 if (!std::equal(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_))) {
136 FAIL() << "Fatal error: debounce() modified raw matrix at " << strTime()
137 << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_)
138 << "\nraw_matrix:\n" << strMatrix(raw_matrix_);
139 }
140}
141
142void DebounceTest::checkCookedMatrix(bool changed, const std::string &error_message) {
143 if (!std::equal(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_))) {
144 FAIL() << "Unexpected event: " << error_message << " at " << strTime()
145 << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_)
146 << "\nexpected_matrix:\n" << strMatrix(output_matrix_)
147 << "\nactual_matrix:\n" << strMatrix(cooked_matrix_);
148 }
149}
150
151std::string DebounceTest::strTime() {
152 std::stringstream text;
153
154 text << "time " << (timer_read_fast() - time_offset_)
155 << " (extra_iterations=" << extra_iterations_
156 << ", auto_advance_time=" << auto_advance_time_ << ")";
157
158 return text.str();
159}
160
161std::string DebounceTest::strMatrix(matrix_row_t matrix[]) {
162 std::stringstream text;
163
164 text << "\t" << std::setw(3) << "";
165 for (int col = 0; col < MATRIX_COLS; col++) {
166 text << " " << std::setw(2) << col;
167 }
168 text << "\n";
169
170 for (int row = 0; row < MATRIX_ROWS; row++) {
171 text << "\t" << std::setw(2) << row << ":";
172 for (int col = 0; col < MATRIX_COLS; col++) {
173 text << ((matrix[row] & (1U << col)) ? " XX" : " __");
174 }
175
176 text << "\n";
177 }
178
179 return text.str();
180}
181
182bool DebounceTest::directionValue(Direction direction) {
183 switch (direction) {
184 case DOWN:
185 return true;
186
187 case UP:
188 return false;
189 }
190}
191
192std::string DebounceTest::directionLabel(Direction direction) {
193 switch (direction) {
194 case DOWN:
195 return "DOWN";
196
197 case UP:
198 return "UP";
199 }
200}
201
202/* Modify a matrix and verify that events always specify a change */
203void DebounceTest::matrixUpdate(matrix_row_t matrix[], const std::string &name, const MatrixTestEvent &event) {
204 ASSERT_NE(!!(matrix[event.row_] & (1U << event.col_)), directionValue(event.direction_))
205 << "Test " << name << " at " << strTime()
206 << " sets key " << event.row_ << "," << event.col_ << " " << directionLabel(event.direction_)
207 << " but it is already " << directionLabel(event.direction_)
208 << "\n" << name << "_matrix:\n" << strMatrix(matrix);
209
210 switch (event.direction_) {
211 case DOWN:
212 matrix[event.row_] |= (1U << event.col_);
213 break;
214
215 case UP:
216 matrix[event.row_] &= ~(1U << event.col_);
217 break;
218 }
219}
220
221DebounceTestEvent::DebounceTestEvent(fast_timer_t time,
222 std::initializer_list<MatrixTestEvent> inputs,
223 std::initializer_list<MatrixTestEvent> outputs)
224 : time_(time), inputs_(inputs), outputs_(outputs) {
225}
226
227MatrixTestEvent::MatrixTestEvent(int row, int col, Direction direction)
228 : row_(row), col_(col), direction_(direction) {
229}
diff --git a/quantum/debounce/tests/debounce_test_common.h b/quantum/debounce/tests/debounce_test_common.h
new file mode 100644
index 000000000..d87e31059
--- /dev/null
+++ b/quantum/debounce/tests/debounce_test_common.h
@@ -0,0 +1,83 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "gtest/gtest.h"
18
19#include <initializer_list>
20#include <list>
21#include <string>
22
23extern "C" {
24#include "quantum.h"
25#include "timer.h"
26}
27
28enum Direction {
29 DOWN,
30 UP,
31};
32
33class MatrixTestEvent {
34public:
35 MatrixTestEvent(int row, int col, Direction direction);
36
37 const int row_;
38 const int col_;
39 const Direction direction_;
40};
41
42class DebounceTestEvent {
43public:
44 // 0, {{0, 1, DOWN}}, {{0, 1, DOWN}})
45 DebounceTestEvent(fast_timer_t time,
46 std::initializer_list<MatrixTestEvent> inputs,
47 std::initializer_list<MatrixTestEvent> outputs);
48
49 const fast_timer_t time_;
50 const std::list<MatrixTestEvent> inputs_;
51 const std::list<MatrixTestEvent> outputs_;
52};
53
54class DebounceTest : public ::testing::Test {
55protected:
56 void addEvents(std::initializer_list<DebounceTestEvent> events);
57 void runEvents();
58
59 fast_timer_t time_offset_ = 7777;
60 bool time_jumps_ = false;
61
62private:
63 static bool directionValue(Direction direction);
64 static std::string directionLabel(Direction direction);
65
66 void runEventsInternal();
67 void runDebounce(bool changed);
68 void checkCookedMatrix(bool changed, const std::string &error_message);
69 void matrixUpdate(matrix_row_t matrix[], const std::string &name, const MatrixTestEvent &event);
70
71 std::string strTime();
72 std::string strMatrix(matrix_row_t matrix[]);
73
74 std::list<DebounceTestEvent> events_;
75
76 matrix_row_t input_matrix_[MATRIX_ROWS];
77 matrix_row_t raw_matrix_[MATRIX_ROWS];
78 matrix_row_t cooked_matrix_[MATRIX_ROWS];
79 matrix_row_t output_matrix_[MATRIX_ROWS];
80
81 int extra_iterations_;
82 bool auto_advance_time_;
83};
diff --git a/quantum/debounce/tests/rules.mk b/quantum/debounce/tests/rules.mk
new file mode 100644
index 000000000..66928d7eb
--- /dev/null
+++ b/quantum/debounce/tests/rules.mk
@@ -0,0 +1,44 @@
1# Copyright 2021 Simon Arlott
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16DEBOUNCE_COMMON_DEFS := -DMATRIX_ROWS=4 -DMATRIX_COLS=10 -DDEBOUNCE=5
17
18DEBOUNCE_COMMON_SRC := $(QUANTUM_PATH)/debounce/tests/debounce_test_common.cpp \
19 $(TMK_PATH)/common/test/timer.c
20
21debounce_sym_defer_g_DEFS := $(DEBOUNCE_COMMON_DEFS)
22debounce_sym_defer_g_SRC := $(DEBOUNCE_COMMON_SRC) \
23 $(QUANTUM_PATH)/debounce/sym_defer_g.c \
24 $(QUANTUM_PATH)/debounce/tests/sym_defer_g_tests.cpp
25
26debounce_sym_defer_pk_DEFS := $(DEBOUNCE_COMMON_DEFS)
27debounce_sym_defer_pk_SRC := $(DEBOUNCE_COMMON_SRC) \
28 $(QUANTUM_PATH)/debounce/sym_defer_pk.c \
29 $(QUANTUM_PATH)/debounce/tests/sym_defer_pk_tests.cpp
30
31debounce_sym_eager_pk_DEFS := $(DEBOUNCE_COMMON_DEFS)
32debounce_sym_eager_pk_SRC := $(DEBOUNCE_COMMON_SRC) \
33 $(QUANTUM_PATH)/debounce/sym_eager_pk.c \
34 $(QUANTUM_PATH)/debounce/tests/sym_eager_pk_tests.cpp
35
36debounce_sym_eager_pr_DEFS := $(DEBOUNCE_COMMON_DEFS)
37debounce_sym_eager_pr_SRC := $(DEBOUNCE_COMMON_SRC) \
38 $(QUANTUM_PATH)/debounce/sym_eager_pr.c \
39 $(QUANTUM_PATH)/debounce/tests/sym_eager_pr_tests.cpp
40
41debounce_asym_eager_defer_pk_DEFS := $(DEBOUNCE_COMMON_DEFS)
42debounce_asym_eager_defer_pk_SRC := $(DEBOUNCE_COMMON_SRC) \
43 $(QUANTUM_PATH)/debounce/asym_eager_defer_pk.c \
44 $(QUANTUM_PATH)/debounce/tests/asym_eager_defer_pk_tests.cpp
diff --git a/quantum/debounce/tests/sym_defer_g_tests.cpp b/quantum/debounce/tests/sym_defer_g_tests.cpp
new file mode 100644
index 000000000..a56aecd8f
--- /dev/null
+++ b/quantum/debounce/tests/sym_defer_g_tests.cpp
@@ -0,0 +1,223 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "gtest/gtest.h"
18
19#include "debounce_test_common.h"
20
21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {}},
24
25 {5, {}, {{0, 1, DOWN}}},
26 /* 0ms delay (fast scan rate) */
27 {5, {{0, 1, UP}}, {}},
28
29 {10, {}, {{0, 1, UP}}},
30 });
31 runEvents();
32}
33
34TEST_F(DebounceTest, OneKeyShort2) {
35 addEvents({ /* Time, Inputs, Outputs */
36 {0, {{0, 1, DOWN}}, {}},
37
38 {5, {}, {{0, 1, DOWN}}},
39 /* 1ms delay */
40 {6, {{0, 1, UP}}, {}},
41
42 {11, {}, {{0, 1, UP}}},
43 });
44 runEvents();
45}
46
47TEST_F(DebounceTest, OneKeyShort3) {
48 addEvents({ /* Time, Inputs, Outputs */
49 {0, {{0, 1, DOWN}}, {}},
50
51 {5, {}, {{0, 1, DOWN}}},
52 /* 2ms delay */
53 {7, {{0, 1, UP}}, {}},
54
55 {12, {}, {{0, 1, UP}}},
56 });
57 runEvents();
58}
59
60TEST_F(DebounceTest, OneKeyTooQuick1) {
61 addEvents({ /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {}},
63 /* Release key exactly on the debounce time */
64 {5, {{0, 1, UP}}, {}},
65 });
66 runEvents();
67}
68
69TEST_F(DebounceTest, OneKeyTooQuick2) {
70 addEvents({ /* Time, Inputs, Outputs */
71 {0, {{0, 1, DOWN}}, {}},
72
73 {5, {}, {{0, 1, DOWN}}},
74 {6, {{0, 1, UP}}, {}},
75
76 /* Press key exactly on the debounce time */
77 {11, {{0, 1, DOWN}}, {}},
78 });
79 runEvents();
80}
81
82TEST_F(DebounceTest, OneKeyBouncing1) {
83 addEvents({ /* Time, Inputs, Outputs */
84 {0, {{0, 1, DOWN}}, {}},
85 {1, {{0, 1, UP}}, {}},
86 {2, {{0, 1, DOWN}}, {}},
87 {3, {{0, 1, UP}}, {}},
88 {4, {{0, 1, DOWN}}, {}},
89 {5, {{0, 1, UP}}, {}},
90 {6, {{0, 1, DOWN}}, {}},
91 {11, {}, {{0, 1, DOWN}}}, /* 5ms after DOWN at time 7 */
92 });
93 runEvents();
94}
95
96TEST_F(DebounceTest, OneKeyBouncing2) {
97 addEvents({ /* Time, Inputs, Outputs */
98 {0, {{0, 1, DOWN}}, {}},
99 {5, {}, {{0, 1, DOWN}}},
100 {6, {{0, 1, UP}}, {}},
101 {7, {{0, 1, DOWN}}, {}},
102 {8, {{0, 1, UP}}, {}},
103 {9, {{0, 1, DOWN}}, {}},
104 {10, {{0, 1, UP}}, {}},
105 {15, {}, {{0, 1, UP}}}, /* 5ms after UP at time 10 */
106 });
107 runEvents();
108}
109
110TEST_F(DebounceTest, OneKeyLong) {
111 addEvents({ /* Time, Inputs, Outputs */
112 {0, {{0, 1, DOWN}}, {}},
113
114 {5, {}, {{0, 1, DOWN}}},
115
116 {25, {{0, 1, UP}}, {}},
117
118 {30, {}, {{0, 1, UP}}},
119
120 {50, {{0, 1, DOWN}}, {}},
121
122 {55, {}, {{0, 1, DOWN}}},
123 });
124 runEvents();
125}
126
127TEST_F(DebounceTest, TwoKeysShort) {
128 addEvents({ /* Time, Inputs, Outputs */
129 {0, {{0, 1, DOWN}}, {}},
130 {1, {{0, 2, DOWN}}, {}},
131
132 {6, {}, {{0, 1, DOWN}, {0, 2, DOWN}}},
133
134 {7, {{0, 1, UP}}, {}},
135 {8, {{0, 2, UP}}, {}},
136
137 {13, {}, {{0, 1, UP}, {0, 2, UP}}},
138 });
139 runEvents();
140}
141
142TEST_F(DebounceTest, TwoKeysSimultaneous1) {
143 addEvents({ /* Time, Inputs, Outputs */
144 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}},
145
146 {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}},
147 {6, {{0, 1, UP}, {0, 2, UP}}, {}},
148
149 {11, {}, {{0, 1, UP}, {0, 2, UP}}},
150 });
151 runEvents();
152}
153
154TEST_F(DebounceTest, TwoKeysSimultaneous2) {
155 addEvents({ /* Time, Inputs, Outputs */
156 {0, {{0, 1, DOWN}}, {}},
157 {1, {{0, 2, DOWN}}, {}},
158
159 {5, {}, {}},
160 {6, {}, {{0, 1, DOWN}, {0, 2, DOWN}}},
161 {7, {{0, 1, UP}}, {}},
162 {8, {{0, 2, UP}}, {}},
163
164 {13, {}, {{0, 1, UP}, {0, 2, UP}}},
165 });
166 runEvents();
167}
168
169TEST_F(DebounceTest, OneKeyDelayedScan1) {
170 addEvents({ /* Time, Inputs, Outputs */
171 {0, {{0, 1, DOWN}}, {}},
172
173 /* Processing is very late */
174 {300, {}, {{0, 1, DOWN}}},
175 /* Immediately release key */
176 {300, {{0, 1, UP}}, {}},
177
178 {305, {}, {{0, 1, UP}}},
179 });
180 time_jumps_ = true;
181 runEvents();
182}
183
184TEST_F(DebounceTest, OneKeyDelayedScan2) {
185 addEvents({ /* Time, Inputs, Outputs */
186 {0, {{0, 1, DOWN}}, {}},
187
188 /* Processing is very late */
189 {300, {}, {{0, 1, DOWN}}},
190 /* Release key after 1ms */
191 {301, {{0, 1, UP}}, {}},
192
193 {306, {}, {{0, 1, UP}}},
194 });
195 time_jumps_ = true;
196 runEvents();
197}
198
199TEST_F(DebounceTest, OneKeyDelayedScan3) {
200 addEvents({ /* Time, Inputs, Outputs */
201 {0, {{0, 1, DOWN}}, {}},
202
203 /* Release key before debounce expires */
204 {300, {{0, 1, UP}}, {}},
205 });
206 time_jumps_ = true;
207 runEvents();
208}
209
210TEST_F(DebounceTest, OneKeyDelayedScan4) {
211 addEvents({ /* Time, Inputs, Outputs */
212 {0, {{0, 1, DOWN}}, {}},
213
214 /* Processing is a bit late */
215 {50, {}, {{0, 1, DOWN}}},
216 /* Release key after 1ms */
217 {51, {{0, 1, UP}}, {}},
218
219 {56, {}, {{0, 1, UP}}},
220 });
221 time_jumps_ = true;
222 runEvents();
223}
diff --git a/quantum/debounce/tests/sym_defer_pk_tests.cpp b/quantum/debounce/tests/sym_defer_pk_tests.cpp
new file mode 100644
index 000000000..1f3061e59
--- /dev/null
+++ b/quantum/debounce/tests/sym_defer_pk_tests.cpp
@@ -0,0 +1,225 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "gtest/gtest.h"
18
19#include "debounce_test_common.h"
20
21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {}},
24
25 {5, {}, {{0, 1, DOWN}}},
26 /* 0ms delay (fast scan rate) */
27 {5, {{0, 1, UP}}, {}},
28
29 {10, {}, {{0, 1, UP}}},
30 });
31 runEvents();
32}
33
34TEST_F(DebounceTest, OneKeyShort2) {
35 addEvents({ /* Time, Inputs, Outputs */
36 {0, {{0, 1, DOWN}}, {}},
37
38 {5, {}, {{0, 1, DOWN}}},
39 /* 1ms delay */
40 {6, {{0, 1, UP}}, {}},
41
42 {11, {}, {{0, 1, UP}}},
43 });
44 runEvents();
45}
46
47TEST_F(DebounceTest, OneKeyShort3) {
48 addEvents({ /* Time, Inputs, Outputs */
49 {0, {{0, 1, DOWN}}, {}},
50
51 {5, {}, {{0, 1, DOWN}}},
52 /* 2ms delay */
53 {7, {{0, 1, UP}}, {}},
54
55 {12, {}, {{0, 1, UP}}},
56 });
57 runEvents();
58}
59
60TEST_F(DebounceTest, OneKeyTooQuick1) {
61 addEvents({ /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {}},
63 /* Release key exactly on the debounce time */
64 {5, {{0, 1, UP}}, {}},
65 });
66 runEvents();
67}
68
69TEST_F(DebounceTest, OneKeyTooQuick2) {
70 addEvents({ /* Time, Inputs, Outputs */
71 {0, {{0, 1, DOWN}}, {}},
72
73 {5, {}, {{0, 1, DOWN}}},
74 {6, {{0, 1, UP}}, {}},
75
76 /* Press key exactly on the debounce time */
77 {11, {{0, 1, DOWN}}, {}},
78 });
79 runEvents();
80}
81
82TEST_F(DebounceTest, OneKeyBouncing1) {
83 addEvents({ /* Time, Inputs, Outputs */
84 {0, {{0, 1, DOWN}}, {}},
85 {1, {{0, 1, UP}}, {}},
86 {2, {{0, 1, DOWN}}, {}},
87 {3, {{0, 1, UP}}, {}},
88 {4, {{0, 1, DOWN}}, {}},
89 {5, {{0, 1, UP}}, {}},
90 {6, {{0, 1, DOWN}}, {}},
91 {11, {}, {{0, 1, DOWN}}}, /* 5ms after DOWN at time 7 */
92 });
93 runEvents();
94}
95
96TEST_F(DebounceTest, OneKeyBouncing2) {
97 addEvents({ /* Time, Inputs, Outputs */
98 {0, {{0, 1, DOWN}}, {}},
99 {5, {}, {{0, 1, DOWN}}},
100 {6, {{0, 1, UP}}, {}},
101 {7, {{0, 1, DOWN}}, {}},
102 {8, {{0, 1, UP}}, {}},
103 {9, {{0, 1, DOWN}}, {}},
104 {10, {{0, 1, UP}}, {}},
105 {15, {}, {{0, 1, UP}}}, /* 5ms after UP at time 10 */
106 });
107 runEvents();
108}
109
110TEST_F(DebounceTest, OneKeyLong) {
111 addEvents({ /* Time, Inputs, Outputs */
112 {0, {{0, 1, DOWN}}, {}},
113
114 {5, {}, {{0, 1, DOWN}}},
115
116 {25, {{0, 1, UP}}, {}},
117
118 {30, {}, {{0, 1, UP}}},
119
120 {50, {{0, 1, DOWN}}, {}},
121
122 {55, {}, {{0, 1, DOWN}}},
123 });
124 runEvents();
125}
126
127TEST_F(DebounceTest, TwoKeysShort) {
128 addEvents({ /* Time, Inputs, Outputs */
129 {0, {{0, 1, DOWN}}, {}},
130 {1, {{0, 2, DOWN}}, {}},
131
132 {5, {}, {{0, 1, DOWN}}},
133 {6, {}, {{0, 2, DOWN}}},
134
135 {7, {{0, 1, UP}}, {}},
136 {8, {{0, 2, UP}}, {}},
137
138 {12, {}, {{0, 1, UP}}},
139 {13, {}, {{0, 2, UP}}},
140 });
141 runEvents();
142}
143
144TEST_F(DebounceTest, TwoKeysSimultaneous1) {
145 addEvents({ /* Time, Inputs, Outputs */
146 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {}},
147
148 {5, {}, {{0, 1, DOWN}, {0, 2, DOWN}}},
149 {6, {{0, 1, UP}, {0, 2, UP}}, {}},
150
151 {11, {}, {{0, 1, UP}, {0, 2, UP}}},
152 });
153 runEvents();
154}
155
156TEST_F(DebounceTest, TwoKeysSimultaneous2) {
157 addEvents({ /* Time, Inputs, Outputs */
158 {0, {{0, 1, DOWN}}, {}},
159 {1, {{0, 2, DOWN}}, {}},
160
161 {5, {}, {{0, 1, DOWN}}},
162 {6, {{0, 1, UP}}, {{0, 2, DOWN}}},
163 {7, {{0, 2, UP}}, {}},
164
165 {11, {}, {{0, 1, UP}}},
166 {12, {}, {{0, 2, UP}}},
167 });
168 runEvents();
169}
170
171TEST_F(DebounceTest, OneKeyDelayedScan1) {
172 addEvents({ /* Time, Inputs, Outputs */
173 {0, {{0, 1, DOWN}}, {}},
174
175 /* Processing is very late */
176 {300, {}, {{0, 1, DOWN}}},
177 /* Immediately release key */
178 {300, {{0, 1, UP}}, {}},
179
180 {305, {}, {{0, 1, UP}}},
181 });
182 time_jumps_ = true;
183 runEvents();
184}
185
186TEST_F(DebounceTest, OneKeyDelayedScan2) {
187 addEvents({ /* Time, Inputs, Outputs */
188 {0, {{0, 1, DOWN}}, {}},
189
190 /* Processing is very late */
191 {300, {}, {{0, 1, DOWN}}},
192 /* Release key after 1ms */
193 {301, {{0, 1, UP}}, {}},
194
195 {306, {}, {{0, 1, UP}}},
196 });
197 time_jumps_ = true;
198 runEvents();
199}
200
201TEST_F(DebounceTest, OneKeyDelayedScan3) {
202 addEvents({ /* Time, Inputs, Outputs */
203 {0, {{0, 1, DOWN}}, {}},
204
205 /* Release key before debounce expires */
206 {300, {{0, 1, UP}}, {}},
207 });
208 time_jumps_ = true;
209 runEvents();
210}
211
212TEST_F(DebounceTest, OneKeyDelayedScan4) {
213 addEvents({ /* Time, Inputs, Outputs */
214 {0, {{0, 1, DOWN}}, {}},
215
216 /* Processing is a bit late */
217 {50, {}, {{0, 1, DOWN}}},
218 /* Release key after 1ms */
219 {51, {{0, 1, UP}}, {}},
220
221 {56, {}, {{0, 1, UP}}},
222 });
223 time_jumps_ = true;
224 runEvents();
225}
diff --git a/quantum/debounce/tests/sym_eager_pk_tests.cpp b/quantum/debounce/tests/sym_eager_pk_tests.cpp
new file mode 100644
index 000000000..e0fc205e3
--- /dev/null
+++ b/quantum/debounce/tests/sym_eager_pk_tests.cpp
@@ -0,0 +1,237 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "gtest/gtest.h"
18
19#include "debounce_test_common.h"
20
21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
24 {1, {{0, 1, UP}}, {}},
25
26 {5, {}, {{0, 1, UP}}},
27 /* Press key again after 1ms delay (debounce has not yet finished) */
28 {6, {{0, 1, DOWN}}, {}},
29 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
30 });
31 runEvents();
32}
33
34TEST_F(DebounceTest, OneKeyShort2) {
35 addEvents({ /* Time, Inputs, Outputs */
36 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
37 {1, {{0, 1, UP}}, {}},
38
39 {5, {}, {{0, 1, UP}}},
40 /* Press key again after 2ms delay (debounce has not yet finished) */
41 {7, {{0, 1, DOWN}}, {}},
42 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
43 });
44 runEvents();
45}
46
47TEST_F(DebounceTest, OneKeyShort3) {
48 addEvents({ /* Time, Inputs, Outputs */
49 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
50 {1, {{0, 1, UP}}, {}},
51
52 {5, {}, {{0, 1, UP}}},
53 /* Press key again after 3ms delay (debounce has not yet finished) */
54 {8, {{0, 1, DOWN}}, {}},
55 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
56 });
57 runEvents();
58}
59
60TEST_F(DebounceTest, OneKeyShort4) {
61 addEvents({ /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
63 {1, {{0, 1, UP}}, {}},
64
65 {5, {}, {{0, 1, UP}}},
66 /* Press key again after 4ms delay (debounce has not yet finished) */
67 {9, {{0, 1, DOWN}}, {}},
68 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
69 });
70 runEvents();
71}
72
73TEST_F(DebounceTest, OneKeyShort5) {
74 addEvents({ /* Time, Inputs, Outputs */
75 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
76 {1, {{0, 1, UP}}, {}},
77
78 {5, {}, {{0, 1, UP}}},
79 /* Press key again after 5ms delay (debounce has finished) */
80 {10, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
81 });
82 runEvents();
83}
84
85TEST_F(DebounceTest, OneKeyShort6) {
86 addEvents({ /* Time, Inputs, Outputs */
87 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
88 {1, {{0, 1, UP}}, {}},
89
90 {5, {}, {{0, 1, UP}}},
91 /* Press key after after 6ms delay (debounce has finished) */
92 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
93 });
94 runEvents();
95}
96
97TEST_F(DebounceTest, OneKeyBouncing1) {
98 addEvents({ /* Time, Inputs, Outputs */
99 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
100 {1, {{0, 1, UP}}, {}},
101 {2, {{0, 1, DOWN}}, {}},
102 {3, {{0, 1, UP}}, {}},
103 {4, {{0, 1, DOWN}}, {}},
104 {5, {{0, 1, UP}}, {{0, 1, UP}}},
105 /* Press key again after 1ms delay (debounce has not yet finished) */
106 {6, {{0, 1, DOWN}}, {}},
107 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
108 });
109 runEvents();
110}
111
112TEST_F(DebounceTest, OneKeyBouncing2) {
113 addEvents({ /* Time, Inputs, Outputs */
114 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
115 /* Change twice in the same time period */
116 {1, {{0, 1, UP}}, {}},
117 {1, {{0, 1, DOWN}}, {}},
118 /* Change three times in the same time period */
119 {2, {{0, 1, UP}}, {}},
120 {2, {{0, 1, DOWN}}, {}},
121 {2, {{0, 1, UP}}, {}},
122 /* Change three times in the same time period */
123 {3, {{0, 1, DOWN}}, {}},
124 {3, {{0, 1, UP}}, {}},
125 {3, {{0, 1, DOWN}}, {}},
126 /* Change twice in the same time period */
127 {4, {{0, 1, UP}}, {}},
128 {4, {{0, 1, DOWN}}, {}},
129 {5, {{0, 1, UP}}, {{0, 1, UP}}},
130 /* Press key again after 1ms delay (debounce has not yet finished) */
131 {6, {{0, 1, DOWN}}, {}},
132 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
133 });
134 runEvents();
135}
136
137TEST_F(DebounceTest, OneKeyLong) {
138 addEvents({ /* Time, Inputs, Outputs */
139 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
140
141 {25, {{0, 1, UP}}, {{0, 1, UP}}},
142
143 {50, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
144 });
145 runEvents();
146}
147
148TEST_F(DebounceTest, TwoKeysShort) {
149 addEvents({ /* Time, Inputs, Outputs */
150 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
151 {1, {{0, 1, UP}}, {}},
152 {2, {{0, 2, DOWN}}, {{0, 2, DOWN}}},
153 {3, {{0, 2, UP}}, {}},
154
155 {5, {}, {{0, 1, UP}}},
156 /* Press key again after 1ms delay (debounce has not yet finished) */
157 {6, {{0, 1, DOWN}}, {}},
158 {7, {}, {{0, 2, UP}}},
159
160 /* Press key again after 1ms delay (debounce has not yet finished) */
161 {9, {{0, 2, DOWN}}, {}},
162 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
163
164 {12, {}, {{0, 2, DOWN}}}, /* 5ms after UP at time 7 */
165 });
166 runEvents();
167}
168
169TEST_F(DebounceTest, OneKeyDelayedScan1) {
170 addEvents({ /* Time, Inputs, Outputs */
171 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
172
173 /* Processing is very late but the change will now be accepted */
174 {300, {{0, 1, UP}}, {{0, 1, UP}}},
175 });
176 time_jumps_ = true;
177 runEvents();
178}
179
180TEST_F(DebounceTest, OneKeyDelayedScan2) {
181 addEvents({ /* Time, Inputs, Outputs */
182 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
183
184 /* Processing is very late but the change will now be accepted even with a 1 scan delay */
185 {300, {}, {}},
186 {300, {{0, 1, UP}}, {{0, 1, UP}}},
187 });
188 time_jumps_ = true;
189 runEvents();
190}
191
192TEST_F(DebounceTest, OneKeyDelayedScan3) {
193 addEvents({ /* Time, Inputs, Outputs */
194 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
195
196 /* Processing is very late but the change will now be accepted even with a 1ms delay */
197 {300, {}, {}},
198 {301, {{0, 1, UP}}, {{0, 1, UP}}},
199 });
200 time_jumps_ = true;
201 runEvents();
202}
203
204TEST_F(DebounceTest, OneKeyDelayedScan4) {
205 addEvents({ /* Time, Inputs, Outputs */
206 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
207
208 /* Processing is a bit late but the change will now be accepted */
209 {50, {{0, 1, UP}}, {{0, 1, UP}}},
210 });
211 time_jumps_ = true;
212 runEvents();
213}
214
215TEST_F(DebounceTest, OneKeyDelayedScan5) {
216 addEvents({ /* Time, Inputs, Outputs */
217 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
218
219 /* Processing is very late but the change will now be accepted even with a 1 scan delay */
220 {50, {}, {}},
221 {50, {{0, 1, UP}}, {{0, 1, UP}}},
222 });
223 time_jumps_ = true;
224 runEvents();
225}
226
227TEST_F(DebounceTest, OneKeyDelayedScan6) {
228 addEvents({ /* Time, Inputs, Outputs */
229 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
230
231 /* Processing is very late but the change will now be accepted even with a 1ms delay */
232 {50, {}, {}},
233 {51, {{0, 1, UP}}, {{0, 1, UP}}},
234 });
235 time_jumps_ = true;
236 runEvents();
237}
diff --git a/quantum/debounce/tests/sym_eager_pr_tests.cpp b/quantum/debounce/tests/sym_eager_pr_tests.cpp
new file mode 100644
index 000000000..2c4bca127
--- /dev/null
+++ b/quantum/debounce/tests/sym_eager_pr_tests.cpp
@@ -0,0 +1,280 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "gtest/gtest.h"
18
19#include "debounce_test_common.h"
20
21TEST_F(DebounceTest, OneKeyShort1) {
22 addEvents({ /* Time, Inputs, Outputs */
23 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
24 {1, {{0, 1, UP}}, {}},
25
26 {5, {}, {{0, 1, UP}}},
27 /* Press key again after 1ms delay (debounce has not yet finished) */
28 {6, {{0, 1, DOWN}}, {}},
29 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
30 });
31 runEvents();
32}
33
34TEST_F(DebounceTest, OneKeyShort2) {
35 addEvents({ /* Time, Inputs, Outputs */
36 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
37 {1, {{0, 1, UP}}, {}},
38
39 {5, {}, {{0, 1, UP}}},
40 /* Press key again after 2ms delay (debounce has not yet finished) */
41 {7, {{0, 1, DOWN}}, {}},
42 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
43 });
44 runEvents();
45}
46
47TEST_F(DebounceTest, OneKeyShort3) {
48 addEvents({ /* Time, Inputs, Outputs */
49 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
50 {1, {{0, 1, UP}}, {}},
51
52 {5, {}, {{0, 1, UP}}},
53 /* Press key again after 3ms delay (debounce has not yet finished) */
54 {8, {{0, 1, DOWN}}, {}},
55 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
56 });
57 runEvents();
58}
59
60TEST_F(DebounceTest, OneKeyShort4) {
61 addEvents({ /* Time, Inputs, Outputs */
62 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
63 {1, {{0, 1, UP}}, {}},
64
65 {5, {}, {{0, 1, UP}}},
66 /* Press key again after 4ms delay (debounce has not yet finished) */
67 {9, {{0, 1, DOWN}}, {}},
68 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
69 });
70 runEvents();
71}
72
73TEST_F(DebounceTest, OneKeyShort5) {
74 addEvents({ /* Time, Inputs, Outputs */
75 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
76 {1, {{0, 1, UP}}, {}},
77
78 {5, {}, {{0, 1, UP}}},
79 /* Press key again after 5ms delay (debounce has finished) */
80 {10, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
81 });
82 runEvents();
83}
84
85TEST_F(DebounceTest, OneKeyShort6) {
86 addEvents({ /* Time, Inputs, Outputs */
87 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
88 {1, {{0, 1, UP}}, {}},
89
90 {5, {}, {{0, 1, UP}}},
91 /* Press key after after 6ms delay (debounce has finished) */
92 {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
93 });
94 runEvents();
95}
96
97TEST_F(DebounceTest, OneKeyBouncing1) {
98 addEvents({ /* Time, Inputs, Outputs */
99 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
100 {1, {{0, 1, UP}}, {}},
101 {2, {{0, 1, DOWN}}, {}},
102 {3, {{0, 1, UP}}, {}},
103 {4, {{0, 1, DOWN}}, {}},
104 {5, {{0, 1, UP}}, {{0, 1, UP}}},
105 /* Press key again after 1ms delay (debounce has not yet finished) */
106 {6, {{0, 1, DOWN}}, {}},
107 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
108 });
109 runEvents();
110}
111
112TEST_F(DebounceTest, OneKeyBouncing2) {
113 addEvents({ /* Time, Inputs, Outputs */
114 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
115 /* Change twice in the same time period */
116 {1, {{0, 1, UP}}, {}},
117 {1, {{0, 1, DOWN}}, {}},
118 /* Change three times in the same time period */
119 {2, {{0, 1, UP}}, {}},
120 {2, {{0, 1, DOWN}}, {}},
121 {2, {{0, 1, UP}}, {}},
122 /* Change three times in the same time period */
123 {3, {{0, 1, DOWN}}, {}},
124 {3, {{0, 1, UP}}, {}},
125 {3, {{0, 1, DOWN}}, {}},
126 /* Change twice in the same time period */
127 {4, {{0, 1, UP}}, {}},
128 {4, {{0, 1, DOWN}}, {}},
129 {5, {{0, 1, UP}}, {{0, 1, UP}}},
130 /* Press key again after 1ms delay (debounce has not yet finished) */
131 {6, {{0, 1, DOWN}}, {}},
132 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
133 });
134 runEvents();
135}
136
137TEST_F(DebounceTest, OneKeyLong) {
138 addEvents({ /* Time, Inputs, Outputs */
139 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
140
141 {25, {{0, 1, UP}}, {{0, 1, UP}}},
142
143 {50, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
144 });
145 runEvents();
146}
147
148TEST_F(DebounceTest, TwoRowsShort) {
149 addEvents({ /* Time, Inputs, Outputs */
150 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
151 {1, {{0, 1, UP}}, {}},
152 {2, {{2, 0, DOWN}}, {{2, 0, DOWN}}},
153 {3, {{2, 0, UP}}, {}},
154
155 {5, {}, {{0, 1, UP}}},
156 /* Press key again after 1ms delay (debounce has not yet finished) */
157 {6, {{0, 1, DOWN}}, {}},
158 {7, {}, {{2, 0, UP}}},
159
160 /* Press key again after 1ms delay (debounce has not yet finished) */
161 {9, {{2, 0, DOWN}}, {}},
162 {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
163
164 {12, {}, {{2, 0, DOWN}}}, /* 5ms after UP at time 7 */
165 });
166 runEvents();
167}
168
169TEST_F(DebounceTest, TwoKeysOverlap) {
170 addEvents({ /* Time, Inputs, Outputs */
171 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
172 {1, {{0, 1, UP}}, {}},
173 /* Press a second key during the first debounce */
174 {2, {{0, 2, DOWN}}, {}},
175
176 /* Key registers as soon as debounce finishes, 5ms after time 0 */
177 {5, {}, {{0, 1, UP}, {0, 2, DOWN}}},
178 {6, {{0, 1, DOWN}}, {}},
179
180 /* Key registers as soon as debounce finishes, 5ms after time 5 */
181 {10, {}, {{0, 1, DOWN}}},
182 /* Release both keys */
183 {11, {{0, 1, UP}}, {}},
184 {12, {{0, 2, UP}}, {}},
185
186 /* Keys register as soon as debounce finishes, 5ms after time 10 */
187 {15, {}, {{0, 1, UP}, {0, 2, UP}}},
188 });
189 runEvents();
190}
191
192TEST_F(DebounceTest, TwoKeysSimultaneous1) {
193 addEvents({ /* Time, Inputs, Outputs */
194 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}},
195 {20, {{0, 1, UP}}, {{0, 1, UP}}},
196 {21, {{0, 2, UP}}, {}},
197
198 /* Key registers as soon as debounce finishes, 5ms after time 20 */
199 {25, {}, {{0, 2, UP}}},
200 });
201 runEvents();
202}
203
204TEST_F(DebounceTest, TwoKeysSimultaneous2) {
205 addEvents({ /* Time, Inputs, Outputs */
206 {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}},
207 {20, {{0, 1, UP}, {0, 2, UP}}, {{0, 1, UP}, {0, 2, UP}}},
208 });
209 runEvents();
210}
211
212TEST_F(DebounceTest, OneKeyDelayedScan1) {
213 addEvents({ /* Time, Inputs, Outputs */
214 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
215
216 /* Processing is very late but the change will now be accepted */
217 {300, {{0, 1, UP}}, {{0, 1, UP}}},
218 });
219 time_jumps_ = true;
220 runEvents();
221}
222
223TEST_F(DebounceTest, OneKeyDelayedScan2) {
224 addEvents({ /* Time, Inputs, Outputs */
225 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
226
227 /* Processing is very late but the change will now be accepted even with a 1 scan delay */
228 {300, {}, {}},
229 {300, {{0, 1, UP}}, {{0, 1, UP}}},
230 });
231 time_jumps_ = true;
232 runEvents();
233}
234
235TEST_F(DebounceTest, OneKeyDelayedScan3) {
236 addEvents({ /* Time, Inputs, Outputs */
237 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
238
239 /* Processing is very late but the change will now be accepted even with a 1ms delay */
240 {300, {}, {}},
241 {301, {{0, 1, UP}}, {{0, 1, UP}}},
242 });
243 time_jumps_ = true;
244 runEvents();
245}
246
247TEST_F(DebounceTest, OneKeyDelayedScan4) {
248 addEvents({ /* Time, Inputs, Outputs */
249 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
250
251 /* Processing is a bit late but the change will now be accepted */
252 {50, {{0, 1, UP}}, {{0, 1, UP}}},
253 });
254 time_jumps_ = true;
255 runEvents();
256}
257
258TEST_F(DebounceTest, OneKeyDelayedScan5) {
259 addEvents({ /* Time, Inputs, Outputs */
260 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
261
262 /* Processing is very late but the change will now be accepted even with a 1 scan delay */
263 {50, {}, {}},
264 {50, {{0, 1, UP}}, {{0, 1, UP}}},
265 });
266 time_jumps_ = true;
267 runEvents();
268}
269
270TEST_F(DebounceTest, OneKeyDelayedScan6) {
271 addEvents({ /* Time, Inputs, Outputs */
272 {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
273
274 /* Processing is very late but the change will now be accepted even with a 1ms delay */
275 {50, {}, {}},
276 {51, {{0, 1, UP}}, {{0, 1, UP}}},
277 });
278 time_jumps_ = true;
279 runEvents();
280}
diff --git a/quantum/debounce/tests/testlist.mk b/quantum/debounce/tests/testlist.mk
new file mode 100644
index 000000000..c54c45aa6
--- /dev/null
+++ b/quantum/debounce/tests/testlist.mk
@@ -0,0 +1,6 @@
1TEST_LIST += \
2 debounce_sym_defer_g \
3 debounce_sym_defer_pk \
4 debounce_sym_eager_pk \
5 debounce_sym_eager_pr \
6 debounce_asym_eager_defer_pk
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c
index 7e0fdf896..942e6d7dc 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -67,10 +67,6 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER;
67# define LED_DISABLE_TIMEOUT 0 67# define LED_DISABLE_TIMEOUT 0
68#endif 68#endif
69 69
70#if LED_DISABLE_WHEN_USB_SUSPENDED != 1
71# undef LED_DISABLE_WHEN_USB_SUSPENDED
72#endif
73
74#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX 70#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
75# undef LED_MATRIX_MAXIMUM_BRIGHTNESS 71# undef LED_MATRIX_MAXIMUM_BRIGHTNESS
76# define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX 72# define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 34d6af2e6..71ef27089 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -16,6 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#include <stdint.h> 17#include <stdint.h>
18#include <stdbool.h> 18#include <stdbool.h>
19#include <string.h>
19#include "util.h" 20#include "util.h"
20#include "matrix.h" 21#include "matrix.h"
21#include "debounce.h" 22#include "debounce.h"
@@ -24,14 +25,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#ifdef DIRECT_PINS 25#ifdef DIRECT_PINS
25static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS; 26static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS;
26#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) 27#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
28# ifdef MATRIX_ROW_PINS
27static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; 29static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
30# endif // MATRIX_ROW_PINS
31# ifdef MATRIX_COL_PINS
28static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; 32static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
33# endif // MATRIX_COL_PINS
29#endif 34#endif
30 35
31/* matrix state(1:on, 0:off) */ 36/* matrix state(1:on, 0:off) */
32extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values 37extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
33extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values 38extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
34 39
40// user-defined overridable functions
41__attribute__((weak)) void matrix_init_pins(void);
42__attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row);
43__attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
44
35static inline void setPinOutput_writeLow(pin_t pin) { 45static inline void setPinOutput_writeLow(pin_t pin) {
36 ATOMIC_BLOCK_FORCEON { 46 ATOMIC_BLOCK_FORCEON {
37 setPinOutput(pin); 47 setPinOutput(pin);
@@ -47,7 +57,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) {
47 57
48#ifdef DIRECT_PINS 58#ifdef DIRECT_PINS
49 59
50static void init_pins(void) { 60__attribute__((weak)) void matrix_init_pins(void) {
51 for (int row = 0; row < MATRIX_ROWS; row++) { 61 for (int row = 0; row < MATRIX_ROWS; row++) {
52 for (int col = 0; col < MATRIX_COLS; col++) { 62 for (int col = 0; col < MATRIX_COLS; col++) {
53 pin_t pin = direct_pins[row][col]; 63 pin_t pin = direct_pins[row][col];
@@ -58,7 +68,7 @@ static void init_pins(void) {
58 } 68 }
59} 69}
60 70
61static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { 71__attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
62 // Start with a clear matrix row 72 // Start with a clear matrix row
63 matrix_row_t current_row_value = 0; 73 matrix_row_t current_row_value = 0;
64 74
@@ -69,16 +79,13 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
69 } 79 }
70 } 80 }
71 81
72 // If the row has changed, store the row and return the changed flag. 82 // Update the matrix
73 if (current_matrix[current_row] != current_row_value) { 83 current_matrix[current_row] = current_row_value;
74 current_matrix[current_row] = current_row_value;
75 return true;
76 }
77 return false;
78} 84}
79 85
80#elif defined(DIODE_DIRECTION) 86#elif defined(DIODE_DIRECTION)
81# if (DIODE_DIRECTION == COL2ROW) 87# if defined(MATRIX_ROW_PINS) && defined(MATRIX_COL_PINS)
88# if (DIODE_DIRECTION == COL2ROW)
82 89
83static void select_row(uint8_t row) { setPinOutput_writeLow(row_pins[row]); } 90static void select_row(uint8_t row) { setPinOutput_writeLow(row_pins[row]); }
84 91
@@ -90,14 +97,14 @@ static void unselect_rows(void) {
90 } 97 }
91} 98}
92 99
93static void init_pins(void) { 100__attribute__((weak)) void matrix_init_pins(void) {
94 unselect_rows(); 101 unselect_rows();
95 for (uint8_t x = 0; x < MATRIX_COLS; x++) { 102 for (uint8_t x = 0; x < MATRIX_COLS; x++) {
96 setPinInputHigh_atomic(col_pins[x]); 103 setPinInputHigh_atomic(col_pins[x]);
97 } 104 }
98} 105}
99 106
100static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { 107__attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
101 // Start with a clear matrix row 108 // Start with a clear matrix row
102 matrix_row_t current_row_value = 0; 109 matrix_row_t current_row_value = 0;
103 110
@@ -118,15 +125,11 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
118 unselect_row(current_row); 125 unselect_row(current_row);
119 matrix_output_unselect_delay(); // wait for all Col signals to go HIGH 126 matrix_output_unselect_delay(); // wait for all Col signals to go HIGH
120 127
121 // If the row has changed, store the row and return the changed flag. 128 // Update the matrix
122 if (current_matrix[current_row] != current_row_value) { 129 current_matrix[current_row] = current_row_value;
123 current_matrix[current_row] = current_row_value;
124 return true;
125 }
126 return false;
127} 130}
128 131
129# elif (DIODE_DIRECTION == ROW2COL) 132# elif (DIODE_DIRECTION == ROW2COL)
130 133
131static void select_col(uint8_t col) { setPinOutput_writeLow(col_pins[col]); } 134static void select_col(uint8_t col) { setPinOutput_writeLow(col_pins[col]); }
132 135
@@ -138,59 +141,46 @@ static void unselect_cols(void) {
138 } 141 }
139} 142}
140 143
141static void init_pins(void) { 144__attribute__((weak)) void matrix_init_pins(void) {
142 unselect_cols(); 145 unselect_cols();
143 for (uint8_t x = 0; x < MATRIX_ROWS; x++) { 146 for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
144 setPinInputHigh_atomic(row_pins[x]); 147 setPinInputHigh_atomic(row_pins[x]);
145 } 148 }
146} 149}
147 150
148static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { 151__attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
149 bool matrix_changed = false;
150
151 // Select col 152 // Select col
152 select_col(current_col); 153 select_col(current_col);
153 matrix_output_select_delay(); 154 matrix_output_select_delay();
154 155
155 // For each row... 156 // For each row...
156 for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) { 157 for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
157 // Store last value of row prior to reading
158 matrix_row_t last_row_value = current_matrix[row_index];
159 matrix_row_t current_row_value = last_row_value;
160
161 // Check row pin state 158 // Check row pin state
162 if (readPin(row_pins[row_index]) == 0) { 159 if (readPin(row_pins[row_index]) == 0) {
163 // Pin LO, set col bit 160 // Pin LO, set col bit
164 current_row_value |= (MATRIX_ROW_SHIFTER << current_col); 161 current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col);
165 } else { 162 } else {
166 // Pin HI, clear col bit 163 // Pin HI, clear col bit
167 current_row_value &= ~(MATRIX_ROW_SHIFTER << current_col); 164 current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col);
168 }
169
170 // Determine if the matrix changed state
171 if ((last_row_value != current_row_value)) {
172 matrix_changed |= true;
173 current_matrix[row_index] = current_row_value;
174 } 165 }
175 } 166 }
176 167
177 // Unselect col 168 // Unselect col
178 unselect_col(current_col); 169 unselect_col(current_col);
179 matrix_output_unselect_delay(); // wait for all Row signals to go HIGH 170 matrix_output_unselect_delay(); // wait for all Row signals to go HIGH
180
181 return matrix_changed;
182} 171}
183 172
184# else 173# else
185# error DIODE_DIRECTION must be one of COL2ROW or ROW2COL! 174# error DIODE_DIRECTION must be one of COL2ROW or ROW2COL!
186# endif 175# endif
176# endif // defined(MATRIX_ROW_PINS) && defined(MATRIX_COL_PINS)
187#else 177#else
188# error DIODE_DIRECTION is not defined! 178# error DIODE_DIRECTION is not defined!
189#endif 179#endif
190 180
191void matrix_init(void) { 181void matrix_init(void) {
192 // initialize key pins 182 // initialize key pins
193 init_pins(); 183 matrix_init_pins();
194 184
195 // initialize matrix state: all keys off 185 // initialize matrix state: all keys off
196 for (uint8_t i = 0; i < MATRIX_ROWS; i++) { 186 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
@@ -204,20 +194,23 @@ void matrix_init(void) {
204} 194}
205 195
206uint8_t matrix_scan(void) { 196uint8_t matrix_scan(void) {
207 bool changed = false; 197 matrix_row_t curr_matrix[MATRIX_ROWS] = {0};
208 198
209#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) 199#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
210 // Set row, read cols 200 // Set row, read cols
211 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { 201 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
212 changed |= read_cols_on_row(raw_matrix, current_row); 202 matrix_read_cols_on_row(curr_matrix, current_row);
213 } 203 }
214#elif (DIODE_DIRECTION == ROW2COL) 204#elif (DIODE_DIRECTION == ROW2COL)
215 // Set col, read rows 205 // Set col, read rows
216 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { 206 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
217 changed |= read_rows_on_col(raw_matrix, current_col); 207 matrix_read_rows_on_col(curr_matrix, current_col);
218 } 208 }
219#endif 209#endif
220 210
211 bool changed = memcmp(raw_matrix, curr_matrix, sizeof(curr_matrix)) != 0;
212 if (changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix));
213
221 debounce(raw_matrix, matrix, MATRIX_ROWS, changed); 214 debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
222 215
223 matrix_scan_quantum(); 216 matrix_scan_quantum();
diff --git a/quantum/quantum.h b/quantum/quantum.h
index e4a7c5723..66ba96fde 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -176,6 +176,10 @@ extern layer_state_t layer_state;
176# include "oled_driver.h" 176# include "oled_driver.h"
177#endif 177#endif
178 178
179#ifdef ST7565_ENABLE
180# include "st7565.h"
181#endif
182
179#ifdef DIP_SWITCH_ENABLE 183#ifdef DIP_SWITCH_ENABLE
180# include "dip_switch.h" 184# include "dip_switch.h"
181#endif 185#endif
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index ab8dbd849..27f641797 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -67,10 +67,6 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv
67# define RGB_DISABLE_TIMEOUT 0 67# define RGB_DISABLE_TIMEOUT 0
68#endif 68#endif
69 69
70#if RGB_DISABLE_WHEN_USB_SUSPENDED != 1
71# undef RGB_DISABLE_WHEN_USB_SUSPENDED
72#endif
73
74#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX 70#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
75# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS 71# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
76# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX 72# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
index a615b8422..741a2fe44 100644
--- a/quantum/rgb_matrix.h
+++ b/quantum/rgb_matrix.h
@@ -33,6 +33,8 @@
33# include "is31fl3737.h" 33# include "is31fl3737.h"
34#elif defined(IS31FL3741) 34#elif defined(IS31FL3741)
35# include "is31fl3741.h" 35# include "is31fl3741.h"
36#elif defined(AW20216)
37# include "aw20216.h"
36#elif defined(WS2812) 38#elif defined(WS2812)
37# include "ws2812.h" 39# include "ws2812.h"
38#endif 40#endif
diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
index 9493b3850..a17e954b1 100644
--- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
+++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
@@ -4,7 +4,7 @@ RGB_MATRIX_EFFECT(JELLYBEAN_RAINDROPS)
4 4
5static void jellybean_raindrops_set_color(int i, effect_params_t* params) { 5static void jellybean_raindrops_set_color(int i, effect_params_t* params) {
6 if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; 6 if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
7 HSV hsv = {rand() & 0xFF, rand() & 0xFF, rgb_matrix_config.hsv.v}; 7 HSV hsv = {rand() & 0xFF, qadd8(rand() & 0x7F, 0x80), rgb_matrix_config.hsv.v};
8 RGB rgb = rgb_matrix_hsv_to_rgb(hsv); 8 RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
9 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 9 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
10} 10}
diff --git a/quantum/rgb_matrix_drivers.c b/quantum/rgb_matrix_drivers.c
index 896fa6d0e..6a11d4791 100644
--- a/quantum/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix_drivers.c
@@ -171,6 +171,22 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
171}; 171};
172# endif 172# endif
173 173
174#elif defined(AW20216)
175# include "spi_master.h"
176static void init(void) {
177 spi_init();
178 AW20216_init();
179}
180
181static void flush(void) { AW20216_update_pwm_buffers(); }
182
183const rgb_matrix_driver_t rgb_matrix_driver = {
184 .init = init,
185 .flush = flush,
186 .set_color = AW20216_set_color,
187 .set_color_all = AW20216_set_color_all,
188};
189
174#elif defined(WS2812) 190#elif defined(WS2812)
175# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_CUSTOM_DRIVER) 191# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_CUSTOM_DRIVER)
176# pragma message "Cannot use RGBLIGHT and RGB Matrix using WS2812 at the same time." 192# pragma message "Cannot use RGBLIGHT and RGB Matrix using WS2812 at the same time."
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index 039e7d977..2cf7b7058 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -16,6 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#include <stdint.h> 17#include <stdint.h>
18#include <stdbool.h> 18#include <stdbool.h>
19#include <string.h>
19#include "util.h" 20#include "util.h"
20#include "matrix.h" 21#include "matrix.h"
21#include "debounce.h" 22#include "debounce.h"
@@ -31,8 +32,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
31#ifdef DIRECT_PINS 32#ifdef DIRECT_PINS
32static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS; 33static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS;
33#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) 34#elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
35# ifdef MATRIX_ROW_PINS
34static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; 36static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
37# endif // MATRIX_ROW_PINS
38# ifdef MATRIX_COL_PINS
35static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; 39static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
40# endif // MATRIX_COL_PINS
36#endif 41#endif
37 42
38/* matrix state(1:on, 0:off) */ 43/* matrix state(1:on, 0:off) */
@@ -45,6 +50,9 @@ uint8_t thisHand, thatHand;
45// user-defined overridable functions 50// user-defined overridable functions
46__attribute__((weak)) void matrix_slave_scan_kb(void) { matrix_slave_scan_user(); } 51__attribute__((weak)) void matrix_slave_scan_kb(void) { matrix_slave_scan_user(); }
47__attribute__((weak)) void matrix_slave_scan_user(void) {} 52__attribute__((weak)) void matrix_slave_scan_user(void) {}
53__attribute__((weak)) void matrix_init_pins(void);
54__attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row);
55__attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
48 56
49static inline void setPinOutput_writeLow(pin_t pin) { 57static inline void setPinOutput_writeLow(pin_t pin) {
50 ATOMIC_BLOCK_FORCEON { 58 ATOMIC_BLOCK_FORCEON {
@@ -61,7 +69,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) {
61 69
62#ifdef DIRECT_PINS 70#ifdef DIRECT_PINS
63 71
64static void init_pins(void) { 72__attribute__((weak)) void matrix_init_pins(void) {
65 for (int row = 0; row < MATRIX_ROWS; row++) { 73 for (int row = 0; row < MATRIX_ROWS; row++) {
66 for (int col = 0; col < MATRIX_COLS; col++) { 74 for (int col = 0; col < MATRIX_COLS; col++) {
67 pin_t pin = direct_pins[row][col]; 75 pin_t pin = direct_pins[row][col];
@@ -72,7 +80,7 @@ static void init_pins(void) {
72 } 80 }
73} 81}
74 82
75static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { 83__attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
76 // Start with a clear matrix row 84 // Start with a clear matrix row
77 matrix_row_t current_row_value = 0; 85 matrix_row_t current_row_value = 0;
78 86
@@ -83,16 +91,13 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
83 } 91 }
84 } 92 }
85 93
86 // If the row has changed, store the row and return the changed flag. 94 // Update the matrix
87 if (current_matrix[current_row] != current_row_value) { 95 current_matrix[current_row] = current_row_value;
88 current_matrix[current_row] = current_row_value;
89 return true;
90 }
91 return false;
92} 96}
93 97
94#elif defined(DIODE_DIRECTION) 98#elif defined(DIODE_DIRECTION)
95# if (DIODE_DIRECTION == COL2ROW) 99# if defined(MATRIX_ROW_PINS) && defined(MATRIX_COL_PINS)
100# if (DIODE_DIRECTION == COL2ROW)
96 101
97static void select_row(uint8_t row) { setPinOutput_writeLow(row_pins[row]); } 102static void select_row(uint8_t row) { setPinOutput_writeLow(row_pins[row]); }
98 103
@@ -104,14 +109,14 @@ static void unselect_rows(void) {
104 } 109 }
105} 110}
106 111
107static void init_pins(void) { 112__attribute__((weak)) void matrix_init_pins(void) {
108 unselect_rows(); 113 unselect_rows();
109 for (uint8_t x = 0; x < MATRIX_COLS; x++) { 114 for (uint8_t x = 0; x < MATRIX_COLS; x++) {
110 setPinInputHigh_atomic(col_pins[x]); 115 setPinInputHigh_atomic(col_pins[x]);
111 } 116 }
112} 117}
113 118
114static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { 119__attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
115 // Start with a clear matrix row 120 // Start with a clear matrix row
116 matrix_row_t current_row_value = 0; 121 matrix_row_t current_row_value = 0;
117 122
@@ -132,15 +137,11 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
132 unselect_row(current_row); 137 unselect_row(current_row);
133 matrix_output_unselect_delay(); // wait for all Col signals to go HIGH 138 matrix_output_unselect_delay(); // wait for all Col signals to go HIGH
134 139
135 // If the row has changed, store the row and return the changed flag. 140 // Update the matrix
136 if (current_matrix[current_row] != current_row_value) { 141 current_matrix[current_row] = current_row_value;
137 current_matrix[current_row] = current_row_value;
138 return true;
139 }
140 return false;
141} 142}
142 143
143# elif (DIODE_DIRECTION == ROW2COL) 144# elif (DIODE_DIRECTION == ROW2COL)
144 145
145static void select_col(uint8_t col) { setPinOutput_writeLow(col_pins[col]); } 146static void select_col(uint8_t col) { setPinOutput_writeLow(col_pins[col]); }
146 147
@@ -152,52 +153,39 @@ static void unselect_cols(void) {
152 } 153 }
153} 154}
154 155
155static void init_pins(void) { 156__attribute__((weak)) void matrix_init_pins(void) {
156 unselect_cols(); 157 unselect_cols();
157 for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { 158 for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
158 setPinInputHigh_atomic(row_pins[x]); 159 setPinInputHigh_atomic(row_pins[x]);
159 } 160 }
160} 161}
161 162
162static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { 163__attribute__((weak)) void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
163 bool matrix_changed = false;
164
165 // Select col 164 // Select col
166 select_col(current_col); 165 select_col(current_col);
167 matrix_output_select_delay(); 166 matrix_output_select_delay();
168 167
169 // For each row... 168 // For each row...
170 for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) { 169 for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
171 // Store last value of row prior to reading
172 matrix_row_t last_row_value = current_matrix[row_index];
173 matrix_row_t current_row_value = last_row_value;
174
175 // Check row pin state 170 // Check row pin state
176 if (readPin(row_pins[row_index]) == 0) { 171 if (readPin(row_pins[row_index]) == 0) {
177 // Pin LO, set col bit 172 // Pin LO, set col bit
178 current_row_value |= (MATRIX_ROW_SHIFTER << current_col); 173 current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col);
179 } else { 174 } else {
180 // Pin HI, clear col bit 175 // Pin HI, clear col bit
181 current_row_value &= ~(MATRIX_ROW_SHIFTER << current_col); 176 current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col);
182 }
183
184 // Determine if the matrix changed state
185 if ((last_row_value != current_row_value)) {
186 matrix_changed |= true;
187 current_matrix[row_index] = current_row_value;
188 } 177 }
189 } 178 }
190 179
191 // Unselect col 180 // Unselect col
192 unselect_col(current_col); 181 unselect_col(current_col);
193 matrix_output_unselect_delay(); // wait for all Row signals to go HIGH 182 matrix_output_unselect_delay(); // wait for all Row signals to go HIGH
194
195 return matrix_changed;
196} 183}
197 184
198# else 185# else
199# error DIODE_DIRECTION must be one of COL2ROW or ROW2COL! 186# error DIODE_DIRECTION must be one of COL2ROW or ROW2COL!
200# endif 187# endif
188# endif // defined(MATRIX_ROW_PINS) && defined(MATRIX_COL_PINS)
201#else 189#else
202# error DIODE_DIRECTION is not defined! 190# error DIODE_DIRECTION is not defined!
203#endif 191#endif
@@ -233,7 +221,7 @@ void matrix_init(void) {
233 thatHand = ROWS_PER_HAND - thisHand; 221 thatHand = ROWS_PER_HAND - thisHand;
234 222
235 // initialize key pins 223 // initialize key pins
236 init_pins(); 224 matrix_init_pins();
237 225
238 // initialize matrix state: all keys off 226 // initialize matrix state: all keys off
239 for (uint8_t i = 0; i < MATRIX_ROWS; i++) { 227 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
@@ -288,20 +276,23 @@ bool matrix_post_scan(void) {
288} 276}
289 277
290uint8_t matrix_scan(void) { 278uint8_t matrix_scan(void) {
291 bool local_changed = false; 279 matrix_row_t curr_matrix[MATRIX_ROWS] = {0};
292 280
293#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) 281#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
294 // Set row, read cols 282 // Set row, read cols
295 for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { 283 for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) {
296 local_changed |= read_cols_on_row(raw_matrix, current_row); 284 matrix_read_cols_on_row(curr_matrix, current_row);
297 } 285 }
298#elif (DIODE_DIRECTION == ROW2COL) 286#elif (DIODE_DIRECTION == ROW2COL)
299 // Set col, read rows 287 // Set col, read rows
300 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { 288 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
301 local_changed |= read_rows_on_col(raw_matrix, current_col); 289 matrix_read_rows_on_col(curr_matrix, current_col);
302 } 290 }
303#endif 291#endif
304 292
293 bool local_changed = memcmp(raw_matrix, curr_matrix, sizeof(curr_matrix)) != 0;
294 if (local_changed) memcpy(raw_matrix, curr_matrix, sizeof(curr_matrix));
295
305 debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed); 296 debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed);
306 297
307 bool remote_changed = matrix_post_scan(); 298 bool remote_changed = matrix_post_scan();
diff --git a/testlist.mk b/testlist.mk
index 0d7609b9f..d256f4c81 100644
--- a/testlist.mk
+++ b/testlist.mk
@@ -1,6 +1,7 @@
1TEST_LIST = $(notdir $(patsubst %/rules.mk,%,$(wildcard $(ROOT_DIR)/tests/*/rules.mk))) 1TEST_LIST = $(notdir $(patsubst %/rules.mk,%,$(wildcard $(ROOT_DIR)/tests/*/rules.mk)))
2FULL_TESTS := $(TEST_LIST) 2FULL_TESTS := $(TEST_LIST)
3 3
4include $(ROOT_DIR)/quantum/debounce/tests/testlist.mk
4include $(ROOT_DIR)/quantum/sequencer/tests/testlist.mk 5include $(ROOT_DIR)/quantum/sequencer/tests/testlist.mk
5include $(ROOT_DIR)/quantum/serial_link/tests/testlist.mk 6include $(ROOT_DIR)/quantum/serial_link/tests/testlist.mk
6 7
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index eb934ffe6..b787e77ec 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -301,7 +301,7 @@ ifneq ($(strip $(BOOTLOADER)), qmk-dfu)
301endif 301endif
302 make -C lib/lufa/Bootloaders/DFU/ clean 302 make -C lib/lufa/Bootloaders/DFU/ clean
303 $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h 303 $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
304 $(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)) 304 $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(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))
305 $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) 305 $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
306 $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) 306 $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
307 $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) 307 $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0))
diff --git a/tmk_core/common/arm_atsam/_timer.h b/tmk_core/common/arm_atsam/_timer.h
new file mode 100644
index 000000000..77402b612
--- /dev/null
+++ b/tmk_core/common/arm_atsam/_timer.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18// The platform is 32-bit, so prefer 32-bit timers to avoid overflow
19#define FAST_TIMER_T_SIZE 32
diff --git a/tmk_core/common/avr/_timer.h b/tmk_core/common/avr/_timer.h
new file mode 100644
index 000000000..b81e0f68b
--- /dev/null
+++ b/tmk_core/common/avr/_timer.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18// The platform is 8-bit, so prefer 16-bit timers to reduce code size
19#define FAST_TIMER_T_SIZE 16
diff --git a/tmk_core/common/avr/gpio.h b/tmk_core/common/avr/gpio.h
index 231556c29..e9be68491 100644
--- a/tmk_core/common/avr/gpio.h
+++ b/tmk_core/common/avr/gpio.h
@@ -20,6 +20,8 @@
20 20
21typedef uint8_t pin_t; 21typedef uint8_t pin_t;
22 22
23/* Operation of GPIO by pin. */
24
23#define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) 25#define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
24#define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) 26#define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
25#define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low") 27#define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
@@ -32,3 +34,16 @@ typedef uint8_t pin_t;
32#define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF))) 34#define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
33 35
34#define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF)) 36#define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF))
37
38/* Operation of GPIO by port. */
39
40typedef uint8_t port_data_t;
41
42#define readPort(port) PINx_ADDRESS(port)
43
44#define setPortBitInput(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
45#define setPortBitInputHigh(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) |= _BV((bit)&0xF))
46#define setPortBitOutput(port, bit) (DDRx_ADDRESS(port) |= _BV((bit)&0xF))
47
48#define writePortBitLow(port, bit) (PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
49#define writePortBitHigh(port, bit) (PORTx_ADDRESS(port) |= _BV((bit)&0xF))
diff --git a/tmk_core/common/chibios/_timer.h b/tmk_core/common/chibios/_timer.h
new file mode 100644
index 000000000..77402b612
--- /dev/null
+++ b/tmk_core/common/chibios/_timer.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 Simon Arlott
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18// The platform is 32-bit, so prefer 32-bit timers to avoid overflow
19#define FAST_TIMER_T_SIZE 32
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c
index 11f7abf43..76d52ea60 100644
--- a/tmk_core/common/chibios/bootloader.c
+++ b/tmk_core/common/chibios/bootloader.c
@@ -95,7 +95,7 @@ void enter_bootloader_mode_if_requested(void) {
95 } 95 }
96} 96}
97 97
98#elif defined(KL2x) || defined(K20x) || defined(MK66F18) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS 98#elif defined(KL2x) || defined(K20x) || defined(MK66F18) || defined(MIMXRT1062) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS
99/* Kinetis */ 99/* Kinetis */
100 100
101# if defined(BOOTLOADER_KIIBOHD) 101# if defined(BOOTLOADER_KIIBOHD)
diff --git a/tmk_core/common/chibios/gpio.h b/tmk_core/common/chibios/gpio.h
index 5d0e142ab..4d057f1ca 100644
--- a/tmk_core/common/chibios/gpio.h
+++ b/tmk_core/common/chibios/gpio.h
@@ -20,6 +20,8 @@
20 20
21typedef ioline_t pin_t; 21typedef ioline_t pin_t;
22 22
23/* Operation of GPIO by pin. */
24
23#define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT) 25#define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT)
24#define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP) 26#define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)
25#define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN) 27#define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)
@@ -32,3 +34,17 @@ typedef ioline_t pin_t;
32#define readPin(pin) palReadLine(pin) 34#define readPin(pin) palReadLine(pin)
33 35
34#define togglePin(pin) palToggleLine(pin) 36#define togglePin(pin) palToggleLine(pin)
37
38/* Operation of GPIO by port. */
39
40typedef uint16_t port_data_t;
41
42#define readPort(pin) palReadPort(PAL_PORT(pin))
43
44#define setPortBitInput(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT)
45#define setPortBitInputHigh(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT_PULLUP)
46#define setPortBitInputLow(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT_PULLDOWN)
47#define setPortBitOutput(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_OUTPUT_PUSHPULL)
48
49#define writePortBitLow(pin, bit) palClearLine(PAL_LINE(PAL_PORT(pin), bit))
50#define writePortBitHigh(pin, bit) palSetLine(PAL_LINE(PAL_PORT(pin), bit))
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 3d6092e71..249da85bd 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -85,6 +85,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
85#ifdef OLED_DRIVER_ENABLE 85#ifdef OLED_DRIVER_ENABLE
86# include "oled_driver.h" 86# include "oled_driver.h"
87#endif 87#endif
88#ifdef ST7565_ENABLE
89# include "st7565.h"
90#endif
88#ifdef VELOCIKEY_ENABLE 91#ifdef VELOCIKEY_ENABLE
89# include "velocikey.h" 92# include "velocikey.h"
90#endif 93#endif
@@ -306,6 +309,9 @@ void keyboard_init(void) {
306#ifdef OLED_DRIVER_ENABLE 309#ifdef OLED_DRIVER_ENABLE
307 oled_init(OLED_ROTATION_0); 310 oled_init(OLED_ROTATION_0);
308#endif 311#endif
312#ifdef ST7565_ENABLE
313 st7565_init(DISPLAY_ROTATION_0);
314#endif
309#ifdef PS2_MOUSE_ENABLE 315#ifdef PS2_MOUSE_ENABLE
310 ps2_mouse_init(); 316 ps2_mouse_init();
311#endif 317#endif
@@ -470,6 +476,18 @@ MATRIX_LOOP_END:
470# endif 476# endif
471#endif 477#endif
472 478
479#ifdef ST7565_ENABLE
480 st7565_task();
481# ifndef ST7565_DISABLE_TIMEOUT
482 // Wake up display if user is using those fabulous keys or spinning those encoders!
483# ifdef ENCODER_ENABLE
484 if (matrix_changed || encoders_changed) st7565_on();
485# else
486 if (matrix_changed) st7565_on();
487# endif
488# endif
489#endif
490
473#ifdef MOUSEKEY_ENABLE 491#ifdef MOUSEKEY_ENABLE
474 // mousekey repeat & acceleration 492 // mousekey repeat & acceleration
475 mousekey_task(); 493 mousekey_task();
diff --git a/tmk_core/common/timer.h b/tmk_core/common/timer.h
index 58f637dd9..928811a2b 100644
--- a/tmk_core/common/timer.h
+++ b/tmk_core/common/timer.h
@@ -1,5 +1,6 @@
1/* 1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com> 2Copyright 2011 Jun Wako <wakojun@gmail.com>
3Copyright 2021 Simon Arlott
3 4
4This program is free software: you can redistribute it and/or modify 5This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 6it under the terms of the GNU General Public License as published by
@@ -17,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 18
18#pragma once 19#pragma once
19 20
21#if __has_include_next("_timer.h")
22# include_next "_timer.h" /* Include the platform's _timer.h */
23#endif
24
20#include <stdint.h> 25#include <stdint.h>
21#include <stdbool.h> 26#include <stdbool.h>
22 27
23#if defined(__AVR__)
24# include "avr/timer_avr.h"
25#endif
26
27#define TIMER_DIFF(a, b, max) ((max == UINT8_MAX) ? ((uint8_t)((a) - (b))) : ((max == UINT16_MAX) ? ((uint16_t)((a) - (b))) : ((max == UINT32_MAX) ? ((uint32_t)((a) - (b))) : ((a) >= (b) ? (a) - (b) : (max) + 1 - (b) + (a))))) 28#define TIMER_DIFF(a, b, max) ((max == UINT8_MAX) ? ((uint8_t)((a) - (b))) : ((max == UINT16_MAX) ? ((uint16_t)((a) - (b))) : ((max == UINT32_MAX) ? ((uint32_t)((a) - (b))) : ((a) >= (b) ? (a) - (b) : (max) + 1 - (b) + (a)))))
28#define TIMER_DIFF_8(a, b) TIMER_DIFF(a, b, UINT8_MAX) 29#define TIMER_DIFF_8(a, b) TIMER_DIFF(a, b, UINT8_MAX)
29#define TIMER_DIFF_16(a, b) TIMER_DIFF(a, b, UINT16_MAX) 30#define TIMER_DIFF_16(a, b) TIMER_DIFF(a, b, UINT16_MAX)
@@ -47,6 +48,21 @@ uint32_t timer_elapsed32(uint32_t last);
47#define timer_expired(current, future) ((uint16_t)(current - future) < UINT16_MAX / 2) 48#define timer_expired(current, future) ((uint16_t)(current - future) < UINT16_MAX / 2)
48#define timer_expired32(current, future) ((uint32_t)(current - future) < UINT32_MAX / 2) 49#define timer_expired32(current, future) ((uint32_t)(current - future) < UINT32_MAX / 2)
49 50
51// Use an appropriate timer integer size based on architecture (16-bit will overflow sooner)
52#if FAST_TIMER_T_SIZE < 32
53# define TIMER_DIFF_FAST(a, b) TIMER_DIFF_16(a, b)
54# define timer_expired_fast(current, future) timer_expired(current, future)
55typedef uint16_t fast_timer_t;
56fast_timer_t inline timer_read_fast(void) { return timer_read(); }
57fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { return timer_elapsed(last); }
58#else
59# define TIMER_DIFF_FAST(a, b) TIMER_DIFF_32(a, b)
60# define timer_expired_fast(current, future) timer_expired32(current, future)
61typedef uint32_t fast_timer_t;
62fast_timer_t inline timer_read_fast(void) { return timer_read32(); }
63fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { return timer_elapsed32(last); }
64#endif
65
50#ifdef __cplusplus 66#ifdef __cplusplus
51} 67}
52#endif 68#endif
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index d04302aca..407b8ea75 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -903,7 +903,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
903 return; 903 return;
904 } 904 }
905 905
906 report_extra_t report = {.report_id = report_id, .usage = data}; 906 static report_extra_t report;
907 report = (report_extra_t){.report_id = report_id, .usage = data};
907 908
908 usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); 909 usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t));
909 osalSysUnlock(); 910 osalSysUnlock();
@@ -1051,45 +1052,44 @@ void virtser_task(void) {
1051#ifdef JOYSTICK_ENABLE 1052#ifdef JOYSTICK_ENABLE
1052 1053
1053void send_joystick_packet(joystick_t *joystick) { 1054void send_joystick_packet(joystick_t *joystick) {
1054 joystick_report_t rep = { 1055 static joystick_report_t rep;
1056 rep = (joystick_report_t) {
1055# if JOYSTICK_AXES_COUNT > 0 1057# if JOYSTICK_AXES_COUNT > 0
1056 .axes = 1058 .axes =
1057 { 1059 { joystick->axes[0],
1058 joystick->axes[0],
1059 1060
1060# if JOYSTICK_AXES_COUNT >= 2 1061# if JOYSTICK_AXES_COUNT >= 2
1061 joystick->axes[1], 1062 joystick->axes[1],
1062# endif 1063# endif
1063# if JOYSTICK_AXES_COUNT >= 3 1064# if JOYSTICK_AXES_COUNT >= 3
1064 joystick->axes[2], 1065 joystick->axes[2],
1065# endif 1066# endif
1066# if JOYSTICK_AXES_COUNT >= 4 1067# if JOYSTICK_AXES_COUNT >= 4
1067 joystick->axes[3], 1068 joystick->axes[3],
1068# endif 1069# endif
1069# if JOYSTICK_AXES_COUNT >= 5 1070# if JOYSTICK_AXES_COUNT >= 5
1070 joystick->axes[4], 1071 joystick->axes[4],
1071# endif 1072# endif
1072# if JOYSTICK_AXES_COUNT >= 6 1073# if JOYSTICK_AXES_COUNT >= 6
1073 joystick->axes[5], 1074 joystick->axes[5],
1074# endif 1075# endif
1075 }, 1076 },
1076# endif // JOYSTICK_AXES_COUNT>0 1077# endif // JOYSTICK_AXES_COUNT>0
1077 1078
1078# if JOYSTICK_BUTTON_COUNT > 0 1079# if JOYSTICK_BUTTON_COUNT > 0
1079 .buttons = 1080 .buttons = {
1080 { 1081 joystick->buttons[0],
1081 joystick->buttons[0],
1082 1082
1083# if JOYSTICK_BUTTON_COUNT > 8 1083# if JOYSTICK_BUTTON_COUNT > 8
1084 joystick->buttons[1], 1084 joystick->buttons[1],
1085# endif 1085# endif
1086# if JOYSTICK_BUTTON_COUNT > 16 1086# if JOYSTICK_BUTTON_COUNT > 16
1087 joystick->buttons[2], 1087 joystick->buttons[2],
1088# endif 1088# endif
1089# if JOYSTICK_BUTTON_COUNT > 24 1089# if JOYSTICK_BUTTON_COUNT > 24
1090 joystick->buttons[3], 1090 joystick->buttons[3],
1091# endif 1091# endif
1092 } 1092 }
1093# endif // JOYSTICK_BUTTON_COUNT>0 1093# endif // JOYSTICK_BUTTON_COUNT>0
1094 }; 1094 };
1095 1095
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 63619fdb3..4ac079e16 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -314,45 +314,44 @@ static void Console_Task(void) {
314void send_joystick_packet(joystick_t *joystick) { 314void send_joystick_packet(joystick_t *joystick) {
315 uint8_t timeout = 255; 315 uint8_t timeout = 255;
316 316
317 joystick_report_t r = { 317 static joystick_report_t;
318 r = (joystick_report_t) {
318# if JOYSTICK_AXES_COUNT > 0 319# if JOYSTICK_AXES_COUNT > 0
319 .axes = 320 .axes =
320 { 321 { joystick->axes[0],
321 joystick->axes[0],
322 322
323# if JOYSTICK_AXES_COUNT >= 2 323# if JOYSTICK_AXES_COUNT >= 2
324 joystick->axes[1], 324 joystick->axes[1],
325# endif 325# endif
326# if JOYSTICK_AXES_COUNT >= 3 326# if JOYSTICK_AXES_COUNT >= 3
327 joystick->axes[2], 327 joystick->axes[2],
328# endif 328# endif
329# if JOYSTICK_AXES_COUNT >= 4 329# if JOYSTICK_AXES_COUNT >= 4
330 joystick->axes[3], 330 joystick->axes[3],
331# endif 331# endif
332# if JOYSTICK_AXES_COUNT >= 5 332# if JOYSTICK_AXES_COUNT >= 5
333 joystick->axes[4], 333 joystick->axes[4],
334# endif 334# endif
335# if JOYSTICK_AXES_COUNT >= 6 335# if JOYSTICK_AXES_COUNT >= 6
336 joystick->axes[5], 336 joystick->axes[5],
337# endif 337# endif
338 }, 338 },
339# endif // JOYSTICK_AXES_COUNT>0 339# endif // JOYSTICK_AXES_COUNT>0
340 340
341# if JOYSTICK_BUTTON_COUNT > 0 341# if JOYSTICK_BUTTON_COUNT > 0
342 .buttons = 342 .buttons = {
343 { 343 joystick->buttons[0],
344 joystick->buttons[0],
345 344
346# if JOYSTICK_BUTTON_COUNT > 8 345# if JOYSTICK_BUTTON_COUNT > 8
347 joystick->buttons[1], 346 joystick->buttons[1],
348# endif 347# endif
349# if JOYSTICK_BUTTON_COUNT > 16 348# if JOYSTICK_BUTTON_COUNT > 16
350 joystick->buttons[2], 349 joystick->buttons[2],
351# endif 350# endif
352# if JOYSTICK_BUTTON_COUNT > 24 351# if JOYSTICK_BUTTON_COUNT > 24
353 joystick->buttons[3], 352 joystick->buttons[3],
354# endif 353# endif
355 } 354 }
356# endif // JOYSTICK_BUTTON_COUNT>0 355# endif // JOYSTICK_BUTTON_COUNT>0
357 }; 356 };
358 357
@@ -768,7 +767,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
768 767
769 if (USB_DeviceState != DEVICE_STATE_Configured) return; 768 if (USB_DeviceState != DEVICE_STATE_Configured) return;
770 769
771 report_extra_t r = {.report_id = report_id, .usage = data}; 770 static report_extra_t r;
771 r = (report_extra_t){.report_id = report_id, .usage = data};
772 Endpoint_SelectEndpoint(SHARED_IN_EPNUM); 772 Endpoint_SelectEndpoint(SHARED_IN_EPNUM);
773 773
774 /* Check if write ready for a polling interval around 10ms */ 774 /* Check if write ready for a polling interval around 10ms */
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index ba7760f28..c88aceb6e 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -351,7 +351,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
351 .Size = sizeof(USB_Descriptor_Device_t), 351 .Size = sizeof(USB_Descriptor_Device_t),
352 .Type = DTYPE_Device 352 .Type = DTYPE_Device
353 }, 353 },
354 .USBSpecification = VERSION_BCD(1, 1, 0), 354 .USBSpecification = VERSION_BCD(2, 0, 0),
355 355
356#if VIRTSER_ENABLE 356#if VIRTSER_ENABLE
357 .Class = USB_CSCP_IADDeviceClass, 357 .Class = USB_CSCP_IADDeviceClass,
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 9362fbde7..876a31378 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -272,7 +272,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
272 last_id = report_id; 272 last_id = report_id;
273 last_data = data; 273 last_data = data;
274 274
275 report_extra_t report = {.report_id = report_id, .usage = data}; 275 static report_extra_t report;
276 report = (report_extra_t){.report_id = report_id, .usage = data};
276 if (usbInterruptIsReadyShared()) { 277 if (usbInterruptIsReadyShared()) {
277 usbSetInterruptShared((void *)&report, sizeof(report_extra_t)); 278 usbSetInterruptShared((void *)&report, sizeof(report_extra_t));
278 } 279 }
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index fc2dc68be..597f7aa82 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -458,7 +458,7 @@ ifeq ($(findstring avr-gcc,$(CC)),avr-gcc)
458SIZE_MARGIN = 1024 458SIZE_MARGIN = 1024
459 459
460check-size: 460check-size:
461 $(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)) 461 $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(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))
462 $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) 462 $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi))
463 $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) 463 $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE)))
464 $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) 464 $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE)))
diff --git a/users/bcat/config.h b/users/bcat/config.h
index 16188950e..5bb93f383 100644
--- a/users/bcat/config.h
+++ b/users/bcat/config.h
@@ -33,7 +33,7 @@
33 33
34#if defined(RGB_MATRIX_ENABLE) 34#if defined(RGB_MATRIX_ENABLE)
35/* Turn off per-key RGB when the host goes to sleep. */ 35/* Turn off per-key RGB when the host goes to sleep. */
36# define RGB_DISABLE_WHEN_USB_SUSPENDED true 36# define RGB_DISABLE_WHEN_USB_SUSPENDED
37 37
38/* Keep per-key RGB increments consistent across keyboards. */ 38/* Keep per-key RGB increments consistent across keyboards. */
39# undef RGB_MATRIX_HUE_STEP 39# undef RGB_MATRIX_HUE_STEP
diff --git a/users/bocaj/config.h b/users/bocaj/config.h
index 2a44aabfc..ecfb09c6f 100644
--- a/users/bocaj/config.h
+++ b/users/bocaj/config.h
@@ -28,7 +28,7 @@
28// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) 28// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened)
29# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 29# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
30// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 30// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
31# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 31# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
32// # 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 32// # 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
33// # define EECONFIG_RGB_MATRIX (uint32_t *)16 33// # define EECONFIG_RGB_MATRIX (uint32_t *)16
34 34
diff --git a/users/curry/config.h b/users/curry/config.h
index b982dab03..e3c0a103e 100644
--- a/users/curry/config.h
+++ b/users/curry/config.h
@@ -17,7 +17,7 @@
17#if defined(RGB_MATRIX_ENABLE) 17#if defined(RGB_MATRIX_ENABLE)
18# define RGB_MATRIX_KEYPRESSES 18# define RGB_MATRIX_KEYPRESSES
19# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 19# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
20# define RGB_DISABLE_WHEN_USB_SUSPENDED true 20# define RGB_DISABLE_WHEN_USB_SUSPENDED
21 21
22# define DISABLE_RGB_MATRIX_ALPHAS_MODS 22# define DISABLE_RGB_MATRIX_ALPHAS_MODS
23# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN 23# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/users/drashna/config.h b/users/drashna/config.h
index 5f7c32ff3..796485689 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -65,7 +65,7 @@
65// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) 65// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened)
66# define RGB_MATRIX_FRAMEBUFFER_EFFECTS 66# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
67// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects 67// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects
68# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 68# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
69// # 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 69// # 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
70// # define EECONFIG_RGB_MATRIX (uint32_t *)16 70// # define EECONFIG_RGB_MATRIX (uint32_t *)16
71 71
diff --git a/users/spidey3/config.h b/users/spidey3/config.h
index 7062fde03..f5f5e07f0 100644
--- a/users/spidey3/config.h
+++ b/users/spidey3/config.h
@@ -1,7 +1,7 @@
1#pragma once 1#pragma once
2 2
3#define LED_DISABLE_WHEN_USB_SUSPENDED true 3#define LED_DISABLE_WHEN_USB_SUSPENDED
4#define RGB_DISABLE_WHEN_USB_SUSPENDED true 4#define RGB_DISABLE_WHEN_USB_SUSPENDED
5#define RGBLIGHT_LAYERS 5#define RGBLIGHT_LAYERS
6#define RGBLIGHT_MAX_LAYERS 17 6#define RGBLIGHT_MAX_LAYERS 17
7#define RGBLIGHT_LAYER_BLINK 7#define RGBLIGHT_LAYER_BLINK
diff --git a/users/tominabox1/config.h b/users/tominabox1/config.h
index 2a8c1e943..004f58ab5 100644
--- a/users/tominabox1/config.h
+++ b/users/tominabox1/config.h
@@ -31,7 +31,7 @@
31// RGB_Matrix settings 31// RGB_Matrix settings
32#ifdef RGB_MATRIX_ENABLE 32#ifdef RGB_MATRIX_ENABLE
33 #define RGB_MATRIX_KEYPRESSES // reacts to keypresses 33 #define RGB_MATRIX_KEYPRESSES // reacts to keypresses
34 #define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended 34 #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
35 #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) 35 #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)
36 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. 36 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
37 #define RGB_MATRIX_HUE_STEP 8 37 #define RGB_MATRIX_HUE_STEP 8