-
Notifications
You must be signed in to change notification settings - Fork 1.3k
dbounce: add instant-read for probing moves #4052
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,49 @@ | ||
| component dbounce """alternative debounce component"""; | ||
| description """ | ||
| This component is similar to the *debounce*(9) component but uses settable | ||
| delay pins for each instance and supports *count*= or *names*= parameters | ||
| (groups are not used) | ||
| component dbounce """alternative debounce component\n | ||
| This component is similar to the \\fBdebounce\\fR component | ||
| (man \\fBdebounce\\fR) but uses settable delay pins for each instance | ||
| and supports \\fBcount\\fR= or \\fBnames\\fR= parameters | ||
| (groups are not used). It also supports an instant-hit mode for probing moves | ||
| where the output changes immediately but further changes (bounces) | ||
| are ignored until stable. | ||
| """; | ||
|
|
||
| pin in bit in; | ||
| pin out bit out; | ||
| pin in u32 delay = 5; | ||
| pin in u32 delay = 5 "delay in cycles when not probing"; | ||
| pin in u32 probedelay = 0 "delay in cycles when probing (if unconnected, uses delay)"; | ||
| pin in s32 motiontype = -1 """connect to motion.motion-type - | ||
| when equal to 5 it means probing"""; | ||
|
|
||
| variable unsigned state; | ||
| option period no; | ||
| function _; | ||
| /*variable int state;*/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to keep this as a comment? |
||
| pin out u32 state; | ||
| function _ nofp; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There no longer is a difference between |
||
| license "GPL"; | ||
| author "Dewey Garrett"; | ||
| ;; | ||
| FUNCTION(_) { | ||
| int d = (motiontype == 5 && probedelay > 0) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using an The reason is that the variable |
||
| ? probedelay : delay; | ||
|
|
||
| if (in) { | ||
| /* probing, trigger on first edge. */ | ||
| if (motiontype == 5 && state == 0) { | ||
| state = d / 2; | ||
| out = 1; | ||
| /* input true, is state at threshold? */ | ||
| if (state < delay) { | ||
| } else if (state < d) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a comparison with different signedness. |
||
| /* no, increment */ | ||
| state++; | ||
| } else { | ||
| /* yes, set output */ | ||
| out = 1; | ||
| } | ||
| } else { | ||
| /* probing, trigger on first edge. */ | ||
| if (motiontype == 5 && state >= d) { | ||
| state = d / 2; | ||
| out = 0; | ||
| /* input false, is state at zero? */ | ||
| if (state > 0) { | ||
| } else if (state > 0) { | ||
| /* no, decrement */ | ||
| state--; | ||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a reason why the
option period nois present. The code does not use the period argument in the_function and it would therefore result in a warning, which are now treated as errors.