phidgets 0.1.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +3 -0
  3. data/README.rdoc +32 -43
  4. data/Rakefile +4 -2
  5. data/bin/phidget +18 -72
  6. data/ext/phidgets/extconf.rb +5 -8
  7. data/ext/phidgets/phidgets.c +708 -173
  8. data/ext/phidgets/phidgets.h +54 -35
  9. data/ext/phidgets/phidgets_accelerometer.c +193 -109
  10. data/ext/phidgets/phidgets_bldc_motor.c +529 -0
  11. data/ext/phidgets/phidgets_capacitive_touch.c +302 -0
  12. data/ext/phidgets/phidgets_common.c +570 -315
  13. data/ext/phidgets/phidgets_current_input.c +229 -0
  14. data/ext/phidgets/phidgets_dc_motor.c +562 -0
  15. data/ext/phidgets/phidgets_dictionary.c +154 -213
  16. data/ext/phidgets/phidgets_digital_input.c +127 -0
  17. data/ext/phidgets/phidgets_digital_output.c +288 -0
  18. data/ext/phidgets/phidgets_distance_sensor.c +295 -0
  19. data/ext/phidgets/phidgets_encoder.c +211 -192
  20. data/ext/phidgets/phidgets_frequency_counter.c +310 -177
  21. data/ext/phidgets/phidgets_gps.c +226 -164
  22. data/ext/phidgets/phidgets_gyroscope.c +195 -0
  23. data/ext/phidgets/phidgets_hub.c +39 -0
  24. data/ext/phidgets/phidgets_humidity_sensor.c +200 -0
  25. data/ext/phidgets/phidgets_ir.c +211 -171
  26. data/ext/phidgets/phidgets_lcd.c +512 -0
  27. data/ext/phidgets/phidgets_light_sensor.c +200 -0
  28. data/ext/phidgets/phidgets_log.c +263 -0
  29. data/ext/phidgets/phidgets_magnetometer.c +279 -0
  30. data/ext/phidgets/phidgets_manager.c +86 -297
  31. data/ext/phidgets/phidgets_motor_position_controller.c +787 -0
  32. data/ext/phidgets/phidgets_phsensor.c +200 -152
  33. data/ext/phidgets/phidgets_power_guard.c +144 -0
  34. data/ext/phidgets/phidgets_pressure_sensor.c +200 -0
  35. data/ext/phidgets/phidgets_rc_servo.c +672 -0
  36. data/ext/phidgets/phidgets_resistance_input.c +227 -0
  37. data/ext/phidgets/phidgets_rfid.c +107 -221
  38. data/ext/phidgets/phidgets_sound_sensor.c +284 -0
  39. data/ext/phidgets/phidgets_spatial.c +124 -318
  40. data/ext/phidgets/phidgets_stepper.c +457 -430
  41. data/ext/phidgets/phidgets_temp_sensor.c +223 -228
  42. data/ext/phidgets/phidgets_voltage_input.c +428 -0
  43. data/ext/phidgets/phidgets_voltage_output.c +167 -0
  44. data/ext/phidgets/phidgets_voltage_ratio_input.c +435 -0
  45. data/lib/phidgets.rb +21 -14
  46. data/lib/phidgets/accelerometer.rb +11 -15
  47. data/lib/phidgets/bldc_motor.rb +45 -0
  48. data/lib/phidgets/capacitive_touch.rb +33 -0
  49. data/lib/phidgets/common.rb +40 -69
  50. data/lib/phidgets/current_input.rb +21 -0
  51. data/lib/phidgets/dc_motor.rb +45 -0
  52. data/lib/phidgets/dictionary.rb +30 -39
  53. data/lib/phidgets/digital_input.rb +21 -0
  54. data/lib/phidgets/digital_output.rb +56 -0
  55. data/lib/phidgets/distance_sensor.rb +33 -0
  56. data/lib/phidgets/encoder.rb +1 -29
  57. data/lib/phidgets/frequency_counter.rb +23 -14
  58. data/lib/phidgets/gps.rb +34 -26
  59. data/lib/phidgets/gyroscope.rb +21 -0
  60. data/lib/phidgets/humidity_sensor.rb +21 -0
  61. data/lib/phidgets/ir.rb +34 -39
  62. data/lib/phidgets/light_sensor.rb +21 -0
  63. data/lib/phidgets/magnetometer.rb +21 -0
  64. data/lib/phidgets/manager.rb +18 -66
  65. data/lib/phidgets/motor_position_controller.rb +45 -0
  66. data/lib/phidgets/ph_sensor.rb +2 -6
  67. data/lib/phidgets/pressure_sensor.rb +21 -0
  68. data/lib/phidgets/rc_servo.rb +58 -0
  69. data/lib/phidgets/resistance_input.rb +21 -0
  70. data/lib/phidgets/rfid.rb +22 -38
  71. data/lib/phidgets/sound_sensor.rb +21 -0
  72. data/lib/phidgets/spatial.rb +11 -15
  73. data/lib/phidgets/stepper.rb +48 -50
  74. data/lib/phidgets/temperature_sensor.rb +11 -15
  75. data/lib/phidgets/version.rb +5 -0
  76. data/lib/phidgets/voltage_input.rb +34 -0
  77. data/lib/phidgets/voltage_output.rb +23 -0
  78. data/lib/phidgets/voltage_ratio_input.rb +34 -0
  79. data/phidgets.gemspec +3 -22
  80. data/test/test_accelerometer.rb +42 -23
  81. data/test/test_bldc_motor.rb +134 -0
  82. data/test/test_capacitive_touch.rb +82 -0
  83. data/test/test_common.rb +125 -108
  84. data/test/test_current_input.rb +62 -0
  85. data/test/test_dc_motor.rb +146 -0
  86. data/test/test_dictionary.rb +22 -54
  87. data/test/test_digital_input.rb +30 -0
  88. data/test/test_digital_output.rb +70 -0
  89. data/test/test_distance_sensor.rb +76 -0
  90. data/test/test_encoder.rb +45 -38
  91. data/test/test_frequency_counter.rb +71 -36
  92. data/test/test_gps.rb +29 -38
  93. data/test/test_gyroscope.rb +54 -0
  94. data/test/test_helper.rb +0 -1
  95. data/test/test_hub.rb +14 -0
  96. data/test/test_humidity_sensor.rb +58 -0
  97. data/test/test_ir.rb +34 -34
  98. data/test/test_lcd.rb +146 -0
  99. data/test/test_light_sensor.rb +58 -0
  100. data/test/test_magnetometer.rb +78 -0
  101. data/test/test_manager.rb +10 -79
  102. data/test/test_motor_control.rb +146 -108
  103. data/test/test_phidgets.rb +2 -14
  104. data/test/test_phsensor.rb +46 -34
  105. data/test/test_power_guard.rb +42 -0
  106. data/test/test_pressure_sensor.rb +58 -0
  107. data/test/test_rc_servo.rb +174 -0
  108. data/test/test_resistance_input.rb +66 -0
  109. data/test/test_rfid.rb +15 -54
  110. data/test/test_sound_sensor.rb +78 -0
  111. data/test/test_spatial.rb +19 -85
  112. data/test/test_stepper.rb +89 -98
  113. data/test/test_temp_sensor.rb +42 -47
  114. data/test/test_voltage_input.rb +102 -0
  115. data/test/test_voltage_output.rb +46 -0
  116. data/test/test_voltage_ratio_input.rb +102 -0
  117. metadata +72 -89
  118. data/ext/phidgets/phidgets_advanced_servo.c +0 -567
  119. data/ext/phidgets/phidgets_analog.c +0 -139
  120. data/ext/phidgets/phidgets_bridge.c +0 -263
  121. data/ext/phidgets/phidgets_interface_kit.c +0 -340
  122. data/ext/phidgets/phidgets_led.c +0 -178
  123. data/ext/phidgets/phidgets_motor_control.c +0 -642
  124. data/ext/phidgets/phidgets_servo.c +0 -276
  125. data/ext/phidgets/phidgets_text_lcd.c +0 -381
  126. data/ext/phidgets/phidgets_text_led.c +0 -107
  127. data/ext/phidgets/phidgets_weight_sensor.c +0 -113
  128. data/lib/phidgets/advanced_servo.rb +0 -49
  129. data/lib/phidgets/analog.rb +0 -8
  130. data/lib/phidgets/bridge.rb +0 -25
  131. data/lib/phidgets/interfacekit.rb +0 -49
  132. data/lib/phidgets/led.rb +0 -8
  133. data/lib/phidgets/motor_control.rb +0 -110
  134. data/lib/phidgets/servo.rb +0 -23
  135. data/lib/phidgets/text_lcd.rb +0 -8
  136. data/lib/phidgets/text_led.rb +0 -8
  137. data/lib/phidgets/weight_sensor.rb +0 -25
  138. data/test/test_advanced_servo.rb +0 -152
  139. data/test/test_analog.rb +0 -45
  140. data/test/test_bridge.rb +0 -77
  141. data/test/test_interfacekit.rb +0 -97
  142. data/test/test_led.rb +0 -55
  143. data/test/test_servo.rb +0 -67
  144. data/test/test_text_lcd.rb +0 -115
  145. data/test/test_text_led.rb +0 -35
  146. data/test/test_weight_sensor.rb +0 -32
