Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haptic and solenoid cleanup #9700

Merged
merged 14 commits into from
Oct 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
drivers/haptic: fix compilation issue, when haptic is enabled, but so…
…lenoid isn't
  • Loading branch information
purdeaandrei committed Sep 13, 2020
commit d5c748e2aa4ab99ee30d175c6228560a770611d6
8 changes: 6 additions & 2 deletions drivers/haptic/haptic.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void haptic_mode_decrease(void) {
}

void haptic_dwell_increase(void) {
int16_t next_dwell = ((int16_t)haptic_config.dwell) + SOLENOID_DWELL_STEP_SIZE;
#ifdef SOLENOID_ENABLE
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
next_dwell = SOLENOID_MIN_DWELL;
Expand All @@ -135,13 +135,15 @@ void haptic_dwell_increase(void) {
next_dwell = SOLENOID_MAX_DWELL;
}
solenoid_set_dwell(next_dwell);
#else
int16_t next_dwell = ((int16_t)haptic_config.dwell) + 1;
#endif
haptic_set_dwell(next_dwell);
}

void haptic_dwell_decrease(void) {
int16_t next_dwell = ((int16_t)haptic_config.dwell) - SOLENOID_DWELL_STEP_SIZE;
#ifdef SOLENOID_ENABLE
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
next_dwell = SOLENOID_MAX_DWELL;
Expand All @@ -150,6 +152,8 @@ void haptic_dwell_decrease(void) {
next_dwell = SOLENOID_MIN_DWELL;
}
solenoid_set_dwell(next_dwell);
#else
int16_t next_dwell = ((int16_t)haptic_config.dwell) - 1;
#endif
haptic_set_dwell(next_dwell);
}
Expand Down