gpio

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package gpio provides functions for interacting with GPIO pins via the GPIO Sysfs Interface for Userspace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(pin int) error

Export enables access to the given gpio pin.

func GetPinID

func GetPinID(controller string, pin uint) (int, error)

GetPinID computes the sysfs pin ID for a specific port on a specific GPIO controller chip. The controller arg is matched to a gpiochip's label in sysfs. GetPinID gets the base offset of that chip, and adds the specific pin number.

func SetOutputValue

func SetOutputValue(pin int, val Value) error

SetOutputValue configures the gpio as an output pin with the given value.

Types

type Value

type Value bool

Value represents the value of a gpio pin

const (
	Low  Value = false
	High Value = true
)

Gpio pin values can either be low (0) or high (1)

func ReadValue

func ReadValue(pin int) (Value, error)

ReadValue returns the value of the given gpio pin. If the read was unsuccessful, it returns a value of Low and the associated error.

func (Value) Dir

func (v Value) Dir() string

Dir returns the representation that sysfs likes to use.

func (Value) String

func (v Value) String() string

Jump to

Keyboard shortcuts

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