@@ -0,0 +1,45 @@
1
+
2
+
3
+ module Phidgets
4
+ class MotorPositionController < Common
5
+
6
+ # call-seq:
7
+ # setOnDutyCycleUpdateHandler(proc=nil, &block)
8
+ #
9
+ # Assigns a handler that will be called when the DutyCycleUpdate event occurs.
10
+ #
11
+ def setOnDutyCycleUpdateHandler(cb_proc = nil, &cb_block)
12
+ @on_duty_cycle_update_thread.kill if defined? @on_duty_cycle_update_thread and @on_duty_cycle_update_thread.alive?
13
+ callback = cb_proc || cb_block
14
+ @on_duty_cycle_update_thread = Thread.new {ext_setOnDutyCycleUpdateHandler(callback)}
15
+ end
16
+
17
+ # call-seq:
18
+ # setOnPositionChangeHandler(proc=nil, &block)
19
+ #
20
+ # Assigns a handler that will be called when the PositionChange event occurs.
21
+ #
22
+ def setOnPositionChangeHandler(cb_proc = nil, &cb_block)
23
+ @on_position_change_thread.kill if defined? @on_position_change_thread and @on_position_change_thread.alive?
24
+ callback = cb_proc || cb_block
25
+ @on_position_change_thread = Thread.new {ext_setOnPositionChangeHandler(callback)}
26
+ end
27
+
28
+ # call-seq:
29
+ # setTargetPosition_async(proc=nil, &block)
30
+ #
31
+ # If the controller is configured and the TargetPosition is set, the motor will try to reach the TargetPostiion.
32
+ #
33
+ def setTargetPosition_async(position, cb_proc = nil, &cb_block)
34
+ @target_position_async_thread.kill if defined? @target_position_async_thread and @target_position_async_thread.alive?
35
+ callback = cb_proc || cb_block
36
+ @target_position_async_thread = Thread.new {ext_setTargetPosition_async(position, callback)}
37
+ end
38
+
39
+ alias :on_duty_cycle_update :setOnDutyCycleUpdateHandler
40
+ alias :on_position_change :setOnPositionChangeHandler
41
+ alias :set_target_position_async :setTargetPosition_async
42
+
43
+ end
44
+ end
45
+
@@ -3,23 +3,19 @@
3
3
  module Phidgets
