debounce.hs

来自「Cores are generated from Confluence a mo」· HS 代码 · 共 30 行

HS
30
字号
-- | 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 + =
减小字号Ctrl + -
显示快捷键?