diff options
Diffstat (limited to 'drivers/haptic/haptic.c')
| -rw-r--r-- | drivers/haptic/haptic.c | 85 |
1 files changed, 41 insertions, 44 deletions
diff --git a/drivers/haptic/haptic.c b/drivers/haptic/haptic.c index 989970bee..2ce279b75 100644 --- a/drivers/haptic/haptic.c +++ b/drivers/haptic/haptic.c | |||
| @@ -169,12 +169,12 @@ void haptic_set_mode(uint8_t mode) { | |||
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | void haptic_set_amplitude(uint8_t amp) { | 171 | void haptic_set_amplitude(uint8_t amp) { |
| 172 | haptic_config.amplitude = amp; | 172 | haptic_config.amplitude = amp; |
| 173 | eeconfig_update_haptic(haptic_config.raw); | 173 | eeconfig_update_haptic(haptic_config.raw); |
| 174 | xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude); | 174 | xprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude); |
| 175 | #ifdef DRV2605L | 175 | #ifdef DRV2605L |
| 176 | DRV_amplitude(amp); | 176 | DRV_amplitude(amp); |
| 177 | #endif | 177 | #endif |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | void haptic_set_buzz(uint8_t buzz) { | 180 | void haptic_set_buzz(uint8_t buzz) { |
| @@ -211,52 +211,50 @@ uint8_t haptic_get_dwell(void) { | |||
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | void haptic_enable_continuous(void) { | 213 | void haptic_enable_continuous(void) { |
| 214 | haptic_config.cont = 1; | 214 | haptic_config.cont = 1; |
| 215 | xprintf("haptic_config.cont = %u\n", haptic_config.cont); | 215 | xprintf("haptic_config.cont = %u\n", haptic_config.cont); |
| 216 | eeconfig_update_haptic(haptic_config.raw); | 216 | eeconfig_update_haptic(haptic_config.raw); |
| 217 | #ifdef DRV2605L | 217 | #ifdef DRV2605L |
| 218 | DRV_rtp_init(); | 218 | DRV_rtp_init(); |
| 219 | #endif | 219 | #endif |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | void haptic_disable_continuous(void) { | 222 | void haptic_disable_continuous(void) { |
| 223 | haptic_config.cont = 0; | 223 | haptic_config.cont = 0; |
| 224 | xprintf("haptic_config.cont = %u\n", haptic_config.cont); | 224 | xprintf("haptic_config.cont = %u\n", haptic_config.cont); |
| 225 | eeconfig_update_haptic(haptic_config.raw); | 225 | eeconfig_update_haptic(haptic_config.raw); |
| 226 | #ifdef DRV2605L | 226 | #ifdef DRV2605L |
| 227 | DRV_write(DRV_MODE,0x00); | 227 | DRV_write(DRV_MODE, 0x00); |
| 228 | #endif | 228 | #endif |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | void haptic_toggle_continuous(void) { | 231 | void haptic_toggle_continuous(void) { |
| 232 | #ifdef DRV2605L | 232 | #ifdef DRV2605L |
| 233 | if (haptic_config.cont) { | 233 | if (haptic_config.cont) { |
| 234 | haptic_disable_continuous(); | 234 | haptic_disable_continuous(); |
| 235 | } else { | 235 | } else { |
| 236 | haptic_enable_continuous(); | 236 | haptic_enable_continuous(); |
| 237 | } | 237 | } |
| 238 | eeconfig_update_haptic(haptic_config.raw); | 238 | eeconfig_update_haptic(haptic_config.raw); |
| 239 | #endif | 239 | #endif |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | |||
| 243 | void haptic_cont_increase(void) { | 242 | void haptic_cont_increase(void) { |
| 244 | uint8_t amp = haptic_config.amplitude + 10; | 243 | uint8_t amp = haptic_config.amplitude + 10; |
| 245 | if (haptic_config.amplitude >= 120) { | 244 | if (haptic_config.amplitude >= 120) { |
| 246 | amp = 120; | 245 | amp = 120; |
| 247 | } | 246 | } |
| 248 | haptic_set_amplitude(amp); | 247 | haptic_set_amplitude(amp); |
| 249 | } | 248 | } |
| 250 | 249 | ||
| 251 | void haptic_cont_decrease(void) { | 250 | void haptic_cont_decrease(void) { |
| 252 | uint8_t amp = haptic_config.amplitude - 10; | 251 | uint8_t amp = haptic_config.amplitude - 10; |
| 253 | if (haptic_config.amplitude < 20) { | 252 | if (haptic_config.amplitude < 20) { |
| 254 | amp = 20; | 253 | amp = 20; |
| 255 | } | 254 | } |
| 256 | haptic_set_amplitude(amp); | 255 | haptic_set_amplitude(amp); |
| 257 | } | 256 | } |
| 258 | 257 | ||
| 259 | |||
| 260 | void haptic_play(void) { | 258 | void haptic_play(void) { |
| 261 | #ifdef DRV2605L | 259 | #ifdef DRV2605L |
| 262 | uint8_t play_eff = 0; | 260 | uint8_t play_eff = 0; |
| @@ -269,7 +267,6 @@ void haptic_play(void) { | |||
| 269 | } | 267 | } |
| 270 | 268 | ||
| 271 | bool process_haptic(uint16_t keycode, keyrecord_t *record) { | 269 | bool process_haptic(uint16_t keycode, keyrecord_t *record) { |
| 272 | |||
| 273 | if (keycode == HPT_ON && record->event.pressed) { | 270 | if (keycode == HPT_ON && record->event.pressed) { |
| 274 | haptic_enable(); | 271 | haptic_enable(); |
| 275 | } | 272 | } |
| @@ -300,16 +297,16 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) { | |||
| 300 | if (keycode == HPT_DWLD && record->event.pressed) { | 297 | if (keycode == HPT_DWLD && record->event.pressed) { |
| 301 | haptic_dwell_decrease(); | 298 | haptic_dwell_decrease(); |
| 302 | } | 299 | } |
| 303 | if (keycode == HPT_CONT && record->event.pressed) { | 300 | if (keycode == HPT_CONT && record->event.pressed) { |
| 304 | haptic_toggle_continuous(); | 301 | haptic_toggle_continuous(); |
| 305 | } | 302 | } |
| 306 | if (keycode == HPT_CONI && record->event.pressed) { | 303 | if (keycode == HPT_CONI && record->event.pressed) { |
| 307 | haptic_cont_increase(); | 304 | haptic_cont_increase(); |
| 308 | } | 305 | } |
| 309 | if (keycode == HPT_COND && record->event.pressed) { | 306 | if (keycode == HPT_COND && record->event.pressed) { |
| 310 | haptic_cont_decrease(); | 307 | haptic_cont_decrease(); |
| 311 | } | 308 | } |
| 312 | 309 | ||
| 313 | if (haptic_config.enable) { | 310 | if (haptic_config.enable) { |
| 314 | if (record->event.pressed) { | 311 | if (record->event.pressed) { |
| 315 | // keypress | 312 | // keypress |
