ultrasonic

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ultrasonic implements an ultrasonic sensor based of the yahboom ultrasonic sensor

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSensor added in v0.4.0

func NewSensor(ctx context.Context, deps resource.Dependencies,
	name resource.Name, config *Config, logger logging.Logger,
) (sensor.Sensor, error)

NewSensor creates and configures a new ultrasonic sensor.

Types

type Config added in v0.2.36

type Config struct {
	TriggerPin    string `json:"trigger_pin"`
	EchoInterrupt string `json:"echo_interrupt_pin"`
	Board         string `json:"board"`
	TimeoutMs     uint   `json:"timeout_ms,omitempty"`
}

Config is used for converting config attributes.

func (*Config) Validate added in v0.2.36

func (conf *Config) Validate(path string) ([]string, error)

Validate ensures all parts of the config are valid.

type Sensor

type Sensor struct {
	resource.Named
	resource.AlwaysRebuild
	// contains filtered or unexported fields
}

Sensor ultrasonic sensor.

func (*Sensor) Close

func (s *Sensor) Close(ctx context.Context) error

Close remove interrupt callback of ultrasonic sensor.

func (*Sensor) Readings

func (s *Sensor) Readings(ctx context.Context, extra map[string]interface{}) (map[string]interface{}, error)

Readings returns the calculated distance.

Jump to

Keyboard shortcuts

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