From 6b6667f573cd4dd342f0e67d96a70629048cb5e1 Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Sat, 22 Jul 2023 04:50:12 -0500 Subject: [PATCH 1/5] Enable solenoid haptics on secondary keyboards --- quantum/haptic.c | 13 ++++++++++++- quantum/keyboard.c | 14 +++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/quantum/haptic.c b/quantum/haptic.c index c151547fcafc..dad6bd715b46 100644 --- a/quantum/haptic.c +++ b/quantum/haptic.c @@ -19,6 +19,8 @@ #include "debug.h" #include "usb_device_state.h" #include "gpio.h" +#include "keyboard.h" + #ifdef DRV2605L # include "DRV2605L.h" #endif @@ -55,6 +57,11 @@ static void set_haptic_config_enable(bool enabled) { } void haptic_init(void) { +// only initialize on secondary boards if the user desires +#if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE) + if (!is_keyboard_master()) return; +#endif + if (!eeconfig_is_enabled()) { eeconfig_init(); } @@ -96,8 +103,12 @@ void haptic_init(void) { void haptic_task(void) { #ifdef SOLENOID_ENABLE - solenoid_check(); +// Only run task on seconary boards if the user desires +#if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE) + if (!is_keyboard_master()) return; #endif + solenoid_check(); +#endif // SOLENOID_ENABLE } void eeconfig_debug_haptic(void) { diff --git a/quantum/keyboard.c b/quantum/keyboard.c index 511570974878..630df5cc7f39 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -365,9 +365,6 @@ void quantum_init(void) { #if defined(UNICODE_COMMON_ENABLE) unicode_input_mode_init(); #endif -#ifdef HAPTIC_ENABLE - haptic_init(); -#endif } /** \brief keyboard_init @@ -432,6 +429,9 @@ void keyboard_init(void) { #ifdef BLUETOOTH_ENABLE bluetooth_init(); #endif +#ifdef HAPTIC_ENABLE + haptic_init(); +#endif #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) debug_enable = true; @@ -587,10 +587,6 @@ void quantum_task(void) { decay_wpm(); #endif -#ifdef HAPTIC_ENABLE - haptic_task(); -#endif - #ifdef DIP_SWITCH_ENABLE dip_switch_read(false); #endif @@ -696,5 +692,9 @@ void keyboard_task(void) { bluetooth_task(); #endif +#ifdef HAPTIC_ENABLE + haptic_task(); +#endif + led_task(); } From d331530088f7b5bb9b5e3c630bc05417e54e66cb Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Sat, 22 Jul 2023 05:01:25 -0500 Subject: [PATCH 2/5] use dwell from haptic_config in solenoid driver --- drivers/haptic/solenoid.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c index 4e4390325527..da4095cda4d2 100644 --- a/drivers/haptic/solenoid.c +++ b/drivers/haptic/solenoid.c @@ -23,7 +23,6 @@ #include "util.h" #include -uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL; static pin_t solenoid_pads[] = SOLENOID_PINS; #define NUMBER_OF_SOLENOIDS ARRAY_SIZE(solenoid_pads) bool solenoid_on[NUMBER_OF_SOLENOIDS] = {false}; @@ -53,7 +52,7 @@ void solenoid_set_buzz(uint8_t buzz) { } void solenoid_set_dwell(uint8_t dwell) { - solenoid_dwell = dwell; + haptic_set_dwell(dwell); } /** @@ -119,7 +118,7 @@ void solenoid_check(void) { elapsed[i] = timer_elapsed(solenoid_start[i]); // Check if it's time to finish this solenoid click cycle - if (elapsed[i] > solenoid_dwell) { + if (elapsed[i] > haptic_config.dwell) { solenoid_stop(i); continue; } From 75a18a245eacc4a256be7d30093abaef5e3e690c Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Sat, 22 Jul 2023 05:22:09 -0500 Subject: [PATCH 3/5] Update docs for SPLIT_HAPTIC_ENABLE --- docs/feature_split_keyboard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/feature_split_keyboard.md b/docs/feature_split_keyboard.md index 1705ea922217..c67f04995b3a 100644 --- a/docs/feature_split_keyboard.md +++ b/docs/feature_split_keyboard.md @@ -298,7 +298,7 @@ This enables transmitting the pointing device status to the master side of the s #define SPLIT_HAPTIC_ENABLE ``` -This enables triggering of haptic feedback on the slave side of the split keyboard. For DRV2605L this will send the mode, but for solenoids it is expected that the desired mode is already set up on the slave. +This enables the triggering of haptic feedback on the slave side of the split keyboard. This will send information to the slave side such as the mode, dwell, and whether buzz is enabled. ```c #define SPLIT_ACTIVITY_ENABLE From 11d90cc1c0c5daf4c6142d26e891de4117f81ce4 Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Sat, 22 Jul 2023 06:40:13 -0500 Subject: [PATCH 4/5] Rename constant to work with develop branch --- quantum/haptic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/haptic.c b/quantum/haptic.c index ed73646cd61f..eba4b462096f 100644 --- a/quantum/haptic.c +++ b/quantum/haptic.c @@ -104,13 +104,13 @@ void haptic_init(void) { } void haptic_task(void) { -#ifdef SOLENOID_ENABLE +#ifdef HAPTIC_SOLENOID // Only run task on seconary boards if the user desires #if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE) if (!is_keyboard_master()) return; #endif solenoid_check(); -#endif // SOLENOID_ENABLE +#endif // HAPTIC_SOLENOID } void eeconfig_debug_haptic(void) { From c6fb501b6e2ed0cc3bc5c7f36fa4d0f1b6dc5143 Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Sat, 22 Jul 2023 06:54:37 -0500 Subject: [PATCH 5/5] Linting --- quantum/haptic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/haptic.c b/quantum/haptic.c index eba4b462096f..446e7ab1af8f 100644 --- a/quantum/haptic.c +++ b/quantum/haptic.c @@ -106,9 +106,9 @@ void haptic_init(void) { void haptic_task(void) { #ifdef HAPTIC_SOLENOID // Only run task on seconary boards if the user desires -#if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE) +# if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE) if (!is_keyboard_master()) return; -#endif +# endif solenoid_check(); #endif // HAPTIC_SOLENOID }