pedometer

package
v0.0.14 Latest Latest
Warning

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

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

Documentation

Overview

Package pedometer counts steps.

nimbus native plugin add pedometer

if ok, _ := pedometer.Request(ctx); ok {
	go pedometer.Watch(ctx, setSteps)
}

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 Between

func Between(ctx context.Context, from, to time.Time) (int, error)

Between counts the steps taken in a past period. iOS keeps about a week; Android keeps nothing, so there it fails with plugin.Unavailable.

func Request

func Request(ctx context.Context) (bool, error)

Request asks to read their steps, once.

func Watch

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

Watch calls f with the steps taken since it began, each time the count changes, until ctx ends. It blocks, so run it from a goroutine in an effect. Where there's no sensor, as on the iOS simulator, it fails with plugin.Unavailable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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