Direction
Includes the functionalities of the digital pin: input or output.
enum Direction
Includes the functionalities of the digital pin: input or output.
enum Direction
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.
case output
case input
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.
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 direction: Direction { get set }
The pin’s usage: input
or output
.
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 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.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.