Module: BubbleWrap::Motion

Defined in:
motion/motion/motion.rb,
motion/motion/motion.rb

Overview

These module methods provide the main interface. It uses a shared manager (per Apple's recommendation), and they all have a common set of supported methods:

available?
active?
repeat(opts)
once(opts)
every(time_interval, opts)

If you insist on using your own manager, or you want more than one BW::Motion::Whatever running at the same time, you'll need to instantiate them yourself.

Examples:

if BW::Motion.accelerometer.available?
  BW::Motion.accelerometer.every(5) do |result|
    # see the README for the keys that are available in result.
  end
end
mgr = CMMotionManager.alloc.init
accel = BW::Motion::Accelerometer.new(mgr)
accel.once do |result_data|
end
# => BW::Motion::accelerometer.once do |result_data| ... end

Defined Under Namespace

Modules: Error Classes: Accelerometer, DeviceMotion, GenericMotionInterface, Gyroscope, Magnetometer

Class Method Summary collapse

Class Method Details

.accelerometerObject



37
38
39
# File 'motion/motion/motion.rb', line 37

def accelerometer
  @accelerometer ||= Accelerometer.new(self.manager)
end

.deviceObject



49
50
51
# File 'motion/motion/motion.rb', line 49

def device
  @device ||= DeviceMotion.new(self.manager)
end

.gyroscopeObject



41
42
43
# File 'motion/motion/motion.rb', line 41

def gyroscope
  @gyroscope ||= Gyroscope.new(self.manager)
end

.magnetometerObject



45
46
47
# File 'motion/motion/motion.rb', line 45

def magnetometer
  @magnetometer ||= Magnetometer.new(self.manager)
end

.managerObject



33
34
35
# File 'motion/motion/motion.rb', line 33

def manager
  @manager ||= CMMotionManager.alloc.init
end