write(_:)
Sets the output value of the specific pin: true for high voltage and false for low voltage.
func write(_ value: Bool)
Parameters
- value
The output value:
true
orfalse
.
Sets the output value of the specific pin: true for high voltage and false for low voltage.
func write(_ value: Bool)
The output value: true
or false
.
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.
@frozen struct Bool
A value type whose instances are either true
or false
.
@discardableResult func setToOutput(_ mode: DigitalOut.Mode? = nil, value: Bool? = nil) -> Result<(), Errno>
Sets the pin to output digital signal.
func high()
Sets the output value to true.
func low()
Sets the output value to false.
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 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 read() -> Bool
Reads the value from the pin.
@discardableResult func setToInput(_ mode: DigitalIn.Mode? = nil) -> Result<(), Errno>
Sets the pin to read digital input.
enum Direction
Includes the functionalities of the digital pin: input or output.