gpio

package
v0.0.0-...-27e653a Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BananaPI = map[BananaPiPIN]Pin{
	PWR_LED:  {"gpiochip1", 10},
	CON2_P03: {"gpiochip0", 12},
	CON2_P05: {"gpiochip0", 11},
	CON2_P07: {"gpiochip0", 6},
	CON2_P08: {"gpiochip0", 13},
	CON2_P10: {"gpiochip0", 14},
	CON2_P11: {"gpiochip0", 1},
	CON2_P12: {"gpiochip0", 16},
	CON2_P13: {"gpiochip0", 0},
	CON2_P15: {"gpiochip0", 3},
	CON2_P16: {"gpiochip0", 15},
	CON2_P18: {"gpiochip0", 68},
	CON2_P19: {"gpiochip0", 64},
	CON2_P21: {"gpiochip0", 65},
	CON2_P22: {"gpiochip0", 2},
	CON2_P23: {"gpiochip0", 66},
	CON2_P24: {"gpiochip0", 67},
	CON2_P26: {"gpiochip0", 71},
	CON2_P27: {"gpiochip0", 19},
	CON2_P28: {"gpiochip0", 18},
	CON2_P29: {"gpiochip0", 7},
	CON2_P31: {"gpiochip0", 8},
	CON2_P32: {"gpiochip1", 2},
	CON2_P33: {"gpiochip0", 9},
	CON2_P35: {"gpiochip0", 10},
	CON2_P36: {"gpiochip1", 4},
	CON2_P37: {"gpiochip0", 17},
	CON2_P38: {"gpiochip0", 21},
	CON2_P40: {"gpiochip0", 20},
}
View Source
var (
	ErrNotExist = fmt.Errorf("not exist")
)

Functions

This section is empty.

Types

type ActiveLevel

type ActiveLevel int
const (
	Low ActiveLevel = iota
	High
)

type BananaPiPIN

type BananaPiPIN int
const (
	PWR_LED BananaPiPIN = iota
	CON2_P03
	CON2_P05
	CON2_P07
	CON2_P08
	CON2_P10
	CON2_P11
	CON2_P12
	CON2_P13
	CON2_P15
	CON2_P16
	CON2_P18
	CON2_P19
	CON2_P21
	CON2_P22
	CON2_P23
	CON2_P24
	CON2_P26
	CON2_P27
	CON2_P28
	CON2_P29
	CON2_P31
	CON2_P32
	CON2_P33
	CON2_P35
	CON2_P36
	CON2_P37
	CON2_P38
	CON2_P40
)

type Closer

type Closer interface {
	Close() error
}

Closer closes line

type Config

type Config struct {
	ID          string      `json:"id"`
	Direction   Direction   `json:"direction"`
	ActiveLevel ActiveLevel `json:"active_level"`
	Value       bool        `json:"value"`
}

type Direction

type Direction int
const (
	DirInput Direction = iota
	DirOutput
)

type Error

type Error struct {
	Pin Pin    `json:"pin"`
	Op  string `json:"op"`
	Err string `json:"error"`
}

func (*Error) Error

func (e *Error) Error() string

type In

type In struct {
	Config

	*gpiod.Line
	// contains filtered or unexported fields
}

func Input

func Input(pin Pin, id string, options ...gpiod.LineReqOption) (*In, error)

func (*In) Configure

func (in *In) Configure(new Config) error

func (*In) Get

func (in *In) Get() (bool, error)

func (*In) GetConfig

func (in *In) GetConfig() (Config, error)

func (*In) ID

func (in *In) ID() string

type Out

type Out struct {
	Config

	*gpiod.Line
	// contains filtered or unexported fields
}

func Output

func Output(pin Pin, id string, initValue bool, options ...gpiod.LineReqOption) (*Out, error)

func (*Out) Configure

func (o *Out) Configure(new Config) error

func (*Out) Get

func (o *Out) Get() (bool, error)

func (*Out) GetConfig

func (o *Out) GetConfig() (Config, error)

func (*Out) ID

func (o *Out) ID() string

func (*Out) Set

func (o *Out) Set(value bool) error

type Pin

type Pin struct {
	Chip string `json:"chip"`
	Line uint   `json:"line"`
}

func GetBananaPin

func GetBananaPin(pin BananaPiPIN) Pin

type Reader

type Reader interface {
	Get() (bool, error)
}

Reader returns current value of gpio, input or output

type Writer

type Writer interface {
	Set(bool) error
}

Writer provides access to set value on digital output

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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