Ejemplo n.º 1
0
func (m *manager) disable(t Type) error {
	channels.Lock()
	defer channels.Unlock()

	switch t {
	case Accelerometer:
		if channels.acceleroDone == nil {
			return fmt.Errorf("sensor: cannot disable; %v sensor is not enabled", t)
		}
		close(channels.acceleroDone)
		channels.acceleroDone = nil
		C.GoIOS_stopAccelerometer()
	case Gyroscope:
	case Magnetometer:
	default:
		return fmt.Errorf("sensor: unknown sensor type: %v", t)
	}
	return nil
}
Ejemplo n.º 2
0
func (m *manager) disable(t Type) error {
	mu.Lock()
	mu.Unlock()

	switch t {
	case Accelerometer:
		if doneA == nil {
			return fmt.Errorf("sensor: cannot disable; %v sensor is not enabled", t)
		}
		doneA <- struct{}{}
		C.GoIOS_stopAccelerometer(m.m)
		doneA = nil
	case Gyroscope:
	case Magnetometer:
	default:
		return fmt.Errorf("sensor: unknown sensor type: %v", t)
	}
	return nil
}
Ejemplo n.º 3
0
func disable(t Type) error {
	channels.Lock()
	defer channels.Unlock()

	if channels.done[t] == nil {
		return fmt.Errorf("sensor: cannot disable; %v sensor is not enabled", t)
	}
	close(channels.done[t])
	channels.done[t] = nil

	switch t {
	case Accelerometer:
		C.GoIOS_stopAccelerometer()
	case Gyroscope:
		C.GoIOS_stopGyro()
	case Magnetometer:
		C.GoIOS_stopMagneto()
	}
	return nil
}