Skip to content

Send pedal position on change#3

Merged
dmadison merged 9 commits intomasterfrom
pedal-deadzone
May 30, 2022
Merged

Send pedal position on change#3
dmadison merged 9 commits intomasterfrom
pedal-deadzone

Conversation

@dmadison
Copy link
Copy Markdown
Owner

These changes make it so that pedal data in the PedalsJoystick example is only sent whenever the pedals actually move. The goal is to avoid spamming games with pedal input and grabbing focus away from other input devices like wheels or mice. The latter of which makes it really difficult to actually set up the pedals in certain games. This can be overridden with an option in the example to restore its previous behavior.

Because of an underlying change to the AnalogInput class, all classes that use an ADC input will only report changes if the ADC input is within the calibration range (to avoid saying "data changed" when it's outside of the range we are reporting). The Handbrake class is the one most noticeably affected.

Pedal serial calibration now includes deadzone options for the start and end of the travel range. The former should reduce issues with pedals being always "on", the latter should reduce issues with being unable to get the pedal to 100%. Both are set at low values by default (1% and 2.5%, respectively). These only affect serial (conversational) calibration. Applied calibration is unmodified.

This also slightly adjusts the calibration of the Logitech pedals' brake, which was registering a constant low input during more thorough testing.

dmadison added 9 commits May 30, 2022 13:52
This was slightly "riding" the brake output on my setup.
Similar to gearChanged() for the shifter, this saves the 'changed' return value from the update function so it can be retrieved later to see if any of the pedal positions have changed since the last call.
Matching the layout of the ShiftJoystick example, this only sends the Joystick USB packet if the pedals have actually changed position. This should avoid issues with the pedals "spamming" inputs and stealing a game's input priority even when they're constantly 0.
For checking whether a value is within the calibrated range.
Changing my mind on this. Going to tackle it in another way.

This reverts commit 6c5ba50.
Fixes a bug where pedal state would not be detected until the pedals were moved for the first time.

Also refactors the function name from "updatePedals" to "updateJoystick", as the pedal object is updated from within loop().
Instead of detecting simply if the ADC value changed, this now checks if the changed value is outside of the calibrated range (in the same direction it was previously). If so, the user-facing classes aren't going to care and can safely ignore the update.

This was written specifically to solve an issue with the pedals, which don't need to send constant updates when they're at their resting position.
This allows the user to set independent 'start' and 'end' deadzones for their pedal serial calibration. The purpose is to prevent pedals from being slightly pressed in their resting position, and to prevent pedals from reaching their 100% "pressed" position at full extension.

By default, this uses a 1% deadzone for the start of travel and a 2.5% deadzone for the end of travel.

I'm trying to be conservative here, because the last thing I want is for a user to set a large deadzone and then be unable to compensate for it when using the pedals as an HID device. Still, I think a tiny bit of fuzzing is good and can compensate for noise at the input extremes.
Restores the old behavior of the example if set. Always nice to have an override.
@dmadison dmadison merged commit 078c5e0 into master May 30, 2022
@dmadison dmadison deleted the pedal-deadzone branch May 30, 2022 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant