barometer

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package barometer reads the air pressure, and how far the phone has climbed.

nimbus native plugin add barometer

go barometer.Watch(ctx, 1, func(r barometer.Reading) { setFloors(r.Altitude / 3) })

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available(ctx context.Context) bool

Available reports whether this phone has the sensor.

func Watch

func Watch(ctx context.Context, hz int, f func(Reading)) error

Watch calls f about hz times a second until ctx ends. It blocks, so run it from a goroutine in an effect. Where there's no sensor it fails with plugin.Unavailable.

Types

type Reading

type Reading struct {
	Pressure float64 `json:"pressure"` // in hectopascals; about 1013 at sea level
	Altitude float64 `json:"altitude"` // metres climbed since Watch began; negative is down
}

Reading is one sample.

Jump to

Keyboard shortcuts

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