Block-based RubyMotion gem for interacting with the CMAltimeter class.
Add this line to your application's Gemfile:
gem 'motion-altimeter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install motion-altimeter
It's fairly easy to get altitude data using motion-altimeter
:
# Create your `Motion::Altimeter` object
my_altimeter = Motion::Altimeter.new
# Start getting updates
if CMAltimeter.isRelativeAltitudeAvailable
my_altimeter.start do |altitude|
# Do something with the altitude data.
#
# altitude is a hash with the following properties:
# {
# relative_altitude: 0.0,
# pressure: 0.0,
# error: nil
# }
# See Apple docs for CMAltitudeData to see what each of these is
end
else
puts "This device doesn't have a barometer to support relative altitudes."
end
# Somewhere else: stop getting updates
my_altimeter.stop
If the device doesn't support CMAltimeter, it will not start. You should check
before starting updates with a check to CMAltimeter.isRelativeAltitudeAvailable
.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request