kinect 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require 'usb'
4
+
5
+ require 'kinect/device'
6
+
7
+ module Kinect
8
+ class << Version = [0,1]
9
+ def to_s; join '.' end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ module Kinect
4
+ class DeviceError < StandardError; end
5
+ class Device
6
+ DeviceId = 0x02b0
7
+ DeviceVendor = 0x045e
8
+
9
+ def self.connect
10
+ new.tap do |this|
11
+ this.connect
12
+ end
13
+ end
14
+
15
+ def initialize
16
+ @device = select_device
17
+ end
18
+
19
+ def connect
20
+ raise DeviceError, "No kinect available" unless @device
21
+
22
+ @handle ||= @device.usb_open
23
+ end
24
+
25
+ private
26
+
27
+ def select_device
28
+ USB.devices.select do |device|
29
+ device.idVendor == DeviceVendor && device.idProduct == DeviceId
30
+ end.first
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module Kinect
4
+ class Devices
5
+ class LED < Kinect::Device
6
+ States = {
7
+ on: 0,
8
+ red: 2,
9
+ green: 1,
10
+ yellow: 3,
11
+
12
+ # Blinking …
13
+ _green: 5,
14
+ _yellow: 4,
15
+ _orange: 6,
16
+ _purple: 7
17
+ }
18
+ end
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kinect
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - Mikkel Kroman
12
+ autorequire:
13
+ bindir: executables
14
+ cert_chain: []
15
+
16
+ date: 2011-01-04 00:00:00 +01:00
17
+ default_executable:
18
+ dependencies: []
19
+
20
+ description:
21
+ email: mk@maero.dk
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files: []
27
+
28
+ files:
29
+ - library/kinect.rb
30
+ - library/kinect/device.rb
31
+ - library/kinect/devices/led.rb
32
+ has_rdoc: true
33
+ homepage:
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - library
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ segments:
47
+ - 1
48
+ - 9
49
+ - 1
50
+ version: 1.9.1
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.7
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Kinect library written in Ruby
66
+ test_files: []
67
+