Compare commits
59 Commits
Author | SHA1 | Date | |
---|---|---|---|
eef0cb2f90 | |||
63e4ad13c8 | |||
f9e67338a4 | |||
5f9f62fb8c | |||
147bc6ec43 | |||
bea62add55 | |||
d511e52c1f | |||
789e199450 | |||
a747c1c3de | |||
a521fc2b6c | |||
8651eef298 | |||
f4799481cd | |||
675b153525 | |||
5df2424651 | |||
f9c53ca71a | |||
0d189582c1 | |||
c6b667623a | |||
d96380e654 | |||
7e80686f1e | |||
e967471c4f | |||
eca3f9d935 | |||
44c62117ee | |||
f235822fba | |||
5d5ff807c6 | |||
1c7c5daad4 | |||
aeab11da88 | |||
b53934805a | |||
6bfbdc30ca | |||
02eb949479 | |||
3a0f11eb27 | |||
c2013f0b7c | |||
19d7cbc858 | |||
73f903906e | |||
d235612e48 | |||
6ad3328b83 | |||
13d736d6ab | |||
0b810bdff3 | |||
3f19117124 | |||
fe3e5cba69 | |||
6ba383cc5f | |||
d44ca60cb0 | |||
42b0e95ae6 | |||
b6316c5024 | |||
fc4ef6934d | |||
0dff26b550 | |||
76d8558b1a | |||
8123dd2649 | |||
1ec648932f | |||
427f7b3a39 | |||
c670240503 | |||
59d6b0faab | |||
6f55aa993a | |||
e34764502f | |||
8b0efc2124 | |||
2f936420dd | |||
6698af9c3d | |||
61da615308 | |||
ece14278ef | |||
567bfc97ac |
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -11,6 +11,7 @@
|
||||
"files.associations": {
|
||||
"*.h": "c",
|
||||
"*.c": "c",
|
||||
"*.inc": "c",
|
||||
"*.cpp": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"xstddef": "c",
|
||||
|
@ -231,13 +231,16 @@ endif
|
||||
# We can assume a ChibiOS target When MCU_FAMILY is defined since it's
|
||||
# not used for LUFA
|
||||
ifdef MCU_FAMILY
|
||||
FIRMWARE_FORMAT?=bin
|
||||
PLATFORM=CHIBIOS
|
||||
PLATFORM_KEY=chibios
|
||||
FIRMWARE_FORMAT?=bin
|
||||
else ifdef ARM_ATSAM
|
||||
PLATFORM=ARM_ATSAM
|
||||
PLATFORM_KEY=arm_atsam
|
||||
FIRMWARE_FORMAT=bin
|
||||
else
|
||||
PLATFORM=AVR
|
||||
PLATFORM_KEY=avr
|
||||
FIRMWARE_FORMAT?=hex
|
||||
endif
|
||||
|
||||
|
@ -41,6 +41,7 @@ all: elf
|
||||
|
||||
VPATH += $(COMMON_VPATH)
|
||||
PLATFORM:=TEST
|
||||
PLATFORM_KEY:=test
|
||||
|
||||
ifneq ($(filter $(FULL_TESTS),$(TEST)),)
|
||||
include tests/$(TEST)/rules.mk
|
||||
|
@ -13,52 +13,42 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
SERIAL_DIR := $(QUANTUM_DIR)/serial_link
|
||||
SERIAL_PATH := $(QUANTUM_PATH)/serial_link
|
||||
SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c)
|
||||
SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
|
||||
SERIAL_DEFS += -DSERIAL_LINK_ENABLE
|
||||
COMMON_VPATH += $(SERIAL_PATH)
|
||||
|
||||
QUANTUM_SRC += \
|
||||
$(QUANTUM_DIR)/quantum.c \
|
||||
$(QUANTUM_DIR)/keymap_common.c \
|
||||
$(QUANTUM_DIR)/keycode_config.c
|
||||
|
||||
ifeq ($(strip $(API_SYSEX_ENABLE)), yes)
|
||||
OPT_DEFS += -DAPI_SYSEX_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/api/api_sysex.c
|
||||
OPT_DEFS += -DAPI_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/api.c
|
||||
MIDI_ENABLE=yes
|
||||
SRC += $(QUANTUM_DIR)/api/api_sysex.c
|
||||
SRC += $(QUANTUM_DIR)/api.c
|
||||
endif
|
||||
|
||||
MUSIC_ENABLE := 0
|
||||
|
||||
ifeq ($(strip $(AUDIO_ENABLE)), yes)
|
||||
OPT_DEFS += -DAUDIO_ENABLE
|
||||
MUSIC_ENABLE := 1
|
||||
MUSIC_ENABLE = yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_clicky.c
|
||||
ifeq ($(PLATFORM),AVR)
|
||||
SRC += $(QUANTUM_DIR)/audio/audio.c
|
||||
else
|
||||
SRC += $(QUANTUM_DIR)/audio/audio_arm.c
|
||||
endif
|
||||
SRC += $(QUANTUM_DIR)/audio/audio_$(PLATFORM_KEY).c
|
||||
SRC += $(QUANTUM_DIR)/audio/voices.c
|
||||
SRC += $(QUANTUM_DIR)/audio/luts.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(MIDI_ENABLE)), yes)
|
||||
OPT_DEFS += -DMIDI_ENABLE
|
||||
MUSIC_ENABLE := 1
|
||||
MUSIC_ENABLE = yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c
|
||||
endif
|
||||
|
||||
ifeq ($(MUSIC_ENABLE), 1)
|
||||
MUSIC_ENABLE ?= no
|
||||
ifeq ($(MUSIC_ENABLE), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_music.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMBO_ENABLE)), yes)
|
||||
OPT_DEFS += -DCOMBO_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(STENO_ENABLE)), yes)
|
||||
OPT_DEFS += -DSTENO_ENABLE
|
||||
VIRTSER_ENABLE ?= yes
|
||||
@ -80,28 +70,6 @@ ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/pointing_device.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UCIS_ENABLE)), yes)
|
||||
OPT_DEFS += -DUCIS_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
|
||||
OPT_DEFS += -DUNICODEMAP_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODE_ENABLE)), yes)
|
||||
OPT_DEFS += -DUNICODE_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODE_COMMON)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
|
||||
endif
|
||||
|
||||
VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c
|
||||
EEPROM_DRIVER ?= vendor
|
||||
ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),)
|
||||
@ -249,31 +217,18 @@ ifeq ($(strip $(RGB_KEYCODES_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
|
||||
OPT_DEFS += -DTAP_DANCE_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
|
||||
OPT_DEFS += -DKEY_LOCK_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PRINTING_ENABLE)), yes)
|
||||
OPT_DEFS += -DPRINTING_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
|
||||
SRC += $(TMK_DIR)/protocol/serial_uart.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
|
||||
OPT_DEFS += -DAUTO_SHIFT_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
|
||||
ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
|
||||
OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
|
||||
SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c)
|
||||
SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
|
||||
SERIAL_DEFS += -DSERIAL_LINK_ENABLE
|
||||
COMMON_VPATH += $(SERIAL_PATH)
|
||||
|
||||
SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
|
||||
OPT_DEFS += $(SERIAL_DEFS)
|
||||
VAPTH += $(SERIAL_PATH)
|
||||
@ -315,11 +270,7 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
|
||||
else
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight_driver_common.c
|
||||
ifeq ($(strip $(BACKLIGHT_DRIVER)), pwm)
|
||||
ifeq ($(PLATFORM),AVR)
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight_avr.c
|
||||
else
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight_arm.c
|
||||
endif
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight_$(PLATFORM_KEY).c
|
||||
else
|
||||
SRC += $(QUANTUM_DIR)/backlight/backlight_$(strip $(BACKLIGHT_DRIVER)).c
|
||||
endif
|
||||
@ -376,29 +327,6 @@ ifeq ($(strip $(ENCODER_ENABLE)), yes)
|
||||
OPT_DEFS += -DENCODER_ENABLE
|
||||
endif
|
||||
|
||||
HAPTIC_ENABLE ?= no
|
||||
ifneq ($(strip $(HAPTIC_ENABLE)),no)
|
||||
COMMON_VPATH += $(DRIVER_PATH)/haptic
|
||||
SRC += haptic.c
|
||||
OPT_DEFS += -DHAPTIC_ENABLE
|
||||
endif
|
||||
|
||||
ifneq ($(filter DRV2605L, $(HAPTIC_ENABLE)), )
|
||||
SRC += DRV2605L.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
OPT_DEFS += -DDRV2605L
|
||||
endif
|
||||
|
||||
ifneq ($(filter SOLENOID, $(HAPTIC_ENABLE)), )
|
||||
SRC += solenoid.c
|
||||
OPT_DEFS += -DSOLENOID_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(HD44780_ENABLE)), yes)
|
||||
SRC += drivers/avr/hd44780.c
|
||||
OPT_DEFS += -DHD44780_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(VELOCIKEY_ENABLE)), yes)
|
||||
OPT_DEFS += -DVELOCIKEY_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/velocikey.c
|
||||
@ -417,26 +345,11 @@ ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/dynamic_keymap.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LEADER_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
|
||||
OPT_DEFS += -DLEADER_ENABLE
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/dip_switch.c
|
||||
OPT_DEFS += -DDIP_SWITCH_ENABLE
|
||||
OPT_DEFS += -DDIP_SWITCH_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/dip_switch.c
|
||||
endif
|
||||
|
||||
include $(DRIVER_PATH)/qwiic/qwiic.mk
|
||||
|
||||
QUANTUM_SRC:= \
|
||||
$(QUANTUM_DIR)/quantum.c \
|
||||
$(QUANTUM_DIR)/keymap_common.c \
|
||||
$(QUANTUM_DIR)/keycode_config.c
|
||||
|
||||
|
||||
|
||||
VALID_CUSTOM_MATRIX_TYPES:= yes lite no
|
||||
|
||||
CUSTOM_MATRIX ?= no
|
||||
@ -494,6 +407,29 @@ ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
|
||||
COMMON_VPATH += $(QUANTUM_PATH)/split_common
|
||||
endif
|
||||
|
||||
HAPTIC_ENABLE ?= no
|
||||
ifneq ($(strip $(HAPTIC_ENABLE)),no)
|
||||
COMMON_VPATH += $(DRIVER_PATH)/haptic
|
||||
SRC += haptic.c
|
||||
OPT_DEFS += -DHAPTIC_ENABLE
|
||||
endif
|
||||
|
||||
ifneq ($(filter DRV2605L, $(HAPTIC_ENABLE)), )
|
||||
SRC += DRV2605L.c
|
||||
QUANTUM_LIB_SRC += i2c_master.c
|
||||
OPT_DEFS += -DDRV2605L
|
||||
endif
|
||||
|
||||
ifneq ($(filter SOLENOID, $(HAPTIC_ENABLE)), )
|
||||
SRC += solenoid.c
|
||||
OPT_DEFS += -DSOLENOID_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(HD44780_ENABLE)), yes)
|
||||
SRC += drivers/avr/hd44780.c
|
||||
OPT_DEFS += -DHD44780_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
|
||||
OPT_DEFS += -DOLED_DRIVER_ENABLE
|
||||
COMMON_VPATH += $(DRIVER_PATH)/oled
|
||||
@ -501,10 +437,34 @@ ifeq ($(strip $(OLED_DRIVER_ENABLE)), yes)
|
||||
SRC += oled_driver.c
|
||||
endif
|
||||
|
||||
include $(DRIVER_PATH)/qwiic/qwiic.mk
|
||||
|
||||
ifeq ($(strip $(UCIS_ENABLE)), yes)
|
||||
OPT_DEFS += -DUCIS_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
|
||||
OPT_DEFS += -DUNICODEMAP_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODE_ENABLE)), yes)
|
||||
OPT_DEFS += -DUNICODE_ENABLE
|
||||
UNICODE_COMMON := yes
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(UNICODE_COMMON)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c
|
||||
endif
|
||||
|
||||
SPACE_CADET_ENABLE ?= yes
|
||||
ifeq ($(strip $(SPACE_CADET_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c
|
||||
OPT_DEFS += -DSPACE_CADET_ENABLE
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_space_cadet.c
|
||||
OPT_DEFS += -DSPACE_CADET_ENABLE
|
||||
endif
|
||||
|
||||
MAGIC_ENABLE ?= yes
|
||||
@ -523,3 +483,31 @@ ifeq ($(strip $(DYNAMIC_MACRO_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_dynamic_macro.c
|
||||
OPT_DEFS += -DDYNAMIC_MACRO_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(COMBO_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c
|
||||
OPT_DEFS += -DCOMBO_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
|
||||
OPT_DEFS += -DTAP_DANCE_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(KEY_LOCK_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_key_lock.c
|
||||
OPT_DEFS += -DKEY_LOCK_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(LEADER_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_leader.c
|
||||
OPT_DEFS += -DLEADER_ENABLE
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
|
||||
SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c
|
||||
OPT_DEFS += -DAUTO_SHIFT_ENABLE
|
||||
ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes)
|
||||
OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
|
||||
endif
|
||||
endif
|
||||
|
@ -52,7 +52,7 @@
|
||||
* Simple Keycodes
|
||||
* [Full List](keycodes.md)
|
||||
* [Basic Keycodes](keycodes_basic.md)
|
||||
* [Layer Switching](feature_advanced_keycodes.md)
|
||||
* [Modifier Keys](feature_advanced_keycodes.md)
|
||||
* [Quantum Keycodes](quantum_keycodes.md)
|
||||
|
||||
* Advanced Keycodes
|
||||
@ -71,6 +71,7 @@
|
||||
* [Combos](feature_combo.md)
|
||||
* [Debounce API](feature_debounce_type.md)
|
||||
* [Key Lock](feature_key_lock.md)
|
||||
* [Layers](feature_layers.md)
|
||||
* [One Shot Keys](one_shot_keys.md)
|
||||
* [Pointing Device](feature_pointing_device.md)
|
||||
* [Swap Hands](feature_swap_hands.md)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
QMK can leverage the Analog-to-Digital Converter (ADC) on supported MCUs to measure voltages on certain pins. This can be useful for implementing things such as battery level indicators for Bluetooth keyboards, or volume controls using a potentiometer, as opposed to a [rotary encoder](feature_encoders.md).
|
||||
|
||||
This driver currently supports both AVR and a limited selection of ARM devices. On AVR devices, the values returned are 10-bit integers (0-1023) mapped between 0V and VCC (usually 5V or 3.3V). On supported ARM devices, there is more flexibility in control of operation through `#define`s, but by default the values returned are 12-bit integers (0-4095) mapped between 0V and VCC (usually 3.3V).
|
||||
This driver currently supports both AVR and a limited selection of ARM devices. The values returned are 10-bit integers (0-1023) mapped between 0V and VCC (usually 5V or 3.3V for AVR, 3.3V only for ARM), however on ARM there is more flexibility in control of operation through `#define`s if you need more precision.
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -1,46 +1,3 @@
|
||||
# Switching and Toggling Layers :id=switching-and-toggling-layers
|
||||
|
||||
These functions allow you to activate layers in various ways. Note that layers are not generally independent layouts -- multiple layers can be activated at once, and it's typical for layers to use `KC_TRNS` to allow keypresses to pass through to lower layers. For a detailed explanation of layers, see [Keymap Overview](keymap.md#keymap-and-layers). When using momentary layer switching with MO(), LM(), TT(), or LT(), make sure to leave the key on the above layers transparent or it may not work as intended.
|
||||
|
||||
* `DF(layer)` - switches the default layer. The default layer is the always-active base layer that other layers stack on top of. See below for more about the default layer. This might be used to switch from QWERTY to Dvorak layout. (Note that this is a temporary switch that only persists until the keyboard loses power. To modify the default layer in a persistent way requires deeper customization, such as calling the `set_single_persistent_default_layer` function inside of [process_record_user](custom_quantum_functions.md#programming-the-behavior-of-any-keycode).)
|
||||
* `MO(layer)` - momentarily activates *layer*. As soon as you let go of the key, the layer is deactivated.
|
||||
* `LM(layer, mod)` - Momentarily activates *layer* (like `MO`), but with modifier(s) *mod* active. Only supports layers 0-15 and the left modifiers: `MOD_LCTL`, `MOD_LSFT`, `MOD_LALT`, `MOD_LGUI` (note the use of `MOD_` constants instead of `KC_`). These modifiers can be combined using bitwise OR, e.g. `LM(_RAISE, MOD_LCTL | MOD_LALT)`.
|
||||
* `LT(layer, kc)` - momentarily activates *layer* when held, and sends *kc* when tapped. Only supports layers 0-15.
|
||||
* `OSL(layer)` - momentarily activates *layer* until the next key is pressed. See [One Shot Keys](one_shot_keys.md) for details and additional functionality.
|
||||
* `TG(layer)` - toggles *layer*, activating it if it's inactive and vice versa
|
||||
* `TO(layer)` - activates *layer* and de-activates all other layers (except your default layer). This function is special, because instead of just adding/removing one layer to your active layer stack, it will completely replace your current active layers, uniquely allowing you to replace higher layers with a lower one. This is activated on keydown (as soon as the key is pressed).
|
||||
* `TT(layer)` - Layer Tap-Toggle. If you hold the key down, *layer* is activated, and then is de-activated when you let go (like `MO`). If you repeatedly tap it, the layer will be toggled on or off (like `TG`). It needs 5 taps by default, but you can change this by defining `TAPPING_TOGGLE` -- for example, `#define TAPPING_TOGGLE 2` to toggle on just two taps.
|
||||
|
||||
## Caveats
|
||||
|
||||
Currently, `LT()` and `MT()` are limited to the [Basic Keycode set](keycodes_basic.md), meaning you can't use keycodes like `LCTL()`, `KC_TILD`, or anything greater than `0xFF`. Modifiers specified as part of a Layer Tap or Mod Tap's keycode will be ignored. If you need to apply modifiers to your tapped keycode, [Tap Dance](feature_tap_dance.md#example-5-using-tap-dance-for-advanced-mod-tap-and-layer-tap-keys) can be used to accomplish this.
|
||||
|
||||
Additionally, if at least one right-handed modifier is specified in a Mod Tap or Layer Tap, it will cause all modifiers specified to become right-handed, so it is not possible to mix and match the two.
|
||||
|
||||
# Working with Layers
|
||||
|
||||
Care must be taken when switching layers, it's possible to lock yourself into a layer with no way to deactivate that layer (without unplugging your keyboard.) We've created some guidelines to help users avoid the most common problems.
|
||||
|
||||
## Beginners
|
||||
|
||||
If you are just getting started with QMK you will want to keep everything simple. Follow these guidelines when setting up your layers:
|
||||
|
||||
* Setup layer 0 as your default, "base" layer. This is your normal typing layer, and could be whatever layout you want (qwerty, dvorak, colemak, etc.). It's important to set this as the lowest layer since it will typically have most or all of the keyboard's keys defined, so would block other layers from having any effect if it were above them (i.e., had a higher layer number).
|
||||
* Arrange your layers in a "tree" layout, with layer 0 as the root. Do not try to enter the same layer from more than one other layer.
|
||||
* In a layer's keymap, only reference higher-numbered layers. Because layers are processed from the highest-numbered (topmost) active layer down, modifying the state of lower layers can be tricky and error-prone.
|
||||
|
||||
## Intermediate Users
|
||||
|
||||
Sometimes you need more than one base layer. For example, if you want to switch between QWERTY and Dvorak, switch between layouts for different countries, or switch your layout for different videogames. Your base layers should always be the lowest numbered layers. When you have multiple base layers you should always treat them as mutually exclusive. When one base layer is on the others are off.
|
||||
|
||||
## Advanced Users
|
||||
|
||||
Once you have a good feel for how layers work and what you can do, you can get more creative. The rules listed in the beginner section will help you be successful by avoiding some of the tricker details but they can be constraining, especially for ultra-compact keyboard users. Understanding how layers work will allow you to use them in more advanced ways.
|
||||
|
||||
Layers stack on top of each other in numerical order. When determining what a keypress does, QMK scans the layers from the top down, stopping when it reaches the first active layer that is not set to `KC_TRNS`. As a result if you activate a layer that is numerically lower than your current layer, and your current layer (or another layer that is active and higher than your target layer) has something other than `KC_TRNS`, that is the key that will be sent, not the key on the layer you just activated. This is the cause of most people's "why doesn't my layer get switched" problem.
|
||||
|
||||
Sometimes, you might want to switch between layers in a macro or as part of a tap dance routine. `layer_on` activates a layer, and `layer_off` deactivates it. More layer-related functions can be found in [action_layer.h](https://github.com/qmk/qmk_firmware/blob/master/tmk_core/common/action_layer.h).
|
||||
|
||||
# Modifier Keys :id=modifier-keys
|
||||
|
||||
These allow you to combine a modifier with a keycode. When pressed, the keydown event for the modifier, then `kc` will be sent. On release, the keyup event for `kc`, then the modifier will be sent.
|
||||
@ -63,10 +20,14 @@ These allow you to combine a modifier with a keycode. When pressed, the keydown
|
||||
|
||||
You can also chain them, for example `LCTL(LALT(KC_DEL))` makes a key that sends Control+Alt+Delete with a single keypress.
|
||||
|
||||
# Legacy Content
|
||||
# Legacy Content :id=legacy-content
|
||||
|
||||
This page used to encompass a large set of features. We have moved many sections that used to be part of this page to their own pages. Everything below this point is simply a redirect so that people following old links on the web find what they're looking for.
|
||||
|
||||
## Layers :id=switching-and-toggling-layers
|
||||
|
||||
* [Layers](feature_layers.md)
|
||||
|
||||
## Mod-Tap :id=mod-tap
|
||||
|
||||
* [Mod-Tap](mod_tap.md)
|
||||
|
@ -123,7 +123,7 @@ If you would like to change the hotkey assignments for Bootmagic, `#define` thes
|
||||
|
||||
# Bootmagic Lite :id=bootmagic-lite
|
||||
|
||||
In addition to the full blown Bootmagic feature, is the Bootmagic Lite feature that only handles jumping into the bootloader. This is great for boards that don't have a physical reset button but you need a way to jump into the bootloader, and don't want to deal with the headache that Bootmagic can cause.
|
||||
In addition to the full blown Bootmagic feature, is the Bootmagic Lite feature that only handles jumping into the bootloader. This is great for boards that don't have a physical reset button but you need a way to jump into the bootloader, and don't want to deal with the headache that Bootmagic can cause.
|
||||
|
||||
To enable this version of Bootmagic, you need to enable it in your `rules.mk` with:
|
||||
|
||||
@ -131,7 +131,7 @@ To enable this version of Bootmagic, you need to enable it in your `rules.mk` wi
|
||||
BOOTMAGIC_ENABLE = lite
|
||||
```
|
||||
|
||||
Additionally, you may want to specify which key to use. This is especially useful for keyboards that have unusual matrices. To do so, you need to specify the row and column of the key that you want to use. Add these entries to your `config.h` file:
|
||||
Additionally, you may want to specify which key to use. This is especially useful for keyboards that have unusual matrices. To do so, you need to specify the row and column of the key that you want to use. Add these entries to your `config.h` file:
|
||||
|
||||
```c
|
||||
#define BOOTMAGIC_LITE_ROW 0
|
||||
@ -144,9 +144,20 @@ And to trigger the bootloader, you hold this key down when plugging the keyboard
|
||||
|
||||
!> Using bootmagic lite will **always reset** the EEPROM, so you will lose any settings that have been saved.
|
||||
|
||||
## Split Keyboards
|
||||
|
||||
When handedness is predetermined via an option like `SPLIT_HAND_PIN`, you might need to configure a different key between halves. This To do so, add these entries to your `config.h` file:
|
||||
|
||||
```c
|
||||
#define BOOTMAGIC_LITE_ROW_RIGHT 4
|
||||
#define BOOTMAGIC_LITE_COLUMN_RIGHT 1
|
||||
```
|
||||
|
||||
By default, these values are not set.
|
||||
|
||||
## Advanced Bootmagic Lite
|
||||
|
||||
The `bootmagic_lite` function is defined weakly, so that you can replace this in your code, if you need. A great example of this is the Zeal60 boards that have some additional handling needed.
|
||||
The `bootmagic_lite` function is defined weakly, so that you can replace this in your code, if you need. A great example of this is the Zeal60 boards that have some additional handling needed.
|
||||
|
||||
To replace the function, all you need to do is add something like this to your code:
|
||||
|
||||
@ -163,4 +174,4 @@ void bootmagic_lite(void) {
|
||||
}
|
||||
```
|
||||
|
||||
You can additional feature here. For instance, resetting the eeprom or requiring additional keys to be pressed to trigger bootmagic. Keep in mind that `bootmagic_lite` is called before a majority of features are initialized in the firmware.
|
||||
You can additional feature here. For instance, resetting the eeprom or requiring additional keys to be pressed to trigger bootmagic. Keep in mind that `bootmagic_lite` is called before a majority of features are initialized in the firmware.
|
||||
|
94
docs/feature_layers.md
Normal file
94
docs/feature_layers.md
Normal file
@ -0,0 +1,94 @@
|
||||
# Layers :id=layers
|
||||
|
||||
One of the most powerful and well used features of QMK Firmware is the ability to use layers. For most people, this amounts to a function key that allows for different keys, much like what you would see on a laptop or tablet keyboard.
|
||||
|
||||
For a detailed explanation of how the layer stack works, checkout [Keymap Overview](keymap.md#keymap-and-layers).
|
||||
|
||||
## Switching and Toggling Layers :id=switching-and-toggling-layers
|
||||
|
||||
These functions allow you to activate layers in various ways. Note that layers are not generally independent layouts -- multiple layers can be activated at once, and it's typical for layers to use `KC_TRNS` to allow keypresses to pass through to lower layers. When using momentary layer switching with MO(), LM(), TT(), or LT(), make sure to leave the key on the above layers transparent or it may not work as intended.
|
||||
|
||||
* `DF(layer)` - switches the default layer. The default layer is the always-active base layer that other layers stack on top of. See below for more about the default layer. This might be used to switch from QWERTY to Dvorak layout. (Note that this is a temporary switch that only persists until the keyboard loses power. To modify the default layer in a persistent way requires deeper customization, such as calling the `set_single_persistent_default_layer` function inside of [process_record_user](custom_quantum_functions.md#programming-the-behavior-of-any-keycode).)
|
||||
* `MO(layer)` - momentarily activates *layer*. As soon as you let go of the key, the layer is deactivated.
|
||||
* `LM(layer, mod)` - Momentarily activates *layer* (like `MO`), but with modifier(s) *mod* active. Only supports layers 0-15 and the left modifiers: `MOD_LCTL`, `MOD_LSFT`, `MOD_LALT`, `MOD_LGUI` (note the use of `MOD_` constants instead of `KC_`). These modifiers can be combined using bitwise OR, e.g. `LM(_RAISE, MOD_LCTL | MOD_LALT)`.
|
||||
* `LT(layer, kc)` - momentarily activates *layer* when held, and sends *kc* when tapped. Only supports layers 0-15.
|
||||
* `OSL(layer)` - momentarily activates *layer* until the next key is pressed. See [One Shot Keys](one_shot_keys.md) for details and additional functionality.
|
||||
* `TG(layer)` - toggles *layer*, activating it if it's inactive and vice versa
|
||||
* `TO(layer)` - activates *layer* and de-activates all other layers (except your default layer). This function is special, because instead of just adding/removing one layer to your active layer stack, it will completely replace your current active layers, uniquely allowing you to replace higher layers with a lower one. This is activated on keydown (as soon as the key is pressed).
|
||||
* `TT(layer)` - Layer Tap-Toggle. If you hold the key down, *layer* is activated, and then is de-activated when you let go (like `MO`). If you repeatedly tap it, the layer will be toggled on or off (like `TG`). It needs 5 taps by default, but you can change this by defining `TAPPING_TOGGLE` -- for example, `#define TAPPING_TOGGLE 2` to toggle on just two taps.
|
||||
|
||||
### Caveats :id=caveats
|
||||
|
||||
Currently, `LT()` and `MT()` are limited to the [Basic Keycode set](keycodes_basic.md), meaning you can't use keycodes like `LCTL()`, `KC_TILD`, or anything greater than `0xFF`. Specifically, dual function keys like `LT` and `MT` use a 16 bit keycode. 4 bits are used for the function identifier, the next 12 are divided into the parameters. Layer Tap uses 4 bits for the layer (and is why it's limited to layers 0-16, actually), while Mod Tap does the same, 4 bits for the identifier, 4 bits for which mods are used, and all of them use 8 bits for the keycode. Because of this, the keycode used is limited to `0xFF` (0-255), which are the basic keycodes only.
|
||||
|
||||
Expanding this would be complicated, at best. Moving to a 32-bit keycode would solve a lot of this, but would double the amount of space that the keymap matrix uses. And it could potentially cause issues, too. If you need to apply modifiers to your tapped keycode, [Tap Dance](feature_tap_dance.md#example-5-using-tap-dance-for-advanced-mod-tap-and-layer-tap-keys) can be used to accomplish this.
|
||||
|
||||
Additionally, if at least one right-handed modifier is specified in a Mod Tap or Layer Tap, it will cause all modifiers specified to become right-handed, so it is not possible to mix and match the two.
|
||||
|
||||
## Working with Layers :id=working-with-layers
|
||||
|
||||
Care must be taken when switching layers, it's possible to lock yourself into a layer with no way to deactivate that layer (without unplugging your keyboard.) We've created some guidelines to help users avoid the most common problems.
|
||||
|
||||
### Beginners :id=beginners
|
||||
|
||||
If you are just getting started with QMK you will want to keep everything simple. Follow these guidelines when setting up your layers:
|
||||
|
||||
* Setup layer 0 as your default, "base" layer. This is your normal typing layer, and could be whatever layout you want (qwerty, dvorak, colemak, etc.). It's important to set this as the lowest layer since it will typically have most or all of the keyboard's keys defined, so would block other layers from having any effect if it were above them (i.e., had a higher layer number).
|
||||
* Arrange your layers in a "tree" layout, with layer 0 as the root. Do not try to enter the same layer from more than one other layer.
|
||||
* In a layer's keymap, only reference higher-numbered layers. Because layers are processed from the highest-numbered (topmost) active layer down, modifying the state of lower layers can be tricky and error-prone.
|
||||
|
||||
### Intermediate Users :id=intermediate-users
|
||||
|
||||
Sometimes you need more than one base layer. For example, if you want to switch between QWERTY and Dvorak, switch between layouts for different countries, or switch your layout for different videogames. Your base layers should always be the lowest numbered layers. When you have multiple base layers you should always treat them as mutually exclusive. When one base layer is on the others are off.
|
||||
|
||||
### Advanced Users :id=advanced-users
|
||||
|
||||
Once you have a good feel for how layers work and what you can do, you can get more creative. The rules listed in the beginner section will help you be successful by avoiding some of the tricker details but they can be constraining, especially for ultra-compact keyboard users. Understanding how layers work will allow you to use them in more advanced ways.
|
||||
|
||||
Layers stack on top of each other in numerical order. When determining what a keypress does, QMK scans the layers from the top down, stopping when it reaches the first active layer that is not set to `KC_TRNS`. As a result if you activate a layer that is numerically lower than your current layer, and your current layer (or another layer that is active and higher than your target layer) has something other than `KC_TRNS`, that is the key that will be sent, not the key on the layer you just activated. This is the cause of most people's "why doesn't my layer get switched" problem.
|
||||
|
||||
Sometimes, you might want to switch between layers in a macro or as part of a tap dance routine. `layer_on` activates a layer, and `layer_off` deactivates it. More layer-related functions can be found in [action_layer.h](https://github.com/qmk/qmk_firmware/blob/master/tmk_core/common/action_layer.h).
|
||||
|
||||
## Functions :id=functions
|
||||
|
||||
There are a number of functions (and variables) related to how you can use or manipulate the layers.
|
||||
|
||||
|Function |Description |
|
||||
|----------------------------------------------|---------------------------------------------------------------------------------------------------------|
|
||||
| `layer_state_set(layer_mask)` | Directly sets the layer state (recommended, do not use unless you know what you are doing). |
|
||||
| `layer_clear()` | Clears all layers (turns them all off). |
|
||||
| `layer_move(layer)` | Turns specified layer on, and all other layers off. |
|
||||
| `layer_on(layer)` | Turns specified layer on, leaves all other layers in existing state. |
|
||||
| `layer_off(layer)` | Turns specified layer off, leaves all other layers in existing state. |
|
||||
| `layer_invert(layer)` | Interverts/toggles the state of the specified layer |
|
||||
| `layer_or(layer_mask)` | Turns on layers based on matching bits between specifed layer and existing layer state. |
|
||||
| `layer_and(layer_mask)` | Turns on layers based on matching enabled bits between specifed layer and existing layer state. |
|
||||
| `layer_xor(layer_mask)` | Turns on layers based on non-matching bits between specifed layer and existing layer state. |
|
||||
| `layer_debug(layer_mask)` | Prints out the current bit mask and highest active layer to debugger console. |
|
||||
| `default_layer_set(layer_mask)` | Directly sets the default layer state (recommended, do not use unless you know what you are doing). |
|
||||
| `default_layer_or(layer_mask)` | Turns on layers based on matching bits between specifed layer and existing default layer state. |
|
||||
| `default_layer_and(layer_mask)` | Turns on layers based on matching enabled bits between specifed layer and existing default layer state. |
|
||||
| `default_layer_xor(layer_mask)` | Turns on layers based on non-matching bits between specifed layer and existing default layer state. |
|
||||
| `default_layer_debug(layer_mask)` | Prints out the current bit mask and highest active default layer to debugger console. |
|
||||
| [`set_single_persistent_default_layer(layer)`](ref_functions.md#setting-the-persistent-default-layer) | Sets the default layer and writes it to persistent memory (EEPROM). |
|
||||
| [`update_tri_layer(x, y, z)`](ref_functions.md#update_tri_layerx-y-z) | Checks if layers `x` and `y` are both on, and sets `z` based on that (on if both on, otherwise off). |
|
||||
| [`update_tri_layer_state(state, x, y, z)`](ref_functions.md#update_tri_layer_statestate-x-y-z) | Does the same as `update_tri_layer(x, y, z)`, but from `layer_state_set_*` functions. |
|
||||
|
||||
|
||||
In additional to the functions that you can call, there are a number of callback functions that get called every time the layer changes. This passed the layer state to the function, which can be read or modified.
|
||||
|
||||
|Callbacks |Description |
|
||||
|-----------------------------------------------------|----------------------------------------------------------------------------------------|
|
||||
| `layer_state_set_kb(layer_state_t state)` | Callback for layer functions, for keyboard. |
|
||||
| `layer_state_set_user(layer_state_t state)` | Callback for layer functions, for users. |
|
||||
| `default_layer_state_set_kb(layer_state_t state)` | Callback for default layer functions, for keyboard. Called on keyboard initialization. |
|
||||
| `default_layer_state_set_user(layer_state_t state)` | Callback for default layer functions, for users. Called on keyboard initialization. |
|
||||
|
||||
?> For additional details on how you can use these callbacks, check out the [Layer Change Code](custom_quantum_functions.md#layer-change-code) document.
|
||||
|
||||
|Check functions |Description |
|
||||
|-------------------------------------------|------------------------------------------------------------------------------|
|
||||
| `layer_state_cmp(cmp_layer_state, layer)` | This checks the `cmp_layer_state` to see if the specific `layer` is enabled. This is meant for use with the layer callbacks. |
|
||||
| `layer_state_is(layer)` | This checks the layer state to see if the specific `layer` is enabled. (calls `layer_state_cmp` for the global layer state). |
|
||||
|
||||
!> There is `IS_LAYER_ON(layer)` as well, however the `layer_state_cmp` function has some additional handling to ensure that on layer 0 that it returns the correct value. Otherwise, if you check to see if layer 0 is on, you may get an incorrect value returned.
|
@ -74,9 +74,9 @@ SEQ_THREE_KEYS(KC_C, KC_C, KC_C) {
|
||||
|
||||
## Strict Key Processing
|
||||
|
||||
By default, the Leader Key feature will filter the keycode out of [`Mod-Tap`](mod_tap.md) and [`Layer Tap`](feature_advanced_keycodes.md#switching-and-toggling-layers) functions when checking for the Leader sequences. That means if you're using `LT(3, KC_A)`, it will pick this up as `KC_A` for the sequence, rather than `LT(3, KC_A)`, giving a more expected behavior for newer users.
|
||||
By default, the Leader Key feature will filter the keycode out of [`Mod-Tap`](mod_tap.md) and [`Layer Tap`](feature_layers.md#switching-and-toggling-layers) functions when checking for the Leader sequences. That means if you're using `LT(3, KC_A)`, it will pick this up as `KC_A` for the sequence, rather than `LT(3, KC_A)`, giving a more expected behavior for newer users.
|
||||
|
||||
While, this may be fine for most, if you want to specify the whole keycode (eg, `LT(3, KC_A)` from the example above) in the sequence, you can enable this by added `#define LEADER_KEY_STRICT_KEY_PROCESSING` to your `config.h` file. This well then disable the filtering, and you'll need to specify the whole keycode.
|
||||
While, this may be fine for most, if you want to specify the whole keycode (eg, `LT(3, KC_A)` from the example above) in the sequence, you can enable this by added `#define LEADER_KEY_STRICT_KEY_PROCESSING` to your `config.h` file. This will then disable the filtering, and you'll need to specify the whole keycode.
|
||||
|
||||
## Customization
|
||||
|
||||
|
@ -175,23 +175,23 @@ const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64};
|
||||
## Lighting Layers
|
||||
|
||||
By including `#define RGBLIGHT_LAYERS` in your `config.h` file you can enable lighting layers. These make
|
||||
it easy to use your underglow LEDs as status indicators to show which keyboard layer is currently active, or the state of caps lock, all without disrupting any animations. [Here's a video](https://youtu.be/uLGE1epbmdY) showing an example of what you can do.
|
||||
it easy to use your underglow LEDs as status indicators to show which keyboard layer is currently active, or the state of caps lock, all without disrupting any animations. [Here's a video](https://youtu.be/uLGE1epbmdY) showing an example of what you can do.
|
||||
|
||||
To define a layer, we modify `keymap.c` to list out LED ranges and the colors we want to overlay on them using an array of `rgblight_segment_t` using the `RGBLIGHT_LAYER_SEGMENTS` macro. We can define multiple layers and enable/disable them independently:
|
||||
|
||||
```c
|
||||
// Light LEDs 6 to 9 and 12 to 15 red when caps lock is active. Hard to ignore!
|
||||
const rgblight_segment_t PROGMEM my_capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
||||
{6, 4, HSV_RED}, // Light 4 LEDs, starting with LED 6
|
||||
{12, 4, HSV_RED} // Light 4 LEDs, starting with LED 12
|
||||
{6, 4, HSV_RED}, // Light 4 LEDs, starting with LED 6
|
||||
{12, 4, HSV_RED} // Light 4 LEDs, starting with LED 12
|
||||
);
|
||||
// Light LEDs 9 & 10 in cyan when keyboard layer 1 is active
|
||||
const rgblight_segment_t PROGMEM my_layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
||||
{9, 2, HSV_CYAN}
|
||||
{9, 2, HSV_CYAN}
|
||||
);
|
||||
// Light LEDs 11 & 12 in purple when keyboard layer 2 is active
|
||||
const rgblight_segment_t PROGMEM my_layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
||||
{11, 2, HSV_PURPLE},
|
||||
{11, 2, HSV_PURPLE}
|
||||
);
|
||||
// etc..
|
||||
```
|
||||
@ -201,14 +201,14 @@ We combine these layers into an array using the `RGBLIGHT_LAYERS_LIST` macro, an
|
||||
```c
|
||||
// Now define the array of layers. Later layers take precedence
|
||||
const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
|
||||
my_capslock_layer,
|
||||
my_layer1_layer, // Overrides caps lock layer
|
||||
my_layer2_layer // Overrides other layers
|
||||
my_capslock_layer,
|
||||
my_layer1_layer, // Overrides caps lock layer
|
||||
my_layer2_layer // Overrides other layers
|
||||
);
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
// Enable the LED layers
|
||||
rgblight_layers = my_rgb_layers;
|
||||
// Enable the LED layers
|
||||
rgblight_layers = my_rgb_layers;
|
||||
}
|
||||
```
|
||||
|
||||
@ -216,18 +216,20 @@ Finally, we enable and disable the lighting layers whenever the state of the key
|
||||
|
||||
```c
|
||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
// Both layers will light up if both kb layers are active
|
||||
rgblight_set_layer_state(1, layer_state_cmp(state, 1));
|
||||
rgblight_set_layer_state(2, layer_state_cmp(state, 2));
|
||||
return state;
|
||||
// Both layers will light up if both kb layers are active
|
||||
rgblight_set_layer_state(1, layer_state_cmp(state, 1));
|
||||
rgblight_set_layer_state(2, layer_state_cmp(state, 2));
|
||||
return state;
|
||||
}
|
||||
|
||||
bool led_update_user(led_t led_state) {
|
||||
rgblight_set_layer_state(0, led_state.caps_lock);
|
||||
return true;
|
||||
rgblight_set_layer_state(0, led_state.caps_lock);
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
Note: For split keyboards with two controllers, both sides need to be flashed when updating the contents of rgblight_layers.
|
||||
|
||||
## Functions
|
||||
|
||||
If you need to change your RGB lighting in code, for example in a macro to change the color whenever you switch layers, QMK provides a set of functions to assist you. See [`rgblight.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight.h) for the full list, but the most commonly used functions include:
|
||||
|
@ -78,7 +78,7 @@
|
||||
* [キーロック](ja/feature_key_lock.md)
|
||||
* [レイアウト](ja/feature_layouts.md)
|
||||
* [リーダー キー](ja/feature_leader_key.md)
|
||||
* [LED マトリクス](ja/feature_led_matrix.md)
|
||||
* [LED マトリックス](ja/feature_led_matrix.md)
|
||||
* [マクロ](ja/feature_macros.md)
|
||||
* [マウスキー](ja/feature_mouse_keys.md)
|
||||
* [OLED ドライバ](ja/feature_oled_driver.md)
|
||||
@ -86,7 +86,7 @@
|
||||
* [ポインティング デバイス](ja/feature_pointing_device.md)
|
||||
* [PS/2 マウス](ja/feature_ps2_mouse.md)
|
||||
* [RGB ライト](ja/feature_rgblight.md)
|
||||
* [RGB マトリクス](ja/feature_rgb_matrix.md)
|
||||
* [RGB マトリックス](ja/feature_rgb_matrix.md)
|
||||
* [Space Cadet](ja/feature_space_cadet.md)
|
||||
* [分割キーボード](ja/feature_split_keyboard.md)
|
||||
* [Stenography](ja/feature_stenography.md)
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Eclipse を使った ARM デバッグ
|
||||
|
||||
<!---
|
||||
original document: eae21eed7:docs/arm_debugging.md
|
||||
git diff eae21eed7 HEAD -- docs/arm_debugging.md | cat
|
||||
original document: 0.8.58:docs/arm_debugging.md
|
||||
git diff 0.8.58 HEAD -- docs/arm_debugging.md | cat
|
||||
-->
|
||||
|
||||
このページでは、SWD アダプタとオープンソース/フリーツールを使って ARM MCU をデバッグするためのセットアップ方法について説明します。このガイドでは、GNU MCU Eclipse IDE for C/C++ Developers および OpenOCD を必要な依存関係と一緒にインストールします。
|
||||
@ -60,7 +60,7 @@ Java は Eclipse で必要とされるため、[ここ](https://www.oracle.com/t
|
||||
|
||||
Eclipse に QMK をビルドしようとするデバイスを教える必要があります。QMK フォルダを右クリック -> Properties -> C/C++ Build -> Settings を選択します。Devices タブを選択し、Devices の下から MCU の適切な種類を選択します。私の例では、STM32F303CC です。
|
||||
|
||||
この間に、Build コマンドもセットアップしましょう。C/C++ Build を選択し、Behavior タブを選択します。build コマンドのところで、`all` を必要な make コマンドに置き換えます。例えば、rev6 Planck の default キーマップの場合、これは `planck/rev6:default` になります。Apply and Close を選択します。
|
||||
この間に、Build コマンドもセットアップしましょう。C/C++ Build を選択し、Behavior タブを選択します。Build コマンドのところで、`all` を必要な make コマンドに置き換えます。例えば、rev6 Planck の default キーマップの場合、これは `planck/rev6:default` になります。Apply and Close を選択します。
|
||||
|
||||
## ビルド
|
||||
|
||||
@ -70,13 +70,13 @@ Eclipse に QMK をビルドしようとするデバイスを教える必要が
|
||||
|
||||
### デバッガの接続
|
||||
|
||||
ARM MCU は、クロック信号(SWCLK) とデータ信号(SWDIO) で構成される Single Wire Debug (SWD) プロトコルを使います。MCU を 完全に操作するには、この2本のワイヤとグラウンドを接続するだけで十分です。ここでは、キーボードは USB を介して電力が供給されると想定しています。手動でリセットボタンを使えるため、RESET 信号は必要ありません。より高度なセットアップのために printf と scanf をホストに非同期にパイプする SWO 信号を使用できますが、私たちのセットアップでは無視します。
|
||||
ARM MCU は、クロック信号(SWCLK) とデータ信号(SWDIO) で構成される Single Wire Debug (SWD) プロトコルを使います。MCU を完全に操作するには、この2本のワイヤとグラウンドを接続するだけで十分です。ここでは、キーボードは USB を介して電力が供給されると想定しています。手動でリセットボタンを使えるため、RESET 信号は必要ありません。より高度なセットアップのために printf と scanf をホストに非同期にパイプする SWO 信号を使用できますが、私たちのセットアップでは無視します。
|
||||
|
||||
注意: SWCLK と SWDIO ピンがキーボードのマトリックスで使われていないことを確認してください。もし使われている場合は、一時的に他のピンに切り替えることができます。
|
||||
|
||||
### デバッガの設定
|
||||
|
||||
QMK フォルダを右クリックし、Debug As -> Debug Configurations... を選択します。ここで、GDB OpenOCD Debugging をダブルクリックします。Debugger タブを選択し、MCU に必要な設定を入力します。これを見つけるにはいじったりググったりする必要があるかもしれません。STM32F3 用のデフォルトスクリプトは stm32f3discovery.cfg と呼ばれます。OpenOCD に伝えるには、Config options で `-f board/stm32f3discovery.cfg` と入力します。
|
||||
QMK フォルダを右クリックし、Debug As -> Debug Configurations... を選択します。ここで、GDB OpenOCD Debugging をダブルクリックします。Debugger タブを選択し、MCU に必要な設定を入力します。これを見つけるにはいじったりググったりする必要があるかもしれません。STM32F3 用のデフォルトスクリプトは `stm32f3discovery.cfg` と呼ばれます。OpenOCD に伝えるには、Config options で `-f board/stm32f3discovery.cfg` と入力します。
|
||||
|
||||
注意: 私の場合、この設定スクリプトはリセット操作を無効にするために編集が必要です。スクリプトの場所は、通常はパス `openocd/version/.content/scripts/board` の下の実際の実行可能フィールドの中で見つかります。ここで、私は `reset_config srst_only` を `reset_config none` に編集しました。
|
||||
|
||||
@ -86,7 +86,7 @@ Apply and Close を選択します。
|
||||
|
||||
キーボードをリセットしてください。
|
||||
|
||||
虫アイコンをクリックし、もし全てうまく行けば Debug パースペクティブに移動します。ここでは、main 関数の最初でプログラムカウンタが停止するので、Play ボタンを押します。全てのデバッガのほとんどの機能は ARM MCU で動作しますが、正確な詳細については google があなたのお友達です!
|
||||
虫アイコンをクリックし、もし全てうまく行けば Debug パースペクティブに移動します。ここでは、main 関数の最初でプログラムカウンタが停止し、Play ボタンが押されるのを待ちます。全てのデバッガのほとんどの機能は Arm MCU で動作しますが、正確な詳細については Google があなたのお友達です!
|
||||
|
||||
|
||||
ハッピーデバッギング!
|
||||
|
114
docs/ja/custom_matrix.md
Normal file
114
docs/ja/custom_matrix.md
Normal file
@ -0,0 +1,114 @@
|
||||
# カスタムマトリックス
|
||||
|
||||
<!---
|
||||
grep --no-filename "^[ ]*git diff" docs/ja/*.md | sh
|
||||
original document: 0.8.46:docs/custom_matrix.md
|
||||
git diff 0.8.46 HEAD -- docs/custom_matrix.md | cat
|
||||
-->
|
||||
|
||||
QMKは、デフォルトのマトリックススキャンルーチンを独自のコードで部分的に入れ替えたり全部入れ替えたりしたりするメカニズムを提供します。
|
||||
|
||||
この機能を使用する理由は次のとおりです:
|
||||
|
||||
* キーボードのスイッチと MCU ピンの間に追加のハードウェアがある場合
|
||||
* I/O マルチプレクサ
|
||||
* ラインデコーダー
|
||||
* 一般的ではないキースイッチマトリックス
|
||||
* `COL2ROW` と `ROW2COL` の同時使用
|
||||
|
||||
## 前提条件
|
||||
|
||||
カスタムマトリックスの実装には、通常、追加のソースファイルのコンパイルが含まれます。
|
||||
一貫性を保つために、このソースファイルのファイル名は `matrix.c` とすることをお勧めします。
|
||||
|
||||
あなたのキーボードディレクトリに新しいファイルを追加します:
|
||||
```text
|
||||
keyboards/<keyboard>/matrix.c
|
||||
```
|
||||
|
||||
そして、新しいファイルのコンパイルを指定するため、以下を `rules.mk` に追加します
|
||||
```make
|
||||
SRC += matrix.c
|
||||
```
|
||||
|
||||
## マトリックスコードの部分置き換え
|
||||
|
||||
カスタムマトリックスを実装する際、定型コードを書かなくてすむように、さまざまなスキャン関数のデフォルト実装を提供しています。
|
||||
|
||||
設定するには、以下を `rules.mk` に追加します:
|
||||
```make
|
||||
CUSTOM_MATRIX = lite
|
||||
```
|
||||
|
||||
そして、キーボードディレクトリの `matrix.c` ファイルに次の関数を実装します。
|
||||
|
||||
```c
|
||||
void matrix_init_custom(void) {
|
||||
// TODO: ここでハードウェアの初期化をする
|
||||
}
|
||||
|
||||
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
||||
bool matrix_has_changed = false;
|
||||
|
||||
// TODO: ここで、マトリックススキャンを行なう
|
||||
|
||||
return matrix_has_changed;
|
||||
}
|
||||
```
|
||||
|
||||
## マトリックスコードの全面置き換え
|
||||
|
||||
スキャンルーチンをさらに変更する必要がある場合は、完全なスキャンルーチンを実装することを選択できます。
|
||||
|
||||
設定するには、以下を `rules.mk` に追加します:
|
||||
```make
|
||||
CUSTOM_MATRIX = yes
|
||||
```
|
||||
|
||||
そして、キーボードディレクトリの `matrix.c` ファイルに次の関数を実装します。
|
||||
|
||||
```c
|
||||
matrix_row_t matrix_get_row(uint8_t row) {
|
||||
// TODO: 要求された行データを返します
|
||||
}
|
||||
|
||||
void matrix_print(void) {
|
||||
// TODO: printf() を使って現在のマトリックスの状態をコンソールにダンプします
|
||||
}
|
||||
|
||||
void matrix_init(void) {
|
||||
// TODO: ここでハードウェアとグローバルマトリックスの状態を初期化します
|
||||
|
||||
// ハードウェアによるデバウンスがない場合 - 設定されているデバウンスルーチンを初期化します
|
||||
debounce_init(MATRIX_ROWS);
|
||||
|
||||
// 正しいキーボード動作のためにこれを呼び出す*必要があります*
|
||||
matrix_init_quantum();
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void) {
|
||||
bool matrix_has_changed = false;
|
||||
|
||||
// TODO: ここにマトリックススキャンルーチンを追加します
|
||||
|
||||
// ハードウェアによるデバウンスがない場合 - 設定されているデバウンスルーチンを使用します
|
||||
debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
|
||||
|
||||
// 正しいキーボード動作のためにこれを呼び出す*必要があります*
|
||||
matrix_scan_quantum();
|
||||
|
||||
return matrix_has_changed;
|
||||
}
|
||||
```
|
||||
|
||||
また、次のコールバックのデフォルトも提供します。
|
||||
|
||||
```c
|
||||
__attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); }
|
||||
|
||||
__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); }
|
||||
|
||||
__attribute__((weak)) void matrix_init_user(void) {}
|
||||
|
||||
__attribute__((weak)) void matrix_scan_user(void) {}
|
||||
```
|
@ -326,7 +326,7 @@ See also: [Key Lock](feature_key_lock.md)
|
||||
|
||||
## Layer Switching :id=layer-switching
|
||||
|
||||
See also: [Layer Switching](feature_advanced_keycodes.md#switching-and-toggling-layers)
|
||||
See also: [Layer Switching](feature_layers.md#switching-and-toggling-layers)
|
||||
|
||||
|Key |Description |
|
||||
|----------------|----------------------------------------------------------------------------------|
|
||||
|
@ -42,9 +42,13 @@ We've tried to make QMK as easy to set up as possible. You only have to prepare
|
||||
You will need to install MSYS2, Git, and the QMK CLI.
|
||||
|
||||
* Follow the installation instructions on the [MSYS2 homepage](http://www.msys2.org).
|
||||
* Close any open MSYS2 terminals and open a new MSYS2 MinGW 64-bit terminal.
|
||||
* Close any open MSYS2 terminals and open a new MSYS2 MinGW 64-bit terminal. NOTE: This is **not** the same as the MSYS terminal that opens when installation is completed.
|
||||
|
||||
After opening a new MSYS2 MinGW 64-bit terminal run these commands:
|
||||
After opening a new MSYS2 MinGW 64-bit terminal, make sure `pacman` is up to date with:
|
||||
|
||||
pacman -Syu
|
||||
|
||||
You may be asked to close and reopen the window. Do this and keep running the above command until it says `there is nothing to do`. Then run the following:
|
||||
|
||||
pacman -S git python3-pip
|
||||
python3 -m pip install qmk
|
||||
|
@ -1,207 +0,0 @@
|
||||
/* Copyright 2019 Drew Mills
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "analog.h"
|
||||
#include "quantum.h"
|
||||
|
||||
/* User configurable ADC options */
|
||||
#ifndef ADC_CIRCULAR_BUFFER
|
||||
# define ADC_CIRCULAR_BUFFER FALSE
|
||||
#endif
|
||||
|
||||
#ifndef ADC_NUM_CHANNELS
|
||||
# define ADC_NUM_CHANNELS 1
|
||||
#elif ADC_NUM_CHANNELS != 1
|
||||
# error "The ARM ADC implementation currently only supports reading one channel at a time."
|
||||
#endif
|
||||
|
||||
#ifndef ADC_BUFFER_DEPTH
|
||||
# define ADC_BUFFER_DEPTH 2
|
||||
#endif
|
||||
|
||||
// For more sampling rate options, look at hal_adc_lld.h in ChibiOS
|
||||
#ifndef ADC_SAMPLING_RATE
|
||||
# define ADC_SAMPLING_RATE ADC_SMPR_SMP_1P5
|
||||
#endif
|
||||
|
||||
// Options are 12, 10, 8, and 6 bit.
|
||||
#ifndef ADC_RESOLUTION
|
||||
# define ADC_RESOLUTION ADC_CFGR1_RES_12BIT
|
||||
#endif
|
||||
|
||||
static ADCConfig adcCfg = {};
|
||||
static adcsample_t sampleBuffer[ADC_NUM_CHANNELS * ADC_BUFFER_DEPTH];
|
||||
|
||||
// Initialize to max number of ADCs, set to empty object to initialize all to false.
|
||||
#if defined(STM32F0XX)
|
||||
static bool adcInitialized[1] = {};
|
||||
#elif defined(STM32F3XX)
|
||||
static bool adcInitialized[4] = {};
|
||||
#else
|
||||
# error "adcInitialized has not been implemented for this ARM microcontroller."
|
||||
#endif
|
||||
|
||||
static ADCConversionGroup adcConversionGroup = {
|
||||
ADC_CIRCULAR_BUFFER,
|
||||
(uint16_t)(ADC_NUM_CHANNELS),
|
||||
NULL, // No end callback
|
||||
NULL, // No error callback
|
||||
#if defined(STM32F0XX)
|
||||
ADC_CFGR1_CONT | ADC_RESOLUTION,
|
||||
ADC_TR(0, 0).ADC_SAMPLING_RATE,
|
||||
NULL, // Doesn't specify a default channel
|
||||
#elif defined(STM32F3XX)
|
||||
ADC_CFGR_CONT | ADC_RESOLUTION,
|
||||
ADC_TR(0, 4095),
|
||||
{
|
||||
ADC_SAMPLING_RATE,
|
||||
ADC_SAMPLING_RATE,
|
||||
},
|
||||
{
|
||||
0, // Doesn't specify a default channel
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline ADCDriver* intToADCDriver(uint8_t adcInt) {
|
||||
ADCDriver* target;
|
||||
|
||||
switch (adcInt) {
|
||||
// clang-format off
|
||||
#if STM32_ADC_USE_ADC1
|
||||
case 0: target = &ADCD1; break;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC2
|
||||
case 1: target = &ADCD2; break;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC3
|
||||
case 2: target = &ADCD3; break;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC4
|
||||
case 3: target = &ADCD4; break;
|
||||
#endif
|
||||
default: target = NULL; break;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
static inline void manageAdcInitializationDriver(uint8_t adc, ADCDriver* adcDriver) {
|
||||
if (!adcInitialized[adc]) {
|
||||
adcStart(adcDriver, &adcCfg);
|
||||
adcInitialized[adc] = true;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void manageAdcInitialization(uint8_t adc) { manageAdcInitializationDriver(adc, intToADCDriver(adc)); }
|
||||
|
||||
pin_and_adc pinToMux(pin_t pin) {
|
||||
switch (pin) {
|
||||
// clang-format off
|
||||
#if defined(STM32F0XX)
|
||||
case A0: return (pin_and_adc){ ADC_CHANNEL_IN0, 0 };
|
||||
case A1: return (pin_and_adc){ ADC_CHANNEL_IN1, 0 };
|
||||
case A2: return (pin_and_adc){ ADC_CHANNEL_IN2, 0 };
|
||||
case A3: return (pin_and_adc){ ADC_CHANNEL_IN3, 0 };
|
||||
case A4: return (pin_and_adc){ ADC_CHANNEL_IN4, 0 };
|
||||
case A5: return (pin_and_adc){ ADC_CHANNEL_IN5, 0 };
|
||||
case A6: return (pin_and_adc){ ADC_CHANNEL_IN6, 0 };
|
||||
case A7: return (pin_and_adc){ ADC_CHANNEL_IN7, 0 };
|
||||
case B0: return (pin_and_adc){ ADC_CHANNEL_IN8, 0 };
|
||||
case B1: return (pin_and_adc){ ADC_CHANNEL_IN9, 0 };
|
||||
case C0: return (pin_and_adc){ ADC_CHANNEL_IN10, 0 };
|
||||
case C1: return (pin_and_adc){ ADC_CHANNEL_IN11, 0 };
|
||||
case C2: return (pin_and_adc){ ADC_CHANNEL_IN12, 0 };
|
||||
case C3: return (pin_and_adc){ ADC_CHANNEL_IN13, 0 };
|
||||
case C4: return (pin_and_adc){ ADC_CHANNEL_IN14, 0 };
|
||||
case C5: return (pin_and_adc){ ADC_CHANNEL_IN15, 0 };
|
||||
#elif defined(STM32F3XX)
|
||||
case A0: return (pin_and_adc){ ADC_CHANNEL_IN1, 0 };
|
||||
case A1: return (pin_and_adc){ ADC_CHANNEL_IN2, 0 };
|
||||
case A2: return (pin_and_adc){ ADC_CHANNEL_IN3, 0 };
|
||||
case A3: return (pin_and_adc){ ADC_CHANNEL_IN4, 0 };
|
||||
case A4: return (pin_and_adc){ ADC_CHANNEL_IN1, 1 };
|
||||
case A5: return (pin_and_adc){ ADC_CHANNEL_IN2, 1 };
|
||||
case A6: return (pin_and_adc){ ADC_CHANNEL_IN3, 1 };
|
||||
case A7: return (pin_and_adc){ ADC_CHANNEL_IN4, 1 };
|
||||
case B0: return (pin_and_adc){ ADC_CHANNEL_IN12, 2 };
|
||||
case B1: return (pin_and_adc){ ADC_CHANNEL_IN1, 2 };
|
||||
case B2: return (pin_and_adc){ ADC_CHANNEL_IN12, 1 };
|
||||
case B12: return (pin_and_adc){ ADC_CHANNEL_IN2, 3 };
|
||||
case B13: return (pin_and_adc){ ADC_CHANNEL_IN3, 3 };
|
||||
case B14: return (pin_and_adc){ ADC_CHANNEL_IN4, 3 };
|
||||
case B15: return (pin_and_adc){ ADC_CHANNEL_IN5, 3 };
|
||||
case C0: return (pin_and_adc){ ADC_CHANNEL_IN6, 0 }; // Can also be ADC2
|
||||
case C1: return (pin_and_adc){ ADC_CHANNEL_IN7, 0 }; // Can also be ADC2
|
||||
case C2: return (pin_and_adc){ ADC_CHANNEL_IN8, 0 }; // Can also be ADC2
|
||||
case C3: return (pin_and_adc){ ADC_CHANNEL_IN9, 0 }; // Can also be ADC2
|
||||
case C4: return (pin_and_adc){ ADC_CHANNEL_IN5, 1 };
|
||||
case C5: return (pin_and_adc){ ADC_CHANNEL_IN11, 1 };
|
||||
case D8: return (pin_and_adc){ ADC_CHANNEL_IN12, 3 };
|
||||
case D9: return (pin_and_adc){ ADC_CHANNEL_IN13, 3 };
|
||||
case D10: return (pin_and_adc){ ADC_CHANNEL_IN7, 2 }; // Can also be ADC4
|
||||
case D11: return (pin_and_adc){ ADC_CHANNEL_IN8, 2 }; // Can also be ADC4
|
||||
case D12: return (pin_and_adc){ ADC_CHANNEL_IN9, 2 }; // Can also be ADC4
|
||||
case D13: return (pin_and_adc){ ADC_CHANNEL_IN10, 2 }; // Can also be ADC4
|
||||
case D14: return (pin_and_adc){ ADC_CHANNEL_IN11, 2 }; // Can also be ADC4
|
||||
case E7: return (pin_and_adc){ ADC_CHANNEL_IN13, 2 };
|
||||
case E8: return (pin_and_adc){ ADC_CHANNEL_IN6, 2 }; // Can also be ADC4
|
||||
case E9: return (pin_and_adc){ ADC_CHANNEL_IN2, 2 };
|
||||
case E10: return (pin_and_adc){ ADC_CHANNEL_IN14, 2 };
|
||||
case E11: return (pin_and_adc){ ADC_CHANNEL_IN15, 2 };
|
||||
case E12: return (pin_and_adc){ ADC_CHANNEL_IN16, 2 };
|
||||
case E13: return (pin_and_adc){ ADC_CHANNEL_IN3, 2 };
|
||||
case E14: return (pin_and_adc){ ADC_CHANNEL_IN1, 3 };
|
||||
case E15: return (pin_and_adc){ ADC_CHANNEL_IN2, 3 };
|
||||
case F2: return (pin_and_adc){ ADC_CHANNEL_IN10, 0 }; // Can also be ADC2
|
||||
case F4: return (pin_and_adc){ ADC_CHANNEL_IN5, 0 };
|
||||
#else
|
||||
#error "An ADC pin-to-mux configuration has not been specified for this microcontroller."
|
||||
#endif
|
||||
default: return (pin_and_adc){ 0, 0 };
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
|
||||
adcsample_t analogReadPin(pin_t pin) { return adc_read(pinToMux(pin)); }
|
||||
|
||||
adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc) {
|
||||
pin_and_adc target = pinToMux(pin);
|
||||
target.adc = adc;
|
||||
return adc_read(target);
|
||||
}
|
||||
|
||||
adcsample_t adc_read(pin_and_adc mux) {
|
||||
#if defined(STM32F0XX)
|
||||
adcConversionGroup.sqr = ADC_CHSELR_CHSEL1;
|
||||
#elif defined(STM32F3XX)
|
||||
adcConversionGroup.sqr[0] = ADC_SQR1_SQ1_N(mux.pin);
|
||||
#else
|
||||
# error "adc_read has not been updated to support this ARM microcontroller."
|
||||
#endif
|
||||
|
||||
ADCDriver* targetDriver = intToADCDriver(mux.adc);
|
||||
manageAdcInitializationDriver(mux.adc, targetDriver);
|
||||
|
||||
adcConvert(targetDriver, &adcConversionGroup, &sampleBuffer[0], ADC_BUFFER_DEPTH);
|
||||
adcsample_t* result = sampleBuffer;
|
||||
|
||||
return *result;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/* Copyright 2019 Drew Mills
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "ch.h"
|
||||
#include <hal.h>
|
||||
|
||||
#if !defined(STM32F0XX) && !defined(STM32F3XX)
|
||||
# error "Only STM23F0 and STM32F3 devices have ADC support in QMK at this time."
|
||||
#endif
|
||||
|
||||
#if !HAL_USE_ADC
|
||||
# error "You need to set HAL_USE_ADC to TRUE in your halconf.h to use the ADC."
|
||||
#endif
|
||||
|
||||
#if !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4
|
||||
# error "You need to set one of the 'STM32_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC."
|
||||
#endif
|
||||
|
||||
#if STM32_ADC_DUAL_MODE
|
||||
# error "STM32 ADC Dual Mode is not supported at this time."
|
||||
#endif
|
||||
|
||||
#if STM32_ADCV3_OVERSAMPLING
|
||||
# error "STM32 ADCV3 Oversampling is not supported at this time."
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
pin_t pin;
|
||||
uint8_t adc;
|
||||
} pin_and_adc;
|
||||
#define PIN_AND_ADC(p, a) \
|
||||
(pin_and_adc) { p, a }
|
||||
|
||||
// analogReference has been left un-defined for ARM devices.
|
||||
// void analogReference(uint8_t mode);
|
||||
|
||||
adcsample_t analogReadPin(pin_t pin);
|
||||
adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc);
|
||||
pin_and_adc pinToMux(pin_t pin);
|
||||
|
||||
adcsample_t adc_read(pin_and_adc mux);
|
276
drivers/chibios/analog.c
Normal file
276
drivers/chibios/analog.c
Normal file
@ -0,0 +1,276 @@
|
||||
/* Copyright 2019 Drew Mills
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "quantum.h"
|
||||
#include "analog.h"
|
||||
#include "ch.h"
|
||||
#include <hal.h>
|
||||
|
||||
#if !HAL_USE_ADC
|
||||
# error "You need to set HAL_USE_ADC to TRUE in your halconf.h to use the ADC."
|
||||
#endif
|
||||
|
||||
#if !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4
|
||||
# error "You need to set one of the 'STM32_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC."
|
||||
#endif
|
||||
|
||||
#if STM32_ADC_DUAL_MODE
|
||||
# error "STM32 ADC Dual Mode is not supported at this time."
|
||||
#endif
|
||||
|
||||
#if STM32_ADCV3_OVERSAMPLING
|
||||
# error "STM32 ADCV3 Oversampling is not supported at this time."
|
||||
#endif
|
||||
|
||||
// Otherwise assume V3
|
||||
#if defined(STM32F0XX) || defined(STM32L0XX)
|
||||
# define USE_ADCV1
|
||||
#elif defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX)
|
||||
# define USE_ADCV2
|
||||
#endif
|
||||
|
||||
// BODGE to make v2 look like v1,3 and 4
|
||||
#ifdef USE_ADCV2
|
||||
# if !defined(ADC_SMPR_SMP_1P5) && defined(ADC_SAMPLE_3)
|
||||
# define ADC_SMPR_SMP_1P5 ADC_SAMPLE_3
|
||||
# define ADC_SMPR_SMP_7P5 ADC_SAMPLE_15
|
||||
# define ADC_SMPR_SMP_13P5 ADC_SAMPLE_28
|
||||
# define ADC_SMPR_SMP_28P5 ADC_SAMPLE_56
|
||||
# define ADC_SMPR_SMP_41P5 ADC_SAMPLE_84
|
||||
# define ADC_SMPR_SMP_55P5 ADC_SAMPLE_112
|
||||
# define ADC_SMPR_SMP_71P5 ADC_SAMPLE_144
|
||||
# define ADC_SMPR_SMP_239P5 ADC_SAMPLE_480
|
||||
# endif
|
||||
|
||||
# if !defined(ADC_SMPR_SMP_1P5) && defined(ADC_SAMPLE_1P5)
|
||||
# define ADC_SMPR_SMP_1P5 ADC_SAMPLE_1P5
|
||||
# define ADC_SMPR_SMP_7P5 ADC_SAMPLE_7P5
|
||||
# define ADC_SMPR_SMP_13P5 ADC_SAMPLE_13P5
|
||||
# define ADC_SMPR_SMP_28P5 ADC_SAMPLE_28P5
|
||||
# define ADC_SMPR_SMP_41P5 ADC_SAMPLE_41P5
|
||||
# define ADC_SMPR_SMP_55P5 ADC_SAMPLE_55P5
|
||||
# define ADC_SMPR_SMP_71P5 ADC_SAMPLE_71P5
|
||||
# define ADC_SMPR_SMP_239P5 ADC_SAMPLE_239P5
|
||||
# endif
|
||||
|
||||
// we still sample at 12bit, but scale down to the requested bit range
|
||||
# define ADC_CFGR1_RES_12BIT 12
|
||||
# define ADC_CFGR1_RES_10BIT 10
|
||||
# define ADC_CFGR1_RES_8BIT 8
|
||||
# define ADC_CFGR1_RES_6BIT 6
|
||||
#endif
|
||||
|
||||
/* User configurable ADC options */
|
||||
#ifndef ADC_COUNT
|
||||
# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX)
|
||||
# define ADC_COUNT 1
|
||||
# elif defined(STM32F3XX)
|
||||
# define ADC_COUNT 4
|
||||
# else
|
||||
# error "ADC_COUNT has not been set for this ARM microcontroller."
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ADC_NUM_CHANNELS
|
||||
# define ADC_NUM_CHANNELS 1
|
||||
#elif ADC_NUM_CHANNELS != 1
|
||||
# error "The ARM ADC implementation currently only supports reading one channel at a time."
|
||||
#endif
|
||||
|
||||
#ifndef ADC_BUFFER_DEPTH
|
||||
# define ADC_BUFFER_DEPTH 1
|
||||
#endif
|
||||
|
||||
// For more sampling rate options, look at hal_adc_lld.h in ChibiOS
|
||||
#ifndef ADC_SAMPLING_RATE
|
||||
# define ADC_SAMPLING_RATE ADC_SMPR_SMP_1P5
|
||||
#endif
|
||||
|
||||
// Options are 12, 10, 8, and 6 bit.
|
||||
#ifndef ADC_RESOLUTION
|
||||
# define ADC_RESOLUTION ADC_CFGR1_RES_10BIT
|
||||
#endif
|
||||
|
||||
static ADCConfig adcCfg = {};
|
||||
static adcsample_t sampleBuffer[ADC_NUM_CHANNELS * ADC_BUFFER_DEPTH];
|
||||
|
||||
// Initialize to max number of ADCs, set to empty object to initialize all to false.
|
||||
static bool adcInitialized[ADC_COUNT] = {};
|
||||
|
||||
// TODO: add back TR handling???
|
||||
static ADCConversionGroup adcConversionGroup = {
|
||||
.circular = FALSE,
|
||||
.num_channels = (uint16_t)(ADC_NUM_CHANNELS),
|
||||
#if defined(USE_ADCV1)
|
||||
.cfgr1 = ADC_CFGR1_CONT | ADC_RESOLUTION,
|
||||
.smpr = ADC_SAMPLING_RATE,
|
||||
#elif defined(USE_ADCV2)
|
||||
# if !defined(STM32F1XX)
|
||||
.cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without...
|
||||
# endif
|
||||
.smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE),
|
||||
.smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE),
|
||||
#else
|
||||
.cfgr = ADC_CFGR_CONT | ADC_RESOLUTION,
|
||||
.smpr = {ADC_SMPR1_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN9(ADC_SAMPLING_RATE), ADC_SMPR2_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN15(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN16(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN17(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN18(ADC_SAMPLING_RATE)},
|
||||
#endif
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
__attribute__((weak)) adc_mux pinToMux(pin_t pin) {
|
||||
switch (pin) {
|
||||
#if defined(STM32F0XX)
|
||||
case A0: return TO_MUX( ADC_CHSELR_CHSEL0, 0 );
|
||||
case A1: return TO_MUX( ADC_CHSELR_CHSEL1, 0 );
|
||||
case A2: return TO_MUX( ADC_CHSELR_CHSEL2, 0 );
|
||||
case A3: return TO_MUX( ADC_CHSELR_CHSEL3, 0 );
|
||||
case A4: return TO_MUX( ADC_CHSELR_CHSEL4, 0 );
|
||||
case A5: return TO_MUX( ADC_CHSELR_CHSEL5, 0 );
|
||||
case A6: return TO_MUX( ADC_CHSELR_CHSEL6, 0 );
|
||||
case A7: return TO_MUX( ADC_CHSELR_CHSEL7, 0 );
|
||||
case B0: return TO_MUX( ADC_CHSELR_CHSEL8, 0 );
|
||||
case B1: return TO_MUX( ADC_CHSELR_CHSEL9, 0 );
|
||||
case C0: return TO_MUX( ADC_CHSELR_CHSEL10, 0 );
|
||||
case C1: return TO_MUX( ADC_CHSELR_CHSEL11, 0 );
|
||||
case C2: return TO_MUX( ADC_CHSELR_CHSEL12, 0 );
|
||||
case C3: return TO_MUX( ADC_CHSELR_CHSEL13, 0 );
|
||||
case C4: return TO_MUX( ADC_CHSELR_CHSEL14, 0 );
|
||||
case C5: return TO_MUX( ADC_CHSELR_CHSEL15, 0 );
|
||||
#elif defined(STM32F3XX)
|
||||
case A0: return TO_MUX( ADC_CHANNEL_IN1, 0 );
|
||||
case A1: return TO_MUX( ADC_CHANNEL_IN2, 0 );
|
||||
case A2: return TO_MUX( ADC_CHANNEL_IN3, 0 );
|
||||
case A3: return TO_MUX( ADC_CHANNEL_IN4, 0 );
|
||||
case A4: return TO_MUX( ADC_CHANNEL_IN1, 1 );
|
||||
case A5: return TO_MUX( ADC_CHANNEL_IN2, 1 );
|
||||
case A6: return TO_MUX( ADC_CHANNEL_IN3, 1 );
|
||||
case A7: return TO_MUX( ADC_CHANNEL_IN4, 1 );
|
||||
case B0: return TO_MUX( ADC_CHANNEL_IN12, 2 );
|
||||
case B1: return TO_MUX( ADC_CHANNEL_IN1, 2 );
|
||||
case B2: return TO_MUX( ADC_CHANNEL_IN12, 1 );
|
||||
case B12: return TO_MUX( ADC_CHANNEL_IN2, 3 );
|
||||
case B13: return TO_MUX( ADC_CHANNEL_IN3, 3 );
|
||||
case B14: return TO_MUX( ADC_CHANNEL_IN4, 3 );
|
||||
case B15: return TO_MUX( ADC_CHANNEL_IN5, 3 );
|
||||
case C0: return TO_MUX( ADC_CHANNEL_IN6, 0 ); // Can also be ADC2
|
||||
case C1: return TO_MUX( ADC_CHANNEL_IN7, 0 ); // Can also be ADC2
|
||||
case C2: return TO_MUX( ADC_CHANNEL_IN8, 0 ); // Can also be ADC2
|
||||
case C3: return TO_MUX( ADC_CHANNEL_IN9, 0 ); // Can also be ADC2
|
||||
case C4: return TO_MUX( ADC_CHANNEL_IN5, 1 );
|
||||
case C5: return TO_MUX( ADC_CHANNEL_IN11, 1 );
|
||||
case D8: return TO_MUX( ADC_CHANNEL_IN12, 3 );
|
||||
case D9: return TO_MUX( ADC_CHANNEL_IN13, 3 );
|
||||
case D10: return TO_MUX( ADC_CHANNEL_IN7, 2 ); // Can also be ADC4
|
||||
case D11: return TO_MUX( ADC_CHANNEL_IN8, 2 ); // Can also be ADC4
|
||||
case D12: return TO_MUX( ADC_CHANNEL_IN9, 2 ); // Can also be ADC4
|
||||
case D13: return TO_MUX( ADC_CHANNEL_IN10, 2 ); // Can also be ADC4
|
||||
case D14: return TO_MUX( ADC_CHANNEL_IN11, 2 ); // Can also be ADC4
|
||||
case E7: return TO_MUX( ADC_CHANNEL_IN13, 2 );
|
||||
case E8: return TO_MUX( ADC_CHANNEL_IN6, 2 ); // Can also be ADC4
|
||||
case E9: return TO_MUX( ADC_CHANNEL_IN2, 2 );
|
||||
case E10: return TO_MUX( ADC_CHANNEL_IN14, 2 );
|
||||
case E11: return TO_MUX( ADC_CHANNEL_IN15, 2 );
|
||||
case E12: return TO_MUX( ADC_CHANNEL_IN16, 2 );
|
||||
case E13: return TO_MUX( ADC_CHANNEL_IN3, 2 );
|
||||
case E14: return TO_MUX( ADC_CHANNEL_IN1, 3 );
|
||||
case E15: return TO_MUX( ADC_CHANNEL_IN2, 3 );
|
||||
case F2: return TO_MUX( ADC_CHANNEL_IN10, 0 ); // Can also be ADC2
|
||||
case F4: return TO_MUX( ADC_CHANNEL_IN5, 0 );
|
||||
#elif defined(STM32F4XX) // TODO: add all pins
|
||||
case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 );
|
||||
//case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 );
|
||||
#elif defined(STM32F1XX) // TODO: add all pins
|
||||
case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
// return an adc that would never be used so intToADCDriver will bail out
|
||||
return TO_MUX(0, 0xFF);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
static inline ADCDriver* intToADCDriver(uint8_t adcInt) {
|
||||
switch (adcInt) {
|
||||
#if STM32_ADC_USE_ADC1
|
||||
case 0:
|
||||
return &ADCD1;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC2
|
||||
case 1:
|
||||
return &ADCD2;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC3
|
||||
case 2:
|
||||
return &ADCD3;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC4
|
||||
case 3:
|
||||
return &ADCD4;
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void manageAdcInitializationDriver(uint8_t adc, ADCDriver* adcDriver) {
|
||||
if (!adcInitialized[adc]) {
|
||||
adcStart(adcDriver, &adcCfg);
|
||||
adcInitialized[adc] = true;
|
||||
}
|
||||
}
|
||||
|
||||
int16_t analogReadPin(pin_t pin) {
|
||||
palSetLineMode(pin, PAL_MODE_INPUT_ANALOG);
|
||||
|
||||
return adc_read(pinToMux(pin));
|
||||
}
|
||||
|
||||
int16_t analogReadPinAdc(pin_t pin, uint8_t adc) {
|
||||
palSetLineMode(pin, PAL_MODE_INPUT_ANALOG);
|
||||
|
||||
adc_mux target = pinToMux(pin);
|
||||
target.adc = adc;
|
||||
return adc_read(target);
|
||||
}
|
||||
|
||||
int16_t adc_read(adc_mux mux) {
|
||||
#if defined(USE_ADCV1)
|
||||
// TODO: fix previous assumption of only 1 input...
|
||||
adcConversionGroup.chselr = 1 << mux.input; /*no macro to convert N to ADC_CHSELR_CHSEL1*/
|
||||
#elif defined(USE_ADCV2)
|
||||
adcConversionGroup.sqr3 = ADC_SQR3_SQ1_N(mux.input);
|
||||
#else
|
||||
adcConversionGroup.sqr[0] = ADC_SQR1_SQ1_N(mux.input);
|
||||
#endif
|
||||
|
||||
ADCDriver* targetDriver = intToADCDriver(mux.adc);
|
||||
if (!targetDriver) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
manageAdcInitializationDriver(mux.adc, targetDriver);
|
||||
if (adcConvert(targetDriver, &adcConversionGroup, &sampleBuffer[0], ADC_BUFFER_DEPTH) != MSG_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef USE_ADCV2
|
||||
// fake 12-bit -> N-bit scale
|
||||
return (*sampleBuffer) >> (12 - ADC_RESOLUTION);
|
||||
#else
|
||||
// already handled as part of adcConvert
|
||||
return *sampleBuffer;
|
||||
#endif
|
||||
}
|
41
drivers/chibios/analog.h
Normal file
41
drivers/chibios/analog.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* Copyright 2019 Drew Mills
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "quantum.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint16_t input;
|
||||
uint8_t adc;
|
||||
} adc_mux;
|
||||
#define TO_MUX(i, a) \
|
||||
(adc_mux) { i, a }
|
||||
|
||||
int16_t analogReadPin(pin_t pin);
|
||||
int16_t analogReadPinAdc(pin_t pin, uint8_t adc);
|
||||
adc_mux pinToMux(pin_t pin);
|
||||
|
||||
int16_t adc_read(adc_mux mux);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1 +1,33 @@
|
||||
# Dummy rules.mk, rev0 uses parent rules.mk as is
|
||||
# MCU name
|
||||
MCU = atmega32u2
|
||||
|
||||
# Bootloader selection
|
||||
# Teensy halfkay
|
||||
# Pro Micro caterina
|
||||
# Atmel DFU atmel-dfu
|
||||
# LUFA DFU lufa-dfu
|
||||
# QMK DFU qmk-dfu
|
||||
# ATmega32A bootloadHID
|
||||
# ATmega328P USBasp
|
||||
BOOTLOADER = atmel-dfu
|
||||
|
||||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = no # 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 = 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
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
MIDI_ENABLE = no # MIDI support
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
|
||||
HD44780_ENABLE = no # Enable support for HD44780 based LCDs
|
||||
|
@ -1 +1,33 @@
|
||||
# Dummy rules.mk, rev1 uses parent rules.mk as is
|
||||
# MCU name
|
||||
MCU = atmega32u2
|
||||
|
||||
# Bootloader selection
|
||||
# Teensy halfkay
|
||||
# Pro Micro caterina
|
||||
# Atmel DFU atmel-dfu
|
||||
# LUFA DFU lufa-dfu
|
||||
# QMK DFU qmk-dfu
|
||||
# ATmega32A bootloadHID
|
||||
# ATmega328P USBasp
|
||||
BOOTLOADER = atmel-dfu
|
||||
|
||||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = no # 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 = 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
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
MIDI_ENABLE = no # MIDI support
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
|
||||
HD44780_ENABLE = no # Enable support for HD44780 based LCDs
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"keyboard_name": "Polaris",
|
||||
"url": "https://kb.ai03.me/projects/polaris.html",
|
||||
"maintainer": "ai03",
|
||||
"width": 15,
|
||||
"height": 5,
|
||||
"keyboard_name": "Polaris",
|
||||
"url": "https://kb.ai03.me/projects/polaris.html",
|
||||
"maintainer": "ai03",
|
||||
"width": 15,
|
||||
"height": 5,
|
||||
"layouts": {
|
||||
"LAYOUT_all": {
|
||||
"layout": [
|
||||
@ -75,6 +75,138 @@
|
||||
{"label":"Ctrl", "x":13.75, "y":4, "w":1.25}
|
||||
]
|
||||
},
|
||||
"LAYOUT_60_ansi": {
|
||||
"layout": [
|
||||
{"label":"~", "x":0, "y":0},
|
||||
{"label":"!", "x":1, "y":0},
|
||||
{"label":"@", "x":2, "y":0},
|
||||
{"label":"#", "x":3, "y":0},
|
||||
{"label":"$", "x":4, "y":0},
|
||||
{"label":"%", "x":5, "y":0},
|
||||
{"label":"^", "x":6, "y":0},
|
||||
{"label":"&", "x":7, "y":0},
|
||||
{"label":"*", "x":8, "y":0},
|
||||
{"label":"(", "x":9, "y":0},
|
||||
{"label":")", "x":10, "y":0},
|
||||
{"label":"_", "x":11, "y":0},
|
||||
{"label":"+", "x":12, "y":0},
|
||||
{"label":"Backspace", "x":13, "y":0, "w":2},
|
||||
{"label":"Tab", "x":0, "y":1, "w":1.5},
|
||||
{"label":"Q", "x":1.5, "y":1},
|
||||
{"label":"W", "x":2.5, "y":1},
|
||||
{"label":"E", "x":3.5, "y":1},
|
||||
{"label":"R", "x":4.5, "y":1},
|
||||
{"label":"T", "x":5.5, "y":1},
|
||||
{"label":"Y", "x":6.5, "y":1},
|
||||
{"label":"U", "x":7.5, "y":1},
|
||||
{"label":"I", "x":8.5, "y":1},
|
||||
{"label":"O", "x":9.5, "y":1},
|
||||
{"label":"P", "x":10.5, "y":1},
|
||||
{"label":"{", "x":11.5, "y":1},
|
||||
{"label":"}", "x":12.5, "y":1},
|
||||
{"label":"|", "x":13.5, "y":1, "w":1.5},
|
||||
{"label":"Caps Lock", "x":0, "y":2, "w":1.75},
|
||||
{"label":"A", "x":1.75, "y":2},
|
||||
{"label":"S", "x":2.75, "y":2},
|
||||
{"label":"D", "x":3.75, "y":2},
|
||||
{"label":"F", "x":4.75, "y":2},
|
||||
{"label":"G", "x":5.75, "y":2},
|
||||
{"label":"H", "x":6.75, "y":2},
|
||||
{"label":"J", "x":7.75, "y":2},
|
||||
{"label":"K", "x":8.75, "y":2},
|
||||
{"label":"L", "x":9.75, "y":2},
|
||||
{"label":":", "x":10.75, "y":2},
|
||||
{"label":"\"", "x":11.75, "y":2},
|
||||
{"label":"Enter", "x":12.75, "y":2, "w":2.25},
|
||||
{"label":"Shift", "x":0, "y":3, "w":2.25},
|
||||
{"label":"Z", "x":2.25, "y":3},
|
||||
{"label":"X", "x":3.25, "y":3},
|
||||
{"label":"C", "x":4.25, "y":3},
|
||||
{"label":"V", "x":5.25, "y":3},
|
||||
{"label":"B", "x":6.25, "y":3},
|
||||
{"label":"N", "x":7.25, "y":3},
|
||||
{"label":"M", "x":8.25, "y":3},
|
||||
{"label":"<", "x":9.25, "y":3},
|
||||
{"label":">", "x":10.25, "y":3},
|
||||
{"label":"?", "x":11.25, "y":3},
|
||||
{"label":"Shift", "x":12.25, "y":3, "w":2.75},
|
||||
{"label":"Ctrl", "x":0, "y":4, "w":1.25},
|
||||
{"label":"Win", "x":1.25, "y":4, "w":1.25},
|
||||
{"label":"Alt", "x":2.5, "y":4, "w":1.25},
|
||||
{"x":3.75, "y":4, "w":6.25},
|
||||
{"label":"Alt", "x":10, "y":4, "w":1.25},
|
||||
{"label":"Win", "x":11.25, "y":4, "w":1.25},
|
||||
{"label":"Menu", "x":12.5, "y":4, "w":1.25},
|
||||
{"label":"Ctrl", "x":13.75, "y":4, "w":1.25}
|
||||
]
|
||||
},
|
||||
"LAYOUT_60_ansi_split_bs_rshift": {
|
||||
"layout": [
|
||||
{"label":"~", "x":0, "y":0},
|
||||
{"label":"!", "x":1, "y":0},
|
||||
{"label":"@", "x":2, "y":0},
|
||||
{"label":"#", "x":3, "y":0},
|
||||
{"label":"$", "x":4, "y":0},
|
||||
{"label":"%", "x":5, "y":0},
|
||||
{"label":"^", "x":6, "y":0},
|
||||
{"label":"&", "x":7, "y":0},
|
||||
{"label":"*", "x":8, "y":0},
|
||||
{"label":"(", "x":9, "y":0},
|
||||
{"label":")", "x":10, "y":0},
|
||||
{"label":"_", "x":11, "y":0},
|
||||
{"label":"+", "x":12, "y":0},
|
||||
{"label":"Backspace", "x":13, "y":0},
|
||||
{"label":"Delete", "x":14, "y":0},
|
||||
{"label":"Tab", "x":0, "y":1, "w":1.5},
|
||||
{"label":"Q", "x":1.5, "y":1},
|
||||
{"label":"W", "x":2.5, "y":1},
|
||||
{"label":"E", "x":3.5, "y":1},
|
||||
{"label":"R", "x":4.5, "y":1},
|
||||
{"label":"T", "x":5.5, "y":1},
|
||||
{"label":"Y", "x":6.5, "y":1},
|
||||
{"label":"U", "x":7.5, "y":1},
|
||||
{"label":"I", "x":8.5, "y":1},
|
||||
{"label":"O", "x":9.5, "y":1},
|
||||
{"label":"P", "x":10.5, "y":1},
|
||||
{"label":"{", "x":11.5, "y":1},
|
||||
{"label":"}", "x":12.5, "y":1},
|
||||
{"label":"|", "x":13.5, "y":1, "w":1.5},
|
||||
{"label":"Caps Lock", "x":0, "y":2, "w":1.75},
|
||||
{"label":"A", "x":1.75, "y":2},
|
||||
{"label":"S", "x":2.75, "y":2},
|
||||
{"label":"D", "x":3.75, "y":2},
|
||||
{"label":"F", "x":4.75, "y":2},
|
||||
{"label":"G", "x":5.75, "y":2},
|
||||
{"label":"H", "x":6.75, "y":2},
|
||||
{"label":"J", "x":7.75, "y":2},
|
||||
{"label":"K", "x":8.75, "y":2},
|
||||
{"label":"L", "x":9.75, "y":2},
|
||||
{"label":":", "x":10.75, "y":2},
|
||||
{"label":"\"", "x":11.75, "y":2},
|
||||
{"label":"Enter", "x":12.75, "y":2, "w":2.25},
|
||||
{"label":"Shift", "x":0, "y":3, "w":2.25},
|
||||
{"label":"Z", "x":2.25, "y":3},
|
||||
{"label":"X", "x":3.25, "y":3},
|
||||
{"label":"C", "x":4.25, "y":3},
|
||||
{"label":"V", "x":5.25, "y":3},
|
||||
{"label":"B", "x":6.25, "y":3},
|
||||
{"label":"N", "x":7.25, "y":3},
|
||||
{"label":"M", "x":8.25, "y":3},
|
||||
{"label":"<", "x":9.25, "y":3},
|
||||
{"label":">", "x":10.25, "y":3},
|
||||
{"label":"?", "x":11.25, "y":3},
|
||||
{"label":"Shift", "x":12.25, "y":3, "w":1.75},
|
||||
{"label":"Print Screen", "x":14, "y":3},
|
||||
{"label":"Ctrl", "x":0, "y":4, "w":1.25},
|
||||
{"label":"Win", "x":1.25, "y":4, "w":1.25},
|
||||
{"label":"Alt", "x":2.5, "y":4, "w":1.25},
|
||||
{"x":3.75, "y":4, "w":6.25},
|
||||
{"label":"Alt", "x":10, "y":4, "w":1.25},
|
||||
{"label":"Win", "x":11.25, "y":4, "w":1.25},
|
||||
{"label":"Menu", "x":12.5, "y":4, "w":1.25},
|
||||
{"label":"Ctrl", "x":13.75, "y":4, "w":1.25}
|
||||
]
|
||||
},
|
||||
"LAYOUT_60_tsangan_hhkb": {
|
||||
"layout": [
|
||||
{"label":"~", "x":0, "y":0},
|
||||
|
@ -40,6 +40,36 @@
|
||||
{ K400, K401, K402, KC_NO, K404, KC_NO, K406, KC_NO, K408, KC_NO, K410, K411, K412, K413 } \
|
||||
}
|
||||
|
||||
#define LAYOUT_60_ansi( \
|
||||
K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, \
|
||||
K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, \
|
||||
K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K213, \
|
||||
K300, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, \
|
||||
K400, K401, K402, K406, K410, K411, K412, K413 \
|
||||
) \
|
||||
{ \
|
||||
{ K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013 }, \
|
||||
{ K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113 }, \
|
||||
{ K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, KC_NO, K213 }, \
|
||||
{ K300, KC_NO, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, KC_NO}, \
|
||||
{ K400, K401, K402, KC_NO, KC_NO, KC_NO, K406, KC_NO, KC_NO, KC_NO, K410, K411, K412, K413 } \
|
||||
}
|
||||
|
||||
#define LAYOUT_60_ansi_split_bs_rshift( \
|
||||
K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, K212, \
|
||||
K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, \
|
||||
K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K213, \
|
||||
K300, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313, \
|
||||
K400, K401, K402, K406, K410, K411, K412, K413 \
|
||||
) \
|
||||
{ \
|
||||
{ K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013 }, \
|
||||
{ K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113 }, \
|
||||
{ K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213 }, \
|
||||
{ K300, KC_NO, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313 }, \
|
||||
{ K400, K401, K402, KC_NO, KC_NO, KC_NO, K406, KC_NO, KC_NO, KC_NO, K410, K411, K412, K413 } \
|
||||
}
|
||||
|
||||
#define LAYOUT_60_tsangan_hhkb( \
|
||||
K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, K013, K212, \
|
||||
K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, \
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user