phidgets-ffi 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/.gitignore +3 -0
  2. data/LICENSE +1 -1
  3. data/README.rdoc +92 -42
  4. data/examples/accelerometer.rb +39 -0
  5. data/examples/advanced_servo.rb +94 -0
  6. data/examples/analog.rb +43 -0
  7. data/examples/bridge.rb +57 -0
  8. data/examples/dictionary.rb +46 -31
  9. data/examples/encoder.rb +59 -0
  10. data/examples/frequency_counter.rb +63 -0
  11. data/examples/gps.rb +91 -0
  12. data/examples/interface_kit_with_block.rb +68 -0
  13. data/examples/interface_kit_without_block.rb +60 -0
  14. data/examples/ir.rb +157 -0
  15. data/examples/led.rb +36 -0
  16. data/examples/manager.rb +16 -10
  17. data/examples/motor_control.rb +108 -0
  18. data/examples/{ffi → raw-ffi}/dictionary.rb +11 -1
  19. data/examples/{ffi → raw-ffi}/interface_kit.rb +19 -2
  20. data/examples/{ffi → raw-ffi}/library_version.rb +0 -0
  21. data/examples/{ffi → raw-ffi}/log.rb +0 -0
  22. data/examples/{ffi → raw-ffi}/manager.rb +6 -3
  23. data/examples/rfid.rb +63 -0
  24. data/examples/servo.rb +45 -30
  25. data/examples/spatial.rb +75 -0
  26. data/examples/stepper.rb +87 -0
  27. data/examples/temperature_sensor.rb +49 -0
  28. data/examples/text_lcd.rb +101 -0
  29. data/lib/phidgets-ffi.rb +34 -3
  30. data/lib/phidgets-ffi/accelerometer.rb +122 -0
  31. data/lib/phidgets-ffi/advanced_servo.rb +304 -0
  32. data/lib/phidgets-ffi/analog.rb +111 -0
  33. data/lib/phidgets-ffi/bridge.rb +167 -0
  34. data/lib/phidgets-ffi/common.rb +506 -103
  35. data/lib/phidgets-ffi/dictionary.rb +136 -23
  36. data/lib/phidgets-ffi/encoder.rb +196 -0
  37. data/lib/phidgets-ffi/error.rb +8 -3
  38. data/lib/phidgets-ffi/ffi/accelerometer.rb +30 -0
  39. data/lib/phidgets-ffi/ffi/advanced_servo.rb +73 -0
  40. data/lib/phidgets-ffi/ffi/analog.rb +29 -0
  41. data/lib/phidgets-ffi/ffi/bridge.rb +44 -0
  42. data/lib/phidgets-ffi/ffi/common.rb +51 -34
  43. data/lib/phidgets-ffi/ffi/constants.rb +3 -1
  44. data/lib/phidgets-ffi/ffi/dictionary.rb +25 -20
  45. data/lib/phidgets-ffi/ffi/encoder.rb +32 -0
  46. data/lib/phidgets-ffi/ffi/frequency_counter.rb +38 -0
  47. data/lib/phidgets-ffi/ffi/gps.rb +32 -0
  48. data/lib/phidgets-ffi/ffi/interface_kit.rb +26 -23
  49. data/lib/phidgets-ffi/ffi/ir.rb +50 -0
  50. data/lib/phidgets-ffi/ffi/led.rb +40 -0
  51. data/lib/phidgets-ffi/ffi/log.rb +7 -6
  52. data/lib/phidgets-ffi/ffi/manager.rb +35 -20
  53. data/lib/phidgets-ffi/ffi/motor_control.rb +66 -0
  54. data/lib/phidgets-ffi/ffi/rfid.rb +36 -0
  55. data/lib/phidgets-ffi/ffi/servo.rb +16 -15
  56. data/lib/phidgets-ffi/ffi/spatial.rb +40 -0
  57. data/lib/phidgets-ffi/ffi/stepper.rb +56 -0
  58. data/lib/phidgets-ffi/ffi/temperature_sensor.rb +42 -0
  59. data/lib/phidgets-ffi/ffi/text_lcd.rb +55 -0
  60. data/lib/phidgets-ffi/frequency_counter.rb +148 -0
  61. data/lib/phidgets-ffi/gps.rb +181 -0
  62. data/lib/phidgets-ffi/interface_kit.rb +205 -92
  63. data/lib/phidgets-ffi/ir.rb +290 -0
  64. data/lib/phidgets-ffi/led.rb +112 -0
  65. data/lib/phidgets-ffi/log.rb +14 -2
  66. data/lib/phidgets-ffi/manager.rb +143 -26
  67. data/lib/phidgets-ffi/motor_control.rb +497 -0
  68. data/lib/phidgets-ffi/phidgets-ffi.rb +15 -2
  69. data/lib/phidgets-ffi/rfid.rb +220 -0
  70. data/lib/phidgets-ffi/servo.rb +103 -61
  71. data/lib/phidgets-ffi/spatial.rb +306 -0
  72. data/lib/phidgets-ffi/stepper.rb +370 -0
  73. data/lib/phidgets-ffi/temperature_sensor.rb +157 -0
  74. data/lib/phidgets-ffi/text_lcd.rb +298 -0
  75. data/lib/phidgets-ffi/version.rb +1 -1
  76. data/phidgets-ffi.gemspec +2 -2
  77. metadata +89 -76
  78. data/examples/ffi/servo.rb +0 -67
  79. data/examples/interface_kit.rb +0 -20
@@ -1,5 +1,5 @@
1
1
  module Phidgets
2
2
  module FFI
3
- VERSION = "0.0.5"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
data/phidgets-ffi.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.name = "phidgets-ffi"
6
6
  s.version = Phidgets::FFI::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
- s.authors = ["Kelley Reynolds"]
9
- s.email = ["kelley@insidesystems.net"]
8
+ s.authors = ["Kelley Reynolds, Mike Phi"]
9
+ s.email = ["support@phidgets.com"]
10
10
  s.homepage = "https://github.com/kreynolds/phidgets-ffi"
11
11
  s.summary = "FFI Bindings for the Phidget Library"
12
12
  s.description = "FFI Bindings for the Phidget Library"
metadata CHANGED
@@ -1,135 +1,148 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: phidgets-ffi
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 5
10
- version: 0.0.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
13
- - Kelley Reynolds
7
+ authors:
8
+ - Kelley Reynolds, Mike Phi
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-17 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: bundler
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70297684443800 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 1.0.0
35
22
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: ffi
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70297684443800
25
+ - !ruby/object:Gem::Dependency
26
+ name: ffi
27
+ requirement: &70297684451660 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 5
46
- segments:
47
- - 1
48
- - 0
49
- - 9
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
50
32
  version: 1.0.9
51
33
  type: :runtime
52
- version_requirements: *id002
34
+ prerelease: false
35
+ version_requirements: *70297684451660
53
36
  description: FFI Bindings for the Phidget Library
54
- email:
55
- - kelley@insidesystems.net
37
+ email:
38
+ - support@phidgets.com
56
39
  executables: []
57
-
58
40
  extensions: []
59
-
60
41
  extra_rdoc_files: []
61
-
62
- files:
42
+ files:
63
43
  - .gitignore
64
44
  - Gemfile
65
45
  - LICENSE
66
46
  - README.rdoc
67
47
  - Rakefile
48
+ - examples/accelerometer.rb
49
+ - examples/advanced_servo.rb
50
+ - examples/analog.rb
51
+ - examples/bridge.rb
68
52
  - examples/dictionary.rb
69
- - examples/ffi/dictionary.rb
70
- - examples/ffi/interface_kit.rb
71
- - examples/ffi/library_version.rb
72
- - examples/ffi/log.rb
73
- - examples/ffi/manager.rb
74
- - examples/ffi/servo.rb
75
- - examples/interface_kit.rb
53
+ - examples/encoder.rb
54
+ - examples/frequency_counter.rb
55
+ - examples/gps.rb
56
+ - examples/interface_kit_with_block.rb
57
+ - examples/interface_kit_without_block.rb
58
+ - examples/ir.rb
59
+ - examples/led.rb
76
60
  - examples/log.rb
77
61
  - examples/manager.rb
62
+ - examples/motor_control.rb
63
+ - examples/raw-ffi/dictionary.rb
64
+ - examples/raw-ffi/interface_kit.rb
65
+ - examples/raw-ffi/library_version.rb
66
+ - examples/raw-ffi/log.rb
67
+ - examples/raw-ffi/manager.rb
68
+ - examples/rfid.rb
78
69
  - examples/servo.rb
70
+ - examples/spatial.rb
71
+ - examples/stepper.rb
72
+ - examples/temperature_sensor.rb
73
+ - examples/text_lcd.rb
79
74
  - lib/phidgets-ffi.rb
75
+ - lib/phidgets-ffi/accelerometer.rb
76
+ - lib/phidgets-ffi/advanced_servo.rb
77
+ - lib/phidgets-ffi/analog.rb
78
+ - lib/phidgets-ffi/bridge.rb
80
79
  - lib/phidgets-ffi/common.rb
81
80
  - lib/phidgets-ffi/dictionary.rb
81
+ - lib/phidgets-ffi/encoder.rb
82
82
  - lib/phidgets-ffi/error.rb
83
+ - lib/phidgets-ffi/ffi/accelerometer.rb
84
+ - lib/phidgets-ffi/ffi/advanced_servo.rb
85
+ - lib/phidgets-ffi/ffi/analog.rb
86
+ - lib/phidgets-ffi/ffi/bridge.rb
83
87
  - lib/phidgets-ffi/ffi/common.rb
84
88
  - lib/phidgets-ffi/ffi/constants.rb
85
89
  - lib/phidgets-ffi/ffi/core_ext.rb
86
90
  - lib/phidgets-ffi/ffi/dictionary.rb
91
+ - lib/phidgets-ffi/ffi/encoder.rb
92
+ - lib/phidgets-ffi/ffi/frequency_counter.rb
93
+ - lib/phidgets-ffi/ffi/gps.rb
87
94
  - lib/phidgets-ffi/ffi/interface_kit.rb
95
+ - lib/phidgets-ffi/ffi/ir.rb
96
+ - lib/phidgets-ffi/ffi/led.rb
88
97
  - lib/phidgets-ffi/ffi/log.rb
89
98
  - lib/phidgets-ffi/ffi/manager.rb
99
+ - lib/phidgets-ffi/ffi/motor_control.rb
100
+ - lib/phidgets-ffi/ffi/rfid.rb
90
101
  - lib/phidgets-ffi/ffi/servo.rb
102
+ - lib/phidgets-ffi/ffi/spatial.rb
103
+ - lib/phidgets-ffi/ffi/stepper.rb
104
+ - lib/phidgets-ffi/ffi/temperature_sensor.rb
105
+ - lib/phidgets-ffi/ffi/text_lcd.rb
106
+ - lib/phidgets-ffi/frequency_counter.rb
107
+ - lib/phidgets-ffi/gps.rb
91
108
  - lib/phidgets-ffi/interface_kit.rb
109
+ - lib/phidgets-ffi/ir.rb
110
+ - lib/phidgets-ffi/led.rb
92
111
  - lib/phidgets-ffi/log.rb
93
112
  - lib/phidgets-ffi/manager.rb
113
+ - lib/phidgets-ffi/motor_control.rb
94
114
  - lib/phidgets-ffi/phidgets-ffi.rb
115
+ - lib/phidgets-ffi/rfid.rb
95
116
  - lib/phidgets-ffi/servo.rb
117
+ - lib/phidgets-ffi/spatial.rb
118
+ - lib/phidgets-ffi/stepper.rb
119
+ - lib/phidgets-ffi/temperature_sensor.rb
120
+ - lib/phidgets-ffi/text_lcd.rb
96
121
  - lib/phidgets-ffi/version.rb
97
122
  - phidgets-ffi.gemspec
98
- has_rdoc: true
99
123
  homepage: https://github.com/kreynolds/phidgets-ffi
100
124
  licenses: []
101
-
102
125
  post_install_message:
103
126
  rdoc_options: []
104
-
105
- require_paths:
127
+ require_paths:
106
128
  - lib
107
- required_ruby_version: !ruby/object:Gem::Requirement
129
+ required_ruby_version: !ruby/object:Gem::Requirement
108
130
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
- version: "0"
116
- required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
136
  none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- hash: 23
122
- segments:
123
- - 1
124
- - 3
125
- - 6
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
126
140
  version: 1.3.6
127
141
  requirements: []
128
-
129
142
  rubyforge_project: phidgets-ffi
130
- rubygems_version: 1.3.7
143
+ rubygems_version: 1.8.10
131
144
  signing_key:
132
145
  specification_version: 3
133
146
  summary: FFI Bindings for the Phidget Library
134
147
  test_files: []
135
-
148
+ has_rdoc:
@@ -1,67 +0,0 @@
1
- require 'rubygems'
2
- require 'phidgets-ffi'
3
-
4
- include Phidgets::FFI
5
-
6
- f = FFI::MemoryPointer.new(:pointer, 1)
7
- if !(res = Phidgets::FFI::CPhidgetServo.create(f))
8
- $stderr.puts "Unable to create servo"
9
- exit!(res)
10
- else
11
- servo = f.get_pointer(0)
12
- end
13
- f = nil
14
- def device_name_for(device)
15
- ptr = FFI::MemoryPointer.new(:string, 1)
16
- CPhidget_getDeviceName(device, ptr)
17
- strPtr = ptr.get_pointer(0)
18
- strPtr.null? ? nil : strPtr.read_string
19
- end
20
-
21
- def serial_number_for(device)
22
- ptr = FFI::MemoryPointer.new(:int, 1)
23
- CPhidget_getSerialNumber(device, ptr)
24
- ptr.get_int(0)
25
- end
26
-
27
- # Create an attachment and detachment handler
28
- AttachHandler = Proc.new { |device, ptr|
29
- print "Device attached: #{device_name_for(device)} (#{serial_number_for(device)})\n"
30
- tmp = FFI::MemoryPointer.new(:double)
31
- CPhidgetServo_getPositionMax(device, 0, tmp)
32
- print "Max: #{tmp.get_double(0)}\n"
33
- CPhidgetServo_getPositionMin(device, 0, tmp)
34
- print "Min: #{tmp.get_double(0)}\n"
35
- }
36
- CPhidget_set_OnAttach_Handler(servo, AttachHandler, nil)
37
- DetachHandler = Proc.new { |device, ptr|
38
- print "Device detached: #{device_name_for(device)} (#{serial_number_for(device)})\n"
39
- }
40
- CPhidget_set_OnDetach_Handler(servo, DetachHandler, nil)
41
-
42
- PositionChangeHandler = Proc.new { |device, ptr, index, position|
43
- print "Moving motor #{index} to #{position}\n"
44
- }
45
- CPhidgetServo_set_OnPositionChange_Handler(servo, PositionChangeHandler, nil)
46
-
47
- CPhidget_open(servo, -1)
48
- CPhidget_waitForAttachment(servo, 10000)
49
-
50
- ptr = FFI::MemoryPointer.new(:int)
51
- exit! if CPhidgetServo_getEngaged(servo, 0, ptr) != 0
52
- #CPhidgetServo_setEngaged(servo, 0, 1)
53
-
54
- CPhidgetServo_getServoType(servo, 0, ptr)
55
- print "Servo Type: #{ServoType[ptr.get_int(0)]}\n"
56
-
57
- tmp = FFI::MemoryPointer.new(:double)
58
- CPhidgetServo_getPositionMax(servo, 0, tmp)
59
- max = tmp.get_double(0)
60
- 10.times do
61
- CPhidgetServo_setPosition(servo, 0, rand(max))
62
- sleep 1
63
- end
64
-
65
- CPhidgetServo_setEngaged(servo, 0, 0)
66
- CPhidget_close(servo)
67
- CPhidget_delete(servo)
@@ -1,20 +0,0 @@
1
- require 'rubygems'
2
- require 'phidgets-ffi'
3
-
4
- puts "Library Version: #{Phidgets::FFI.library_version}"
5
- Phidgets::InterfaceKit.new(-1) do |ifkit|
6
- puts "Device attributes: #{ifkit.attributes.inspect}"
7
-
8
- ifkit.on_output_change do |output, state, obj|
9
- print "Output #{output.index} has changed to #{state}\n"
10
- end
11
-
12
- ifkit.wait_for_attachment
13
- ifkit.outputs[0].state = true
14
- ifkit.outputs[0].state = false
15
-
16
- puts ifkit.sensors[0].inspect
17
- ifkit.sensors[0].rate = 64
18
- ifkit.sensors[0].trigger = 20
19
- puts ifkit.sensors[0].inspect
20
- end