4
4
  class PHSensor < Common
5
5
 
6
- unless RUBY_VERSION < '1.9.0'
7
-
8
6
  # call-seq:
9
7
  # setOnPHChangeHandler(proc=nil, &block)
10
8
  #
11
- # Set a PH change handler. This is called when the PH changes by more then the change trigger.
9
+ # Assigns a handler that will be called when the PHChange event occurs.
12
10
  #
13
11
  def setOnPHChangeHandler(cb_proc = nil, &cb_block)
14
- @on_ph_change_thread.kill if defined? @on_ph_change_thread
12
+ @on_ph_change_thread.kill if defined? @on_ph_change_thread and @on_ph_change_thread.alive?
15
13
  callback = cb_proc || cb_block
16
14
  @on_ph_change_thread = Thread.new {ext_setOnPHChangeHandler(callback)}
17
15
  end
18
16
 
19
17
  alias :on_ph_change :setOnPHChangeHandler
20
18
 
21
- end
22
-
23
19
  end
24
20
  end
25
21
 
@@ -0,0 +1,21 @@
1
+
2
+
3
+ module Phidgets
4
+ class PressureSensor < Common
5
+
6
+ # call-seq:
7
+ # setOnPressureChangeHandler(proc=nil, &block)
8
+ #
9
+ # Assigns a handler that will be called when the PressureChange event occurs.
10
+ #
11
+ def setOnPressureChangeHandler(cb_proc = nil, &cb_block)
12
+ @on_pressure_change_thread.kill if defined? @on_pressure_change_thread and @on_pressure_change_thread.alive?
13
+ callback = cb_proc || cb_block
14
+ @on_pressure_change_thread = Thread.new {ext_setOnPressureChangeHandler(callback)}
15
+ end
16
+
17
+ alias :on_pressure_change :setOnPressureChangeHandler
18
+
19
+ end
20
+ end
21
+
@@ -0,0 +1,58 @@
1
+
2
+ module Phidgets
3
+ class RCServo < Common
4
+
5
+ # call-seq:
6
+ # setOnPositionChangeHandler(proc=nil, &block)
7
+ #
8
+ # Assigns a handler that will be called when the PositionChange event occurs.
9
+ #
10
+ def setOnPositionChangeHandler(cb_proc = nil, &cb_block)
11
+ @on_position_change_thread.kill if defined? @on_position_change_thread and @on_position_change_thread.alive?
12
+ callback = cb_proc || cb_block
13
+ @on_position_change_thread = Thread.new {ext_setOnPositionChangeHandler(callback)}
14
+ end
15
+
16
+
17
+ # call-seq:
18
+ # setOnTargetPositionReachedHandler(proc=nil, &block)
19
+ #
20
+ # Assigns a handler that will be called when the TargetPositionReached event occurs.
21
+ #
22
+ def setOnTargetPositionReachedHandler(cb_proc = nil, &cb_block)
23
+ @on_target_position_reached_thread.kill if defined? @on_target_position_reached_thread and @on_target_position_reached_thread.alive?
24
+ callback = cb_proc || cb_block
25
+ @on_target_position_reached_thread = Thread.new {ext_setOnTargetPositionReachedHandler(callback)}
26
+ end
27
+
28
+
29
+ # call-seq:
30
+ # setOnVelocityChangeHandler(proc=nil, &block)
31
+ #
32
+ # Assigns a handler that will be called when the PositionChange event occurs.
33
+ #
34
+ def setOnVelocityChangeHandler(cb_proc = nil, &cb_block)
35
+ @on_velocity_change_thread.kill if defined? @on_velocity_change_thread and @on_velocity_change_thread.alive?
36
+ callback = cb_proc || cb_block
37
+ @on_velocity_change_thread = Thread.new {ext_setOnVelocityChangeHandler(callback)}
38
+ end
39
+
40
+ # call-seq:
41
+ # setTargetPosition_async(proc=nil, &block)
42
+ #
43
+ # If the controller is configured and the TargetPosition is set, the motor will try to reach the TargetPostiion.
44
+ #
45
+ def setTargetPosition_async(position, cb_proc = nil, &cb_block)
46
+ @target_position_async_thread.kill if defined? @target_position_async_thread and @target_position_async_thread.alive?
47
+ callback = cb_proc || cb_block
48
+ @target_position_async_thread = Thread.new {ext_setTargetPosition_async(position, callback)}
49
+ end
50
+
51
+
52
+ alias :on_position_change :setOnPositionChangeHandler
53
+ alias :on_target_position_reached :setOnTargetPositionReachedHandler
54
+ alias :on_velocity_change :setOnVelocityChangeHandler
55
+ alias :set_target_position_async :setTargetPosition_async
56
+
57
+ end
58
+ end
@@ -0,0 +1,21 @@
1
+
2
+
3
+ module Phidgets
4
+ class ResistanceInput < Common
5
+
6
+ # call-seq:
7
+ # setOnResistanceChangeHandler(proc=nil, &block)
8
+ #
9
+ # Assigns a handler that will be called when the ResistanceChange event occurs.
10
+ #
11
+ def setOnResistanceChangeHandler(cb_proc = nil, &cb_block)
12
+ @on_resistance_change_thread.kill if defined? @on_resistance_change_thread and @on_resistance_change_thread.alive?
13
+ callback = cb_proc || cb_block
14
+ @on_resistance_change_thread = Thread.new {ext_setOnResistanceChangeHandler(callback)}
15
+ end
16
+
17
+ alias :on_resistance_change :setOnResistanceChangeHandler
18
+
19
+ end
20
+ end
21
+
@@ -3,47 +3,31 @@
3
3
  module Phidgets
