-- | Like 'withPin', but for 'OutputPin's. Sets the pin's output mode
-- to the specified 'PinOutputMode' value.
--
-- The 'PinValue' argument specifies the pin's initial output value.
-- It is relative to the active level argument, or to the pin's
-- current active level if the active level argument is 'Nothing'.
--
-- It is an error to call this action if the pin cannot be configured
-- for output, or if it does not support the specified output mode.
withOutputPin :: (MaskGpioM h m) => Pin -> PinOutputMode -> Maybe PinActiveLevel -> PinValue -> (OutputPin h -> m a) -> m a
withOutputPin p mode l v action =
  withPin p $ \h ->
    do maybeSetPinActiveLevel h l
       setPinOutputMode h mode v
       action $ OutputPin h

-- | Like 'writePin'.
withOutputPin :: (MaskGpioM h m) => Pin -> PinOutputMode -> Maybe PinActiveLevel -> PinValue -> (OutputPin h -> m a) -> m a
withOutputPin p mode l v action =
  withPin p $ \h ->
    do maybeSetPinActiveLevel h l
       setPinOutputMode h mode v
       action $ OutputPin h

-- | Like 'writePin'.
withOutputPin p mode l v action =
  withPin p $ \h ->
    do maybeSetPinActiveLevel h l
       setPinOutputMode h mode v
       action $ OutputPin h

-- | Like 'writePin'.