lightsensor

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 lightsensor reads how bright it is around the phone. It's Android only: iOS doesn't let apps read this sensor.

nimbus native plugin add light-sensor

go lightsensor.Watch(ctx, 2, func(r lightsensor.Reading) { setDim(r.Lux < 10) })

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 {
	Lux float64 `json:"lux"` // about 10 in a dim room, 400 in an office, 10,000 outdoors
}

Reading is one sample.

Jump to

Keyboard shortcuts

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