read
Reads value from a digital input pin.
func read() -> Bool
Returns
true
or false
of the logic value.
Reads value from a digital input pin.
func read() -> Bool
true
or false
of the logic value.
import SwiftIO
The SwiftIO library allows you to access and control the hardware in an easy way.
final class DigitalIn
The DigitalIn class is intended to detect the state of a digital input pin, either true or false.
@frozen struct Bool
A value type whose instances are either true
or false
.
init(_ idName: Id, mode: Mode = .pullDown)
Initializes a DigitalIn to a specified pin.
var interruptMode: InterruptMode { get set }
The current interrupt mode: .rising
, falling
or bothEdge
.
var mode: Mode { get set }
The current input mode: .pullUp
, .pullDown
or .pullNone
.
let obj: UnsafeMutableRawPointer
@discardableResult func disableInterrupt() -> Result<(), Errno>
Disables the interrupt until you enable it.
@discardableResult func enableInterrupt() -> Result<(), Errno>
Enables the interrupt.
func getInterruptState() -> InterruptState
Checks whether the interrupt is enabled.
func getMode() -> Mode
Gets the configuration of the internal pull-up and pull-down resistor on a specified input pin.
@discardableResult func removeInterrupt() -> Result<(), Errno>
Removes the interrupt.
@discardableResult func setInterrupt(_ mode: InterruptMode, enable: Bool = true, callback: @escaping () -> Void) -> Result<(), Errno>
Adds a callback function to a specified input pin. It sets interrupt by detecting the changes of the signal.
@discardableResult func setMode(_ mode: Mode) -> Result<(), Errno>
Sets the input mode, which means the pull-up and pull-down resistor pull-up and pull-down resistor.
enum InterruptMode
Determines the event to raise an interrupt: rising edge, falling edge or both.
enum InterruptState
Determines whether the interrupt is enabled and will occur.
enum Mode
The digital input mode sets the pull resistors connected to a pin.