|
|
|
@ -169,12 +169,12 @@ void haptic_set_mode(uint8_t mode) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void haptic_set_amplitude(uint8_t amp) {
|
|
|
|
void haptic_set_amplitude(uint8_t amp) {
|
|
|
|
haptic_config.amplitude = amp;
|
|
|
|
haptic_config.amplitude = amp;
|
|
|
|
eeconfig_update_haptic(haptic_config.raw);
|
|
|
|
eeconfig_update_haptic(haptic_config.raw);
|
|
|
|
xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude);
|
|
|
|
xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude);
|
|
|
|
#ifdef DRV2605L
|
|
|
|
#ifdef DRV2605L
|
|
|
|
DRV_amplitude(amp);
|
|
|
|
DRV_amplitude(amp);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void haptic_set_buzz(uint8_t buzz) {
|
|
|
|
void haptic_set_buzz(uint8_t buzz) {
|
|
|
|
@ -211,52 +211,50 @@ uint8_t haptic_get_dwell(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void haptic_enable_continuous(void) {
|
|
|
|
void haptic_enable_continuous(void) {
|
|
|
|
haptic_config.cont = 1;
|
|
|
|
haptic_config.cont = 1;
|
|
|
|
xprintf("haptic_config.cont = %u\n", haptic_config.cont);
|
|
|
|
xprintf("haptic_config.cont = %u\n", haptic_config.cont);
|
|
|
|
eeconfig_update_haptic(haptic_config.raw);
|
|
|
|
eeconfig_update_haptic(haptic_config.raw);
|
|
|
|
#ifdef DRV2605L
|
|
|
|
#ifdef DRV2605L
|
|
|
|
DRV_rtp_init();
|
|
|
|
DRV_rtp_init();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void haptic_disable_continuous(void) {
|
|
|
|
void haptic_disable_continuous(void) {
|
|
|
|
haptic_config.cont = 0;
|
|
|
|
haptic_config.cont = 0;
|
|
|
|
xprintf("haptic_config.cont = %u\n", haptic_config.cont);
|
|
|
|
xprintf("haptic_config.cont = %u\n", haptic_config.cont);
|
|
|
|
eeconfig_update_haptic(haptic_config.raw);
|
|
|
|
eeconfig_update_haptic(haptic_config.raw);
|
|
|
|
#ifdef DRV2605L
|
|
|
|
#ifdef DRV2605L
|
|
|
|
DRV_write(DRV_MODE,0x00);
|
|
|
|
DRV_write(DRV_MODE, 0x00);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void haptic_toggle_continuous(void) {
|
|
|
|
void haptic_toggle_continuous(void) {
|
|
|
|
#ifdef DRV2605L
|
|
|
|
#ifdef DRV2605L
|
|
|
|
if (haptic_config.cont) {
|
|
|
|
if (haptic_config.cont) {
|
|
|
|
haptic_disable_continuous();
|
|
|
|
haptic_disable_continuous();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
haptic_enable_continuous();
|
|
|
|
haptic_enable_continuous();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eeconfig_update_haptic(haptic_config.raw);
|
|
|
|
eeconfig_update_haptic(haptic_config.raw);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void haptic_cont_increase(void) {
|
|
|
|
void haptic_cont_increase(void) {
|
|
|
|
uint8_t amp = haptic_config.amplitude + 10;
|
|
|
|
uint8_t amp = haptic_config.amplitude + 10;
|
|
|
|
if (haptic_config.amplitude >= 120) {
|
|
|
|
if (haptic_config.amplitude >= 120) {
|
|
|
|
amp = 120;
|
|
|
|
amp = 120;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
haptic_set_amplitude(amp);
|
|
|
|
haptic_set_amplitude(amp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void haptic_cont_decrease(void) {
|
|
|
|
void haptic_cont_decrease(void) {
|
|
|
|
uint8_t amp = haptic_config.amplitude - 10;
|
|
|
|
uint8_t amp = haptic_config.amplitude - 10;
|
|
|
|
if (haptic_config.amplitude < 20) {
|
|
|
|
if (haptic_config.amplitude < 20) {
|
|
|
|
amp = 20;
|
|
|
|
amp = 20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
haptic_set_amplitude(amp);
|
|
|
|
haptic_set_amplitude(amp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void haptic_play(void) {
|
|
|
|
void haptic_play(void) {
|
|
|
|
#ifdef DRV2605L
|
|
|
|
#ifdef DRV2605L
|
|
|
|
uint8_t play_eff = 0;
|
|
|
|
uint8_t play_eff = 0;
|
|
|
|
@ -269,7 +267,6 @@ void haptic_play(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool process_haptic(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
bool process_haptic(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
|
|
|
|
|
|
|
|
if (keycode == HPT_ON && record->event.pressed) {
|
|
|
|
if (keycode == HPT_ON && record->event.pressed) {
|
|
|
|
haptic_enable();
|
|
|
|
haptic_enable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -300,16 +297,16 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
if (keycode == HPT_DWLD && record->event.pressed) {
|
|
|
|
if (keycode == HPT_DWLD && record->event.pressed) {
|
|
|
|
haptic_dwell_decrease();
|
|
|
|
haptic_dwell_decrease();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (keycode == HPT_CONT && record->event.pressed) {
|
|
|
|
if (keycode == HPT_CONT && record->event.pressed) {
|
|
|
|
haptic_toggle_continuous();
|
|
|
|
haptic_toggle_continuous();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (keycode == HPT_CONI && record->event.pressed) {
|
|
|
|
if (keycode == HPT_CONI && record->event.pressed) {
|
|
|
|
haptic_cont_increase();
|
|
|
|
haptic_cont_increase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (keycode == HPT_COND && record->event.pressed) {
|
|
|
|
if (keycode == HPT_COND && record->event.pressed) {
|
|
|
|
haptic_cont_decrease();
|
|
|
|
haptic_cont_decrease();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (haptic_config.enable) {
|
|
|
|
if (haptic_config.enable) {
|
|
|
|
if (record->event.pressed) {
|
|
|
|
if (record->event.pressed) {
|
|
|
|
// keypress
|
|
|
|
// keypress
|
|
|
|
|