-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace timedelay with a .comp version, so that we get uniform naming…
… and automatic documentation
- Loading branch information
Showing
3 changed files
with
43 additions
and
255 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
component timedelay "The equivalent of a time-delay relay"; | ||
|
||
pin in bit in; | ||
pin out bit out """Follows the value of \\fBin\\fR after applying the delays | ||
\\fBon-delay\\fR and \\fBoff-delay\\fR."""; | ||
|
||
param rw float on-delay = 0.5 """The time, in seconds, for which \\fBin\\fR must be | ||
\\fBtrue\\fR before \\fBout\\fR becomes \\fBtrue\\fR"""; | ||
param rw float off-delay = 0.5 """The time, in seconds, for which \\fBin\\fR must be | ||
\\fBfalse\\fR before \\fBout\\fR becomes \\fBfalse\\fR"""; | ||
|
||
param r float elapsed "Current value of the internal timer"; | ||
variable double timer; | ||
|
||
function _; | ||
|
||
license "GPL"; | ||
author "Jeff Epler, based on works by Stephen Wille Padnos and John Kasunich"; | ||
;; | ||
hal_bit_t in_ = in; | ||
if(in_ != out) { | ||
timer += fperiod; | ||
elapsed = timer; | ||
if(in_) { | ||
if(timer >= on_delay) { | ||
out = 1; | ||
timer = 0.0; | ||
} | ||
} else { | ||
if(timer >= off_delay) { | ||
out = 0; | ||
timer = 0.0; | ||
} | ||
} | ||
} else { | ||
timer = 0.0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters