module BubbleWrap::Motion
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)
@example
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
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.
@example
mgr = CMMotionManager.alloc.init accel = BW::Motion::Accelerometer.new(mgr) accel.once do |result_data| end # => BW::Motion::accelerometer.once do |result_data| ... end
Public Instance Methods
accelerometer()
click to toggle source
# File motion/motion/motion.rb, line 37 def accelerometer @accelerometer ||= Accelerometer.new(self.manager) end
device()
click to toggle source
# File motion/motion/motion.rb, line 49 def device @device ||= DeviceMotion.new(self.manager) end
gyroscope()
click to toggle source
# File motion/motion/motion.rb, line 41 def gyroscope @gyroscope ||= Gyroscope.new(self.manager) end
magnetometer()
click to toggle source
# File motion/motion/motion.rb, line 45 def magnetometer @magnetometer ||= Magnetometer.new(self.manager) end
manager()
click to toggle source
# File motion/motion/motion.rb, line 33 def manager @manager ||= CMMotionManager.alloc.init end