summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacob-w-gable <82864625+jacob-w-gable@users.noreply.github.com>2023-09-24 21:23:31 -0500
committerGitHub <noreply@github.com>2023-09-25 12:23:31 +1000
commit99290b4c7e891e69ca161d79c74a0e32014645bb (patch)
treee52a0ab1c51c56a78a8157169fb0a8f7c0acdfc2
parent7a761ebf7dfc4aa27132583a9a7ba7790df72b32 (diff)
Add full solenoid support on split keyboards (#21583)
Co-authored-by: Jacob Gable <jacob.gable@statheros.tech>
-rw-r--r--docs/feature_split_keyboard.md2
-rw-r--r--drivers/haptic/solenoid.c5
-rw-r--r--quantum/haptic.c12
-rw-r--r--quantum/keyboard.c14
4 files changed, 21 insertions, 12 deletions
diff --git a/docs/feature_split_keyboard.md b/docs/feature_split_keyboard.md
index 1705ea9222..c67f04995b 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
298#define SPLIT_HAPTIC_ENABLE 298#define SPLIT_HAPTIC_ENABLE
299``` 299```
300 300
301This 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. 301This 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.
302 302
303```c 303```c
304#define SPLIT_ACTIVITY_ENABLE 304#define SPLIT_ACTIVITY_ENABLE
diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c
index 4e43903255..da4095cda4 100644
--- a/drivers/haptic/solenoid.c
+++ b/drivers/haptic/solenoid.c
@@ -23,7 +23,6 @@
23#include "util.h" 23#include "util.h"
24#include <stdlib.h> 24#include <stdlib.h>
25 25
26uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
27static pin_t solenoid_pads[] = SOLENOID_PINS; 26static pin_t solenoid_pads[] = SOLENOID_PINS;
28#define NUMBER_OF_SOLENOIDS ARRAY_SIZE(solenoid_pads) 27#define NUMBER_OF_SOLENOIDS ARRAY_SIZE(solenoid_pads)
29bool solenoid_on[NUMBER_OF_SOLENOIDS] = {false}; 28bool solenoid_on[NUMBER_OF_SOLENOIDS] = {false};
@@ -53,7 +52,7 @@ void solenoid_set_buzz(uint8_t buzz) {
53} 52}
54 53
55void solenoid_set_dwell(uint8_t dwell) { 54void solenoid_set_dwell(uint8_t dwell) {
56 solenoid_dwell = dwell; 55 haptic_set_dwell(dwell);
57} 56}
58 57
59/** 58/**
@@ -119,7 +118,7 @@ void solenoid_check(void) {
119 elapsed[i] = timer_elapsed(solenoid_start[i]); 118 elapsed[i] = timer_elapsed(solenoid_start[i]);
120 119
121 // Check if it's time to finish this solenoid click cycle 120 // Check if it's time to finish this solenoid click cycle
122 if (elapsed[i] > solenoid_dwell) { 121 if (elapsed[i] > haptic_config.dwell) {
123 solenoid_stop(i); 122 solenoid_stop(i);
124 continue; 123 continue;
125 } 124 }
diff --git a/quantum/haptic.c b/quantum/haptic.c
index 5a700dca38..a1fea29625 100644
--- a/quantum/haptic.c
+++ b/quantum/haptic.c
@@ -20,6 +20,7 @@
20#include "debug.h" 20#include "debug.h"
21#include "usb_device_state.h" 21#include "usb_device_state.h"
22#include "gpio.h" 22#include "gpio.h"
23#include "keyboard.h"
23 24
24#ifdef HAPTIC_DRV2605L 25#ifdef HAPTIC_DRV2605L
25# include "drv2605l.h" 26# include "drv2605l.h"
@@ -58,6 +59,11 @@ static void set_haptic_config_enable(bool enabled) {
58} 59}
59 60
60void haptic_init(void) { 61void haptic_init(void) {
62// only initialize on secondary boards if the user desires
63#if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE)
64 if (!is_keyboard_master()) return;
65#endif
66
61 if (!eeconfig_is_enabled()) { 67 if (!eeconfig_is_enabled()) {
62 eeconfig_init(); 68 eeconfig_init();
63 } 69 }
@@ -99,8 +105,12 @@ void haptic_init(void) {
99 105
100void haptic_task(void) { 106void haptic_task(void) {
101#ifdef HAPTIC_SOLENOID 107#ifdef HAPTIC_SOLENOID
108// Only run task on seconary boards if the user desires
109# if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE)
110 if (!is_keyboard_master()) return;
111# endif
102 solenoid_check(); 112 solenoid_check();
103#endif 113#endif // HAPTIC_SOLENOID
104} 114}
105 115
106void eeconfig_debug_haptic(void) { 116void eeconfig_debug_haptic(void) {
diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index c2ca15d52d..cf3361dff9 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -395,9 +395,6 @@ void quantum_init(void) {
395#if defined(UNICODE_COMMON_ENABLE) 395#if defined(UNICODE_COMMON_ENABLE)
396 unicode_input_mode_init(); 396 unicode_input_mode_init();
397#endif 397#endif
398#ifdef HAPTIC_ENABLE
399 haptic_init();
400#endif
401} 398}
402 399
403/** \brief keyboard_init 400/** \brief keyboard_init
@@ -462,6 +459,9 @@ void keyboard_init(void) {
462#ifdef BLUETOOTH_ENABLE 459#ifdef BLUETOOTH_ENABLE
463 bluetooth_init(); 460 bluetooth_init();
464#endif 461#endif
462#ifdef HAPTIC_ENABLE
463 haptic_init();
464#endif
465 465
466#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) 466#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
467 debug_enable = true; 467 debug_enable = true;
@@ -617,10 +617,6 @@ void quantum_task(void) {
617 decay_wpm(); 617 decay_wpm();
618#endif 618#endif
619 619
620#ifdef HAPTIC_ENABLE
621 haptic_task();
622#endif
623
624#ifdef DIP_SWITCH_ENABLE 620#ifdef DIP_SWITCH_ENABLE
625 dip_switch_read(false); 621 dip_switch_read(false);
626#endif 622#endif
@@ -726,5 +722,9 @@ void keyboard_task(void) {
726 bluetooth_task(); 722 bluetooth_task();
727#endif 723#endif
728 724
725#ifdef HAPTIC_ENABLE
726 haptic_task();
727#endif
728
729 led_task(); 729 led_task();
730} 730}