arduino

package
v0.2.34 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package arduino implements the arduino board and some peripherals.

Index

Constants

View Source
const SetPowerZeroThreshold = .0001

SetPowerZeroThreshold represents a power below which value attempting to run the motor simply stops it.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Analogs    []board.AnalogConfig `json:"analogs,omitempty"`
	SerialPath string               `json:"serial_path"`
	Attributes config.AttributeMap  `json:"attributes,omitempty"`
}

A Config describes the configuration of a board and all of its connected parts.

func (*Config) Validate

func (config *Config) Validate(path string) error

Validate ensures all parts of the config are valid.

type Encoder

type Encoder struct {
	A, B string

	generic.Unimplemented
	// contains filtered or unexported fields
}

Encoder keeps track of an arduino motor position.

func NewEncoder

func NewEncoder(ctx context.Context, deps registry.Dependencies, config config.Component, logger golog.Logger) (*Encoder, error)

NewEncoder creates a new incremental Encoder.

func (*Encoder) GetPosition added in v0.2.34

func (e *Encoder) GetPosition(
	ctx context.Context,
	positionType *encoder.PositionType,
	extra map[string]interface{},
) (float64, encoder.PositionType, error)

GetPosition returns the current position in terms of ticks or degrees, and whether it is a relative or absolute position.

func (*Encoder) GetProperties added in v0.2.34

func (e *Encoder) GetProperties(ctx context.Context, extra map[string]interface{}) (map[encoder.Feature]bool, error)

GetProperties returns a list of all the position types that are supported by a given encoder.

func (*Encoder) ResetPosition added in v0.2.34

func (e *Encoder) ResetPosition(ctx context.Context, extra map[string]interface{}) error

ResetPosition sets the current position of the motor (adjusted by a given offset) to be its new zero position.

type EncoderConfig

type EncoderConfig struct {
	Pins      EncoderPins `json:"pins"`
	BoardName string      `json:"board"`
	MotorName string      `json:"motor_name"`
}

EncoderConfig describes the config of an arduino Encoder.

func (*EncoderConfig) Validate added in v0.1.6

func (cfg *EncoderConfig) Validate(path string) ([]string, error)

Validate ensures all parts of the config are valid.

type EncoderPins

type EncoderPins struct {
	A string `json:"a"`
	B string `json:"b"`
}

EncoderPins defines the format the pin config should be in for Encoder.

Jump to

Keyboard shortcuts

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