dbounce: add instant-read for probing moves#4052
Conversation
Add motiontype and probedelay pins If motiontype is 5, then the logic changes as follows: - if state is max or min (i.e. signal stable), the first change forces an output change and sets state to the midpoint The effective result is that an input change after the delay expires, causes an immediate output change, but any further transitions within the delay are ignored. If probedelay is set (non-zero) it is used instead of delay during probing moves. If motiontype is not connected, the behavior is as it was before this patch, for backward compatibility.
| function _; | ||
| /*variable int state;*/ | ||
| pin out u32 state; | ||
| function _ nofp; |
There was a problem hiding this comment.
There no longer is a difference between fp and nofp. All threads are now floating point because newer compilers use sophisticated optimizations using special (floating point) registers. The nofp must not be used anymore and you should not change this line.
| when equal to 5 it means probing"""; | ||
|
|
||
| variable unsigned state; | ||
| option period no; |
There was a problem hiding this comment.
There is a reason why the option period no is 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.
| out = 1; | ||
| /* input true, is state at threshold? */ | ||
| if (state < delay) { | ||
| } else if (state < d) { |
There was a problem hiding this comment.
This is a comparison with different signedness.
| variable unsigned state; | ||
| option period no; | ||
| function _; | ||
| /*variable int state;*/ |
There was a problem hiding this comment.
Is there a reason to keep this as a comment?
| author "Dewey Garrett"; | ||
| ;; | ||
| FUNCTION(_) { | ||
| int d = (motiontype == 5 && probedelay > 0) |
There was a problem hiding this comment.
Using an int results in line 33 with a signdness mismatch.
The reason is that the variable d is declared an int, which should have been rtapi_u32 to make it consistent with the underlying types used in delay and probedelay.
Add motiontype and probedelay pins
If motiontype is 5, then the logic changes as follows:
The effective result is that an input change after the delay expires, causes an immediate output change, but any further transitions within the delay are ignored.
If probedelay is set (non-zero) it is used instead of delay during probing moves.
If motiontype is not connected, the behavior is as it was before this patch, for backward compatibility.