mirror of
https://github.com/kidoman/embd
synced 2024-12-22 12:50:19 +01:00
us020: added close method
This commit is contained in:
parent
d1e0e00ff7
commit
ec8a223b13
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rangeFinder := us020.New(10, 9)
|
rangeFinder := us020.New(10, 9)
|
||||||
|
defer rangeFinder.Close()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
distance, err := rangeFinder.Distance()
|
distance, err := rangeFinder.Distance()
|
||||||
|
@ -18,6 +18,8 @@ const (
|
|||||||
type US020 interface {
|
type US020 interface {
|
||||||
// Distance computes the distance of the bot from the closest obstruction.
|
// Distance computes the distance of the bot from the closest obstruction.
|
||||||
Distance() (float64, error)
|
Distance() (float64, error)
|
||||||
|
|
||||||
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
type us020 struct {
|
type us020 struct {
|
||||||
@ -117,3 +119,8 @@ func (d *us020) Distance() (distance float64, err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *us020) Close() {
|
||||||
|
d.echoPin.Output()
|
||||||
|
rpio.Close()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user