{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Copilot.Zephyr (
zephyr,
Sketch,
Pin,
Zephyr,
Behavior,
TypedBehavior(..),
Event,
(@:),
Input,
input,
input',
pullup,
Output,
(=:),
delay,
MilliSeconds(..),
MicroSeconds(..),
IsDigitalIOPin,
IsAnalogInputPin,
IsPWMPin,
blinking,
firstIteration,
frequency,
sketchSpec,
liftB,
liftB2,
whenB,
scheduleB,
ifThenElse,
IfThenElse,
Stream,
module X,
) where
import Language.Copilot as X hiding (Stream, ifThenElse)
import Language.Copilot (Stream)
import Sketch.FRP.Copilot
import Copilot.Zephyr.Internals
import Copilot.Zephyr.Main
import Control.Monad.Writer
import qualified Data.Map as M
import qualified Data.Set as S
pullup :: IsDigitalIOPin t => Pin t -> Sketch ()
pullup :: Pin t -> Sketch ()
pullup (Pin Zephyr
p) = [(TriggerLimit -> WriterT [SpecItem] Identity (),
TriggerLimit -> GenFramework Zephyr)]
-> Sketch ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [(\TriggerLimit
_ -> () -> WriterT [SpecItem] Identity ()
forall (m :: * -> *) a. Monad m => a -> m a
return (), \TriggerLimit
_ -> GenFramework Zephyr
f)]
where
f :: GenFramework Zephyr
f = (Context Zephyr => GenFramework Zephyr
forall ctx. Context ctx => GenFramework ctx
emptyFramework @Zephyr)
{ pinmodes :: Map Zephyr (Set PinMode)
pinmodes = Zephyr -> Set PinMode -> Map Zephyr (Set PinMode)
forall k a. k -> a -> Map k a
M.singleton Zephyr
p (PinMode -> Set PinMode
forall a. a -> Set a
S.singleton PinMode
InputPullupMode)
}