package
Version:
v0.25.0-rc2
Opens a new window with list of versions in this module.
Published: Apr 12, 2024
License: AGPL-3.0
Opens a new window with license information.
Imports: 10
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package ultrasonic implements an ultrasonic sensor based of the yahboom ultrasonic sensor
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.
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 (conf *Config) Validate(path string) ([]string, error)
Validate ensures all parts of the config are valid.
type Sensor struct {
resource.Named
resource.AlwaysRebuild
}
Sensor ultrasonic sensor.
func (s *Sensor) Close(ctx context.Context) error
Close remove interrupt callback of ultrasonic sensor.
func (s *Sensor) Readings(ctx context.Context, extra map[string]interface{}) (map[string]interface{}, error)
Readings returns the calculated distance.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.