pinwrappers

package
v0.26.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package pinwrappers implements interfaces that wrap the basic board interface and return types, and expands them with new methods and interfaces for the built in board models. Current expands analog reader and digital interrupt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCallback

func AddCallback(i *BasicDigitalInterrupt, c chan board.Tick)

AddCallback adds a listener for interrupts.

func Tick

func Tick(ctx context.Context, i *BasicDigitalInterrupt, high bool, nanoseconds uint64) error

Tick records an interrupt and notifies any interested callbacks. See comment on the DigitalInterrupt interface for caveats.

Types

type AnalogSmoother

type AnalogSmoother struct {
	Raw               board.Analog
	AverageOverMillis int
	SamplesPerSecond  int
	// contains filtered or unexported fields
}

An AnalogSmoother smooths the readings out from an underlying reader.

func SmoothAnalogReader

func SmoothAnalogReader(r board.Analog, c board.AnalogReaderConfig, logger logging.Logger) *AnalogSmoother

SmoothAnalogReader wraps the given reader in a smoother.

func (*AnalogSmoother) Close

func (as *AnalogSmoother) Close(ctx context.Context) error

Close stops the smoothing routine.

func (*AnalogSmoother) Read

func (as *AnalogSmoother) Read(ctx context.Context, extra map[string]interface{}) (int, error)

Read returns the smoothed out reading.

func (*AnalogSmoother) Start

func (as *AnalogSmoother) Start()

Start begins the smoothing routine that reads from the underlying analog reader.

func (*AnalogSmoother) Write

func (as *AnalogSmoother) Write(ctx context.Context, value int, extra map[string]interface{}) error

type BasicDigitalInterrupt

type BasicDigitalInterrupt struct {
	// contains filtered or unexported fields
}

A BasicDigitalInterrupt records how many ticks/interrupts happen and can report when they happen to interested callbacks.

func (*BasicDigitalInterrupt) Name

func (i *BasicDigitalInterrupt) Name() string

Name returns the name of the digital interrupt.

func (*BasicDigitalInterrupt) Reconfigure

Reconfigure reconfigures this digital interrupt with a new formula.

func (*BasicDigitalInterrupt) RemoveCallback

func (i *BasicDigitalInterrupt) RemoveCallback(c chan board.Tick)

RemoveCallback removes a listener for interrupts.

func (*BasicDigitalInterrupt) Ticks

func (i *BasicDigitalInterrupt) Ticks(ctx context.Context, num int, now uint64) error

Ticks is really just for testing.

func (*BasicDigitalInterrupt) Value

func (i *BasicDigitalInterrupt) Value(ctx context.Context, extra map[string]interface{}) (int64, error)

Value returns the amount of ticks that have occurred.

type ReconfigurableDigitalInterrupt

type ReconfigurableDigitalInterrupt interface {
	board.DigitalInterrupt
	Reconfigure(cfg board.DigitalInterruptConfig) error
}

A ReconfigurableDigitalInterrupt is a simple reconfigurable digital interrupt that expects reconfiguration within the same type.

func CreateDigitalInterrupt

CreateDigitalInterrupt is a factory method for creating a specific DigitalInterrupt based on the given config. If no type is specified, a BasicDigitalInterrupt is returned.

Jump to

Keyboard shortcuts

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