4
4
  class RFID < Common
5
5
 
6
- unless RUBY_VERSION < '1.9.0'
7
-
8
- # call-seq:
9
- # setOnTagHandler(proc=nil, &block)
10
- #
11
- # Set a tag handler. This is called when a tag is first detected by the reader.
12
- #
13
- def setOnTagHandler(cb_proc = nil, &cb_block)
14
- @on_tag_thread.kill if defined? @on_tag_thread
15
- callback = cb_proc || cb_block
16
- @on_tag_thread = Thread.new {ext_setOnTagHandler(callback)}
17
- end
18
-
19
- # call-seq:
20
- # setOnTagLostHandler(proc=nil, &block)
21
- #
22
- # Set a tag lost handler. This is called when a tag is no longer detected by the reader.
23
- #
24
- def setOnTagLostHandler(cb_proc = nil, &cb_block)
25
- @on_tag_lost_thread.kill if defined? @on_tag_lost_thread
26
- callback = cb_proc || cb_block
27
- @on_tag_lost_thread = Thread.new {ext_setOnTagLostHandler(callback)}
28
- end
29
-
30
- # call-seq:
31
- # setOnOutputChangeHandler(proc=nil, &block)
32
- #
33
- # Set an output change handler. This is called when an output changes.
34
- #
35
- def setOnOutputChangeHandler(cb_proc = nil, &cb_block)
36
- @on_output_change_thread.kill if defined? @on_output_change_thread
37
- callback = cb_proc || cb_block
38
- @on_output_change_thread = Thread.new {ext_setOnOutputChangeHandler(callback)}
39
- end
40
-
41
- alias :on_tag :setOnTagHandler
42
- alias :on_tag_lost :setOnTagLostHandler
43
- alias :on_output_change :setOnOutputChangeHandler
6
+ # call-seq:
7
+ # setOnTagHandler(proc=nil, &block)
8
+ #
9
+ # Assigns a handler that will be called when the Tag event occurs.
10
+ #
11
+ def setOnTagHandler(cb_proc = nil, &cb_block)
12
+ @on_tag_thread.kill if defined? @on_tag_thread and @on_tag_thread.alive?
13
+ callback = cb_proc || cb_block
14
+ @on_tag_thread = Thread.new {ext_setOnTagHandler(callback)}
15
+ end
44
16
 
