gpio

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package gpio implements a gpio/adc based input.Controller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGPIOController

func NewGPIOController(ctx context.Context, deps registry.Dependencies, config config.Component, logger golog.Logger) (interface{}, error)

NewGPIOController returns a new input.Controller.

Types

type AxisConfig

type AxisConfig struct {
	Control       input.Control `json:"control"`
	Min           int           `json:"min"`
	Max           int           `json:"max"`
	Bidirectional bool          `json:"bidirectional"`
	Deadzone      int           `json:"deadzone"`
	MinChange     int           `json:"min_change"`
	PollHz        float64       `json:"poll_hz"`
	Invert        bool          `json:"invert"`
}

AxisConfig is a subconfig for axes.

type ButtonConfig

type ButtonConfig struct {
	Control    input.Control `json:"control"`
	Invert     bool          `json:"invert"`
	DebounceMs int           `json:"debounce_ms"` // set to -1 to disable, default=5
}

ButtonConfig is a subconfig for buttons.

type Config

type Config struct {
	Board   string                  `json:"board"`
	Buttons map[string]ButtonConfig `json:"buttons"`
	Axes    map[string]AxisConfig   `json:"axes"`
}

Config is the overall config.

type Controller

type Controller struct {
	generic.Unimplemented
	// contains filtered or unexported fields
}

A Controller creates an input.Controller from DigitalInterrupts and AnalogReaders.

func (*Controller) Close

func (c *Controller) Close()

Close terminates background worker threads.

func (*Controller) GetControls

func (c *Controller) GetControls(ctx context.Context) ([]input.Control, error)

GetControls lists the inputs.

func (*Controller) GetEvents

func (c *Controller) GetEvents(ctx context.Context) (map[input.Control]input.Event, error)

GetEvents returns the last input.Event (the current state) of each control.

func (*Controller) RegisterControlCallback

func (c *Controller) RegisterControlCallback(
	ctx context.Context,
	control input.Control,
	triggers []input.EventType,
	ctrlFunc input.ControlFunction,
) error

RegisterControlCallback registers a callback function to be executed on the specified trigger Event.

Jump to

Keyboard shortcuts

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