incremental

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: 12 Imported by: 0

Documentation

Overview

Package incremental implements an incremental encoder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIncrementalEncoder

func NewIncrementalEncoder(
	ctx context.Context,
	deps registry.Dependencies,
	cfg config.Component,
	logger golog.Logger,
) (encoder.Encoder, error)

NewIncrementalEncoder creates a new Encoder.

Types

type AttrConfig

type AttrConfig struct {
	Pins      Pins   `json:"pins"`
	BoardName string `json:"board"`
}

AttrConfig describes the configuration of a quadrature encoder.

func (*AttrConfig) Validate

func (config *AttrConfig) Validate(path string) ([]string, error)

Validate ensures all parts of the config are valid.

type Encoder

type Encoder struct {
	A, B board.DigitalInterrupt

	CancelCtx context.Context

	generic.Unimplemented
	// contains filtered or unexported fields
}

Encoder keeps track of a motor position using a rotary incremental encoder.

func (*Encoder) Close

func (e *Encoder) Close() error

Close shuts down the Encoder.

func (*Encoder) GetPosition

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

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) RawPosition

func (e *Encoder) RawPosition() int64

RawPosition returns the raw position of the encoder.

func (*Encoder) ResetPosition

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..

func (*Encoder) Start

func (e *Encoder) Start(ctx context.Context)

Start starts the Encoder background thread.

type Pins

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

Pins describes the configuration of Pins for a quadrature encoder.

Jump to

Keyboard shortcuts

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