module Control.Debounce (
DI.DebounceSettings,
defaultDebounceSettings,
DI.debounceFreq,
DI.debounceAction,
DI.debounceEdge,
DI.debounceThreadName,
DI.leadingEdge,
DI.trailingEdge,
mkDebounce,
) where
import Control.Concurrent (newEmptyMVar, threadDelay)
import qualified Control.Debounce.Internal as DI
defaultDebounceSettings :: DI.DebounceSettings
defaultDebounceSettings :: DebounceSettings
defaultDebounceSettings =
DI.DebounceSettings
{ debounceFreq :: Int
DI.debounceFreq = Int
1000000
, debounceAction :: IO ()
DI.debounceAction = () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
, debounceEdge :: DebounceEdge
DI.debounceEdge = DebounceEdge
DI.leadingEdge
, debounceThreadName :: String
DI.debounceThreadName = String
"Debounce"
}
mkDebounce :: DI.DebounceSettings -> IO (IO ())
mkDebounce :: DebounceSettings -> IO (IO ())
mkDebounce DebounceSettings
settings = do
MVar ()
baton <- IO (MVar ())
forall a. IO (MVar a)
newEmptyMVar
MVar () -> (Int -> IO ()) -> DebounceSettings -> IO (IO ())
DI.mkDebounceInternal MVar ()
baton Int -> IO ()
threadDelay DebounceSettings
settings