Safe Haskell | None |
---|---|
Language | Haskell98 |
Copilot.Arduino.Internals
Description
You should not need to import this module unless you're adding support for a new model of Arduino, or an Arduino library.
Synopsis
- newtype Sketch t = Sketch (Writer [(Spec, Framework)] t)
- data Framework = Framework {}
- newtype CLine = CLine {}
- class ToFramework t where
- toFramework :: t -> Framework
- type Behavior t = Stream t -> Spec
- data Output t = Output {
- setupOutput :: [CLine]
- outputPinmode :: Map PinId PinMode
- outputCond :: Stream Bool
- outputBehavior :: Stream Bool -> Behavior t
- type Input t = Sketch (Stream t)
- data InputSource t = InputSource {
- defineVar :: [CLine]
- setupInput :: [CLine]
- inputPinmode :: Map PinId PinMode
- readInput :: [CLine]
- inputStream :: Stream t
- mkInput :: InputSource t -> Input t
- newtype Pin t = Pin PinId
- newtype PinId = PinId Int16
- data PinCapabilities
- = DigitalIO
- | AnalogInput
- | PWM
- type family IsDigitalIOPin t where ...
- type family IsAnalogInputPin t where ...
- type family IsPWMPin t where ...
- type family HasPinCapability (c :: t) (list :: [t]) :: Bool where ...
- type family SameCapability (a :: PinCapabilities) (b :: PinCapabilities) :: Bool where ...
- data PinMode
- type MicroSeconds = Int16
Documentation
An Arduino sketch, implemented using Copilot.
It's best to think of the Sketch
as a description of the state of the
Arduino at any point in time.
Under the hood, the Sketch
is run in a loop. On each iteration, it first
reads all inputs and then updates outputs as needed. While it is a monad,
a Sketch's outputs are not updated in any particular order, because
Copilot does not guarantee any order.
The framework of an Arduino sketch.
Constructors
Framework | |
class ToFramework t where Source #
Methods
toFramework :: t -> Framework Source #
Instances
ToFramework (InputSource t) Source # | |
Defined in Copilot.Arduino.Internals Methods toFramework :: InputSource t -> Framework Source # | |
ToFramework (Output t) Source # | |
Defined in Copilot.Arduino.Internals Methods toFramework :: Output t -> Framework Source # |
Somewhere that a Stream can be directed to, in order to control the Arduino.
Constructors
Output | |
Fields
|
Instances
ToFramework (Output t) Source # | |
Defined in Copilot.Arduino.Internals Methods toFramework :: Output t -> Framework Source # |
data InputSource t Source #
Constructors
InputSource | |
Fields
|
Instances
ToFramework (InputSource t) Source # | |
Defined in Copilot.Arduino.Internals Methods toFramework :: InputSource t -> Framework Source # |
mkInput :: InputSource t -> Input t Source #
A pin on the Arduino board.
For definitions of pins like pin12
,
load a module such as Copilot.Arduino.Uno, which provides the pins of a
particular board.
Some pins can only be used for digital IO, while others support analog input and/or digital IO. A type-level list of PinCapabilties indicates how a Pin can be used.
data PinCapabilities Source #
Constructors
DigitalIO | |
AnalogInput | |
PWM |
Instances
Eq PinCapabilities Source # | |
Defined in Copilot.Arduino.Internals Methods (==) :: PinCapabilities -> PinCapabilities -> Bool # (/=) :: PinCapabilities -> PinCapabilities -> Bool # | |
Ord PinCapabilities Source # | |
Defined in Copilot.Arduino.Internals Methods compare :: PinCapabilities -> PinCapabilities -> Ordering # (<) :: PinCapabilities -> PinCapabilities -> Bool # (<=) :: PinCapabilities -> PinCapabilities -> Bool # (>) :: PinCapabilities -> PinCapabilities -> Bool # (>=) :: PinCapabilities -> PinCapabilities -> Bool # max :: PinCapabilities -> PinCapabilities -> PinCapabilities # min :: PinCapabilities -> PinCapabilities -> PinCapabilities # | |
Show PinCapabilities Source # | |
Defined in Copilot.Arduino.Internals Methods showsPrec :: Int -> PinCapabilities -> ShowS # show :: PinCapabilities -> String # showList :: [PinCapabilities] -> ShowS # |
type family IsDigitalIOPin t where ... Source #
Equations
IsDigitalIOPin t = True ~ If (HasPinCapability DigitalIO t) True (TypeError (Text "This Pin does not support digital IO")) |
type family IsAnalogInputPin t where ... Source #
Equations
IsAnalogInputPin t = True ~ If (HasPinCapability AnalogInput t) True (TypeError (Text "This Pin does not support analog input")) |
type family HasPinCapability (c :: t) (list :: [t]) :: Bool where ... Source #
Equations
HasPinCapability c '[] = False | |
HasPinCapability c (x ': xs) = SameCapability c x || HasPinCapability c xs |
type family SameCapability (a :: PinCapabilities) (b :: PinCapabilities) :: Bool where ... Source #
Equations
SameCapability DigitalIO DigitalIO = True | |
SameCapability AnalogInput AnalogInput = True | |
SameCapability PWM PWM = True | |
SameCapability _ _ = False |
Constructors
InputMode | |
InputPullupMode | |
OutputMode |
type MicroSeconds = Int16 Source #