Documentation ¶
Overview ¶
Package gpio implements a gpio/adc based input.Controller.
Index ¶
- func NewGPIOController(ctx context.Context, deps resource.Dependencies, conf resource.Config, ...) (input.Controller, error)
- type AxisConfig
- type ButtonConfig
- type Config
- type Controller
- func (c *Controller) Close(ctx context.Context) error
- func (c *Controller) Controls(ctx context.Context, extra map[string]interface{}) ([]input.Control, error)
- func (c *Controller) Events(ctx context.Context, extra map[string]interface{}) (map[input.Control]input.Event, error)
- func (c *Controller) RegisterControlCallback(ctx context.Context, control input.Control, triggers []input.EventType, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGPIOController ¶
func NewGPIOController( ctx context.Context, deps resource.Dependencies, conf resource.Config, logger logging.Logger, ) (input.Controller, 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_msec"` // 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 { resource.Named resource.AlwaysRebuild // contains filtered or unexported fields }
A Controller creates an input.Controller from DigitalInterrupts and AnalogReaders.
func (*Controller) Close ¶
func (c *Controller) Close(ctx context.Context) error
Close terminates background worker threads.
func (*Controller) Controls ¶
func (c *Controller) Controls(ctx context.Context, extra map[string]interface{}) ([]input.Control, error)
Controls lists the inputs.
func (*Controller) Events ¶
func (c *Controller) Events(ctx context.Context, extra map[string]interface{}) (map[input.Control]input.Event, error)
Events 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, extra map[string]interface{}, ) error
RegisterControlCallback registers a callback function to be executed on the specified trigger Event.
Click to show internal directories.
Click to hide internal directories.