gpio

package
v0.0.0-...-dddc173 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GPIO0     = 0
	GPIO1     = 1
	GPIO2     = 2
	GPIO3     = 3
	GPIO4     = 4
	GPIO7     = 7
	GPIO8     = 8
	GPIO9     = 9
	GPIO10    = 10
	GPIO11    = 11
	GPIO17    = 17
	GPIO18    = 18
	GPIO22    = 22
	GPIO23    = 23
	GPIO24    = 24
	GPIO25    = 25
	GPIOCount = 16 // the number of GPIO pins available
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge string

Edge represents the edge on which a pin interrupt is triggered

const (
	EdgeNone    Edge = "none"
	EdgeRising  Edge = "rising"
	EdgeFalling Edge = "falling"
	EdgeBoth    Edge = "both"
)

type IRQEvent

type IRQEvent func()

IRQEvent defines the callback function used to inform the caller of an interrupt.

type Mode

type Mode string

Mode represents a state of a GPIO pin

const (
	ModeInput  Mode = "in"
	ModeOutput Mode = "out"
	ModePWM         = "pwm"
)

type Pin

type Pin interface {
	Mode() Mode                      // gets the current pin mode
	SetMode(Mode)                    // set the current pin mode
	Set()                            // sets the pin state high
	Clear()                          // sets the pin state low
	Close() error                    // if applicable, closes the pin
	Get() bool                       // returns the current pin state
	BeginWatch(Edge, IRQEvent) error // calls the function argument when an edge trigger event occurs
	EndWatch() error                 // stops watching the pin
	Wait(bool)                       // wait for pin state to match boolean argument

	Err() error // returns the last error state
}

Pin represents a GPIO pin.

func OpenPin

func OpenPin(n int, mode Mode) (Pin, error)

OpenPin exports the pin, creating the virtual files necessary for interacting with the pin. It also sets the mode for the pin, making it ready for use.

Jump to

Keyboard shortcuts

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