phidgets 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,107 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "phidgets.h"
|
3
|
-
|
4
|
-
|
5
|
-
VALUE ph_textled_init(VALUE self);
|
6
|
-
VALUE ph_textled_get_row_count(VALUE self);
|
7
|
-
VALUE ph_textled_get_column_count(VALUE self);
|
8
|
-
VALUE ph_textled_get_brightness(VALUE self);
|
9
|
-
VALUE ph_textled_set_brightness(VALUE self, VALUE brightness);
|
10
|
-
VALUE ph_textled_set_display_string(VALUE self, VALUE index, VALUE string);
|
11
|
-
|
12
|
-
|
13
|
-
void Init_text_led() {
|
14
|
-
VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
|
15
|
-
VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
|
16
|
-
VALUE ph_textled = rb_define_class_under(ph_module, "TextLED", ph_common);
|
17
|
-
|
18
|
-
/* Document-method: new
|
19
|
-
* call-seq: new
|
20
|
-
*
|
21
|
-
* Creates a Phidget TextLED object.
|
22
|
-
*/
|
23
|
-
rb_define_method(ph_textled, "initialize", ph_textled_init, 0);
|
24
|
-
|
25
|
-
/* Document-method: getRowCount
|
26
|
-
* call-seq: getRowCount -> count
|
27
|
-
*
|
28
|
-
* Gets the number of rows supported by this display.
|
29
|
-
*/
|
30
|
-
rb_define_method(ph_textled, "getRowCount", ph_textled_get_row_count, 0);
|
31
|
-
|
32
|
-
/* Document-method: getColumnCount
|
33
|
-
* call-seq: getColumnCount -> count
|
34
|
-
*
|
35
|
-
* Gets the number of columns per supported by this display.
|
36
|
-
*/
|
37
|
-
rb_define_method(ph_textled, "getColumnCount", ph_textled_get_column_count, 0);
|
38
|
-
|
39
|
-
/* Document-method: getBrightness
|
40
|
-
* call-seq: getBrightness -> brightness
|
41
|
-
*
|
42
|
-
* Gets the last set brightness value.
|
43
|
-
*/
|
44
|
-
rb_define_method(ph_textled, "getBrightness", ph_textled_get_brightness, 0);
|
45
|
-
|
46
|
-
/* Document-method: setBrightness
|
47
|
-
* call-seq: setBrightness(brightness)
|
48
|
-
*
|
49
|
-
* Sets the last set brightness value.
|
50
|
-
*/
|
51
|
-
rb_define_method(ph_textled, "setBrightness", ph_textled_set_brightness, 1);
|
52
|
-
|
53
|
-
/* Document-method: setDisplayString
|
54
|
-
* call-seq: setDisplayString(index, string)
|
55
|
-
*
|
56
|
-
* Sets a row on the display.
|
57
|
-
*/
|
58
|
-
rb_define_method(ph_textled, "setDisplayString", ph_textled_set_display_string, 2);
|
59
|
-
|
60
|
-
rb_define_alias(ph_textled, "row_count", "getRowCount");
|
61
|
-
rb_define_alias(ph_textled, "column_count", "getColumnCount");
|
62
|
-
rb_define_alias(ph_textled, "brightness", "getBrightness");
|
63
|
-
rb_define_alias(ph_textled, "brightness=", "setBrightness");
|
64
|
-
rb_define_alias(ph_textled, "display_string", "setDisplayString");
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
VALUE ph_textled_init(VALUE self) {
|
70
|
-
ph_data_t *ph = get_ph_data(self);
|
71
|
-
ph_raise(CPhidgetTextLED_create((CPhidgetTextLEDHandle *)(&(ph->handle))));
|
72
|
-
return self;
|
73
|
-
}
|
74
|
-
|
75
|
-
VALUE ph_textled_get_row_count(VALUE self) {
|
76
|
-
CPhidgetTextLEDHandle handle = (CPhidgetTextLEDHandle)get_ph_handle(self);
|
77
|
-
int count;
|
78
|
-
ph_raise(CPhidgetTextLED_getRowCount(handle, &count));
|
79
|
-
return INT2FIX(count);
|
80
|
-
}
|
81
|
-
|
82
|
-
VALUE ph_textled_get_column_count(VALUE self) {
|
83
|
-
CPhidgetTextLEDHandle handle = (CPhidgetTextLEDHandle)get_ph_handle(self);
|
84
|
-
int count;
|
85
|
-
ph_raise(CPhidgetTextLED_getColumnCount(handle, &count));
|
86
|
-
return INT2FIX(count);
|
87
|
-
}
|
88
|
-
|
89
|
-
VALUE ph_textled_get_brightness(VALUE self) {
|
90
|
-
CPhidgetTextLEDHandle handle = (CPhidgetTextLEDHandle)get_ph_handle(self);
|
91
|
-
int brightness;
|
92
|
-
ph_raise(CPhidgetTextLED_getBrightness(handle, &brightness));
|
93
|
-
return INT2FIX(brightness);
|
94
|
-
}
|
95
|
-
|
96
|
-
VALUE ph_textled_set_brightness(VALUE self, VALUE brightness) {
|
97
|
-
CPhidgetTextLEDHandle handle = (CPhidgetTextLEDHandle)get_ph_handle(self);
|
98
|
-
ph_raise(CPhidgetTextLED_setBrightness(handle, FIX2INT(brightness)));
|
99
|
-
return Qnil;
|
100
|
-
}
|
101
|
-
|
102
|
-
VALUE ph_textled_set_display_string(VALUE self, VALUE index, VALUE string) {
|
103
|
-
CPhidgetTextLEDHandle handle = (CPhidgetTextLEDHandle)get_ph_handle(self);
|
104
|
-
ph_raise(CPhidgetTextLED_setDisplayString(handle, FIX2INT(index), StringValueCStr(string)));
|
105
|
-
return Qnil;
|
106
|
-
}
|
107
|
-
|
@@ -1,113 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "phidgets.h"
|
3
|
-
|
4
|
-
|
5
|
-
VALUE ph_weight_init(VALUE self);
|
6
|
-
VALUE ph_weight_get_weight(VALUE self);
|
7
|
-
VALUE ph_weight_get_weight_change_trigger(VALUE self);
|
8
|
-
VALUE ph_weight_set_weight_change_trigger(VALUE self, VALUE trigger);
|
9
|
-
|
10
|
-
#ifdef PH_CALLBACK
|
11
|
-
VALUE ph_weight_set_on_weight_change_handler(VALUE self, VALUE handler);
|
12
|
-
int ph_weight_on_weight_change(CPhidgetWeightSensorHandle phid, void *userPtr, double weight);
|
13
|
-
#endif
|
14
|
-
|
15
|
-
|
16
|
-
void Init_weight_sensor() {
|
17
|
-
VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
|
18
|
-
VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
|
19
|
-
VALUE ph_weight = rb_define_class_under(ph_module, "WeightSensor", ph_common);
|
20
|
-
|
21
|
-
/* Document-method: new
|
22
|
-
* call-seq: new
|
23
|
-
*
|
24
|
-
* Creates a Phidget WeightSensor object.
|
25
|
-
*/
|
26
|
-
rb_define_method(ph_weight, "initialize", ph_weight_init, 0);
|
27
|
-
|
28
|
-
/* Document-method: getWeight
|
29
|
-
* call-seq: getWeight -> weight
|
30
|
-
*
|
31
|
-
* Gets the sensed weight.
|
32
|
-
*/
|
33
|
-
rb_define_method(ph_weight, "getWeight", ph_weight_get_weight, 0);
|
34
|
-
|
35
|
-
/* Document-method: getWeightChangeTrigger
|
36
|
-
* call-seq: getWeightChangeTrigger -> trigger
|
37
|
-
*
|
38
|
-
* Gets the weight change trigger.
|
39
|
-
*/
|
40
|
-
rb_define_method(ph_weight, "getWeightChangeTrigger", ph_weight_get_weight_change_trigger, 0);
|
41
|
-
|
42
|
-
/* Document-method: setWeightChangeTrigger
|
43
|
-
* call-seq: setWeightChangeTrigger(trigger)
|
44
|
-
*
|
45
|
-
* Sets the weight change trigger.
|
46
|
-
*/
|
47
|
-
rb_define_method(ph_weight, "setWeightChangeTrigger", ph_weight_set_weight_change_trigger, 1);
|
48
|
-
|
49
|
-
#ifdef PH_CALLBACK
|
50
|
-
rb_define_private_method(ph_weight, "ext_setOnWeightChangeHandler", ph_weight_set_on_weight_change_handler, 1);
|
51
|
-
#endif
|
52
|
-
|
53
|
-
rb_define_alias(ph_weight, "weight", "getWeight");
|
54
|
-
rb_define_alias(ph_weight, "weight_change_trigger", "getWeightChangeTrigger");
|
55
|
-
rb_define_alias(ph_weight, "weight_change_trigger=", "setWeightChangeTrigger");
|
56
|
-
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
VALUE ph_weight_init(VALUE self) {
|
61
|
-
ph_data_t *ph = get_ph_data(self);
|
62
|
-
ph_raise(CPhidgetWeightSensor_create((CPhidgetWeightSensorHandle *)(&(ph->handle))));
|
63
|
-
return self;
|
64
|
-
}
|
65
|
-
|
66
|
-
VALUE ph_weight_get_weight(VALUE self) {
|
67
|
-
CPhidgetWeightSensorHandle handle = (CPhidgetWeightSensorHandle)get_ph_handle(self);
|
68
|
-
double weight;
|
69
|
-
ph_raise(CPhidgetWeightSensor_getWeight(handle, &weight));
|
70
|
-
return rb_float_new(weight);
|
71
|
-
}
|
72
|
-
|
73
|
-
VALUE ph_weight_get_weight_change_trigger(VALUE self) {
|
74
|
-
CPhidgetWeightSensorHandle handle = (CPhidgetWeightSensorHandle)get_ph_handle(self);
|
75
|
-
double trigger;
|
76
|
-
ph_raise(CPhidgetWeightSensor_getWeightChangeTrigger(handle, &trigger));
|
77
|
-
return rb_float_new(trigger);
|
78
|
-
}
|
79
|
-
|
80
|
-
VALUE ph_weight_set_weight_change_trigger(VALUE self, VALUE trigger) {
|
81
|
-
CPhidgetWeightSensorHandle handle = (CPhidgetWeightSensorHandle)get_ph_handle(self);
|
82
|
-
ph_raise(CPhidgetWeightSensor_setWeightChangeTrigger(handle, NUM2DBL(trigger)));
|
83
|
-
return Qnil;
|
84
|
-
}
|
85
|
-
|
86
|
-
|
87
|
-
#ifdef PH_CALLBACK
|
88
|
-
VALUE ph_weight_set_on_weight_change_handler(VALUE self, VALUE handler) {
|
89
|
-
ph_data_t *ph = get_ph_data(self);
|
90
|
-
ph_callback_data_t *callback_data = &ph->dev_callback_1;
|
91
|
-
if( TYPE(handler) == T_NIL ) {
|
92
|
-
callback_data->exit = true;
|
93
|
-
ph_raise(CPhidgetWeightSensor_set_OnWeightChange_Handler((CPhidgetWeightSensorHandle)ph->handle, NULL, (void *)NULL));
|
94
|
-
} else {
|
95
|
-
callback_data->called = false;
|
96
|
-
callback_data->exit = false;
|
97
|
-
callback_data->phidget = self;
|
98
|
-
callback_data->callback = handler;
|
99
|
-
ph_raise(CPhidgetWeightSensor_set_OnWeightChange_Handler((CPhidgetWeightSensorHandle)ph->handle, ph_weight_on_weight_change, (void *)callback_data));
|
100
|
-
ph_callback_thread(callback_data);
|
101
|
-
}
|
102
|
-
return Qnil;
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
int ph_weight_on_weight_change(CPhidgetWeightSensorHandle phid, void *userPtr, double weight) {
|
107
|
-
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
108
|
-
callback_data->called = true;
|
109
|
-
return EPHIDGET_OK;
|
110
|
-
}
|
111
|
-
|
112
|
-
#endif
|
113
|
-
|
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Phidgets
|
4
|
-
class AdvancedServo < Common
|
5
|
-
|
6
|
-
unless RUBY_VERSION < '1.9.0'
|
7
|
-
|
8
|
-
# call-seq:
|
9
|
-
# setOnVelocityChangeHandler(proc=nil, &block)
|
10
|
-
#
|
11
|
-
# Sets a velocity change event handler. This is called when the velocity changes.
|
12
|
-
#
|
13
|
-
def setOnVelocityChangeHandler(cb_proc = nil, &cb_block)
|
14
|
-
@on_velocity_change_thread.kill if defined? @on_velocity_change_thread
|
15
|
-
callback = cb_proc || cb_block
|
16
|
-
@on_velocity_change_thread = Thread.new {ext_setOnVelocityChangeHandler(callback)}
|
17
|
-
end
|
18
|
-
|
19
|
-
# call-seq:
|
20
|
-
# setOnPositionChangeHandler(proc=nil, &block)
|
21
|
-
#
|
22
|
-
# Sets a position change event handler. This is called when the position changes.
|
23
|
-
#
|
24
|
-
def setOnPositionChangeHandler(cb_proc = nil, &cb_block)
|
25
|
-
@on_position_change_thread.kill if defined? @on_position_change_thread
|
26
|
-
callback = cb_proc || cb_block
|
27
|
-
@on_position_change_thread = Thread.new {ext_setOnPositionChangeHandler(callback)}
|
28
|
-
end
|
29
|
-
|
30
|
-
# call-seq:
|
31
|
-
# setOnCurrentChangeHandler(proc=nil, &block)
|
32
|
-
#
|
33
|
-
# Sets a current change event handler. This is called when the current draw changes.
|
34
|
-
#
|
35
|
-
def setOnCurrentChangeHandler(cb_proc = nil, &cb_block)
|
36
|
-
@on_current_change_thread.kill if defined? @on_current_change_thread
|
37
|
-
callback = cb_proc || cb_block
|
38
|
-
@on_current_change_thread = Thread.new {ext_setOnCurrentChangeHandler(callback)}
|
39
|
-
end
|
40
|
-
|
41
|
-
alias :on_velocity_change :setOnVelocityChangeHandler
|
42
|
-
alias :on_position_change :setOnPositionChangeHandler
|
43
|
-
alias :on_current_change :setOnCurrentChangeHandler
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
data/lib/phidgets/analog.rb
DELETED
data/lib/phidgets/bridge.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Phidgets
|
4
|
-
class Bridge < Common
|
5
|
-
|
6
|
-
unless RUBY_VERSION < '1.9.0'
|
7
|
-
|
8
|
-
# call-seq:
|
9
|
-
# setOnBridgeDataHandler(proc=nil, &block)
|
10
|
-
#
|
11
|
-
# Sets a bridge data event handler. This is called at a set rate as defined by data rate.
|
12
|
-
#
|
13
|
-
def setOnBridgeDataHandler(cb_proc = nil, &cb_block)
|
14
|
-
@on_bridge_data_thread.kill if defined? @on_bridge_data_thread
|
15
|
-
callback = cb_proc || cb_block
|
16
|
-
@on_bridge_data_thread = Thread.new {ext_setOnBridgeDataHandler(callback)}
|
17
|
-
end
|
18
|
-
|
19
|
-
alias :on_bridge_data :setOnBridgeDataHandler
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Phidgets
|
4
|
-
class InterfaceKit < Common
|
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
|
-
# setOnOutputChangeHandler(proc=nil, &block)
|
21
|
-
#
|
22
|
-
# Set a digital output change handler. This is called when a digital output changes.
|
23
|
-
#
|
24
|
-
def setOnOutputChangeHandler(cb_proc = nil, &cb_block)
|
25
|
-
@on_output_change_thread.kill if defined? @on_output_change_thread
|
26
|
-
callback = cb_proc || cb_block
|
27
|
-
@on_output_change_thread = Thread.new {ext_setOnOutputChangeHandler(callback)}
|
28
|
-
end
|
29
|
-
|
30
|
-
# call-seq:
|
31
|
-
# setOnSensorChangeHandler(proc=nil, &block)
|
32
|
-
#
|
33
|
-
# Set a sensor change handler. This is called when a sensor value changes by more then the change trigger.
|
34
|
-
#
|
35
|
-
def setOnSensorChangeHandler(cb_proc = nil, &cb_block)
|
36
|
-
@on_sensor_change_thread.kill if defined? @on_sensor_change_thread
|
37
|
-
callback = cb_proc || cb_block
|
38
|
-
@on_sensor_change_thread = Thread.new {ext_setOnSensorChangeHandler(callback)}
|
39
|
-
end
|
40
|
-
|
41
|
-
alias :on_input_change :setOnInputChangeHandler
|
42
|
-
alias :on_output_change :setOnOutputChangeHandler
|
43
|
-
alias :on_sensor_change :setOnSensorChangeHandler
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
data/lib/phidgets/led.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Phidgets
|
4
|
-
class MotorControl < Common
|
5
|
-
|
6
|
-
unless RUBY_VERSION < '1.9.0'
|
7
|
-
|
8
|
-
# call-seq:
|
9
|
-
# setOnVelocityChangeHandler(proc=nil, &block)
|
10
|
-
#
|
11
|
-
# Sets a velocity change event handler. This is called when the velocity changes.
|
12
|
-
#
|
13
|
-
def setOnVelocityChangeHandler(cb_proc = nil, &cb_block)
|
14
|
-
@on_velocity_change_thread.kill if defined? @on_velocity_change_thread
|
15
|
-
callback = cb_proc || cb_block
|
16
|
-
@on_velocity_change_thread = Thread.new {ext_setOnVelocityChangeHandler(callback)}
|
17
|
-
end
|
18
|
-
|
19
|
-
# call-seq:
|
20
|
-
# setOnCurrentChangeHandler(proc=nil, &block)
|
21
|
-
#
|
22
|
-
# Sets a current change event handler. This is called when the current draw changes.
|
23
|
-
#
|
24
|
-
def setOnCurrentChangeHandler(cb_proc = nil, &cb_block)
|
25
|
-
@on_current_change_thread.kill if defined? @on_current_change_thread
|
26
|
-
callback = cb_proc || cb_block
|
27
|
-
@on_current_change_thread = Thread.new {ext_setOnCurrentChangeHandler(callback)}
|
28
|
-
end
|
29
|
-
|
30
|
-
# call-seq:
|
31
|
-
# setOnCurrentUpdateHandler(proc=nil, &block)
|
32
|
-
#
|
33
|
-
# Set a current update handler. This is called at a constant rate; every 8ms.
|
34
|
-
#
|
35
|
-
def setOnCurrentUpdateHandler(cb_proc = nil, &cb_block)
|
36
|
-
@on_current_update_thread.kill if defined? @on_current_update_thread
|
37
|
-
callback = cb_proc || cb_block
|
38
|
-
@on_current_update_thread = Thread.new {ext_setOnCurrentUpdateHandler(callback)}
|
39
|
-
end
|
40
|
-
|
41
|
-
# call-seq:
|
42
|
-
# setOnInputChangeHandler(proc=nil, &block)
|
43
|
-
#
|
44
|
-
# Set a digital input change handler. This is called when a digital input changes.
|
45
|
-
#
|
46
|
-
def setOnInputChangeHandler(cb_proc = nil, &cb_block)
|
47
|
-
@on_input_change_thread.kill if defined? @on_input_change_thread
|
48
|
-
callback = cb_proc || cb_block
|
49
|
-
@on_input_change_thread = Thread.new {ext_setOnInputChangeHandler(callback)}
|
50
|
-
end
|
51
|
-
|
52
|
-
# call-seq:
|
53
|
-
# setOnEncoderPositionChangeHandler(proc=nil, &block)
|
54
|
-
#
|
55
|
-
# Set an encoder position change handler. This is called when the encoder position changes.
|
56
|
-
#
|
57
|
-
def setOnEncoderPositionChangeHandler(cb_proc = nil, &cb_block)
|
58
|
-
@on_encoder_position_change_thread.kill if defined? @on_encoder_position_change_thread
|
59
|
-
callback = cb_proc || cb_block
|
60
|
-
@on_encoder_position_change_thread = Thread.new {ext_setOnEncoderPositionChangeHandler(callback)}
|
61
|
-
end
|
62
|
-
|
63
|
-
# call-seq:
|
64
|
-
# setOnEncoderPositionUpdateHandler(proc=nil, &block)
|
65
|
-
#
|
66
|
-
# Set an encoder position update handler. This is called at a constant rate; every 8ms, whether the encoder
|
67
|
-
# position has changed or not.
|
68
|
-
#
|
69
|
-
def setOnEncoderPositionUpdateHandler(cb_proc = nil, &cb_block)
|
70
|
-
@on_encoder_position_update_thread.kill if defined? @on_encoder_position_update_thread
|
71
|
-
callback = cb_proc || cb_block
|
72
|
-
@on_encoder_position_update_thread = Thread.new {ext_setOnEncoderPositionUpdateHandler(callback)}
|
73
|
-
end
|
74
|
-
|
75
|
-
# call-seq:
|
76
|
-
# setOnBackEMFUpdateHandler(proc=nil, &block)
|
77
|
-
#
|
78
|
-
# Set a back EMF update handler. This is called at a constant rate; every 16ms, when back EMF sensing is enabled for that motor.
|
79
|
-
#
|
80
|
-
def setOnBackEMFUpdateHandler(cb_proc = nil, &cb_block)
|
81
|
-
@on_back_emf_update_thread.kill if defined? @on_back_emf_update_thread
|
82
|
-
callback = cb_proc || cb_block
|
83
|
-
@on_back_emf_update_thread = Thread.new {ext_setOnBackEMFUpdateHandler(callback)}
|
84
|
-
end
|
85
|
-
|
86
|
-
# call-seq:
|
87
|
-
# setOnSensorUpdateHandler(proc=nil, &block)
|
88
|
-
#
|
89
|
-
# Set a sensor update handler. This is called at a constant rate; every 8ms.
|
90
|
-
#
|
91
|
-
def setOnSensorUpdateHandler(cb_proc = nil, &cb_block)
|
92
|
-
@on_sensor_update_thread.kill if defined? @on_sensor_update_thread
|
93
|
-
callback = cb_proc || cb_block
|
94
|
-
@on_sensor_update_thread = Thread.new {ext_setOnSensorUpdateHandler(callback)}
|
95
|
-
end
|
96
|
-
|
97
|
-
alias :on_velocity_change :setOnVelocityChangeHandler
|
98
|
-
alias :on_current_change :setOnCurrentChangeHandler
|
99
|
-
alias :on_current_update :setOnCurrentUpdateHandler
|
100
|
-
alias :on_input_change :setOnInputChangeHandler
|
101
|
-
alias :on_encoder_position_change :setOnEncoderPositionChangeHandler
|
102
|
-
alias :on_encoder_position_update :setOnEncoderPositionUpdateHandler
|
103
|
-
alias :on_back_emf_update :setOnBackEMFUpdateHandler
|
104
|
-
alias :on_sensor_update :setOnSensorUpdateHandler
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|