From b228d2945422a4a5ce596f63fc8841f1b9fc39cf Mon Sep 17 00:00:00 2001 From: Gondolindrim Date: Fri, 8 Oct 2021 21:07:28 -0300 Subject: [PATCH 1/5] Update encoder callback --- keyboards/evolv/config.h | 2 ++ keyboards/evolv/evolv.c | 12 ------------ keyboards/evolv/keymaps/default/keymap.c | 14 ++++++++++++++ keyboards/evolv/keymaps/iso/keymap.c | 14 ++++++++++++++ keyboards/evolv/keymaps/via/keymap.c | 14 ++++++++++++++ keyboards/evolv/mcuconf.h | 4 ---- keyboards/evolv/rules.mk | 9 +++------ 7 files changed, 47 insertions(+), 22 deletions(-) diff --git a/keyboards/evolv/config.h b/keyboards/evolv/config.h index 2b91033c98f0..59223cd2c9dd 100644 --- a/keyboards/evolv/config.h +++ b/keyboards/evolv/config.h @@ -59,6 +59,8 @@ along with this program. If not, see . #define ENCODERS_PAD_A { B3 } #define ENCODERS_PAD_B { A15 } +#define ENCODER_RESOLUTION 2 +#define TAPPING_TERM 200 /* * Feature disable options diff --git a/keyboards/evolv/evolv.c b/keyboards/evolv/evolv.c index 90df449ee204..54f92c9dbc4d 100644 --- a/keyboards/evolv/evolv.c +++ b/keyboards/evolv/evolv.c @@ -16,15 +16,3 @@ along with this program. If not, see . */ #include "evolv.h" - -bool encoder_update_kb(uint8_t index, bool clockwise) { - if (!encoder_update_user(index, clockwise)) return false; - if (index == 0) { /* First encoder */ - if (clockwise) { - tap_code(KC_VOLU); - } else { - tap_code(KC_VOLD); - } - } - return true; -} diff --git a/keyboards/evolv/keymaps/default/keymap.c b/keyboards/evolv/keymaps/default/keymap.c index 5e5e5e7abb63..ed76030ae089 100755 --- a/keyboards/evolv/keymaps/default/keymap.c +++ b/keyboards/evolv/keymaps/default/keymap.c @@ -17,6 +17,8 @@ along with this program. If not, see . #include QMK_KEYBOARD_H +#define MEDIA_KEY_DELAY 100 + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT_evolv_ansi( KC_ESC , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_INS , @@ -47,3 +49,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______) }; + +uint32_t held_keycode_timer = 0; +uint16_t mapped_code = 0; +bool encoder_update_user(uint8_t index, bool clockwise) { + if (clockwise) mapped_code = KC_VOLU; + else mapped_code = KC_VOLD; + register_code(mapped_code); + held_keycode_timer = timer_read32(); + while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ; + unregister_code(mapped_code); + return true; +} diff --git a/keyboards/evolv/keymaps/iso/keymap.c b/keyboards/evolv/keymaps/iso/keymap.c index 4efe8268d350..305ff805ff91 100755 --- a/keyboards/evolv/keymaps/iso/keymap.c +++ b/keyboards/evolv/keymaps/iso/keymap.c @@ -17,6 +17,8 @@ along with this program. If not, see . #include QMK_KEYBOARD_H +#define MEDIA_KEY_DELAY 100 + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT_evolv_iso( KC_ESC , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_INS , @@ -47,3 +49,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______) }; + +uint32_t held_keycode_timer = 0; +uint16_t mapped_code = 0; +bool encoder_update_user(uint8_t index, bool clockwise) { + if (clockwise) mapped_code = KC_VOLU; + else mapped_code = KC_VOLD; + register_code(mapped_code); + held_keycode_timer = timer_read32(); + while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ; + unregister_code(mapped_code); + return true; +} diff --git a/keyboards/evolv/keymaps/via/keymap.c b/keyboards/evolv/keymaps/via/keymap.c index 4efe8268d350..305ff805ff91 100755 --- a/keyboards/evolv/keymaps/via/keymap.c +++ b/keyboards/evolv/keymaps/via/keymap.c @@ -17,6 +17,8 @@ along with this program. If not, see . #include QMK_KEYBOARD_H +#define MEDIA_KEY_DELAY 100 + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT_evolv_iso( KC_ESC , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_INS , @@ -47,3 +49,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______) }; + +uint32_t held_keycode_timer = 0; +uint16_t mapped_code = 0; +bool encoder_update_user(uint8_t index, bool clockwise) { + if (clockwise) mapped_code = KC_VOLU; + else mapped_code = KC_VOLD; + register_code(mapped_code); + held_keycode_timer = timer_read32(); + while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ; + unregister_code(mapped_code); + return true; +} diff --git a/keyboards/evolv/mcuconf.h b/keyboards/evolv/mcuconf.h index 2836e4b01a76..84d14114ff36 100644 --- a/keyboards/evolv/mcuconf.h +++ b/keyboards/evolv/mcuconf.h @@ -23,9 +23,5 @@ #include_next -#undef STM32_I2C_USE_DMA -#define STM32_I2C_USE_DMA FALSE - #undef STM32_SPI_USE_SPI2 #define STM32_SPI_USE_SPI2 TRUE - diff --git a/keyboards/evolv/rules.mk b/keyboards/evolv/rules.mk index 380010c7756f..246ec10d90ea 100644 --- a/keyboards/evolv/rules.mk +++ b/keyboards/evolv/rules.mk @@ -1,17 +1,14 @@ # MCU name MCU = STM32F072 -# Bootloader selection -BOOTLOADER = stm32-dfu - # Build Options # change yes to no to disable # -BOOTMAGIC_ENABLE = lite # Enable Bootmagic Lite +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control -CONSOLE_ENABLE = yes # Console for debug -COMMAND_ENABLE = yes # Commands for debug and configuration +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = 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 From 87f3e4aa36021432fb170e3a0e2fea7c71492da3 Mon Sep 17 00:00:00 2001 From: Gondolindrim Date: Tue, 12 Oct 2021 19:53:37 -0300 Subject: [PATCH 2/5] Move encoder callback - Encoder callback function was moved from ``encoder_update_user`` in ``keymap.c`` to ``encoder_update_kb`` in ``keyboard.c`` --- keyboards/evolv/evolv.c | 21 +++++++++++++++++++++ keyboards/evolv/keymaps/default/keymap.c | 12 ------------ keyboards/evolv/keymaps/iso/keymap.c | 12 ------------ keyboards/evolv/keymaps/via/keymap.c | 12 ------------ 4 files changed, 21 insertions(+), 36 deletions(-) diff --git a/keyboards/evolv/evolv.c b/keyboards/evolv/evolv.c index 54f92c9dbc4d..88aba531323b 100644 --- a/keyboards/evolv/evolv.c +++ b/keyboards/evolv/evolv.c @@ -16,3 +16,24 @@ along with this program. If not, see . */ #include "evolv.h" + +#ifndef MEDIA_KEY_DELAY +# define MEDIA_KEY_DELAY 100 +#endif + + +bool encoder_update_kb(uint8_t index, bool clockwise) { + if (!encoder_update_user(index, clockwise)) return false; + static uint32_t held_keycode_timer = 0; + static uint16_t mapped_code = 0; + if (clockwise) { + mapped_code = KC_VOLU; + } else { + mapped_code = KC_VOLD; + } + register_code(mapped_code); + held_keycode_timer = timer_read32(); + while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ; + unregister_code(mapped_code); + return true; +} diff --git a/keyboards/evolv/keymaps/default/keymap.c b/keyboards/evolv/keymaps/default/keymap.c index ed76030ae089..22866270411e 100755 --- a/keyboards/evolv/keymaps/default/keymap.c +++ b/keyboards/evolv/keymaps/default/keymap.c @@ -49,15 +49,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______) }; - -uint32_t held_keycode_timer = 0; -uint16_t mapped_code = 0; -bool encoder_update_user(uint8_t index, bool clockwise) { - if (clockwise) mapped_code = KC_VOLU; - else mapped_code = KC_VOLD; - register_code(mapped_code); - held_keycode_timer = timer_read32(); - while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ; - unregister_code(mapped_code); - return true; -} diff --git a/keyboards/evolv/keymaps/iso/keymap.c b/keyboards/evolv/keymaps/iso/keymap.c index 305ff805ff91..391bcdf5bbf1 100755 --- a/keyboards/evolv/keymaps/iso/keymap.c +++ b/keyboards/evolv/keymaps/iso/keymap.c @@ -49,15 +49,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______) }; - -uint32_t held_keycode_timer = 0; -uint16_t mapped_code = 0; -bool encoder_update_user(uint8_t index, bool clockwise) { - if (clockwise) mapped_code = KC_VOLU; - else mapped_code = KC_VOLD; - register_code(mapped_code); - held_keycode_timer = timer_read32(); - while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ; - unregister_code(mapped_code); - return true; -} diff --git a/keyboards/evolv/keymaps/via/keymap.c b/keyboards/evolv/keymaps/via/keymap.c index 305ff805ff91..391bcdf5bbf1 100755 --- a/keyboards/evolv/keymaps/via/keymap.c +++ b/keyboards/evolv/keymaps/via/keymap.c @@ -49,15 +49,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______) }; - -uint32_t held_keycode_timer = 0; -uint16_t mapped_code = 0; -bool encoder_update_user(uint8_t index, bool clockwise) { - if (clockwise) mapped_code = KC_VOLU; - else mapped_code = KC_VOLD; - register_code(mapped_code); - held_keycode_timer = timer_read32(); - while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ; - unregister_code(mapped_code); - return true; -} From 045dcfbaa2dc16b4a6ac360866cac4f4575a3eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20A=2E=20Volpato?= Date: Wed, 20 Oct 2021 23:48:02 -0300 Subject: [PATCH 3/5] Update keyboards/evolv/rules.mk Co-authored-by: Ryan --- keyboards/evolv/rules.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/keyboards/evolv/rules.mk b/keyboards/evolv/rules.mk index 246ec10d90ea..b0f7124c08ec 100644 --- a/keyboards/evolv/rules.mk +++ b/keyboards/evolv/rules.mk @@ -1,6 +1,9 @@ # MCU name MCU = STM32F072 +# Bootloader selection +BOOTLOADER = stm32-dfu + # Build Options # change yes to no to disable # From 0f8d47ef5586d0052f23317a83d021cc422b1d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20A=2E=20Volpato?= Date: Thu, 21 Oct 2021 00:11:19 -0300 Subject: [PATCH 4/5] Use tap_code() on encoder callback Co-authored-by: Ryan --- keyboards/evolv/evolv.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/keyboards/evolv/evolv.c b/keyboards/evolv/evolv.c index 88aba531323b..a0c2aae94d47 100644 --- a/keyboards/evolv/evolv.c +++ b/keyboards/evolv/evolv.c @@ -24,16 +24,6 @@ along with this program. If not, see . bool encoder_update_kb(uint8_t index, bool clockwise) { if (!encoder_update_user(index, clockwise)) return false; - static uint32_t held_keycode_timer = 0; - static uint16_t mapped_code = 0; - if (clockwise) { - mapped_code = KC_VOLU; - } else { - mapped_code = KC_VOLD; - } - register_code(mapped_code); - held_keycode_timer = timer_read32(); - while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ; - unregister_code(mapped_code); + tap_code(clockwise ? KC_VOLU : KC_VOLD, MEDIA_KEY_DELAY); return true; } From 63cd03cf6167ce5545d051cb3a3afed920e57058 Mon Sep 17 00:00:00 2001 From: Gondolindrim Date: Thu, 21 Oct 2021 00:30:17 -0300 Subject: [PATCH 5/5] Use tap_code_delay --- keyboards/evolv/evolv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/keyboards/evolv/evolv.c b/keyboards/evolv/evolv.c index a0c2aae94d47..3f2762894614 100644 --- a/keyboards/evolv/evolv.c +++ b/keyboards/evolv/evolv.c @@ -21,9 +21,8 @@ along with this program. If not, see . # define MEDIA_KEY_DELAY 100 #endif - bool encoder_update_kb(uint8_t index, bool clockwise) { if (!encoder_update_user(index, clockwise)) return false; - tap_code(clockwise ? KC_VOLU : KC_VOLD, MEDIA_KEY_DELAY); + tap_code_delay(clockwise ? KC_VOLU : KC_VOLD, MEDIA_KEY_DELAY); return true; }