17
+ # call-seq:
18
+ # setOnTagLostHandler(proc=nil, &block)
19
+ #
20
+ # Assigns a handler that will be called when the TagLost event occurs.
21
+ #
22
+ def setOnTagLostHandler(cb_proc = nil, &cb_block)
23
+ @on_tag_lost_thread.kill if defined? @on_tag_lost_thread and @on_tag_lost_thread.alive?
24
+ callback = cb_proc || cb_block
25
+ @on_tag_lost_thread = Thread.new {ext_setOnTagLostHandler(callback)}
45
26
  end
46
27
 
28
+ alias :on_tag :setOnTagHandler
29
+ alias :on_tag_lost :setOnTagLostHandler
30
+
47
31
  end
48
32
  end
49
33
 
@@ -0,0 +1,21 @@
1
+
2
+
3
+ module Phidgets
4
+ class SoundSensor < Common
5
+
6
+ # call-seq:
7
+ # setOnSPLChangeHandler(proc=nil, &block)
8
+ #
9
+ # Assigns a handler that will be called when the SPLChange event occurs.
10
+ #
11
+ def setOnSPLChangeHandler(cb_proc = nil, &cb_block)
12
+ @on_spl_change_thread.kill if defined? @on_spl_change_thread and @on_spl_change_thread.alive?
13
+ callback = cb_proc || cb_block
14
+ @on_spl_change_thread = Thread.new {ext_setOnSPLChangeHandler(callback)}
15
+ end
16
+
17
+ alias :on_spl_change :setOnSPLChangeHandler
18
+
19
+ end
20
+ end
21
+
@@ -3,23 +3,19 @@
3
3
  module Phidgets
