Last active
October 13, 2018 01:31
-
-
Save eschen42/28c1f77eb6aefbe0c10a609004b04313 to your computer and use it in GitHub Desktop.
Icon code for positive-edge triggered bistable multivibrator
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
procedure co_bistable(off_state, on_state) | |
local button, bistable_button, bistable_state | |
/off_state := "off" | |
/on_state := "on" | |
bistable_button := bistable_state := button := off_state | |
return create while button := ( | |
if button ~== bistable_button | |
then if (bistable_button := button) == on_state | |
then bistable_state := if bistable_state == off_state | |
then on_state | |
else off_state | |
else &null | |
else &null | |
, bistable_state | |
) @ &source | |
end | |
procedure main() | |
local bistable, i | |
bistable := co_bistable("no","yes") | |
every i := 1 to 30 do { | |
if 1 = ?2 | |
then write(" button -> off yields state ", "no" @ bistable) | |
else write("button -> ON yields state ", "yes" @ bistable) | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment