summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common_features.mk21
-rw-r--r--docs/feature_rgb_matrix.md2
-rw-r--r--docs/keycodes.md3
-rw-r--r--docs/one_shot_keys.md3
-rw-r--r--docs/ws2812_driver.md3
-rw-r--r--drivers/chibios/ws2812_pwm.c11
-rw-r--r--keyboards/aeboards/ext65/rev2/config.h2
-rw-r--r--keyboards/aeboards/ext65/rev2/halconf.h2
-rw-r--r--keyboards/aeboards/ext65/rev2/mcuconf.h2
-rw-r--r--keyboards/cannonkeys/an_c/rules.mk2
-rw-r--r--keyboards/cannonkeys/chimera65/rules.mk2
-rw-r--r--keyboards/cannonkeys/instant60/rules.mk2
-rw-r--r--keyboards/cannonkeys/iron165/rules.mk2
-rw-r--r--keyboards/cannonkeys/satisfaction75/rules.mk2
-rw-r--r--keyboards/cannonkeys/savage65/rules.mk2
-rw-r--r--keyboards/cannonkeys/tmov2/rules.mk2
-rw-r--r--keyboards/cannonkeys/tsukuyomi/rules.mk2
-rw-r--r--keyboards/crkbd/rev1/common/config.h1
-rw-r--r--keyboards/crkbd/rev1/common/rules.mk1
-rw-r--r--keyboards/crkbd/rev1/rev1.c2
-rw-r--r--keyboards/daji/seis_cinco/rules.mk2
-rw-r--r--keyboards/handwired/ck4x4/rules.mk2
-rw-r--r--keyboards/handwired/onekey/rules.mk4
-rw-r--r--keyboards/projectkb/alice/config.h3
-rw-r--r--keyboards/projectkb/alice/halconf.h2
-rw-r--r--keyboards/projectkb/alice/mcuconf.h2
-rw-r--r--keyboards/projectkb/signature87/rules.mk2
-rw-r--r--keyboards/ramonimbao/wete/config.h2
-rw-r--r--keyboards/ramonimbao/wete/halconf.h2
-rw-r--r--keyboards/ramonimbao/wete/mcuconf.h2
-rw-r--r--keyboards/westfoxtrot/prophet/config.h2
-rw-r--r--keyboards/westfoxtrot/prophet/halconf.h27
-rw-r--r--keyboards/westfoxtrot/prophet/mcuconf.h5
-rw-r--r--quantum/bootmagic/bootmagic.h24
-rw-r--r--quantum/bootmagic/bootmagic_full.c (renamed from tmk_core/common/bootmagic.c)112
-rw-r--r--quantum/bootmagic/bootmagic_full.h (renamed from tmk_core/common/bootmagic.h)21
-rw-r--r--quantum/bootmagic/bootmagic_lite.c (renamed from tmk_core/common/bootmagic_lite.c)17
-rw-r--r--quantum/bootmagic/bootmagic_lite.h25
-rw-r--r--quantum/bootmagic/magic.c54
-rw-r--r--quantum/bootmagic/magic.h18
-rw-r--r--quantum/keycode_config.h1
-rw-r--r--quantum/quantum.c19
-rw-r--r--quantum/quantum.h10
-rw-r--r--quantum/quantum_keycodes.h9
-rw-r--r--quantum/rgb_matrix.c34
-rw-r--r--quantum/rgb_matrix_types.h9
-rw-r--r--quantum/split_common/split_util.c70
-rw-r--r--quantum/split_common/transport.c45
-rw-r--r--readme.md6
-rw-r--r--tmk_core/common.mk23
-rw-r--r--tmk_core/common/action_util.c58
-rw-r--r--tmk_core/common/action_util.h5
-rw-r--r--tmk_core/common/avr/suspend.c4
-rw-r--r--tmk_core/common/chibios/chibios_config.h2
-rw-r--r--tmk_core/common/chibios/sleep_led.c88
-rw-r--r--tmk_core/common/chibios/suspend.c8
-rw-r--r--tmk_core/common/eeconfig.c2
-rw-r--r--tmk_core/common/eeconfig.h9
-rw-r--r--tmk_core/common/keyboard.c10
-rw-r--r--tmk_core/common/magic.c39
-rw-r--r--tmk_core/common/magic.h3
-rw-r--r--tmk_core/common/usb_util.c29
-rw-r--r--tmk_core/common/usb_util.h22
-rw-r--r--tmk_core/protocol.mk4
-rw-r--r--tmk_core/protocol/chibios.mk1
-rw-r--r--tmk_core/protocol/chibios/usb_util.c21
-rw-r--r--tmk_core/protocol/lufa.mk1
-rw-r--r--tmk_core/protocol/lufa/usb_util.c34
-rw-r--r--tmk_core/protocol/vusb.mk1
-rw-r--r--tmk_core/protocol/vusb/usb_util.c24
70 files changed, 679 insertions, 309 deletions
diff --git a/common_features.mk b/common_features.mk
index 8c9d0a90c7..bdde278b98 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -422,10 +422,6 @@ ifeq ($(strip $(TERMINAL_ENABLE)), yes)
OPT_DEFS += -DUSER_PRINT
endif
-ifeq ($(strip $(USB_HID_ENABLE)), yes)
- include $(TMK_DIR)/protocol/usb_hid.mk
-endif
-
ifeq ($(strip $(WPM_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/wpm.c
OPT_DEFS += -DWPM_ENABLE
@@ -459,6 +455,23 @@ ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/dip_switch.c
endif
+VALID_MAGIC_TYPES := yes full lite
+BOOTMAGIC_ENABLE ?= no
+ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
+ ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),)
+ $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic)
+ endif
+ ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite)
+ OPT_DEFS += -DBOOTMAGIC_LITE
+ QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_lite.c
+ else
+ OPT_DEFS += -DBOOTMAGIC_ENABLE
+ QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_full.c
+ endif
+endif
+COMMON_VPATH += $(QUANTUM_DIR)/bootmagic
+QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/magic.c
+
VALID_CUSTOM_MATRIX_TYPES:= yes lite no
CUSTOM_MATRIX ?= no
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index fd866bd571..878acaf8b3 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -439,6 +439,8 @@ These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blo
#define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
#define RGB_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set
#define RGB_MATRIX_DISABLE_KEYCODES // disables control of rgb matrix by keycodes (must use code functions to control the feature)
+#define RGB_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
+ // If RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
```
## EEPROM storage :id=eeprom-storage
diff --git a/docs/keycodes.md b/docs/keycodes.md
index 9acf8b6839..f3c519b130 100644
--- a/docs/keycodes.md
+++ b/docs/keycodes.md
@@ -516,6 +516,9 @@ See also: [One Shot Keys](one_shot_keys.md)
|------------|----------------------------------|
|`OSM(mod)` |Hold `mod` for one keypress |
|`OSL(layer)`|Switch to `layer` for one keypress|
+|`OS_ON` |Turns One Shot keys on |
+|`OS_OFF` |Turns One Shot keys off |
+|`OS_TOGG` |Toggles One Shot keys status |
## Space Cadet :id=space-cadet
diff --git a/docs/one_shot_keys.md b/docs/one_shot_keys.md
index 9a082d7d6d..9fc5486299 100644
--- a/docs/one_shot_keys.md
+++ b/docs/one_shot_keys.md
@@ -17,6 +17,9 @@ You can control the behavior of one shot keys by defining these in `config.h`:
* `OSM(mod)` - Momentarily hold down *mod*. You must use the `MOD_*` keycodes as shown in [Mod Tap](mod_tap.md), not the `KC_*` codes.
* `OSL(layer)` - momentary switch to *layer*.
+* `OS_ON` - Turns on One Shot keys.
+* `OS_OFF` - Turns off One Shot keys. OSM act as regular mod keys, OSL act like `MO`.
+* `ON_TOGG` - Toggles the one shot key status.
Sometimes, you want to activate a one-shot key as part of a macro or tap dance routine.
diff --git a/docs/ws2812_driver.md b/docs/ws2812_driver.md
index cca6827ec8..fa14f02fdb 100644
--- a/docs/ws2812_driver.md
+++ b/docs/ws2812_driver.md
@@ -102,11 +102,14 @@ Configure the hardware via your config.h:
#define WS2812_PWM_DRIVER PWMD2 // default: PWMD2
#define WS2812_PWM_CHANNEL 2 // default: 2
#define WS2812_PWM_PAL_MODE 2 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 2
+//#define WS2812_PWM_COMPLEMENTARY_OUTPUT // Define for a complementary timer output (TIMx_CHyN); omit for a normal timer output (TIMx_CHy).
#define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
#define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM2_UP // DMAMUX configuration for TIMx_UP -- only required if your MCU has a DMAMUX peripheral, see the respective reference manual for the appropriate values for your MCU.
```
+Note that using a complementary timer output (TIMx_CHyN) is possible only for advanced-control timers (TIM1, TIM8, TIM20 on STM32), and the `STM32_PWM_USE_ADVANCED` option in mcuconf.h must be set to `TRUE`. Complementary outputs of general-purpose timers are not supported due to ChibiOS limitations.
+
You must also turn on the PWM feature in your halconf.h and mcuconf.h
#### Testing Notes
diff --git a/drivers/chibios/ws2812_pwm.c b/drivers/chibios/ws2812_pwm.c
index 140120d488..e6af55b6b3 100644
--- a/drivers/chibios/ws2812_pwm.c
+++ b/drivers/chibios/ws2812_pwm.c
@@ -27,6 +27,15 @@
# error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP"
#endif
+#ifndef WS2812_PWM_COMPLEMENTARY_OUTPUT
+# define WS2812_PWM_OUTPUT_MODE PWM_OUTPUT_ACTIVE_HIGH
+#else
+# if !STM32_PWM_USE_ADVANCED
+# error "WS2812_PWM_COMPLEMENTARY_OUTPUT requires STM32_PWM_USE_ADVANCED == TRUE"
+# endif
+# define WS2812_PWM_OUTPUT_MODE PWM_COMPLEMENTARY_OUTPUT_ACTIVE_HIGH
+#endif
+
// Push Pull or Open Drain Configuration
// Default Push Pull
#ifndef WS2812_EXTERNAL_PULLUP
@@ -247,7 +256,7 @@ void ws2812_init(void) {
.channels =
{
[0 ... 3] = {.mode = PWM_OUTPUT_DISABLED, .callback = NULL}, // Channels default to disabled
- [WS2812_PWM_CHANNEL - 1] = {.mode = PWM_OUTPUT_ACTIVE_HIGH, .callback = NULL}, // Turn on the channel we care about
+ [WS2812_PWM_CHANNEL - 1] = {.mode = WS2812_PWM_OUTPUT_MODE, .callback = NULL}, // Turn on the channel we care about
},
.cr2 = 0,
.dier = TIM_DIER_UDE, // DMA on update event for next period
diff --git a/keyboards/aeboards/ext65/rev2/config.h b/keyboards/aeboards/ext65/rev2/config.h
index 541f07ee98..dc1bfb71c2 100644
--- a/keyboards/aeboards/ext65/rev2/config.h
+++ b/keyboards/aeboards/ext65/rev2/config.h
@@ -74,3 +74,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_LEVELS 6
#define BACKLIGHT_BREATHING
#define BREATHING_PERIOD 6
+
+#define SLEEP_LED_GPT_DRIVER GPTD1
diff --git a/keyboards/aeboards/ext65/rev2/halconf.h b/keyboards/aeboards/ext65/rev2/halconf.h
index 6e2f536400..9fa1eca60b 100644
--- a/keyboards/aeboards/ext65/rev2/halconf.h
+++ b/keyboards/aeboards/ext65/rev2/halconf.h
@@ -27,5 +27,7 @@
#define HAL_USE_SPI TRUE
+#define HAL_USE_GPT TRUE
+
#include_next <halconf.h>
diff --git a/keyboards/aeboards/ext65/rev2/mcuconf.h b/keyboards/aeboards/ext65/rev2/mcuconf.h
index 26ce806150..43d53d4f2d 100644
--- a/keyboards/aeboards/ext65/rev2/mcuconf.h
+++ b/keyboards/aeboards/ext65/rev2/mcuconf.h
@@ -32,3 +32,5 @@
#undef STM32_SPI_USE_SPI2
#define STM32_SPI_USE_SPI2 TRUE
+#undef STM32_GPT_USE_TIM1
+#define STM32_GPT_USE_TIM1 TRUE
diff --git a/keyboards/cannonkeys/an_c/rules.mk b/keyboards/cannonkeys/an_c/rules.mk
index 8ed2d0ead7..7309744d1e 100644
--- a/keyboards/cannonkeys/an_c/rules.mk
+++ b/keyboards/cannonkeys/an_c/rules.mk
@@ -11,7 +11,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
BACKLIGHT_ENABLE = yes
diff --git a/keyboards/cannonkeys/chimera65/rules.mk b/keyboards/cannonkeys/chimera65/rules.mk
index 4d940da78d..a08f2fa49d 100644
--- a/keyboards/cannonkeys/chimera65/rules.mk
+++ b/keyboards/cannonkeys/chimera65/rules.mk
@@ -11,7 +11,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
BACKLIGHT_ENABLE = yes
diff --git a/keyboards/cannonkeys/instant60/rules.mk b/keyboards/cannonkeys/instant60/rules.mk
index 0973ad9547..e5ba2903b6 100644
--- a/keyboards/cannonkeys/instant60/rules.mk
+++ b/keyboards/cannonkeys/instant60/rules.mk
@@ -10,7 +10,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
BACKLIGHT_ENABLE = yes
diff --git a/keyboards/cannonkeys/iron165/rules.mk b/keyboards/cannonkeys/iron165/rules.mk
index 3925458dda..9de75a6149 100644
--- a/keyboards/cannonkeys/iron165/rules.mk
+++ b/keyboards/cannonkeys/iron165/rules.mk
@@ -9,7 +9,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
BACKLIGHT_ENABLE = yes
diff --git a/keyboards/cannonkeys/satisfaction75/rules.mk b/keyboards/cannonkeys/satisfaction75/rules.mk
index e3abea5463..3861b4849f 100644
--- a/keyboards/cannonkeys/satisfaction75/rules.mk
+++ b/keyboards/cannonkeys/satisfaction75/rules.mk
@@ -15,7 +15,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
ENCODER_ENABLE = yes
diff --git a/keyboards/cannonkeys/savage65/rules.mk b/keyboards/cannonkeys/savage65/rules.mk
index 8e1b984fd4..2454573d2f 100644
--- a/keyboards/cannonkeys/savage65/rules.mk
+++ b/keyboards/cannonkeys/savage65/rules.mk
@@ -11,7 +11,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
BACKLIGHT_ENABLE = yes
diff --git a/keyboards/cannonkeys/tmov2/rules.mk b/keyboards/cannonkeys/tmov2/rules.mk
index 9b29e8fd17..294c873eec 100644
--- a/keyboards/cannonkeys/tmov2/rules.mk
+++ b/keyboards/cannonkeys/tmov2/rules.mk
@@ -11,7 +11,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
BACKLIGHT_ENABLE = yes
diff --git a/keyboards/cannonkeys/tsukuyomi/rules.mk b/keyboards/cannonkeys/tsukuyomi/rules.mk
index ce881f1986..4e7791a79f 100644
--- a/keyboards/cannonkeys/tsukuyomi/rules.mk
+++ b/keyboards/cannonkeys/tsukuyomi/rules.mk
@@ -10,7 +10,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = yes # USB Nkey Rollover
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
diff --git a/keyboards/crkbd/rev1/common/config.h b/keyboards/crkbd/rev1/common/config.h
index a2c2cde0b7..b468fe3956 100644
--- a/keyboards/crkbd/rev1/common/config.h
+++ b/keyboards/crkbd/rev1/common/config.h
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef RGB_MATRIX_ENABLE
# define RGB_MATRIX_SPLIT { 27, 27 }
+# define SPLIT_TRANSPORT_MIRROR
#endif
#define DIODE_DIRECTION COL2ROW
diff --git a/keyboards/crkbd/rev1/common/rules.mk b/keyboards/crkbd/rev1/common/rules.mk
index 0b8106e3f2..d38a618090 100644
--- a/keyboards/crkbd/rev1/common/rules.mk
+++ b/keyboards/crkbd/rev1/common/rules.mk
@@ -1,2 +1 @@
SPLIT_KEYBOARD = yes
-SPLIT_TRANSPORT = mirror # for when Split Mirroring drops, it will maintain mirroring functionality
diff --git a/keyboards/crkbd/rev1/rev1.c b/keyboards/crkbd/rev1/rev1.c
index f2df8942ab..347f981501 100644
--- a/keyboards/crkbd/rev1/rev1.c
+++ b/keyboards/crkbd/rev1/rev1.c
@@ -87,7 +87,7 @@ led_config_t g_led_config = { {
void matrix_init_kb(void) {
-#ifdef RGB_MATRIX_ENABLE
+#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_SPLIT)
if (!isLeftHand) {
g_led_config = (led_config_t){ {
{ 51, 50, 45, 44, 37, 36 },
diff --git a/keyboards/daji/seis_cinco/rules.mk b/keyboards/daji/seis_cinco/rules.mk
index fa34092cd7..768e50069c 100644
--- a/keyboards/daji/seis_cinco/rules.mk
+++ b/keyboards/daji/seis_cinco/rules.mk
@@ -11,7 +11,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = yes # USB Nkey Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
diff --git a/keyboards/handwired/ck4x4/rules.mk b/keyboards/handwired/ck4x4/rules.mk
index 0709f341bf..e5785270bd 100644
--- a/keyboards/handwired/ck4x4/rules.mk
+++ b/keyboards/handwired/ck4x4/rules.mk
@@ -10,7 +10,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
CUSTOM_MATRIX = no # Custom matrix file
diff --git a/keyboards/handwired/onekey/rules.mk b/keyboards/handwired/onekey/rules.mk
index 259050d553..df2ec1ecf4 100644
--- a/keyboards/handwired/onekey/rules.mk
+++ b/keyboards/handwired/onekey/rules.mk
@@ -7,9 +7,9 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-NKRO_ENABLE = yes # USB Nkey Rollover
+NKRO_ENABLE = yes # USB Nkey Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
diff --git a/keyboards/projectkb/alice/config.h b/keyboards/projectkb/alice/config.h
new file mode 100644
index 0000000000..95fb682e17
--- /dev/null
+++ b/keyboards/projectkb/alice/config.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define SLEEP_LED_GPT_DRIVER GPTD1
diff --git a/keyboards/projectkb/alice/halconf.h b/keyboards/projectkb/alice/halconf.h
index b17808ffeb..0016e53ba8 100644
--- a/keyboards/projectkb/alice/halconf.h
+++ b/keyboards/projectkb/alice/halconf.h
@@ -27,5 +27,7 @@
#define HAL_USE_SPI TRUE
+#define HAL_USE_GPT TRUE
+
#include_next <halconf.h>
diff --git a/keyboards/projectkb/alice/mcuconf.h b/keyboards/projectkb/alice/mcuconf.h
index 4bfc7f9465..6e0f1a50d8 100644
--- a/keyboards/projectkb/alice/mcuconf.h
+++ b/keyboards/projectkb/alice/mcuconf.h
@@ -32,3 +32,5 @@
#undef STM32_SPI_USE_SPI2
#define STM32_SPI_USE_SPI2 TRUE
+#undef STM32_GPT_USE_TIM1
+#define STM32_GPT_USE_TIM1 TRUE
diff --git a/keyboards/projectkb/signature87/rules.mk b/keyboards/projectkb/signature87/rules.mk
index fe0d976d11..caad4c83c2 100644
--- a/keyboards/projectkb/signature87/rules.mk
+++ b/keyboards/projectkb/signature87/rules.mk
@@ -9,7 +9,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
-SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover
BACKLIGHT_ENABLE = no
diff --git a/keyboards/ramonimbao/wete/config.h b/keyboards/ramonimbao/wete/config.h
index 5d68a7efd7..3d89550090 100644
--- a/keyboards/ramonimbao/wete/config.h
+++ b/keyboards/ramonimbao/wete/config.h
@@ -46,6 +46,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLED_NUM 24
#define RGBLIGHT_ANIMATIONS
+#define SLEEP_LED_GPT_DRIVER GPTD1
+
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
diff --git a/keyboards/ramonimbao/wete/halconf.h b/keyboards/ramonimbao/wete/halconf.h
index c43440a459..b3de873be1 100644
--- a/keyboards/ramonimbao/wete/halconf.h
+++ b/keyboards/ramonimbao/wete/halconf.h
@@ -23,5 +23,7 @@
#define HAL_USE_PWM TRUE
+#define HAL_USE_GPT TRUE
+
#include_next <halconf.h>
diff --git a/keyboards/ramonimbao/wete/mcuconf.h b/keyboards/ramonimbao/wete/mcuconf.h
index b7f2c481c6..7a2e877763 100644
--- a/keyboards/ramonimbao/wete/mcuconf.h
+++ b/keyboards/ramonimbao/wete/mcuconf.h
@@ -35,3 +35,5 @@
#undef STM32_SPI_USE_SPI2
#define STM32_SPI_USE_SPI2 TRUE
+#undef STM32_GPT_USE_TIM1
+#define STM32_GPT_USE_TIM1 TRUE
diff --git a/keyboards/westfoxtrot/prophet/config.h b/keyboards/westfoxtrot/prophet/config.h
index 4f447e4ca0..0f2ddc1dc1 100644
--- a/keyboards/westfoxtrot/prophet/config.h
+++ b/keyboards/westfoxtrot/prophet/config.h
@@ -30,3 +30,5 @@
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
+
+#define SLEEP_LED_GPT_DRIVER GPTD1
diff --git a/keyboards/westfoxtrot/prophet/halconf.h b/keyboards/westfoxtrot/prophet/halconf.h
new file mode 100644
index 0000000000..cbfd1307f1
--- /dev/null
+++ b/keyboards/westfoxtrot/prophet/halconf.h
@@ -0,0 +1,27 @@
+/* Copyright 2020 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This file was auto-generated by:
+ * `qmk chibios-confmigrate -i keyboards/projectkb/alice/halconf.h -r platforms/chibios/common/configs/halconf.h`
+ */
+
+#pragma once
+
+#define HAL_USE_GPT TRUE
+
+#include_next <halconf.h>
+
diff --git a/keyboards/westfoxtrot/prophet/mcuconf.h b/keyboards/westfoxtrot/prophet/mcuconf.h
index 2665f9c9e4..550141af6b 100644
--- a/keyboards/westfoxtrot/prophet/mcuconf.h
+++ b/keyboards/westfoxtrot/prophet/mcuconf.h
@@ -23,6 +23,5 @@
#include_next <mcuconf.h>
-#undef STM32_PWM_USE_TIM3
-#define STM32_PWM_USE_TIM3 TRUE
-
+#undef STM32_GPT_USE_TIM1
+#define STM32_GPT_USE_TIM1 TRUE
diff --git a/quantum/bootmagic/bootmagic.h b/quantum/bootmagic/bootmagic.h
new file mode 100644
index 0000000000..959750178d
--- /dev/null
+++ b/quantum/bootmagic/bootmagic.h
@@ -0,0 +1,24 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#if defined(BOOTMAGIC_ENABLE)
+# include "bootmagic_full.h"
+#elif defined(BOOTMAGIC_LITE)
+# include "bootmagic_lite.h"
+#endif
+
+void bootmagic(void);
diff --git a/tmk_core/common/bootmagic.c b/quantum/bootmagic/bootmagic_full.c
index c1b3adf94d..a7a0dcfcb2 100644
--- a/tmk_core/common/bootmagic.c
+++ b/quantum/bootmagic/bootmagic_full.c
@@ -1,3 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include <stdint.h>
#include <stdbool.h>
#include "wait.h"
@@ -10,18 +25,35 @@
#include "eeconfig.h"
#include "bootmagic.h"
-keymap_config_t keymap_config;
-
-/** \brief Bootmagic
+/** \brief Scan Keycode
*
* FIXME: needs doc
*/
-void bootmagic(void) {
- /* check signature */
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
+static bool scan_keycode(uint8_t keycode) {
+ for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
+ matrix_row_t matrix_row = matrix_get_row(r);
+ for (uint8_t c = 0; c < MATRIX_COLS; c++) {
+ if (matrix_row & ((matrix_row_t)1 << c)) {
+ if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) {
+ return true;
+ }
+ }
+ }
}
+ return false;
+}
+
+/** \brief Bootmagic Scan Keycode
+ *
+ * FIXME: needs doc
+ */
+static bool bootmagic_scan_keycode(uint8_t keycode) {
+ if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false;
+
+ return scan_keycode(keycode);
+}
+void bootmagic(void) {
/* do scans in case of bounce */
print("bootmagic scan: ... ");
uint8_t scan = 100;
@@ -46,8 +78,6 @@ void bootmagic(void) {
bootloader_jump();
}
- /* debug enable */
- debug_config.raw = eeconfig_read_debug();
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) {
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) {
debug_config.matrix = !debug_config.matrix;
@@ -61,8 +91,6 @@ void bootmagic(void) {
}
eeconfig_update_debug(debug_config.raw);
- /* keymap config */
- keymap_config.raw = eeconfig_read_keymap();
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) {
keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock;
}
@@ -93,71 +121,27 @@ void bootmagic(void) {
uint8_t default_layer = 0;
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) {
default_layer |= (1 << 0);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) {
default_layer |= (1 << 1);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) {
default_layer |= (1 << 2);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) {
default_layer |= (1 << 3);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) {
default_layer |= (1 << 4);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) {
default_layer |= (1 << 5);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) {
default_layer |= (1 << 6);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) {
default_layer |= (1 << 7);
}
- if (default_layer) {
- eeconfig_update_default_layer(default_layer);
- default_layer_set((layer_state_t)default_layer);
- } else {
- default_layer = eeconfig_read_default_layer();
- default_layer_set((layer_state_t)default_layer);
- }
- /* Also initialize layer state to trigger callback functions for layer_state */
- layer_state_set_kb((layer_state_t)layer_state);
+ eeconfig_update_default_layer(default_layer);
/* EE_HANDS handedness */
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) {
eeconfig_update_handedness(true);
- }
- if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) {
+ } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) {
eeconfig_update_handedness(false);
}
}
-
-/** \brief Scan Keycode
- *
- * FIXME: needs doc
- */
-static bool scan_keycode(uint8_t keycode) {
- for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
- matrix_row_t matrix_row = matrix_get_row(r);
- for (uint8_t c = 0; c < MATRIX_COLS; c++) {
- if (matrix_row & ((matrix_row_t)1 << c)) {
- if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) {
- return true;
- }
- }
- }
- }
- return false;
-}
-
-/** \brief Bootmagic Scan Keycode
- *
- * FIXME: needs doc
- */
-bool bootmagic_scan_keycode(uint8_t keycode) {
- if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false;
-
- return scan_keycode(keycode);
-}
diff --git a/tmk_core/common/bootmagic.h b/quantum/bootmagic/bootmagic_full.h
index 8209d0194f..28f914c1b6 100644
--- a/tmk_core/common/bootmagic.h
+++ b/quantum/bootmagic/bootmagic_full.h
@@ -1,3 +1,19 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#pragma once
/* FIXME: Add special doxygen comments for defines here. */
@@ -96,7 +112,4 @@
#endif
#ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_7
# define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7
-#endif
-
-void bootmagic(void);
-bool bootmagic_scan_keycode(uint8_t keycode);
+#endif \ No newline at end of file
diff --git a/tmk_core/common/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c
index cbf756a175..9cbdcb0bbd 100644
--- a/tmk_core/common/bootmagic_lite.c
+++ b/quantum/bootmagic/bootmagic_lite.c
@@ -1,3 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "quantum.h"
/** \brief Reset eeprom
@@ -47,3 +62,5 @@ __attribute__((weak)) void bootmagic_lite(void) {
bootloader_jump();
}
}
+
+void bootmagic(void) { bootmagic_lite(); }
diff --git a/quantum/bootmagic/bootmagic_lite.h b/quantum/bootmagic/bootmagic_lite.h
new file mode 100644
index 0000000000..17777e6b4a
--- /dev/null
+++ b/quantum/bootmagic/bootmagic_lite.h
@@ -0,0 +1,25 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#ifndef BOOTMAGIC_LITE_COLUMN
+# define BOOTMAGIC_LITE_COLUMN 0
+#endif
+#ifndef BOOTMAGIC_LITE_ROW
+# define BOOTMAGIC_LITE_ROW 0
+#endif
+
+void bootmagic_lite(void);
diff --git a/quantum/bootmagic/magic.c b/quantum/bootmagic/magic.c
new file mode 100644
index 0000000000..f1cb11c395
--- /dev/null
+++ b/quantum/bootmagic/magic.c
@@ -0,0 +1,54 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <stdint.h>
+#include <stdbool.h>
+#include "wait.h"
+#include "matrix.h"
+#include "bootloader.h"
+#include "debug.h"
+#include "keymap.h"
+#include "host.h"
+#include "action_layer.h"
+#include "eeconfig.h"
+#include "bootmagic.h"
+
+keymap_config_t keymap_config;
+
+__attribute__((weak)) void bootmagic(void) {}
+
+/** \brief Magic
+ *
+ * FIXME: Needs doc
+ */
+void magic(void) {
+ /* check signature */
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+
+ /* init globals */
+ debug_config.raw = eeconfig_read_debug();
+ keymap_config.raw = eeconfig_read_keymap();
+
+ bootmagic();
+
+ /* read here just incase bootmagic process changed its value */
+ layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer();
+ default_layer_set(default_layer);
+
+ /* Also initialize layer state to trigger callback functions for layer_state */
+ layer_state_set_kb((layer_state_t)layer_state);
+}
diff --git a/quantum/bootmagic/magic.h b/quantum/bootmagic/magic.h
new file mode 100644
index 0000000000..2c3969b85c
--- /dev/null
+++ b/quantum/bootmagic/magic.h
@@ -0,0 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+void magic(void);
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h
index f878168c5f..d7e334fdc8 100644
--- a/quantum/keycode_config.h
+++ b/quantum/keycode_config.h
@@ -37,6 +37,7 @@ typedef union {
bool nkro : 1;
bool swap_lctl_lgui : 1;
bool swap_rctl_rgui : 1;
+ bool oneshot_disable : 1;
};
} keymap_config_t;
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 80c4e8f00c..78601ce6bf 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -15,6 +15,7 @@
*/
#include "quantum.h"
+#include "magic.h"
#ifdef BLUETOOTH_ENABLE
# include "outputselect.h"
@@ -318,6 +319,17 @@ bool process_record_quantum(keyrecord_t *record) {
set_output(OUTPUT_BLUETOOTH);
return false;
#endif
+#ifndef NO_ACTION_ONESHOT
+ case ONESHOT_TOGGLE:
+ oneshot_toggle();
+ break;
+ case ONESHOT_ENABLE:
+ oneshot_enable();
+ break;
+ case ONESHOT_DISABLE:
+ oneshot_disable();
+ break;
+#endif
}
}
@@ -369,12 +381,7 @@ void tap_random_base64(void) {
}
void matrix_init_quantum() {
-#ifdef BOOTMAGIC_LITE
- bootmagic_lite();
-#endif
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
+ magic();
#if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN)
// TODO: remove calls to led_init_ports from keyboards and remove ifdef
led_init_ports();
diff --git a/quantum/quantum.h b/quantum/quantum.h
index b1600dd724..070bd01317 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -52,6 +52,7 @@
#include "action_layer.h"
#include "eeconfig.h"
#include "bootloader.h"
+#include "bootmagic.h"
#include "timer.h"
#include "sync_timer.h"
#include "config_common.h"
@@ -258,15 +259,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record);
void post_process_record_kb(uint16_t keycode, keyrecord_t *record);
void post_process_record_user(uint16_t keycode, keyrecord_t *record);
-#ifndef BOOTMAGIC_LITE_COLUMN
-# define BOOTMAGIC_LITE_COLUMN 0
-#endif
-#ifndef BOOTMAGIC_LITE_ROW
-# define BOOTMAGIC_LITE_ROW 0
-#endif
-
-void bootmagic_lite(void);
-
void reset_keyboard(void);
void startup_user(void);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index 116fc4b71d..89a7cf7f84 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -576,6 +576,10 @@ enum quantum_keycodes {
#endif
+ ONESHOT_ENABLE,
+ ONESHOT_DISABLE,
+ ONESHOT_TOGGLE,
+
// always leave at the end
SAFE_RANGE
};
@@ -881,3 +885,8 @@ enum quantum_keycodes {
#define DM_RSTP DYN_REC_STOP
#define DM_PLY1 DYN_MACRO_PLAY1
#define DM_PLY2 DYN_MACRO_PLAY2
+
+// One Shot toggle
+#define OS_TOGG ONESHOT_TOGGLE
+#define OS_ON ONESHOT_ENABLE
+#define OS_OFF ONESHOT_DISABLE
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index ec17b4d72c..8aae486034 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -131,7 +131,7 @@ last_hit_t g_last_hit_tracker;
// internals
static uint8_t rgb_last_enable = UINT8_MAX;
static uint8_t rgb_last_effect = UINT8_MAX;
-static effect_params_t rgb_effect_params = {0, 0xFF};
+static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
static rgb_task_states rgb_task_state = SYNCING;
#if RGB_DISABLE_TIMEOUT > 0
static uint32_t rgb_anykey_timer;
@@ -143,6 +143,11 @@ static uint32_t rgb_timer_buffer;
static last_hit_t last_hit_buffer;
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
+// split rgb matrix
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
+#endif
+
void eeconfig_read_rgb_matrix(void) { eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); }
void eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); }
@@ -153,6 +158,7 @@ void eeconfig_update_rgb_matrix_default(void) {
rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE;
rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL};
rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD;
+ rgb_matrix_config.flags = LED_FLAG_ALL;
eeconfig_update_rgb_matrix();
}
@@ -164,6 +170,7 @@ void eeconfig_debug_rgb_matrix(void) {
dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s);
dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v);
dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed);
+ dprintf("rgb_matrix_config.flags = %d\n", rgb_matrix_config.flags);
}
__attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; }
@@ -180,9 +187,22 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l
void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); }
-void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); }
+void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ if (!is_keyboard_left() && index >= k_rgb_matrix_split[0])
+ rgb_matrix_driver.set_color(index - k_rgb_matrix_split[0], red, green, blue);
+ else if (is_keyboard_left() && index < k_rgb_matrix_split[0])
+#endif
+ rgb_matrix_driver.set_color(index, red, green, blue);
+}
-void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color_all(red, green, blue); }
+void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) rgb_matrix_set_color(i, red, green, blue);
+#else
+ rgb_matrix_driver.set_color_all(red, green, blue);
+#endif
+}
void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
#ifndef RGB_MATRIX_SPLIT
@@ -315,6 +335,10 @@ static void rgb_task_start(void) {
static void rgb_task_render(uint8_t effect) {
bool rendering = false;
rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable);
+ if (rgb_effect_params.flags != rgb_matrix_config.flags) {
+ rgb_effect_params.flags = rgb_matrix_config.flags;
+ rgb_matrix_set_color_all(0, 0, 0);
+ }
// each effect can opt to do calculations
// and/or request PWM buffer updates.
@@ -618,6 +642,6 @@ void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_spe
void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); }
void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); }
-led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; }
+led_flags_t rgb_matrix_get_flags(void) { return rgb_matrix_config.flags; }
-void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; }
+void rgb_matrix_set_flags(led_flags_t flags) { rgb_matrix_config.flags = flags; }
diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h
index 7b8171fb23..1a37922af9 100644
--- a/quantum/rgb_matrix_types.h
+++ b/quantum/rgb_matrix_types.h
@@ -85,10 +85,11 @@ typedef struct PACKED {
typedef union {
uint32_t raw;
struct PACKED {
- uint8_t enable : 2;
- uint8_t mode : 6;
- HSV hsv;
- uint8_t speed; // EECONFIG needs to be increased to support this
+ uint8_t enable : 2;
+ uint8_t mode : 6;
+ HSV hsv;
+ uint8_t speed; // EECONFIG needs to be increased to support this
+ led_flags_t flags;
};
} rgb_config_t;
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c
index 2ae44e6e15..9e75e19ce0 100644
--- a/quantum/split_common/split_util.c
+++ b/quantum/split_common/split_util.c
@@ -1,3 +1,18 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "split_util.h"
#include "matrix.h"
#include "keyboard.h"
@@ -6,14 +21,7 @@
#include "transport.h"
#include "quantum.h"
#include "wait.h"
-
-#ifdef PROTOCOL_LUFA
-# include <LUFA/Drivers/USB/USB.h>
-#endif
-
-#ifdef PROTOCOL_VUSB
-# include <usbdrv/usbdrv.h>
-#endif
+#include "usb_util.h"
#ifdef EE_HANDS
# include "eeconfig.h"
@@ -31,56 +39,21 @@
# define SPLIT_USB_TIMEOUT_POLL 10
#endif
-#ifdef PROTOCOL_CHIBIOS
-# define SPLIT_USB_DETECT // Force this on for now
-#endif
-
volatile bool isLeftHand = true;
#if defined(SPLIT_USB_DETECT)
-# if defined(PROTOCOL_LUFA)
-static inline bool usbHasActiveConnection(void) { return USB_Device_IsAddressSet(); }
-static inline void usbDisable(void) {
- USB_Disable();
- USB_DeviceState = DEVICE_STATE_Unattached;
-}
-# elif defined(PROTOCOL_CHIBIOS)
-static inline bool usbHasActiveConnection(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; }
-static inline void usbDisable(void) { usbStop(&USBD1); }
-# elif defined(PROTOCOL_VUSB)
-static inline bool usbHasActiveConnection(void) {
- usbPoll();
- return usbConfiguration;
-}
-static inline void usbDisable(void) { usbDeviceDisconnect(); }
-# else
-static inline bool usbHasActiveConnection(void) { return true; }
-static inline void usbDisable(void) {}
-# endif
-
-bool usbIsActive(void) {
+static bool usbIsActive(void) {
for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) {
// This will return true if a USB connection has been established
- if (usbHasActiveConnection()) {
+ if (usb_connected_state()) {
return true;
}
wait_ms(SPLIT_USB_TIMEOUT_POLL);
}
-
- // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow
- usbDisable();
-
return false;
}
-#elif defined(PROTOCOL_LUFA) && defined(OTGPADE)
-static inline bool usbIsActive(void) {
- USB_OTGPAD_On(); // enables VBUS pad
- wait_us(5);
-
- return USB_VBUS_GetStatus(); // checks state of VBUS
-}
#else
-static inline bool usbIsActive(void) { return true; }
+static inline bool usbIsActive(void) { return usb_vbus_state(); }
#endif
#ifdef SPLIT_HAND_MATRIX_GRID
@@ -126,6 +99,11 @@ __attribute__((weak)) bool is_keyboard_master(void) {
// only check once, as this is called often
if (usbstate == UNKNOWN) {
usbstate = usbIsActive() ? MASTER : SLAVE;
+
+ // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow
+ if (usbstate == SLAVE) {
+ usb_disable();
+ }
}
return (usbstate == MASTER);
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index 61b61ea08c..27a1c0d3a4 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -22,6 +22,10 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A;
# define NUMBER_OF_ENCODERS (sizeof(encoders_pad) / sizeof(pin_t))
#endif
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+# include "rgb_matrix.h"
+#endif
+
#if defined(USE_I2C)
# include "i2c_master.h"
@@ -54,6 +58,10 @@ typedef struct _I2C_slave_buffer_t {
# ifdef WPM_ENABLE
uint8_t current_wpm;
# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_config_t rgb_matrix;
+ bool rgb_suspend_state;
+# endif
} I2C_slave_buffer_t;
static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
@@ -68,6 +76,8 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
# define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state)
# define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm)
+# define I2C_RGB_MATRIX_START offsetof(I2C_slave_buffer_t, rgb_matrix)
+# define I2C_RGB_SUSPEND_START offsetof(I2C_slave_buffer_t, rgb_suspend_state)
# define TIMEOUT 100
@@ -141,6 +151,11 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
# endif
# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_START, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix), TIMEOUT);
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_SUSPEND_START, (void *)g_suspend_state, sizeof(i2c_buffer->rgb_suspend_state), TIMEOUT);
+# endif
+
# ifndef DISABLE_SYNC_TIMER
i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT);
@@ -186,6 +201,11 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
set_oneshot_mods(i2c_buffer->oneshot_mods);
# endif
# endif
+
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ memcpy((void *)i2c_buffer->rgb_matrix, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix));
+ memcpy((void *)i2c_buffer->rgb_suspend_state, (void *)g_suspend_state, sizeof(i2c_buffer->rgb_suspend_state));
+# endif
}
void transport_master_init(void) { i2c_init(); }
@@ -226,6 +246,10 @@ typedef struct _Serial_m2s_buffer_t {
# ifdef WPM_ENABLE
uint8_t current_wpm;
# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_config_t rgb_matrix;
+ bool rgb_suspend_state;
+# endif
} Serial_m2s_buffer_t;
# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
@@ -333,18 +357,24 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
# ifdef WPM_ENABLE
// Write wpm to slave
- serial_m2s_buffer.current_wpm = get_current_wpm();
+ serial_m2s_buffer.current_wpm = get_current_wpm();
# endif
# ifdef SPLIT_MODS_ENABLE
- serial_m2s_buffer.real_mods = get_mods();
- serial_m2s_buffer.weak_mods = get_weak_mods();
+ serial_m2s_buffer.real_mods = get_mods();
+ serial_m2s_buffer.weak_mods = get_weak_mods();
# ifndef NO_ACTION_ONESHOT
- serial_m2s_buffer.oneshot_mods = get_oneshot_mods();
+ serial_m2s_buffer.oneshot_mods = get_oneshot_mods();
# endif
# endif
+
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ serial_m2s_buffer.rgb_matrix = rgb_matrix_config;
+ serial_m2s_buffer.rgb_suspend_state = g_suspend_state;
+# endif
+
# ifndef DISABLE_SYNC_TIMER
- serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
+ serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
# endif
return true;
}
@@ -381,6 +411,11 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
set_oneshot_mods(serial_m2s_buffer.oneshot_mods);
# endif
# endif
+
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_matrix_config = serial_m2s_buffer.rgb_matrix;
+ g_suspend_state = serial_m2s_buffer.rgb_suspend_state;
+# endif
}
#endif
diff --git a/readme.md b/readme.md
index 6092f209be..bb85115af4 100644
--- a/readme.md
+++ b/readme.md
@@ -9,6 +9,12 @@
This is a keyboard firmware based on the [tmk\_keyboard firmware](https://github.com/tmk/tmk_keyboard) with some useful features for Atmel AVR and ARM controllers, and more specifically, the [OLKB product line](https://olkb.com), the [ErgoDox EZ](https://ergodox-ez.com) keyboard, and the [Clueboard product line](https://clueboard.co).
+# THIS IS THE DEVELOP BRANCH
+
+Warning- This is the `develop` branch of QMK Firmware. You may encounter broken code here. Please see [Breaking Changes](https://docs.qmk.fm/#/breaking_changes) for more information.
+
+# Original readme continues
+
## Documentation
* [See the official documentation on docs.qmk.fm](https://docs.qmk.fm)
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index 238b3c69fd..2f8f81126a 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -12,6 +12,7 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \
$(COMMON_DIR)/sendchar_null.c \
$(COMMON_DIR)/eeconfig.c \
$(COMMON_DIR)/report.c \
+ $(COMMON_DIR)/usb_util.c \
$(PLATFORM_COMMON_DIR)/suspend.c \
$(PLATFORM_COMMON_DIR)/timer.c \
$(COMMON_DIR)/sync_timer.c \
@@ -24,28 +25,6 @@ else
include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk
endif
-# Option modules
-BOOTMAGIC_ENABLE ?= no
-VALID_MAGIC_TYPES := yes full lite
-ifneq ($(strip $(BOOTMAGIC_ENABLE)), no)
- ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),)
- $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic)
- endif
- ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite)
- TMK_COMMON_DEFS += -DBOOTMAGIC_LITE
- TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic_lite.c
-
- TMK_COMMON_DEFS += -DMAGIC_ENABLE
- TMK_COMMON_SRC += $(COMMON_DIR)/magic.c
- else
- TMK_COMMON_DEFS += -DBOOTMAGIC_ENABLE
- TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic.c
- endif
-else
- TMK_COMMON_DEFS += -DMAGIC_ENABLE
- TMK_COMMON_SRC += $(COMMON_DIR)/magic.c
-endif
-
SHARED_EP_ENABLE = no
MOUSE_SHARED_EP ?= yes
ifeq ($(strip $(KEYBOARD_SHARED_EP)), yes)
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c
index 000503b082..a57c8bf66a 100644
--- a/tmk_core/common/action_util.c
+++ b/tmk_core/common/action_util.c
@@ -147,12 +147,16 @@ void clear_oneshot_swaphands(void) {
* FIXME: needs doc
*/
void set_oneshot_layer(uint8_t layer, uint8_t state) {
- oneshot_layer_data = layer << 3 | state;
- layer_on(layer);
+ if (!keymap_config.oneshot_disable) {
+ oneshot_layer_data = layer << 3 | state;
+ layer_on(layer);
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
- oneshot_layer_time = timer_read();
+ oneshot_layer_time = timer_read();
# endif
- oneshot_layer_changed_kb(get_oneshot_layer());
+ oneshot_layer_changed_kb(get_oneshot_layer());
+ } else {
+ layer_on(layer);
+ }
}
/** \brief Reset oneshot layer
*
@@ -172,7 +176,7 @@ void reset_oneshot_layer(void) {
void clear_oneshot_layer_state(oneshot_fullfillment_t state) {
uint8_t start_state = oneshot_layer_data;
oneshot_layer_data &= ~state;
- if (!get_oneshot_layer_state() && start_state != oneshot_layer_data) {
+ if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) || keymap_config.oneshot_disable) {
layer_off(get_oneshot_layer());
reset_oneshot_layer();
}
@@ -182,6 +186,39 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state) {
* FIXME: needs doc
*/
bool is_oneshot_layer_active(void) { return get_oneshot_layer_state(); }
+
+/** \brief set oneshot
+ *
+ * FIXME: needs doc
+ */
+void oneshot_set(bool active) {
+ if (keymap_config.oneshot_disable != active) {
+ keymap_config.oneshot_disable = active;
+ eeconfig_update_keymap(keymap_config.raw);
+ dprintf("Oneshot: active: %d\n", active);
+ }
+}
+
+/** \brief toggle oneshot
+ *
+ * FIXME: needs doc
+ */
+void oneshot_toggle(void) { oneshot_set(!keymap_config.oneshot_disable); }
+
+/** \brief enable oneshot
+ *
+ * FIXME: needs doc
+ */
+void oneshot_enable(void) { oneshot_set(true); }
+
+/** \brief disable oneshot
+ *
+ * FIXME: needs doc
+ */
+void oneshot_disable(void) { oneshot_set(false); }
+
+bool is_oneshot_enabled(void) { return keymap_config.oneshot_disable; }
+
#endif
/** \brief Send keyboard report
@@ -321,14 +358,17 @@ void del_oneshot_mods(uint8_t mods) {
* FIXME: needs doc
*/
void set_oneshot_mods(uint8_t mods) {
- if (oneshot_mods != mods) {
+ if (!keymap_config.oneshot_disable) {
+ if (oneshot_mods != mods) {
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
- oneshot_time = timer_read();
+ oneshot_time = timer_read();
# endif
- oneshot_mods = mods;
- oneshot_mods_changed_kb(mods);
+ oneshot_mods = mods;
+ oneshot_mods_changed_kb(mods);
+ }
}
}
+
/** \brief clear oneshot mods
*
* FIXME: needs doc
diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h
index ff29f79b09..f2b3897ae5 100644
--- a/tmk_core/common/action_util.h
+++ b/tmk_core/common/action_util.h
@@ -85,6 +85,11 @@ void oneshot_mods_changed_kb(uint8_t mods);
void oneshot_layer_changed_user(uint8_t layer);
void oneshot_layer_changed_kb(uint8_t layer);
+void oneshot_toggle(void);
+void oneshot_enable(void);
+void oneshot_disable(void);
+bool is_oneshot_enabled(void);
+
/* inspect */
uint8_t has_anymod(void);
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c
index 47a82a2eec..d52c8ac410 100644
--- a/tmk_core/common/avr/suspend.c
+++ b/tmk_core/common/avr/suspend.c
@@ -28,6 +28,10 @@
# include "rgblight.h"
#endif
+#ifdef RGB_MATRIX_ENABLE
+# include "rgb_matrix.h"
+#endif
+
/** \brief Suspend idle
*
* FIXME: needs doc
diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h
index b4d96465d1..bebf026de7 100644
--- a/tmk_core/common/chibios/chibios_config.h
+++ b/tmk_core/common/chibios/chibios_config.h
@@ -15,6 +15,8 @@
*/
#pragma once
+#define SPLIT_USB_DETECT // Force this on for now
+
#if defined(STM32F1XX)
# define USE_GPIOV1
#endif
diff --git a/tmk_core/common/chibios/sleep_led.c b/tmk_core/common/chibios/sleep_led.c
index 5595eec0e5..477056a454 100644
--- a/tmk_core/common/chibios/sleep_led.c
+++ b/tmk_core/common/chibios/sleep_led.c
@@ -9,21 +9,13 @@
* Use LP timer on Kinetises, TIM14 on STM32F0.
*/
-#if defined(KL2x) || defined(K20x)
-
-/* Use Low Power Timer (LPTMR) */
-# define TIMER_INTERRUPT_VECTOR KINETIS_LPTMR0_IRQ_VECTOR
-# define RESET_COUNTER LPTMR0->CSR |= LPTMRx_CSR_TCF
-
-#elif defined(STM32F0XX)
-
-/* Use TIM14 manually */
-# define TIMER_INTERRUPT_VECTOR STM32_TIM14_HANDLER
-# define RESET_COUNTER STM32_TIM14->SR &= ~STM32_TIM_SR_UIF
-
+#ifndef SLEEP_LED_GPT_DRIVER
+# if defined(STM32F0XX)
+# define SLEEP_LED_GPT_DRIVER GPTD14
+# endif
#endif
-#if defined(KL2x) || defined(K20x) || defined(STM32F0XX) /* common parts for timers/interrupts */
+#if defined(KL2x) || defined(K20x) || defined(SLEEP_LED_GPT_DRIVER) /* common parts for timers/interrupts */
/* Breathing Sleep LED brighness(PWM On period) table
* (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle
@@ -33,10 +25,7 @@
*/
static const uint8_t breathing_table[64] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, 15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, 255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, 15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-/* interrupt handler */
-OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) {
- OSAL_IRQ_PROLOGUE();
-
+void sleep_led_timer_callback(void) {
/* Software PWM
* timer:1111 1111 1111 1111
* \_____/\/ \_______/____ count(0-255)
@@ -64,17 +53,16 @@ OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) {
if (timer.pwm.count == breathing_table[timer.pwm.index]) {
led_set(0);
}
-
- /* Reset the counter */
- RESET_COUNTER;
-
- OSAL_IRQ_EPILOGUE();
}
#endif /* common parts for known platforms */
#if defined(KL2x) || defined(K20x) /* platform selection: familiar Kinetis chips */
+/* Use Low Power Timer (LPTMR) */
+# define TIMER_INTERRUPT_VECTOR KINETIS_LPTMR0_IRQ_VECTOR
+# define RESET_COUNTER LPTMR0->CSR |= LPTMRx_CSR_TCF
+
/* LPTMR clock options */
# define LPTMR_CLOCK_MCGIRCLK 0 /* 4MHz clock */
# define LPTMR_CLOCK_LPO 1 /* 1kHz clock */
@@ -86,6 +74,18 @@ OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) {
# define SIM_SCGC5_LPTMR SIM_SCGC5_LPTIMER
# endif
+/* interrupt handler */
+OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) {
+ OSAL_IRQ_PROLOGUE();
+
+ sleep_led_timer_callback();
+
+ /* Reset the counter */
+ RESET_COUNTER;
+
+ OSAL_IRQ_EPILOGUE();
+}
+
/* Initialise the timer */
void sleep_led_init(void) {
/* Make sure the clock to the LPTMR is enabled */
@@ -159,45 +159,23 @@ void sleep_led_toggle(void) {
LPTMR0->CSR ^= LPTMRx_CSR_TEN;
}
-#elif defined(STM32F0XX) /* platform selection: STM32F0XX */
-
-/* Initialise the timer */
-void sleep_led_init(void) {
- /* enable clock */
- rccEnableTIM14(FALSE); /* low power enable = FALSE */
- rccResetTIM14();
-
- /* prescale */
- /* Assuming 48MHz internal clock */
- /* getting cca 65484 irqs/sec */
- STM32_TIM14->PSC = 733;
+#elif defined(SLEEP_LED_GPT_DRIVER)
- /* auto-reload */
- /* 0 => interrupt every time */
- STM32_TIM14->ARR = 3;
+static void gptTimerCallback(GPTDriver *gptp) {
+ (void)gptp;
+ sleep_led_timer_callback();
+}
- /* enable counter update event interrupt */
- STM32_TIM14->DIER |= STM32_TIM_DIER_UIE;
+static const GPTConfig gptcfg = {1000000, gptTimerCallback, 0, 0};
- /* register interrupt vector */
- nvicEnableVector(STM32_TIM14_NUMBER, 2); /* vector, priority */
-}
+/* Initialise the timer */
+void sleep_led_init(void) { gptStart(&SLEEP_LED_GPT_DRIVER, &gptcfg); }
-void sleep_led_enable(void) {
- /* Enable the timer */
- STM32_TIM14->CR1 = STM32_TIM_CR1_CEN | STM32_TIM_CR1_URS;
- /* URS => update event only on overflow; setting UG bit disabled */
-}
+void sleep_led_enable(void) { gptStartContinuous(&SLEEP_LED_GPT_DRIVER, gptcfg.frequency / 0xFFFF); }
-void sleep_led_disable(void) {
- /* Disable the timer */
- STM32_TIM14->CR1 = 0;
-}
+void sleep_led_disable(void) { gptStopTimer(&SLEEP_LED_GPT_DRIVER); }
-void sleep_led_toggle(void) {
- /* Toggle the timer */
- STM32_TIM14->CR1 ^= STM32_TIM_CR1_CEN;
-}
+void sleep_led_toggle(void) { (SLEEP_LED_GPT_DRIVER.state == GPT_READY) ? sleep_led_enable() : sleep_led_disable(); }
#else /* platform selection: not on familiar chips */
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index 49e20641fb..17f024caba 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -24,6 +24,10 @@
# include "rgblight.h"
#endif
+#ifdef RGB_MATRIX_ENABLE
+# include "rgb_matrix.h"
+#endif
+
/** \brief suspend idle
*
* FIXME: needs doc
@@ -53,6 +57,10 @@ void suspend_power_down(void) {
backlight_set(0);
#endif
+#ifdef RGB_MATRIX_ENABLE
+ rgb_matrix_task();
+#endif
+
// Turn off LED indicators
uint8_t leds_off = 0;
#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index 5e3ebe6ee6..92a5092176 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -57,7 +57,7 @@ void eeconfig_init_quantum(void) {
eeprom_update_dword(EECONFIG_HAPTIC, 0);
eeprom_update_byte(EECONFIG_VELOCIKEY, 0);
eeprom_update_dword(EECONFIG_RGB_MATRIX, 0);
- eeprom_update_byte(EECONFIG_RGB_MATRIX_SPEED, 0);
+ eeprom_update_word(EECONFIG_RGB_MATRIX_EXTENDED, 0);
// TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
// within the emulated eeprom via dfu-util or another tool
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index 86b9e6f99b..39bc51d5db 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#ifndef EECONFIG_MAGIC_NUMBER
-# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEEB // When changing, decrement this value to avoid future re-init issues
+# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEEA // When changing, decrement this value to avoid future re-init issues
#endif
#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF
@@ -44,11 +44,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_HAPTIC (uint32_t *)24
#define EECONFIG_RGB_MATRIX (uint32_t *)28
-#define EECONFIG_RGB_MATRIX_SPEED (uint8_t *)32
+// Speed & Flags
+#define EECONFIG_RGB_MATRIX_EXTENDED (uint16_t *)32
// TODO: Combine these into a single word and single block of EEPROM
-#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)33
+#define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)34
// Size of EEPROM being used, other code can refer to this for available EEPROM
-#define EECONFIG_SIZE 34
+#define EECONFIG_SIZE 35
/* debug bit */
#define EECONFIG_DEBUG_ENABLE (1 << 0)
#define EECONFIG_DEBUG_MATRIX (1 << 1)
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index ce3255c069..65d9e00c7a 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -34,11 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
#endif
-#ifdef BOOTMAGIC_ENABLE
-# include "bootmagic.h"
-#else
-# include "magic.h"
-#endif
#ifdef MOUSEKEY_ENABLE
# include "mousekey.h"
#endif
@@ -296,11 +291,6 @@ void keyboard_init(void) {
#ifdef ADB_MOUSE_ENABLE
adb_mouse_init();
#endif
-#ifdef BOOTMAGIC_ENABLE
- bootmagic();
-#else
- magic();
-#endif
#ifdef BACKLIGHT_ENABLE
backlight_init();
#endif
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c
deleted file mode 100644
index e14994164e..0000000000
--- a/tmk_core/common/magic.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <stdint.h>
-#include <stdbool.h>
-#if defined(__AVR__)
-# include <util/delay.h>
-#endif
-#include "matrix.h"
-#include "bootloader.h"
-#include "debug.h"
-#include "keymap.h"
-#include "host.h"
-#include "action_layer.h"
-#include "eeconfig.h"
-#include "magic.h"
-
-keymap_config_t keymap_config;
-
-/** \brief Magic
- *
- * FIXME: Needs doc
- */
-void magic(void) {
- /* check signature */
- if (!eeconfig_is_enabled()) {
- eeconfig_init();
- }
-
- /* debug enable */
- debug_config.raw = eeconfig_read_debug();
-
- /* keymap config */
- keymap_config.raw = eeconfig_read_keymap();
-
- uint8_t default_layer = 0;
- default_layer = eeconfig_read_default_layer();
- default_layer_set((layer_state_t)default_layer);
-
- /* Also initialize layer state to trigger callback functions for layer_state */
- layer_state_set_kb((layer_state_t)layer_state);
-}
diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h
deleted file mode 100644
index a6552c04dc..0000000000
--- a/tmk_core/common/magic.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-void magic(void);
diff --git a/tmk_core/common/usb_util.c b/tmk_core/common/usb_util.c
new file mode 100644
index 0000000000..e4c50fcb10
--- /dev/null
+++ b/tmk_core/common/usb_util.c
@@ -0,0 +1,29 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "usb_util.h"
+#include "wait.h"
+
+__attribute__((weak)) void usb_disable(void) {}
+__attribute__((weak)) bool usb_connected_state(void) { return true; }
+__attribute__((weak)) bool usb_vbus_state(void) {
+#ifdef USB_VBUS_PIN
+ setPinInput(USB_VBUS_PIN);
+ wait_us(5);
+ return readPin(USB_VBUS_PIN);
+#else
+ return true;
+#endif
+}
diff --git a/tmk_core/common/usb_util.h b/tmk_core/common/usb_util.h
new file mode 100644
index 0000000000..4ebedb1e71
--- /dev/null
+++ b/tmk_core/common/usb_util.h
@@ -0,0 +1,22 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <stdbool.h>
+
+void usb_disable(void);
+bool usb_connected_state(void);
+bool usb_vbus_state(void);
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk
index 0c41642b9b..cc87e83478 100644
--- a/tmk_core/protocol.mk
+++ b/tmk_core/protocol.mk
@@ -54,5 +54,9 @@ ifeq ($(strip $(XT_ENABLE)), yes)
OPT_DEFS += -DXT_ENABLE
endif
+ifeq ($(strip $(USB_HID_ENABLE)), yes)
+ include $(TMK_DIR)/protocol/usb_hid.mk
+endif
+
# Search Path
VPATH += $(TMK_DIR)/protocol
diff --git a/tmk_core/protocol/chibios.mk b/tmk_core/protocol/chibios.mk
index 80554abb32..d01697835b 100644
--- a/tmk_core/protocol/chibios.mk
+++ b/tmk_core/protocol/chibios.mk
@@ -6,6 +6,7 @@ SRC += $(CHIBIOS_DIR)/usb_main.c
SRC += $(CHIBIOS_DIR)/main.c
SRC += usb_descriptor.c
SRC += $(CHIBIOS_DIR)/usb_driver.c
+SRC += $(CHIBIOS_DIR)/usb_util.c
SRC += $(LIBSRC)
VPATH += $(TMK_PATH)/$(PROTOCOL_DIR)
diff --git a/tmk_core/protocol/chibios/usb_util.c b/tmk_core/protocol/chibios/usb_util.c
new file mode 100644
index 0000000000..5945e8a8de
--- /dev/null
+++ b/tmk_core/protocol/chibios/usb_util.c
@@ -0,0 +1,21 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <hal.h>
+#include "usb_util.h"
+
+void usb_disable(void) { usbStop(&USBD1); }
+
+bool usb_connected_state(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; }
diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk
index 1cc1fa04e5..9d9fb728b1 100644
--- a/tmk_core/protocol/lufa.mk
+++ b/tmk_core/protocol/lufa.mk
@@ -44,6 +44,7 @@ ifeq ($(strip $(VIRTSER_ENABLE)), yes)
endif
SRC += $(LUFA_SRC)
+SRC += $(LUFA_DIR)/usb_util.c
# Search Path
VPATH += $(TMK_PATH)/$(LUFA_DIR)
diff --git a/tmk_core/protocol/lufa/usb_util.c b/tmk_core/protocol/lufa/usb_util.c
new file mode 100644
index 0000000000..9e943a21b9
--- /dev/null
+++ b/tmk_core/protocol/lufa/usb_util.c
@@ -0,0 +1,34 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <LUFA/Drivers/USB/USB.h>
+#include "usb_util.h"
+#include "wait.h"
+
+void usb_disable(void) {
+ USB_Disable();
+ USB_DeviceState = DEVICE_STATE_Unattached;
+}
+
+bool usb_connected_state(void) { return USB_Device_IsAddressSet(); }
+
+#if defined(OTGPADE)
+bool usb_vbus_state(void) {
+ USB_OTGPAD_On(); // enables VBUS pad
+ wait_us(5);
+
+ return USB_VBUS_GetStatus(); // checks state of VBUS
+}
+#endif
diff --git a/tmk_core/protocol/vusb.mk b/tmk_core/protocol/vusb.mk
index 1de6003089..e4d013b38d 100644
--- a/tmk_core/protocol/vusb.mk
+++ b/tmk_core/protocol/vusb.mk
@@ -5,6 +5,7 @@ VUSB_PATH = $(LIB_PATH)/vusb
SRC += $(VUSB_DIR)/main.c \
$(VUSB_DIR)/vusb.c \
+ $(VUSB_DIR)/usb_util.c \
$(VUSB_PATH)/usbdrv/usbdrv.c \
$(VUSB_PATH)/usbdrv/usbdrvasm.S \
$(VUSB_PATH)/usbdrv/oddebug.c
diff --git a/tmk_core/protocol/vusb/usb_util.c b/tmk_core/protocol/vusb/usb_util.c
new file mode 100644
index 0000000000..602854dbe6
--- /dev/null
+++ b/tmk_core/protocol/vusb/usb_util.c
@@ -0,0 +1,24 @@
+/* Copyright 2021 QMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <usbdrv/usbdrv.h>
+#include "usb_util.h"
+
+void usb_disable(void) { usbDeviceDisconnect(); }
+
+bool usb_connected_state(void) {
+ usbPoll();
+ return usbConfiguration;
+}