phidgets 0.1.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +3 -0
- data/README.rdoc +32 -43
- data/Rakefile +4 -2
- data/bin/phidget +18 -72
- data/ext/phidgets/extconf.rb +5 -8
- data/ext/phidgets/phidgets.c +708 -173
- data/ext/phidgets/phidgets.h +54 -35
- data/ext/phidgets/phidgets_accelerometer.c +193 -109
- data/ext/phidgets/phidgets_bldc_motor.c +529 -0
- data/ext/phidgets/phidgets_capacitive_touch.c +302 -0
- data/ext/phidgets/phidgets_common.c +570 -315
- data/ext/phidgets/phidgets_current_input.c +229 -0
- data/ext/phidgets/phidgets_dc_motor.c +562 -0
- data/ext/phidgets/phidgets_dictionary.c +154 -213
- data/ext/phidgets/phidgets_digital_input.c +127 -0
- data/ext/phidgets/phidgets_digital_output.c +288 -0
- data/ext/phidgets/phidgets_distance_sensor.c +295 -0
- data/ext/phidgets/phidgets_encoder.c +211 -192
- data/ext/phidgets/phidgets_frequency_counter.c +310 -177
- data/ext/phidgets/phidgets_gps.c +226 -164
- data/ext/phidgets/phidgets_gyroscope.c +195 -0
- data/ext/phidgets/phidgets_hub.c +39 -0
- data/ext/phidgets/phidgets_humidity_sensor.c +200 -0
- data/ext/phidgets/phidgets_ir.c +211 -171
- data/ext/phidgets/phidgets_lcd.c +512 -0
- data/ext/phidgets/phidgets_light_sensor.c +200 -0
- data/ext/phidgets/phidgets_log.c +263 -0
- data/ext/phidgets/phidgets_magnetometer.c +279 -0
- data/ext/phidgets/phidgets_manager.c +86 -297
- data/ext/phidgets/phidgets_motor_position_controller.c +787 -0
- data/ext/phidgets/phidgets_phsensor.c +200 -152
- data/ext/phidgets/phidgets_power_guard.c +144 -0
- data/ext/phidgets/phidgets_pressure_sensor.c +200 -0
- data/ext/phidgets/phidgets_rc_servo.c +672 -0
- data/ext/phidgets/phidgets_resistance_input.c +227 -0
- data/ext/phidgets/phidgets_rfid.c +107 -221
- data/ext/phidgets/phidgets_sound_sensor.c +284 -0
- data/ext/phidgets/phidgets_spatial.c +124 -318
- data/ext/phidgets/phidgets_stepper.c +457 -430
- data/ext/phidgets/phidgets_temp_sensor.c +223 -228
- data/ext/phidgets/phidgets_voltage_input.c +428 -0
- data/ext/phidgets/phidgets_voltage_output.c +167 -0
- data/ext/phidgets/phidgets_voltage_ratio_input.c +435 -0
- data/lib/phidgets.rb +21 -14
- data/lib/phidgets/accelerometer.rb +11 -15
- data/lib/phidgets/bldc_motor.rb +45 -0
- data/lib/phidgets/capacitive_touch.rb +33 -0
- data/lib/phidgets/common.rb +40 -69
- data/lib/phidgets/current_input.rb +21 -0
- data/lib/phidgets/dc_motor.rb +45 -0
- data/lib/phidgets/dictionary.rb +30 -39
- data/lib/phidgets/digital_input.rb +21 -0
- data/lib/phidgets/digital_output.rb +56 -0
- data/lib/phidgets/distance_sensor.rb +33 -0
- data/lib/phidgets/encoder.rb +1 -29
- data/lib/phidgets/frequency_counter.rb +23 -14
- data/lib/phidgets/gps.rb +34 -26
- data/lib/phidgets/gyroscope.rb +21 -0
- data/lib/phidgets/humidity_sensor.rb +21 -0
- data/lib/phidgets/ir.rb +34 -39
- data/lib/phidgets/light_sensor.rb +21 -0
- data/lib/phidgets/magnetometer.rb +21 -0
- data/lib/phidgets/manager.rb +18 -66
- data/lib/phidgets/motor_position_controller.rb +45 -0
- data/lib/phidgets/ph_sensor.rb +2 -6
- data/lib/phidgets/pressure_sensor.rb +21 -0
- data/lib/phidgets/rc_servo.rb +58 -0
- data/lib/phidgets/resistance_input.rb +21 -0
- data/lib/phidgets/rfid.rb +22 -38
- data/lib/phidgets/sound_sensor.rb +21 -0
- data/lib/phidgets/spatial.rb +11 -15
- data/lib/phidgets/stepper.rb +48 -50
- data/lib/phidgets/temperature_sensor.rb +11 -15
- data/lib/phidgets/version.rb +5 -0
- data/lib/phidgets/voltage_input.rb +34 -0
- data/lib/phidgets/voltage_output.rb +23 -0
- data/lib/phidgets/voltage_ratio_input.rb +34 -0
- data/phidgets.gemspec +3 -22
- data/test/test_accelerometer.rb +42 -23
- data/test/test_bldc_motor.rb +134 -0
- data/test/test_capacitive_touch.rb +82 -0
- data/test/test_common.rb +125 -108
- data/test/test_current_input.rb +62 -0
- data/test/test_dc_motor.rb +146 -0
- data/test/test_dictionary.rb +22 -54
- data/test/test_digital_input.rb +30 -0
- data/test/test_digital_output.rb +70 -0
- data/test/test_distance_sensor.rb +76 -0
- data/test/test_encoder.rb +45 -38
- data/test/test_frequency_counter.rb +71 -36
- data/test/test_gps.rb +29 -38
- data/test/test_gyroscope.rb +54 -0
- data/test/test_helper.rb +0 -1
- data/test/test_hub.rb +14 -0
- data/test/test_humidity_sensor.rb +58 -0
- data/test/test_ir.rb +34 -34
- data/test/test_lcd.rb +146 -0
- data/test/test_light_sensor.rb +58 -0
- data/test/test_magnetometer.rb +78 -0
- data/test/test_manager.rb +10 -79
- data/test/test_motor_control.rb +146 -108
- data/test/test_phidgets.rb +2 -14
- data/test/test_phsensor.rb +46 -34
- data/test/test_power_guard.rb +42 -0
- data/test/test_pressure_sensor.rb +58 -0
- data/test/test_rc_servo.rb +174 -0
- data/test/test_resistance_input.rb +66 -0
- data/test/test_rfid.rb +15 -54
- data/test/test_sound_sensor.rb +78 -0
- data/test/test_spatial.rb +19 -85
- data/test/test_stepper.rb +89 -98
- data/test/test_temp_sensor.rb +42 -47
- data/test/test_voltage_input.rb +102 -0
- data/test/test_voltage_output.rb +46 -0
- data/test/test_voltage_ratio_input.rb +102 -0
- metadata +72 -89
- data/ext/phidgets/phidgets_advanced_servo.c +0 -567
- data/ext/phidgets/phidgets_analog.c +0 -139
- data/ext/phidgets/phidgets_bridge.c +0 -263
- data/ext/phidgets/phidgets_interface_kit.c +0 -340
- data/ext/phidgets/phidgets_led.c +0 -178
- data/ext/phidgets/phidgets_motor_control.c +0 -642
- data/ext/phidgets/phidgets_servo.c +0 -276
- data/ext/phidgets/phidgets_text_lcd.c +0 -381
- data/ext/phidgets/phidgets_text_led.c +0 -107
- data/ext/phidgets/phidgets_weight_sensor.c +0 -113
- data/lib/phidgets/advanced_servo.rb +0 -49
- data/lib/phidgets/analog.rb +0 -8
- data/lib/phidgets/bridge.rb +0 -25
- data/lib/phidgets/interfacekit.rb +0 -49
- data/lib/phidgets/led.rb +0 -8
- data/lib/phidgets/motor_control.rb +0 -110
- data/lib/phidgets/servo.rb +0 -23
- data/lib/phidgets/text_lcd.rb +0 -8
- data/lib/phidgets/text_led.rb +0 -8
- data/lib/phidgets/weight_sensor.rb +0 -25
- data/test/test_advanced_servo.rb +0 -152
- data/test/test_analog.rb +0 -45
- data/test/test_bridge.rb +0 -77
- data/test/test_interfacekit.rb +0 -97
- data/test/test_led.rb +0 -55
- data/test/test_servo.rb +0 -67
- data/test/test_text_lcd.rb +0 -115
- data/test/test_text_led.rb +0 -35
- 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
|
+
|
data/lib/phidgets/ph_sensor.rb
CHANGED
@@ -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
|
-
#
|
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
|
+
|
data/lib/phidgets/rfid.rb
CHANGED
@@ -3,47 +3,31 @@
|
|
3
3
|
module Phidgets
|
4
4
|
class RFID < Common
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
+
|
data/lib/phidgets/spatial.rb
CHANGED
@@ -3,23 +3,19 @@
|
|
3
3
|
module Phidgets
|
4
4
|
class Spatial < Common
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
|
data/lib/phidgets/stepper.rb
CHANGED
@@ -3,59 +3,57 @@
|
|
3
3
|
module Phidgets
|
4
4
|
class Stepper < Common
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
|