Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Shifts #2

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
31bb05c
Branch point for 2020 Aug 29 Breaking Change
noroadsleft May 30, 2020
24af018
Remove iWRAP protocol (#9284)
fauxpark Jun 5, 2020
faa0401
Initial work for consolidation of ChibiOS platform files (#8327)
tzarc Jun 6, 2020
1aa2a0d
Various tidyups for USB descriptor code (#9005)
fauxpark Jun 7, 2020
f3c6924
Convert `CONSUMER2BLUEFRUIT()` and `CONSUMER2RN42()` macros to static…
fauxpark Jun 7, 2020
e457167
Attempt to fix CI for non-master branches. (#9308)
tzarc Jun 8, 2020
ab99c81
Additional cleanups for V-USB code (#9310)
fauxpark Jun 9, 2020
4887279
Remove inclusion of adafruit_ble.h from ssd1306.c (#9355)
fauxpark Jun 17, 2020
ccb1faf
Don't compile outputselect.c if Bluetooth is disabled (#9356)
fauxpark Jun 17, 2020
970ad01
`qmk cformat` on `develop` (#9501)
tzarc Jun 22, 2020
563728e
Change analogRead calls to analogReadPin (#9023)
fauxpark Jul 2, 2020
208c2f2
Add support for DMAMUX-capable MCU configuration with WS2812 PWM driv…
tzarc Jul 16, 2020
21a884c
F303/Proton-C migration. (#9315)
tzarc Jul 16, 2020
31a0264
Fix the mousekey scrolling (#9174)
dhong44 Jul 16, 2020
c023f1b
Add dual-bank STM32 bootloader support, given GPIO toggle on BOOT0 to…
tzarc Jul 16, 2020
d982abe
Bigger combo index (#9318)
sevanteri Jul 16, 2020
83fc249
Re-fix the STM32 dual-bank bootloader stuff. (#9738)
tzarc Jul 16, 2020
de57f33
Disable NKRO on V-USB controllers (#9054)
drashna Jul 22, 2020
fca5b6f
Update features to use Custom Tapping Term when appropriate (#6259)
drashna Jul 25, 2020
ace17e4
Hid joystick interface (#4226)
a-chol Jul 25, 2020
f9267ec
Tweak the Christmas animation effect to be less harsh on the eyes (#7…
Maxr1998 Jul 25, 2020
d189a57
Initialize Layer State on startup (#8318)
drashna Jul 27, 2020
5484b63
The Key Company project consolidation (#9547)
TerryMathews Jul 28, 2020
80ff2ba
[Keyboard] relocating boards by flehrad (#9635)
flehrad Jul 30, 2020
7de0f17
Add support for hsv->rgb conversion without using CIE curve. (#9856)
tzarc Aug 5, 2020
c4d3b24
Noeeprom functions for rgb_matrix (#9487)
tynanbe Aug 7, 2020
6bd3bf2
Fix joystick compile issues (#9949)
fauxpark Aug 8, 2020
8b7b3ce
Fix Czech keycodes (#9987)
kosorin Aug 11, 2020
d98e044
Keebio RGB wiring update (#7754)
nooges Aug 12, 2020
6a8cbaa
Add `st-flash` flash target (#9964)
sigprof Aug 12, 2020
5cb57c7
Add ability to dump all makefile variables for the specified target. …
tzarc Aug 15, 2020
a9d4e67
#define AUTO_SHIFT_SETUP (#8441)
ThePreviousOne Aug 15, 2020
489dcfa
ARM backlight - timer implementation (#8291)
zvecr Aug 15, 2020
9dc51c0
Remove f072 backlight warning (#10040)
zvecr Aug 16, 2020
f13d897
Remove unused CORTEX_VTOR_INIT (#10053)
fauxpark Aug 18, 2020
a1c9df0
Auto shift: support repeats and early registration (#7048)
p00ya Jul 25, 2020
ff95c13
Add auto shift matrix scan to quantum
p00ya Jul 25, 2020
809465a
Support tap-then-hold for auto shift
p00ya Jul 25, 2020
a80ff49
Flush auto-shifted key
p00ya Jul 25, 2020
eb13f20
Don't register extra keys on release
p00ya Jul 25, 2020
b02fcd5
Fix flaky unshifting
p00ya Jul 25, 2020
5ef01bd
Update docs for auto shift
p00ya Jul 25, 2020
a0b8854
Cleanup and refactoring, mostly prepared for custom values
IsaacElenbaas Jul 28, 2020
92bafff
snake_case
IsaacElenbaas Jul 28, 2020
ea50e83
cformat, requested changes
IsaacElenbaas Jul 28, 2020
cae2d31
Docs and changed defines to not be breaking change
IsaacElenbaas Jul 30, 2020
76457de
Fixed shift not being released and removed unnecessary flush_shift.
IsaacElenbaas Jul 31, 2020
339fe5b
clang-format
p00ya Aug 18, 2020
2a56184
Custom autoshifts and easy extension!
IsaacElenbaas Jul 29, 2020
f58ead5
Manual shift fixes
IsaacElenbaas Jul 29, 2020
3387110
A few changes.
IsaacElenbaas Jul 30, 2020
8d98342
Added a way to have mod-tap-shift cancel if held very long.
IsaacElenbaas Jul 30, 2020
280b801
Remove mod-tap support in favor of upstream 9889
IsaacElenbaas Aug 7, 2020
eb96a3b
Minor comment changes.
IsaacElenbaas Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ addons:
install:
- npm install -g moxygen
script:
- git fetch --depth=50 origin $TRAVIS_BRANCH:$TRAVIS_BRANCH
- git rev-parse --short HEAD
- git diff --name-only HEAD $TRAVIS_BRANCH
- bash util/travis_test.sh
Expand Down
9 changes: 1 addition & 8 deletions build_keyboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ include common.mk
KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD))
TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP)
KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD_FILESAFE)
STM32_PATH := quantum/stm32

# Force expansion
TARGET := $(TARGET)
Expand Down Expand Up @@ -138,7 +137,7 @@ endif

ifeq ($(strip $(CONVERT_TO_PROTON_C)), yes)
TARGET := $(TARGET)_proton_c
include $(STM32_PATH)/proton_c.mk
include platforms/chibios/GENERIC_STM32_F303XC/configs/proton_c.mk
OPT_DEFS += -DCONVERT_TO_PROTON_C
endif

Expand All @@ -148,12 +147,6 @@ endif

include quantum/mcu_selection.mk

ifdef MCU_FAMILY
OPT_DEFS += -DQMK_STM32
KEYBOARD_PATHS += $(STM32_PATH)
endif


# Find all the C source files to be compiled in subfolders.
KEYBOARD_SRC :=

Expand Down
9 changes: 8 additions & 1 deletion common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
BACKLIGHT_DRIVER := custom
endif

VALID_BACKLIGHT_TYPES := pwm software custom
VALID_BACKLIGHT_TYPES := pwm timer software custom

BACKLIGHT_ENABLE ?= no
BACKLIGHT_DRIVER ?= pwm
Expand Down Expand Up @@ -529,3 +529,10 @@ ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
OPT_DEFS += -DAUTO_SHIFT_MODIFIERS
endif
endif

ifeq ($(strip $(JOYSTICK_ENABLE)), yes)
OPT_DEFS += -DJOYSTICK_ENABLE
SRC += $(QUANTUM_DIR)/process_keycode/process_joystick.c
SRC += $(QUANTUM_DIR)/joystick.c
SRC += analog.c
endif
5 changes: 5 additions & 0 deletions docs/ChangeLog/20200829/PR9023.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Deprecation of `analogRead()`

[#9023](https://github.com/qmk/qmk_firmware/pull/9023)

This function takes Arduino pin numbers (eg. `9` vs. `B5`), which is at odds with the rest of the codebase. The replacement for this function is `analogReadPin()`.
11 changes: 11 additions & 0 deletions docs/ChangeLog/20200829/PR9318.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Bigger integer type when looping over combos.

[#9318](https://github.com/qmk/qmk_firmware/pull/9318)

Changes `uint8_t` to `uint16_t` so it is possible have more than 256 combos.

Any fork that uses `process_combo_event` needs to update the function's first argument to `uint16_t`.

| Old function | New Function |
|---------------------------------------------------------------|----------------------------------------------------------------|
| `void process_combo_event(uint8_t combo_index, bool pressed)` | `void process_combo_event(uint16_t combo_index, bool pressed)` |
1 change: 1 addition & 0 deletions docs/_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
* [DIP Switch](feature_dip_switch.md)
* [Encoders](feature_encoders.md)
* [Haptic Feedback](feature_haptic_feedback.md)
* [Joystick](feature_joystick.md)
* [Proton C Conversion](proton_c_conversion.md)
* [PS/2 Mouse](feature_ps2_mouse.md)
* [Split Keyboard](feature_split_keyboard.md)
Expand Down
39 changes: 18 additions & 21 deletions docs/adc_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Then place this include at the top of your code:

Note that some of these pins are doubled-up on ADCs with the same channel. This is because the pins can be used for either ADC.

Also note that the F0 and F3 use different numbering schemes. The F0 has a single ADC and the channels are 0-based, whereas the F3 has 4 ADCs and the channels are 1 based. This is because the F0 uses the `ADCv1` implementation of the ADC, whereas the F3 uses the `ADCv3` implementation.
Also note that the F0 and F3 use different numbering schemes. The F0 has a single ADC and the channels are 0-indexed, whereas the F3 has 4 ADCs and the channels are 1-indexed. This is because the F0 uses the `ADCv1` implementation of the ADC, whereas the F3 uses the `ADCv3` implementation.

|ADC|Channel|STM32F0XX|STM32F3XX|
|ADC|Channel|STM32F0xx|STM32F3xx|
|---|-------|---------|---------|
|1 |0 |`A0` | |
|1 |1 |`A1` |`A0` |
Expand Down Expand Up @@ -122,32 +122,29 @@ Also note that the F0 and F3 use different numbering schemes. The F0 has a singl
|Function |Description |
|----------------------------|-------------------------------------------------------------------------------------------------------------------|
|`analogReference(mode)` |Sets the analog voltage reference source. Must be one of `ADC_REF_EXTERNAL`, `ADC_REF_POWER` or `ADC_REF_INTERNAL`.|
|`analogRead(pin)` |Reads the value from the specified Arduino pin, eg. `4` for ADC6 on the ATmega32U4. |
|`analogReadPin(pin)` |Reads the value from the specified QMK pin, eg. `F6` for ADC6 on the ATmega32U4. |
|`pinToMux(pin)` |Translates a given QMK pin to a mux value. If an unsupported pin is given, returns the mux value for "0V (GND)". |
|`analogReadPin(pin)` |Reads the value from the specified pin, eg. `F6` for ADC6 on the ATmega32U4. |
|`pinToMux(pin)` |Translates a given pin to a mux value. If an unsupported pin is given, returns the mux value for "0V (GND)". |
|`adc_read(mux)` |Reads the value from the ADC according to the specified mux. See your MCU's datasheet for more information. |

### ARM

Note that care was taken to match all of the functions used for AVR devices, however complications in the ARM platform prevent that from always being possible. For example, the `STM32` chips do not have assigned Arduino pins. We could use the default pin numbers, but those numbers change based on the package type of the device. For this reason, please specify your target pins with their identifiers (`A0`, `F3`, etc.). Also note that there are some variants of functions that accept the target ADC for the pin. Some pins can be used for multiple ADCs, and this specified can help you pick which ADC will be used to interact with that pin.

|Function |Description |
|----------------------------|--------------------------------------------------------------------------------------------------------------------|
|`analogReadPin(pin)` |Reads the value from the specified QMK pin, eg. `A0` for channel 0 on the STM32F0 and ADC1 channel 1 on the STM32F3. Note that if a pin can be used for multiple ADCs, it will pick the lower numbered ADC for this function. eg. `C0` will be channel 6 of ADC 1 when it could be used for ADC 2 as well.|
|`analogReadPinAdc(pin, adc)`|Reads the value from the specified QMK pin and ADC, eg. `C0, 1` will read from channel 6, ADC 2 instead of ADC 1. Note that the ADCs are 0-indexed for this function.|
|`pinToMux(pin)` |Translates a given QMK pin to a channel and ADC combination. If an unsupported pin is given, returns the mux value for "0V (GND)".|
|`adc_read(mux)` |Reads the value from the ADC according to the specified pin and adc combination. See your MCU's datasheet for more information.|
|Function |Description |
|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`analogReadPin(pin)` |Reads the value from the specified pin, eg. `A0` for channel 0 on the STM32F0 and ADC1 channel 1 on the STM32F3. Note that if a pin can be used for multiple ADCs, it will pick the lower numbered ADC for this function. eg. `C0` will be channel 6 of ADC 1 when it could be used for ADC 2 as well.|
|`analogReadPinAdc(pin, adc)`|Reads the value from the specified pin and ADC, eg. `C0, 1` will read from channel 6, ADC 2 instead of ADC 1. Note that the ADCs are 0-indexed for this function. |
|`pinToMux(pin)` |Translates a given pin to a channel and ADC combination. If an unsupported pin is given, returns the mux value for "0V (GND)". |
|`adc_read(mux)` |Reads the value from the ADC according to the specified pin and ADC combination. See your MCU's datasheet for more information. |

## Configuration

## ARM

The ARM implementation of the ADC has a few additional options that you can override in your own keyboards and keymaps to change how it operates.
The ARM implementation of the ADC has a few additional options that you can override in your own keyboards and keymaps to change how it operates. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options.

|`#define` |Type |Default |Description|
|-------------------|------|---------------------|-----------|
|ADC_CIRCULAR_BUFFER|`bool`|`false` |If `TRUE`, then the implementation will use a circular buffer.|
|ADC_NUM_CHANNELS |`int` |`1` |Sets the number of channels that will be scanned as part of an ADC operation. The current implementation only supports `1`.|
|ADC_BUFFER_DEPTH |`int` |`2` |Sets the depth of each result. Since we are only getting a 12-bit result by default, we set this to `2` bytes so we can contain our one value. This could be set to 1 if you opt for a 8-bit or lower result.|
|ADC_SAMPLING_RATE |`int` |`ADC_SMPR_SMP_1P5` |Sets the sampling rate of the ADC. By default, it is set to the fastest setting. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options.|
|ADC_RESOLUTION |`int` |`ADC_CFGR1_RES_12BIT`|The resolution of your result. We choose 12 bit by default, but you can opt for 12, 10, 8, or 6 bit. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options.|
|`#define` |Type |Default |Description |
|---------------------|------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`ADC_CIRCULAR_BUFFER`|`bool`|`false` |If `true`, then the implementation will use a circular buffer. |
|`ADC_NUM_CHANNELS` |`int` |`1` |Sets the number of channels that will be scanned as part of an ADC operation. The current implementation only supports `1`. |
|`ADC_BUFFER_DEPTH` |`int` |`2` |Sets the depth of each result. Since we are only getting a 12-bit result by default, we set this to 2 bytes so we can contain our one value. This could be set to 1 if you opt for an 8-bit or lower result.|
|`ADC_SAMPLING_RATE` |`int` |`ADC_SMPR_SMP_1P5` |Sets the sampling rate of the ADC. By default, it is set to the fastest setting. |
|`ADC_RESOLUTION` |`int` |`ADC_CFGR1_RES_12BIT`|The resolution of your result. We choose 12 bit by default, but you can opt for 12, 10, 8, or 6 bit. |
100 changes: 84 additions & 16 deletions docs/feature_auto_shift.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,31 @@ problem.
When you tap a key, it stays depressed for a short period of time before it is
then released. This depressed time is a different length for everyone. Auto Shift
defines a constant `AUTO_SHIFT_TIMEOUT` which is typically set to twice your
normal pressed state time. When you press a key, a timer starts and then stops
when you release the key. If the time depressed is greater than or equal to the
`AUTO_SHIFT_TIMEOUT`, then a shifted version of the key is emitted. If the time
is less than the `AUTO_SHIFT_TIMEOUT` time, then the normal state is emitted.
normal pressed state time. When you press a key, a timer starts, and if you
have not released the key after the `AUTO_SHIFT_TIMEOUT` period, then a shifted
version of the key is emitted. If the time is less than the `AUTO_SHIFT_TIMEOUT`
time, or you press another key, then the normal state is emitted.

If `AUTO_SHIFT_REPEAT` is defined, there is keyrepeat support. Holding the key
down will repeat the shifted key, though this can be disabled with
`AUTO_SHIFT_NO_AUTO_REPEAT`. If you want to repeat the normal key, then tap it
once then immediately (within `TAPPING_TERM`) hold it down again (this works
with the shifted value as well if auto-repeat is disabled).

## Are There Limitations to Auto Shift?

Yes, unfortunately.

1. Key repeat will cease to work. For example, before if you wanted 20 'a'
characters, you could press and hold the 'a' key for a second or two. This no
longer works with Auto Shift because it is timing your depressed time instead
of emitting a depressed key state to your operating system.
2. You will have characters that are shifted when you did not intend on shifting, and
other characters you wanted shifted, but were not. This simply comes down to
practice. As we get in a hurry, we think we have hit the key long enough
for a shifted version, but we did not. On the other hand, we may think we are
tapping the keys, but really we have held it for a little longer than
anticipated.
You will have characters that are shifted when you did not intend on shifting, and
other characters you wanted shifted, but were not. This simply comes down to
practice. As we get in a hurry, we think we have hit the key long enough for a
shifted version, but we did not. On the other hand, we may think we are tapping
the keys, but really we have held it for a little longer than anticipated.

Additionally, with keyrepeat the desired shift state can get mixed up. It will
always 'belong' to the last key pressed. For example, keyrepeating a capital
and then tapping something lowercase (whether or not it's an Auto Shift key)
will result in the capital's *key* still being held, but shift not.

## How Do I Enable Auto Shift?

Expand Down Expand Up @@ -80,7 +86,8 @@ A sample is
This controls how long you have to hold a key before you get the shifted state.
Obviously, this is different for everyone. For the common person, a setting of
135 to 150 works great. However, one should start with a value of at least 175, which
is the default value. Then work down from there. The idea is to have the shortest time required to get the shifted state without having false positives.
is the default value. Then work down from there. The idea is to have the shortest
time required to get the shifted state without having false positives.

Play with this value until things are perfect. Many find that all will work well
at a given value, but one or two keys will still emit the shifted state on
Expand All @@ -103,6 +110,67 @@ Do not Auto Shift numeric keys, zero through nine.

Do not Auto Shift alpha characters, which include A through Z.

### AUTO_SHIFT_REPEAT (simple define)

Enables keyrepeat.

### AUTO_SHIFT_NO_AUTO_REPEAT (simple define)

Disables automatically keyrepeating when `AUTO_SHIFT_TIMEOUT` is exceeded.

### Custom Keys and Custom Shifted Values

Especially on small keyboards, the default shifted value for many keys is not
optimal. To provide more customizability, there are three user-definable
functions. The first, `autoshift_is_custom`, is called on every key event and
returns whether it should be a part of Auto Shift. The other two are
`autoshift_press/release_user`, and press or release the passed key. If one
does not require custom shift values but wants custom keys, only
`autoshift_is_custom` is required. Below is an example adding period to Auto
Shift and making its shifted value exclamation point. Make sure to use weak
mods - setting real would make any keys following it use their shifted values
as if you were holding the key. Clearing of modifiers is handled by Auto Shift,
and the os-sent shift value if keyrepeating multiple keys is always that of
the last key pressed (whether or not it's an Auto Shift key).

You can also have non-shifted keys for the shifted values (or even no shifted
value), just don't set a shift modifier!

```c
bool autoshift_is_custom(uint16_t keycode) {
switch(keycode) {
case KC_DOT:
break;
default:
return false;
}
return true;
}
void autoshift_press_user(uint16_t keycode, bool shifted) {
switch(keycode) {
case KC_DOT:
if (!shifted) {
register_code(KC_DOT);
} else {
add_weak_mods(MOD_BIT(KC_LSFT));
register_code(KC_1);
}
default:
if (shifted) { add_weak_mods(MOD_BIT(KC_LSFT)); }
register_code(keycode);
}
}
void autoshift_release_user(uint16_t keycode, bool shifted) {
switch(keycode) {
case KC_DOT:
unregister_code((!shifted) ? KC_DOT : KC_1);
default:
unregister_code(keycode);
}
}
```


## Using Auto Shift Setup

This will enable you to define three keys temporarily to increase, decrease and report your `AUTO_SHIFT_TIMEOUT`.
Expand Down Expand Up @@ -139,7 +207,7 @@ completely normal and with no intention of shifted keys.
`KC_ASRP`. The keyboard will type by itself the value of your
`AUTO_SHIFT_TIMEOUT`.
7. Update `AUTO_SHIFT_TIMEOUT` in your `config.h` with the value reported.
8. Remove `AUTO_SHIFT_SETUP` from your `config.h`.
8. Add `AUTO_SHIFT_NO_SETUP` to your `config.h`.
9. Remove the key bindings `KC_ASDN`, `KC_ASUP` and `KC_ASRP`.
10. Compile and upload your new firmware.

Expand Down
2 changes: 0 additions & 2 deletions docs/feature_backlight.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ See the ST datasheet for your particular MCU to determine these values. Unless y

Currently only hardware PWM is supported, not timer assisted, and does not provide automatic configuration.

?> Backlight support for STM32F072 has had limited testing, so YMMV. If unsure, set `BACKLIGHT_ENABLE = no` in your `rules.mk`.

### Software PWM Driver :id=software-pwm-driver

In this mode, PWM is "emulated" while running other keyboard tasks. It offers maximum hardware compatibility without extra platform configuration. The tradeoff is the backlight might jitter when the keyboard is busy. To enable, add this to your `rules.mk`:
Expand Down
Loading