📄 debounce.hs
字号:
-- | Debouncing a boolean signal.module Language.Atom.Common.Debounce ( debounce ) whereimport Language.Atomimport Language.Atom.Common.Timer-- | Debounces a boolean given a scope name, number of stable cycles, and an initial condition.debounce :: Name -> Int -> Bool -> Term Bool -> System (Term Bool)debounce name num init input = scope name $ do assert "positiveNumber" $ num >= 0 state <- bool "state" init last <- bool "last" init count <- timer "count" rule "reset" $ do when $ input /=. value last start count num last <== input rule "update" $ do whenDone count state <== input return $ value state
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -