2
0
mirror of synced 2025-02-23 14:58:12 +00:00
mobile/exp/sensor/notmobile.go
Burcu Dogan 9ddeada810 exp/sensor: provide sensor events from the app event channel
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>
2015-09-01 04:44:55 +00:00

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
}