nu40c16

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: MIT Imports: 2 Imported by: 1

README

NU40C16

This is a small libary to read the Grove - Ultrasonic Ranger (spec) in golang.

This libary is a translation of Seeed_Arduino_UltrasonicRanger written in C++.

It depends on the libary github.com/stianeikeland/go-rpio/v4.

Usage

Install via go get gitlab.void-ptr.org/go/nu40c16, here is a small example:

package main

import (
 "github.com/d2r2/go-logger"
 "github.com/stianeikeland/go-rpio/v4"
 "gitlab.void-ptr.org/go/nu40c16"
)

var lg = logger.NewPackageLogger("example01", logger.InfoLevel)

func main() {
 logger.ChangePackageLogLevel("nu40c16", logger.InfoLevel)
 rpio.Open()
 defer rpio.Close()
 n := nu40c16.NewNU40C16(16)
 distance := n.MeasureInCentimeters()
 lg.Infof("distance %d cm", distance)
}

You can also run it directly via go run examples/example01/example01.go. Make sure you user is root or in the gpio group.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NU40C16

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

func NewNU40C16

func NewNU40C16(pin rpio.Pin) *NU40C16

NewNU40C16 creates a new instance on given pin

func (*NU40C16) MeasureInCentimeters

func (n *NU40C16) MeasureInCentimeters() int64

MeasureInCentimeters - The measured distance from the range 0 to 400 Centimeters

func (*NU40C16) MeasureInInches

func (n *NU40C16) MeasureInInches() int64

MeasureInInches - The measured distance from the range 0 to 157 Inches

func (*NU40C16) MeasureInMillimeters

func (n *NU40C16) MeasureInMillimeters() int64

MeasureInMillimeters - The measured distance from the range 0 to 4000 Millimeters

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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