4
4
  class Spatial < Common
5
5
 
6
- unless RUBY_VERSION < '1.9.0'
7
-
8
- # call-seq:
9
- # setOnSpatialDataHandler(proc=nil, &block)
10
- #
11
- # Set a Data event handler. This is called at getDataRate, up to 8ms.
12
- #
13
- def setOnSpatialDataHandler(cb_proc = nil, &cb_block)
14
- @on_spatial_data_thread.kill if defined? @on_spatial_data_thread
15
- callback = cb_proc || cb_block
16
- @on_spatial_data_thread = Thread.new {ext_setOnSpatialDataHandler(callback)}
17
- end
18
-
19
- alias :on_spatial_data :setOnSpatialDataHandler
20
-
6
+ # call-seq:
7
+ # setOnSpatialDataHandler(proc=nil, &block)
8
+ #
9
+ # Assigns a handler that will be called when the SpatialData event occurs.
10
+ #
11
+ def setOnSpatialDataHandler(cb_proc = nil, &cb_block)
12
+ @on_spatial_data_thread.kill if defined? @on_spatial_data_thread and @on_spatial_data_thread.alive?
13
+ callback = cb_proc || cb_block
14
+ @on_spatial_data_thread = Thread.new {ext_setOnSpatialDataHandler(callback)}
21
15
  end
22
16
 
17
+ alias :on_spatial_data :setOnSpatialDataHandler
18
+
23
19
  end
24
20
  end
25
21
 
@@ -3,59 +3,57 @@
3
3
  module Phidgets
4
4
  class Stepper < Common
5
5
 
6
- unless RUBY_VERSION < '1.9.0'
7
-
8
- # call-seq:
9
- # setOnInputChangeHandler(proc=nil, &block)
10
- #
11
- # Set a digital input change handler. This is called when a digital input changes.
12
- #
13
- def setOnInputChangeHandler(cb_proc = nil, &cb_block)
14
- @on_input_change_thread.kill if defined? @on_input_change_thread
15
- callback = cb_proc || cb_block
16
- @on_input_change_thread = Thread.new {ext_setOnInputChangeHandler(callback)}
17
- end
18
-
19
- # call-seq:
20
- # setOnVelocityChangeHandler(proc=nil, &block)
21
- #
22
- # Sets a velocity change event handler. This is called when the velocity changes.
23
- #
24
- def setOnVelocityChangeHandler(cb_proc = nil, &cb_block)
25
- @on_velocity_change_thread.kill if defined? @on_velocity_change_thread
26
- callback = cb_proc || cb_block
27
- @on_velocity_change_thread = Thread.new {ext_setOnVelocityChangeHandler(callback)}
28
- end
29
-
30
- # call-seq:
31
- # setOnPositionChangeHandler(proc=nil, &block)
32
- #
33
- # Sets a position change event handler. This is called when the position changes.
34
- #
35
- def setOnPositionChangeHandler(cb_proc = nil, &cb_block)
36
- @on_position_change_thread.kill if defined? @on_position_change_thread
37
- callback = cb_proc || cb_block
38
- @on_position_change_thread = Thread.new {ext_setOnPositionChangeHandler(callback)}
39
- end
40
-
41
- # call-seq:
42
- # setOnCurrentChangeHandler(proc=nil, &block)
43
- #
44
- # Sets a current change event handler. This is called when the current draw changes.
45
- #
46
- def setOnCurrentChangeHandler(cb_proc = nil, &cb_block)
47
- @on_current_change_thread.kill if defined? @on_current_change_thread
48
- callback = cb_proc || cb_block
49
- @on_current_change_thread = Thread.new {ext_setOnCurrentChangeHandler(callback)}
50
- end
51
-
52
- alias :on_input_change :setOnInputChangeHandler
53
- alias :on_velocity_change :setOnVelocityChangeHandler
54
- alias :on_position_change :setOnPositionChangeHandler
55
- alias :on_current_change :setOnCurrentChangeHandler
6
+ # call-seq:
7
+ # setOnPositionChangeHandler(proc=nil, &block)
8
+ #
9
+ # Assigns a handler that will be called when the PositionChange event occurs.
10
+ #
11
+ def setOnPositionChangeHandler(cb_proc = nil, &cb_block)
12
+ @on_position_change_thread.kill if defined? @on_position_change_thread and @on_position_change_thread.alive?
13
+ callback = cb_proc || cb_block
14
+ @on_position_change_thread = Thread.new {ext_setOnPositionChangeHandler(callback)}
15
+ end
16
+
17
+ # call-seq:
18
+ # setOnStoppedHandler(proc=nil, &block)
19
+ #
20
+ # Assigns a handler that will be called when the Stopped event occurs.
21
+ #
22
+ def setOnStoppedHandler(cb_proc = nil, &cb_block)
23
+ @on_stopped_thread.kill if defined? @on_stopped_thread and @on_stopped_thread.alive?
24
+ callback = cb_proc || cb_block
25
+ @on_stopped_thread = Thread.new {ext_setOnStoppedHandler(callback)}
26
+ end
56
27
 
