InterruptState
Determines whether the interrupt is enabled and will occur.
enum InterruptState
Determines whether the interrupt is enabled and will occur.
enum InterruptState
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.
case disable
case enable
@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 enableInterrupt() -> Result<(), Errno>
Enables the interrupt.
@discardableResult func disableInterrupt() -> Result<(), Errno>
Disables the interrupt until you enable it.
@discardableResult func removeInterrupt() -> Result<(), Errno>
Removes the interrupt.
func getInterruptState() -> InterruptState
Checks whether the interrupt is enabled.
enum InterruptMode
Determines the event to raise an interrupt: rising edge, falling edge or both.
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
func getMode() -> Mode
Gets the configuration of the internal pull-up and pull-down resistor on a specified input pin.
func read() -> Bool
Reads value from a digital input pin.
@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 Mode
The digital input mode sets the pull resistors connected to a pin.
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.