gpio

package module
v0.0.0-...-9b8a2de Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2018 License: BSD-3-Clause Imports: 8 Imported by: 7

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

func NewInput(p uint) Pin

NewInput opens the given pin number for reading. The number provided should be the pin number known by the kernel

func NewOutput

func NewOutput(p uint, initHigh bool) Pin

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) Close

func (p Pin) Close()

Close releases the resources related to Pin

func (Pin) High

func (p Pin) High() error

High sets the value of an output pin to logic high

func (Pin) Low

func (p Pin) Low() error

Low sets the value of an output pin to logic low

func (Pin) Read

func (p Pin) Read() (value uint, err error)

Read returns the value read at the pin as reported by the kernel. This should only be used for input pins

type Watcher

type Watcher struct {
	// 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

func NewWatcher

func NewWatcher() *Watcher

NewWatcher creates a new Watcher instance for asynchronous inputs

func (*Watcher) AddPin

func (w *Watcher) AddPin(p uint)

AddPin adds a new pin to be watched for changes 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) RemovePin

func (w *Watcher) RemovePin(p uint)

RemovePin stops the watcher from watching the specified pin

func (*Watcher) Watch

func (w *Watcher) Watch() (p uint, v uint)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL