Add support for switches using an AC detection circuitry #8606
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:
MOES MS-104B and many of its clones (mine is a BlitzWolf SS5 2 gang) using an AC detection circuitry to emulate switches. This circuit generates a ~4 ms long LOW pulse in every AC period if the external switch is pressed.
My solution is to use the switch debouncing code to detect these AC pulses, so these switches can work almost out-of-the-box. The SwitchDebounce parameter controls the AC detection. If the last digit is 9, it will activate the AC detection code. The other part of the parameter behaves exactly as expected: e.g. 69 means 60 msec debounce time (60 msec / (1 / 50 Hz) -> 3 pulses).
I wanted to be as non-intrusive as possible, so I kept the polling code, but I had to call it 5x faster to detect pulses (of course only if AC detection is requested).
Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass