Skip to content

Read XYZ orientation data from the Sudden Motion Sensor present in most recent Apple laptops. (This is a lie since the Air doesn’t even have one… so I don’t have a way to keep the code updated :)

License

peterhellberg/kinetosis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kinetosis

Read XYZ orientation data from the Sudden Motion Sensor present in most recent Apple laptops.

Kinetosis is a small Ruby extension written in C.

It is largely based on the old sudden_motion_sensor gem but I’ve removed the dependency on RubyInline and added a few specs.

I’ve tested Kinetosis on 1.9.2, 1.8.7 and REE.

Prerequisites

  • Apple laptop with the Sudden Motion Sensor

  • Snow Leopard (Probably)

Installation

gem install kinetosis

Usage example

require 'kinetosis'

include Kinetosis

# Trap ^C and exit
trap("SIGINT") { exit! }

# Call and print the result from the xyz method
loop do
  c = xyz.map { |v| v.to_s.ljust(4) }
  puts "x: #{c[0]} y: #{c[1]} z: #{c[2]}"
end

You would probably do something like this in the real world™:

require 'kinetosis'

class MacBookPro
  include Kinetosis
end

mbp = MacBookPro.new

puts mbp.x

LICENSE

Copyright © 2011 Peter Hellberg

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Read XYZ orientation data from the Sudden Motion Sensor present in most recent Apple laptops. (This is a lie since the Air doesn’t even have one… so I don’t have a way to keep the code updated :)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published