Documentation
¶
Overview ¶
Package motion reads the accelerometer and gyroscope.
nimbus native plugin add motion
go motion.Watch(ctx, 30, func(r motion.Reading) { setTilt(r.Accel.X) })
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Watch ¶
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, as on the iOS simulator, it fails with plugin.Unavailable.
func WatchOrientation ¶
func WatchOrientation(ctx context.Context, hz int, f func(Orientation)) error
WatchOrientation is Watch for how the phone is turned, as angles, for a level or a tilt control.
Types ¶
type Orientation ¶
type Orientation struct {
Pitch float64 `json:"pitch"` // the top raised toward you; 90 is upright
Roll float64 `json:"roll"` // the right edge dipped down; 90 is on its side
// Yaw is the turn around the screen's axis. On Android it's from
// north; on iOS it's from wherever it began, so only changes in it mean
// anything there.
Yaw float64 `json:"yaw"`
}
Orientation is how the phone is turned, in degrees. Lying flat on its back with the top pointing away from you, Pitch and Roll are about 0.
Click to show internal directories.
Click to hide internal directories.