getMode
Gets the configuration of the internal pull-up and pull-down resistor on a specified input pin.
func getMode() -> Mode
Returns
The current input mode: .pullUp
, .pullDown
or .pullNone
.
Gets the configuration of the internal pull-up and pull-down resistor on a specified input pin.
func getMode() -> Mode
The current input mode: .pullUp
, .pullDown
or .pullNone
.
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 Mode
The digital input mode sets the pull resistors connected to a 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.
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 read() -> Bool
Reads value from a digital 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.
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.