summaryrefslogtreecommitdiff
path: root/quantum/haptic.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/haptic.c')
-rw-r--r--quantum/haptic.c81
1 files changed, 42 insertions, 39 deletions
diff --git a/quantum/haptic.c b/quantum/haptic.c
index c151547fca..13b2258eb8 100644
--- a/quantum/haptic.c
+++ b/quantum/haptic.c
@@ -14,17 +14,20 @@
* 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 "haptic.h"
#include "eeconfig.h"
#include "debug.h"
#include "usb_device_state.h"
#include "gpio.h"
-#ifdef DRV2605L
-# include "DRV2605L.h"
+
+#ifdef HAPTIC_DRV2605L
+# include "drv2605l.h"
#endif
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
# include "solenoid.h"
#endif
+
#if defined(SPLIT_KEYBOARD) && defined(SPLIT_HAPTIC_ENABLE)
extern uint8_t split_haptic_play;
#endif
@@ -59,11 +62,11 @@ void haptic_init(void) {
eeconfig_init();
}
haptic_config.raw = eeconfig_read_haptic();
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
solenoid_set_dwell(haptic_config.dwell);
#endif
if ((haptic_config.raw == 0)
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
|| (haptic_config.dwell == 0)
#endif
) {
@@ -77,12 +80,12 @@ void haptic_init(void) {
// This is to execute any side effects of the configuration.
set_haptic_config_enable(haptic_config.enable);
}
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
solenoid_setup();
dprintf("Solenoid driver initialized\n");
#endif
-#ifdef DRV2605L
- DRV_init();
+#ifdef HAPTIC_DRV2605L
+ drv2605l_init();
dprintf("DRV2605 driver initialized\n");
#endif
eeconfig_debug_haptic();
@@ -95,7 +98,7 @@ void haptic_init(void) {
}
void haptic_task(void) {
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
solenoid_check();
#endif
}
@@ -108,13 +111,13 @@ void eeconfig_debug_haptic(void) {
void haptic_enable(void) {
set_haptic_config_enable(true);
- xprintf("haptic_config.enable = %u\n", haptic_config.enable);
+ dprintf("haptic_config.enable = %u\n", haptic_config.enable);
eeconfig_update_haptic(haptic_config.raw);
}
void haptic_disable(void) {
set_haptic_config_enable(false);
- xprintf("haptic_config.enable = %u\n", haptic_config.enable);
+ dprintf("haptic_config.enable = %u\n", haptic_config.enable);
eeconfig_update_haptic(haptic_config.raw);
}
@@ -130,7 +133,7 @@ void haptic_toggle(void) {
void haptic_feedback_toggle(void) {
haptic_config.feedback++;
if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX) haptic_config.feedback = KEY_PRESS;
- xprintf("haptic_config.feedback = %u\n", !haptic_config.feedback);
+ dprintf("haptic_config.feedback = %u\n", !haptic_config.feedback);
eeconfig_update_haptic(haptic_config.raw);
}
@@ -142,7 +145,7 @@ void haptic_buzz_toggle(void) {
void haptic_mode_increase(void) {
uint8_t mode = haptic_config.mode + 1;
-#ifdef DRV2605L
+#ifdef HAPTIC_DRV2605L
if (haptic_config.mode >= drv_effect_max) {
mode = 1;
}
@@ -152,7 +155,7 @@ void haptic_mode_increase(void) {
void haptic_mode_decrease(void) {
uint8_t mode = haptic_config.mode - 1;
-#ifdef DRV2605L
+#ifdef HAPTIC_DRV2605L
if (haptic_config.mode < 1) {
mode = (drv_effect_max - 1);
}
@@ -161,7 +164,7 @@ void haptic_mode_decrease(void) {
}
void haptic_dwell_increase(void) {
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
int16_t next_dwell = ((int16_t)haptic_config.dwell) + SOLENOID_DWELL_STEP_SIZE;
if (haptic_config.dwell >= SOLENOID_MAX_DWELL) {
// if it's already at max, we wrap back to min
@@ -178,7 +181,7 @@ void haptic_dwell_increase(void) {
}
void haptic_dwell_decrease(void) {
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
int16_t next_dwell = ((int16_t)haptic_config.dwell) - SOLENOID_DWELL_STEP_SIZE;
if (haptic_config.dwell <= SOLENOID_MIN_DWELL) {
// if it's already at min, we wrap to max
@@ -196,13 +199,13 @@ void haptic_dwell_decrease(void) {
void haptic_reset(void) {
set_haptic_config_enable(true);
- uint8_t feedback = HAPTIC_FEEDBACK_DEFAULT;
+ uint8_t feedback = HAPTIC_DEFAULT_FEEDBACK;
haptic_config.feedback = feedback;
-#ifdef DRV2605L
- uint8_t mode = HAPTIC_MODE_DEFAULT;
+#ifdef HAPTIC_DRV2605L
+ uint8_t mode = HAPTIC_DEFAULT_MODE;
haptic_config.mode = mode;
#endif
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
uint8_t dwell = SOLENOID_DEFAULT_DWELL;
haptic_config.dwell = dwell;
haptic_config.buzz = SOLENOID_DEFAULT_BUZZ;
@@ -213,41 +216,41 @@ void haptic_reset(void) {
haptic_config.buzz = 0;
#endif
eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
- xprintf("haptic_config.mode = %u\n", haptic_config.mode);
+ dprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
+ dprintf("haptic_config.mode = %u\n", haptic_config.mode);
}
void haptic_set_feedback(uint8_t feedback) {
haptic_config.feedback = feedback;
eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
+ dprintf("haptic_config.feedback = %u\n", haptic_config.feedback);
}
void haptic_set_mode(uint8_t mode) {
haptic_config.mode = mode;
eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.mode = %u\n", haptic_config.mode);
+ dprintf("haptic_config.mode = %u\n", haptic_config.mode);
}
void haptic_set_amplitude(uint8_t amp) {
haptic_config.amplitude = amp;
eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude);
-#ifdef DRV2605L
- DRV_amplitude(amp);
+ dprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude);
+#ifdef HAPTIC_DRV2605L
+ drv2605l_amplitude(amp);
#endif
}
void haptic_set_buzz(uint8_t buzz) {
haptic_config.buzz = buzz;
eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.buzz = %u\n", haptic_config.buzz);
+ dprintf("haptic_config.buzz = %u\n", haptic_config.buzz);
}
void haptic_set_dwell(uint8_t dwell) {
haptic_config.dwell = dwell;
eeconfig_update_haptic(haptic_config.raw);
- xprintf("haptic_config.dwell = %u\n", haptic_config.dwell);
+ dprintf("haptic_config.dwell = %u\n", haptic_config.dwell);
}
uint8_t haptic_get_enable(void) {
@@ -277,19 +280,19 @@ uint8_t haptic_get_dwell(void) {
void haptic_enable_continuous(void) {
haptic_config.cont = 1;
- xprintf("haptic_config.cont = %u\n", haptic_config.cont);
+ dprintf("haptic_config.cont = %u\n", haptic_config.cont);
eeconfig_update_haptic(haptic_config.raw);
-#ifdef DRV2605L
- DRV_rtp_init();
+#ifdef HAPTIC_DRV2605L
+ drv2605l_rtp_init();
#endif
}
void haptic_disable_continuous(void) {
haptic_config.cont = 0;
- xprintf("haptic_config.cont = %u\n", haptic_config.cont);
+ dprintf("haptic_config.cont = %u\n", haptic_config.cont);
eeconfig_update_haptic(haptic_config.raw);
-#ifdef DRV2605L
- DRV_write(DRV_MODE, 0x00);
+#ifdef HAPTIC_DRV2605L
+ drv2605l_write(DRV2605L_REG_MODE, 0x00);
#endif
}
@@ -318,15 +321,15 @@ void haptic_cont_decrease(void) {
}
void haptic_play(void) {
-#ifdef DRV2605L
+#ifdef HAPTIC_DRV2605L
uint8_t play_eff = 0;
play_eff = haptic_config.mode;
- DRV_pulse(play_eff);
+ drv2605l_pulse(play_eff);
# if defined(SPLIT_KEYBOARD) && defined(SPLIT_HAPTIC_ENABLE)
split_haptic_play = haptic_config.mode;
# endif
#endif
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
solenoid_fire_handler();
# if defined(SPLIT_KEYBOARD) && defined(SPLIT_HAPTIC_ENABLE)
split_haptic_play = 1;
@@ -335,7 +338,7 @@ void haptic_play(void) {
}
void haptic_shutdown(void) {
-#ifdef SOLENOID_ENABLE
+#ifdef HAPTIC_SOLENOID
solenoid_shutdown();
#endif
}