Class: BubbleWrap::Motion::Accelerometer

Inherits:
GenericMotionInterface show all
Defined in:
motion/motion/motion.rb

Instance Method Summary collapse

Methods inherited from GenericMotionInterface

#every, #initialize, #once, #repeat

Constructor Details

This class inherits a constructor from BubbleWrap::Motion::GenericMotionInterface

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)

169
170
171
# File 'motion/motion/motion.rb', line 169

def active?
  @manager.accelerometerActive?
end

#available?Boolean

Returns:

  • (Boolean)

165
166
167
# File 'motion/motion/motion.rb', line 165

def available?
  @manager.accelerometerAvailable?
end

#dataObject


173
174
175
# File 'motion/motion/motion.rb', line 173

def data
  @manager.accelerometerData
end

#start(options = {}, &handler) ⇒ Object


134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'motion/motion/motion.rb', line 134

def start(options={}, &handler)
  if options.key?(:interval)
    @manager.accelerometerUpdateInterval = options[:interval]
  end

  if handler
    queue = convert_queue(options[:queue])
    @manager.startAccelerometerUpdatesToQueue(queue, withHandler: internal_handler(handler))
  else
    @manager.startAccelerometerUpdates
  end

  return self
end

#stopObject


177
178
179
# File 'motion/motion/motion.rb', line 177

def stop
  @manager.stopAccelerometerUpdates
end