We are also limiting the number of sensor managers to one. The application provide sensor events to third-party packages by consuming them in the main. An application will be able to consume the sensor events similar to the other events. package main func main() { app.Main(func(a app.App) { // enables the accelerometer sensor.Enable(a, sensor.Accelerometer, 100*time.Millisecond) var sz size.Event for e := range a.Events() { switch e := app.Filter(e).(type) { case sensor.Event: log.Println(e) } } }) } Change-Id: Iaad1c59f8d2322c7620df62ed9b9283c91746fa8 Reviewed-on: https://go-review.googlesource.com/13983 Reviewed-by: Nigel Tao <nigeltao@golang.org>
29 lines
587 B
Go
29 lines
587 B
Go
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build linux,!android darwin,!arm,!arm64 windows
|
|
|
|
package sensor
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
type manager struct{}
|
|
|
|
func (m *manager) initialize() {}
|
|
|
|
func (m *manager) enable(s Sender, t Type, delay time.Duration) error {
|
|
return errors.New("sensor: no sensors available")
|
|
}
|
|
|
|
func (m *manager) disable(t Type) error {
|
|
return errors.New("sensor: no sensors available")
|
|
}
|
|
|
|
func (m *manager) close() error {
|
|
return nil
|
|
}
|