Safe Haskell | None |
---|---|
Language | Haskell98 |
Copilot.Arduino.Library.Serial
Description
Serial port library for arduino-copilot.
This module is designed to be imported qualified as Serial
Synopsis
- baud :: Int -> Sketch ()
- output :: Stream Bool -> [FormatOutput] -> Sketch ()
- 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
- input :: Input Int8
- input' :: [Int8] -> Input Int8
- noInput :: Int8
- 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.
Arguments
:: Stream Bool | This Stream controls when output is sent to the serial port. |
-> [FormatOutput] | |
-> Sketch () |
Output to the serial port.
Note that this can only be used once in a Sketch.
main = arduino $ do Serial.baud 9600 b <- readfrom pin3 n <- readvoltage a1 Serial.output true [ Serial.str "pin3:" , Serial.show b , Serial.str " a1:" , Serial.show n , Serial.char '\n' ]
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.show (constant (1.234 :: Float)) 2 -- "1.23"
When used with any Integral type, provide the Base
to display it in
Serial.show (constant (78 :: Int8)) Serial.HEX -- "4E"
Input from the serial port.
Reads one byte on each iteration of the sketch. When there is no
serial input available, reads noInput
.
userinput <- Serial.input
input' :: [Int8] -> Input Int8 Source #
The list is used to simulate serial input when interpreting the program.
class ShowableType t Source #
Minimal complete definition
showCType
Instances
ShowableType Bool Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Double Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Float Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Int8 Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Int16 Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Int32 Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Int64 Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Word8 Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Word16 Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Word32 Source # | |
Defined in Copilot.Arduino.Library.Serial | |
ShowableType Word64 Source # | |
Defined in Copilot.Arduino.Library.Serial |
class FormatableType t f Source #
Minimal complete definition
formatter