Safe Haskell | None |
---|---|
Language | Haskell98 |
Copilot.Arduino.Library.Serial.XBee
Description
XBee serial library for arduino-copilot.
This module is designed to be imported qualified as XBee
Synopsis
- newtype Baud = Baud Int
- device :: (IsDigitalIOPin rx, IsDigitalIOPin tx) => Pin rx -> Pin tx -> Baud -> 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
- byte :: Stream Int8 -> FormatOutput
- input :: Input Int8
- input' :: [Int8] -> Input Int8
- noInput :: Int8
- class ShowableType t
- class FormatableType t f
- data Base
Documentation
Arguments
:: (IsDigitalIOPin rx, IsDigitalIOPin tx) | |
=> Pin rx | pin on which to receive serial data |
-> Pin tx | pin on which to transfer serial data |
-> Baud | |
-> Sketch () |
Configure the XBee device.
This must be included in your sketch if it uses XBee.
XBee.device pin2 pin3 (XBee.Baud 9600)
Arguments
:: Stream Bool | This Stream controls when output is sent to the XBee. |
-> [FormatOutput] | |
-> Sketch () |
Output to XBee.
Note that this can only be used once in a Sketch.
main = arduino $ doa XBee.device pin2 pin3 (XBee.Baud 9600) b <- readfrom pin4 n <- readvoltage a1 XBee.output true [ Serial.str "pin4:" , Serial.show b , Serial.str " a1:" , Serial.show n , Serial.char '\n' ]
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"
Input from the XBee.
Reads one byte on each iteration of the sketch. When there is no
serial input available, reads noInput
.
userinput <- XBee.input
input' :: [Int8] -> Input Int8 Source #
The list is used to simulate Xbee input when interpreting the program.
class ShowableType t Source #
Minimal complete definition
Instances
class FormatableType t f Source #
Minimal complete definition