getPinData :: IPin -> Arduino PinData
getPinData p = do
  bs  <- gets boardState
  err <- gets bailOut
  liftIO $ withMVar bs $ \bst ->
     case p `M.lookup` pinStates bst of
       Nothing -> err ("Trying to access " ++ show p ++ " without proper configuration.")
                      ["Make sure that you use 'setPinMode' to configure this pin first."]
       Just pd -> return pd

-- | Given a pin, collect the digital value corresponding to the
-- port it belongs to, where the new value of the current pin is given
-- The result is two bytes:
--
--   * First  lsb: pins 0-6 on the port
--   * Second msb: pins 7-13 on the port
--
-- In particular, the result is suitable to be sent with a digital message
getPinData :: IPin -> Arduino PinData
getPinData p = do
  bs  <- gets boardState
  err <- gets bailOut
  liftIO $ withMVar bs $ \bst ->
     case p `M.lookup` pinStates bst of
       Nothing -> err ("Trying to access " ++ show p ++ " without proper configuration.")
                      ["Make sure that you use 'setPinMode' to configure this pin first."]
       Just pd -> return pd

-- | Given a pin, collect the digital value corresponding to the
-- port it belongs to, where the new value of the current pin is given
-- The result is two bytes:
--
--   * First  lsb: pins 0-6 on the port
--   * Second msb: pins 7-13 on the port
--
-- In particular, the result is suitable to be sent with a digital message
getPinData p = do
  bs  <- gets boardState
  err <- gets bailOut
  liftIO $ withMVar bs $ \bst ->
     case p `M.lookup` pinStates bst of
       Nothing -> err ("Trying to access " ++ show p ++ " without proper configuration.")
                      ["Make sure that you use 'setPinMode' to configure this pin first."]
       Just pd -> return pd

-- | Given a pin, collect the digital value corresponding to the
-- port it belongs to, where the new value of the current pin is given
-- The result is two bytes:
--
--   * First  lsb: pins 0-6 on the port
--   * Second msb: pins 7-13 on the port
--
-- In particular, the result is suitable to be sent with a digital message