SwitchMultiPos Enhancement for Swtiches.h #58
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The current version of the SwitchMultiPos has an issue for non-shorting multi-position rotary switches when one of the positions isn't connected to an Arduino pin. While using PIN_NC to default to a position that's not hooked up to a pin the switch's DCSBios output bounces between the default position and the next selected pin. This is caused by the fact that in the middle of a rotation step none of the pins are connected to ground. By adding debounce logic to the multi-position switch , the time when the switch is between steps is ignored.
Closes #57
Testing
This was tested both in the console, and in DCS. The example was ran for an F/A-18, INS switch. In particular having this switch bounce to the off position at each step of the turn after aligning the INS would be extremely annoying. After the debounce logic was added the switch rotates as expected and doesn't bounce to the default position.
In addition to testing for the case with PIN_NC set, the scenario where all pins are connected continues to work.
Example Code:
Output Prior to SwitchMultiPos Update:
Similar results occur regardless of which position is default / not connected to an Arduino pin.
Output After Logic Fix Added
Position 0 is still the default