Safe Haskell | None |
---|---|
Language | Haskell98 |
Serial port library for arduino-copilot.
This module is designed to be imported qualified as Serial
Synopsis
- baud :: Int -> Sketch ()
- device :: SerialDevice
- char :: Char -> FormatOutput
- str :: String -> FormatOutput
- show :: forall t. (ShowableType t, Typed t) => Stream t -> FormatOutput
- showFormatted :: forall t f. (ShowableType t, Typed t, FormatableType t f) => Stream t -> f -> FormatOutput
- byte :: Stream Int8 -> FormatOutput
- noInput :: Int8
- data SerialDevice
- data FormatOutput
- class ShowableType t
- class FormatableType t f
- data Base
Documentation
baud :: Int -> Sketch () Source #
Configure the baud rate of the serial port.
This must be included in your sketch if it uses the serial port.
device :: SerialDevice Source #
Use this to communicate with the serial port, both input and output.
To output to the serial port, simply connect this to a [FormatOutput
]
that describes the serial output. Note that you can only do this once
in a Sketch.
main = arduino $ doa Serial.baud 9600 b <- input pin4 Serial.device =: [ Serial.str "pin4:" , Serial.show b , Serial.char '\n' ]
To input from the serial port, use this with input
.
userinput <- input Serial.device
The resulting `Behavior Int8` will be updated on each iteration
of the sketch. When there is no new serial input available, it will
contain noInput
.
char :: Char -> FormatOutput Source #
Use this to output a Char
str :: String -> FormatOutput Source #
Use this to output a String
show :: forall t. (ShowableType t, Typed t) => Stream t -> FormatOutput Source #
Use this to show the current value of a Stream.
Numbers will be formatted in decimal. Bool is displayed as 0 and 1.
showFormatted :: forall t f. (ShowableType t, Typed t, FormatableType t f) => Stream t -> f -> FormatOutput Source #
Show the current value of a Stream with control over the formatting.
When used with a Float, provide the number of decimal places to show.
Serial.showFormatted (constant (1.234 :: Float)) 2 -- "1.23"
When used with any Integral type, provide the Base
to display it in
Serial.showFormatted (constant (78 :: Int8)) Serial.HEX -- "4E"
data SerialDevice Source #
Instances
Input SerialDevice Int8 Source # | |
Defined in Copilot.Arduino.Library.Serial.Device | |
Output SerialDevice [FormatOutput] Source # | |
Defined in Copilot.Arduino.Library.Serial.Device (=:) :: SerialDevice -> [FormatOutput] -> Sketch () Source # | |
Output SerialDevice (Event () [FormatOutput]) Source # | |
Defined in Copilot.Arduino.Library.Serial.Device (=:) :: SerialDevice -> Event () [FormatOutput] -> Sketch () Source # |
data FormatOutput Source #
Instances
Output SerialDevice [FormatOutput] Source # | |
Defined in Copilot.Arduino.Library.Serial.Device (=:) :: SerialDevice -> [FormatOutput] -> Sketch () Source # | |
Output SerialDevice (Event () [FormatOutput]) Source # | |
Defined in Copilot.Arduino.Library.Serial.Device (=:) :: SerialDevice -> Event () [FormatOutput] -> Sketch () Source # | |
IsBehavior [FormatOutput] Source # | |
Defined in Copilot.Arduino.Library.Serial.Device (@:) :: [FormatOutput] -> Behavior Bool -> BehaviorToEvent [FormatOutput] Source # | |
type BehaviorToEvent [FormatOutput] Source # | |
Defined in Copilot.Arduino.Library.Serial.Device |
class ShowableType t Source #
Instances
class FormatableType t f Source #