Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pin ¶
type Pin struct { Number uint // contains filtered or unexported fields }
Pin represents a single pin, which can be used either for reading or writing
func NewInput ¶
NewInput opens the given pin number for reading. The number provided should be the pin number known by the kernel
func NewOutput ¶
NewOutput opens the given pin number for writing. The number provided should be the pin number known by the kernel NewOutput also needs to know whether the pin should be initialized high (true) or low (false)
func (Pin) Read ¶
Read returns the value read at the pin as reported by the kernel. This should only be used for input pins
func (Pin) SetLogicLevel ¶
func (p Pin) SetLogicLevel(logicLevel LogicLevel) error
SetLogicLevel sets the logic level for the Pin. This can be either "active high" or "active low"
type Watcher ¶
type Watcher struct { Notification chan WatcherNotification // contains filtered or unexported fields }
Watcher provides asynchronous notifications on input changes The user should supply it pins to watch with AddPin and then wait for changes with Watch Alternately, users may receive directly from the Notification channel
func NewWatcher ¶
func NewWatcher() *Watcher
NewWatcher creates a new Watcher instance for asynchronous inputs
func (*Watcher) AddPin ¶
AddPin adds a new pin to be watched for changes. The pin is configured with logic level "active high" and watched for both rising and falling edges. The pin provided should be the pin known by the kernel
func (*Watcher) AddPinWithEdgeAndLogic ¶
func (w *Watcher) AddPinWithEdgeAndLogic(p uint, edge Edge, logicLevel LogicLevel)
AddPinWithEdgeAndLogic adds a new pin to be watched for changes. Edges can be configured to be either rising, falling, or both. Logic level can be active high or active low. The pin provided should be the pin known by the kernel.
func (*Watcher) Close ¶
func (w *Watcher) Close()
Close stops the watcher and releases all resources
func (*Watcher) Watch ¶
Watch blocks until one change occurs on one of the watched pins It returns the pin which changed and its new value Because the Watcher is not perfectly realtime it may miss very high frequency changes If that happens, it's possible to see consecutive changes with the same value Also, if the input is connected to a mechanical switch, the user of this library must deal with debouncing Users can either use Watch() or receive from Watcher.Notification directly
type WatcherNotification ¶
WatcherNotification represents a single pin change The new value of the pin numbered by Pin is Value