28
+ # call-seq:
29
+ # setOnVelocityChangeHandler(proc=nil, &block)
30
+ #
31
+ # Assigns a handler that will be called when the VelocityChange event occurs.
32
+ #
33
+ def setOnVelocityChangeHandler(cb_proc = nil, &cb_block)
34
+ @on_velocity_change_thread.kill if defined? @on_velocity_change_thread and @on_velocity_change_thread.alive?
35
+ callback = cb_proc || cb_block
36
+ @on_velocity_change_thread = Thread.new {ext_setOnVelocityChangeHandler(callback)}
57
37
  end
58
38
 
39
+ # call-seq:
40
+ # setTargetPosition_async(proc=nil, &block)
41
+ #
42
+ # If the controller is configured and the TargetPosition is set, the Stepper motor will move towards the TargetPosition at the specified Acceleration and Velocity.
43
+ # TargetPosition is only used when the ControlMode is set to step mode.
44
+ # Units for Position, Velocity, and Acceleration can be set by the user through the RescaleFactor. The RescaleFactor allows you to use more intuitive units such as rotations, or degrees.
45
+ #
46
+ def setTargetPosition_async(position, cb_proc = nil, &cb_block)
47
+ @target_position_async_thread.kill if defined? @target_position_async_thread and @target_position_async_thread.alive?
48
+ callback = cb_proc || cb_block
49
+ @target_position_async_thread = Thread.new {ext_setTargetPosition_async(position, callback)}
50
+ end
51
+
52
+ alias :on_position_change :setOnPositionChangeHandler
53
+ alias :on_stopped :setOnStoppedHandler
54
+ alias :on_velocity_change :setOnVelocityChangeHandler
55
+ alias :set_target_position_async :setTargetPosition_async
56
+
59
57
  end
60
58
  end
61
59
 
@@ -3,23 +3,19 @@
3
3
  module Phidgets
4
4
  class TemperatureSensor < Common
5
5
 
6
- unless RUBY_VERSION < '1.9.0'
7
-
8
- # call-seq:
9
- # setOnTemperatureChangeHandler(proc=nil, &block)
10
- #
11
- # Set a temperature change handler. This is called when the temperature changes by more then the change trigger.
12
- #
13
- def setOnTemperatureChangeHandler(cb_proc = nil, &cb_block)
14
- @on_temperature_change_thread.kill if defined? @on_temperature_change_thread
15
- callback = cb_proc || cb_block
16
- @on_temperature_change_thread = Thread.new {ext_setOnTemperatureChangeHandler(callback)}
17
- end
18
-
19
- alias :on_temperature_change :setOnTemperatureChangeHandler
20
-
6
+ # call-seq:
7
+ # setOnTemperatureChangeHandler(proc=nil, &block)
8
+ #
9
+ # Assigns a handler that will be called when the TemperatureChange event occurs.
10
+ #
11
+ def setOnTemperatureChangeHandler(cb_proc = nil, &cb_block)
12
+ @on_temperature_change_thread.kill if defined? @on_temperature_change_thread and @on_temperature_change_thread.alive?
13
+ callback = cb_proc || cb_block
14
+ @on_temperature_change_thread = Thread.new {ext_setOnTemperatureChangeHandler(callback)}
21
15
  end
22
16
 
17
+ alias :on_temperature_change :setOnTemperatureChangeHandler
18
+
23
19
  end
24
20
  end
25
21