getInterruptState
Checks whether the interrupt is enabled.
func getInterruptState() -> InterruptState
Returns
The interrupt state: .enable
or .disable
.
Checks whether the interrupt is enabled.
func getInterruptState() -> InterruptState
The interrupt state: .enable
or .disable
.
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.
enum InterruptState
Determines whether the interrupt is enabled and will occur.
@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.
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.