MultiPurposeSwitchGPIO

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventHandler

func EventHandler(h func(sw.Switcher, sw.Device)) func(*MPSwitchGPIO)

EventHandler sets a callback function through which the bandswitch will report Events

func Switch

func Switch(sc SwitchConfig) func(*MPSwitchGPIO)

Switch is a functional option to set the switch's configuration.

Types

type MPSwitchGPIO

type MPSwitchGPIO struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MPSwitchGPIO contains the state and configuration of a multi purpose GPIO switch

func NewMPSwitchGPIO

func NewMPSwitchGPIO(options ...func(*MPSwitchGPIO)) *MPSwitchGPIO

NewMPSwitchGPIO is the constructor for a Multi Purpose GPIO switch. The constructor takes functional arguments for configuring the MPSwitch.

func (*MPSwitchGPIO) Close

func (g *MPSwitchGPIO) Close()

Close shutsdown the switch and sets all GPIO ports to false.

func (*MPSwitchGPIO) GetPort

func (g *MPSwitchGPIO) GetPort(portName string) (sw.Port, error)

GetPort returns switch.Port struct containing the current state of the requested port.

func (*MPSwitchGPIO) Init

func (g *MPSwitchGPIO) Init() error

Init intializes the Multi Purpose GPIO Switch. If your platform does not support GPIO, an error will be returned.

func (*MPSwitchGPIO) Name

func (g *MPSwitchGPIO) Name() string

Name returns the Name of this Multi Purpose GPIO Switch

func (*MPSwitchGPIO) Serialize

func (g *MPSwitchGPIO) Serialize() sw.Device

Serialize returns a switch.Device struct containing the current state and configuration of this MultiPurpose GPIO switch.

func (*MPSwitchGPIO) SetPort

func (g *MPSwitchGPIO) SetPort(portRequest sw.Port) error

SetPort sets the Terminals of a particular Port. The portRequest can contain n termials.

type PinConfig

type PinConfig struct {
	Name     string
	Pin      string
	Inverted bool
	Index    int
}

PinConfig describes a gpio pin.

type PortConfig

type PortConfig struct {
	Name      string
	Index     int
	Exclusive bool
	Terminals []PinConfig
}

PortConfig describes a port which is a collection of gpio pins. This struct is injected through the functional option "Port" during construction of BandswitchGPIO.

type SwitchConfig

type SwitchConfig struct {
	Name      string
	Index     int
	Exclusive bool
	Ports     []PortConfig
}

SwitchConfig describes a switch which is a collection of ports.

Jump to

Keyboard shortcuts

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