direction
The pin’s usage: input
or output
.
var direction: Direction { get set }
The pin’s usage: input
or output
.
var direction: Direction { get set }
import SwiftIO
The SwiftIO library allows you to access and control the hardware in an easy way.
final class DigitalInOut
The DigitalInOut class allows you to set both input and output for a digital pin.
enum Direction
Includes the functionalities of the digital pin: input or output.
init(_ idName: Id, direction: Direction = .output, outputMode: DigitalOut.Mode = .pushPull, inputMode: DigitalIn.Mode = .pullUp, outputValue: Bool = false)
Initializes a digital pin as input or output pin.
var inputMode: DigitalIn.Mode { get set }
The pin’s mode when used for input: pullUp
, pullDown
, pullNone
let obj: UnsafeMutableRawPointer
var outputMode: DigitalOut.Mode { get set }
The pin’s mode when used for output: pushPull/openDrain.
func getDirection() -> Direction
Knows if the pin is used for input or output.
func getInputMode() -> DigitalIn.Mode
Gets the configuration of the internal pull-up and pull-down resistor on a specified input pin.
func getOutputMode() -> DigitalOut.Mode
Gets the current output mode (pushPull
/openDrain
) on a specified pin.
func high()
Sets the output value to true.
func low()
Sets the output value to false.
func read() -> Bool
Reads the value from the pin.
@discardableResult func setToInput(_ mode: DigitalIn.Mode? = nil) -> Result<(), Errno>
Sets the pin to read digital input.
@discardableResult func setToOutput(_ mode: DigitalOut.Mode? = nil, value: Bool? = nil) -> Result<(), Errno>
Sets the pin to output digital signal.
func write(_ value: Bool)
Sets the output value of the specific pin: true for high voltage and false for low voltage.