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,139 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "phidgets.h"
|
3
|
-
|
4
|
-
|
5
|
-
VALUE ph_analog_init(VALUE self);
|
6
|
-
VALUE ph_analog_get_output_count(VALUE self);
|
7
|
-
VALUE ph_analog_get_voltage(VALUE self, VALUE index);
|
8
|
-
VALUE ph_analog_get_voltage_min(VALUE self, VALUE index);
|
9
|
-
VALUE ph_analog_get_voltage_max(VALUE self, VALUE index);
|
10
|
-
VALUE ph_analog_set_voltage(VALUE self, VALUE index, VALUE voltage);
|
11
|
-
VALUE ph_analog_get_enabled(VALUE self, VALUE index);
|
12
|
-
VALUE ph_analog_set_enabled(VALUE self, VALUE index, VALUE state);
|
13
|
-
|
14
|
-
|
15
|
-
void Init_analog() {
|
16
|
-
VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
|
17
|
-
VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
|
18
|
-
VALUE ph_analog = rb_define_class_under(ph_module, "Analog", ph_common);
|
19
|
-
|
20
|
-
/* Document-method: new
|
21
|
-
* call-seq: new
|
22
|
-
*
|
23
|
-
* Creates a Phidget Analog object.
|
24
|
-
*/
|
25
|
-
rb_define_method(ph_analog, "initialize", ph_analog_init, 0);
|
26
|
-
|
27
|
-
/* Document-method: getOutputCount
|
28
|
-
* call-seq: getOutputCount -> output_count
|
29
|
-
*
|
30
|
-
* Gets the number of outputs supported by this phidget analog.
|
31
|
-
*/
|
32
|
-
rb_define_method(ph_analog, "getOutputCount", ph_analog_get_output_count, 0);
|
33
|
-
|
34
|
-
/* Document-method: getVoltage
|
35
|
-
* call-seq: getVoltage(index) -> voltage
|
36
|
-
*
|
37
|
-
* Gets the currently set voltage for an output, in V.
|
38
|
-
*/
|
39
|
-
rb_define_method(ph_analog, "getVoltage", ph_analog_get_voltage, 1);
|
40
|
-
|
41
|
-
/* Document-method: getVoltageMin
|
42
|
-
* call-seq: getVoltageMin(index) -> min
|
43
|
-
*
|
44
|
-
* Gets the minimum settable output voltage, in V.
|
45
|
-
*/
|
46
|
-
rb_define_method(ph_analog, "getVoltageMin", ph_analog_get_voltage_min, 1);
|
47
|
-
|
48
|
-
/* Document-method: getVoltageMax
|
49
|
-
* call-seq: getVoltageMax(index) -> max
|
50
|
-
*
|
51
|
-
* Gets the maximum settable output voltage, in V.
|
52
|
-
*/
|
53
|
-
rb_define_method(ph_analog, "getVoltageMax", ph_analog_get_voltage_max, 1);
|
54
|
-
|
55
|
-
/* Document-method: setVoltage
|
56
|
-
* call-seq: setVoltage(index, voltage)
|
57
|
-
*
|
58
|
-
* Sets the voltage of an output, in V.
|
59
|
-
*/
|
60
|
-
rb_define_method(ph_analog, "setVoltage", ph_analog_set_voltage, 2);
|
61
|
-
|
62
|
-
/* Document-method: getEnabled
|
63
|
-
* call-seq: getEnabled(index) -> true or false
|
64
|
-
*
|
65
|
-
* Gets the enabled state for an output.
|
66
|
-
*/
|
67
|
-
rb_define_method(ph_analog, "getEnabled", ph_analog_get_enabled, 1);
|
68
|
-
|
69
|
-
/* Document-method: setEnabled
|
70
|
-
* call-seq: setEnabled(index, enabled)
|
71
|
-
*
|
72
|
-
* Sets the enabled state for an output.
|
73
|
-
*/
|
74
|
-
rb_define_method(ph_analog, "setEnabled", ph_analog_set_enabled, 2);
|
75
|
-
|
76
|
-
rb_define_alias(ph_analog, "output_count", "getOutputCount");
|
77
|
-
rb_define_alias(ph_analog, "voltage", "getVoltage");
|
78
|
-
rb_define_alias(ph_analog, "voltage_min", "getVoltageMin");
|
79
|
-
rb_define_alias(ph_analog, "voltage_max", "getVoltageMax");
|
80
|
-
rb_define_alias(ph_analog, "set_voltage", "setVoltage");
|
81
|
-
rb_define_alias(ph_analog, "enabled?", "getEnabled");
|
82
|
-
rb_define_alias(ph_analog, "set_enabled", "setEnabled");
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
VALUE ph_analog_init(VALUE self) {
|
88
|
-
ph_data_t *ph = get_ph_data(self);
|
89
|
-
ph_raise(CPhidgetAnalog_create((CPhidgetAnalogHandle *)(&(ph->handle))));
|
90
|
-
return self;
|
91
|
-
}
|
92
|
-
|
93
|
-
VALUE ph_analog_get_output_count(VALUE self) {
|
94
|
-
CPhidgetAnalogHandle handle = (CPhidgetAnalogHandle)get_ph_handle(self);
|
95
|
-
int count;
|
96
|
-
ph_raise(CPhidgetAnalog_getOutputCount(handle, &count));
|
97
|
-
return INT2FIX(count);
|
98
|
-
}
|
99
|
-
|
100
|
-
VALUE ph_analog_get_voltage(VALUE self, VALUE index) {
|
101
|
-
CPhidgetAnalogHandle handle = (CPhidgetAnalogHandle)get_ph_handle(self);
|
102
|
-
double volts;
|
103
|
-
ph_raise(CPhidgetAnalog_getVoltage(handle, FIX2INT(index), &volts));
|
104
|
-
return rb_float_new(volts);
|
105
|
-
}
|
106
|
-
|
107
|
-
VALUE ph_analog_get_voltage_min(VALUE self, VALUE index) {
|
108
|
-
CPhidgetAnalogHandle handle = (CPhidgetAnalogHandle)get_ph_handle(self);
|
109
|
-
double volts;
|
110
|
-
ph_raise(CPhidgetAnalog_getVoltageMin(handle, FIX2INT(index), &volts));
|
111
|
-
return rb_float_new(volts);
|
112
|
-
}
|
113
|
-
|
114
|
-
VALUE ph_analog_get_voltage_max(VALUE self, VALUE index) {
|
115
|
-
CPhidgetAnalogHandle handle = (CPhidgetAnalogHandle)get_ph_handle(self);
|
116
|
-
double volts;
|
117
|
-
ph_raise(CPhidgetAnalog_getVoltageMax(handle, FIX2INT(index), &volts));
|
118
|
-
return rb_float_new(volts);
|
119
|
-
}
|
120
|
-
|
121
|
-
VALUE ph_analog_set_voltage(VALUE self, VALUE index, VALUE voltage) {
|
122
|
-
CPhidgetAnalogHandle handle = (CPhidgetAnalogHandle)get_ph_handle(self);
|
123
|
-
ph_raise(CPhidgetAnalog_setVoltage(handle, FIX2INT(index), NUM2DBL(voltage)));
|
124
|
-
return Qnil;
|
125
|
-
}
|
126
|
-
|
127
|
-
VALUE ph_analog_get_enabled(VALUE self, VALUE index) {
|
128
|
-
CPhidgetAnalogHandle handle = (CPhidgetAnalogHandle)get_ph_handle(self);
|
129
|
-
int state;
|
130
|
-
ph_raise(CPhidgetAnalog_getEnabled(handle, FIX2INT(index), &state));
|
131
|
-
return state == PTRUE ? Qtrue : Qfalse;
|
132
|
-
}
|
133
|
-
|
134
|
-
VALUE ph_analog_set_enabled(VALUE self, VALUE index, VALUE state) {
|
135
|
-
CPhidgetAnalogHandle handle = (CPhidgetAnalogHandle)get_ph_handle(self);
|
136
|
-
ph_raise(CPhidgetAnalog_setEnabled(handle, FIX2INT(index), TYPE(state) == T_TRUE ? PTRUE : PFALSE));
|
137
|
-
return Qnil;
|
138
|
-
}
|
139
|
-
|
@@ -1,263 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "phidgets.h"
|
3
|
-
|
4
|
-
|
5
|
-
VALUE ph_bridge_init(VALUE self);
|
6
|
-
VALUE ph_bridge_get_input_count(VALUE self);
|
7
|
-
VALUE ph_bridge_get_bridge_value(VALUE self, VALUE index);
|
8
|
-
VALUE ph_bridge_get_bridge_min(VALUE self, VALUE index);
|
9
|
-
VALUE ph_bridge_get_bridge_max(VALUE self, VALUE index);
|
10
|
-
VALUE ph_bridge_get_enabled(VALUE self, VALUE index);
|
11
|
-
VALUE ph_bridge_set_enabled(VALUE self, VALUE index, VALUE state);
|
12
|
-
VALUE ph_bridge_get_gain(VALUE self, VALUE index);
|
13
|
-
VALUE ph_bridge_set_gain(VALUE self, VALUE index, VALUE gain);
|
14
|
-
VALUE ph_bridge_get_data_rate(VALUE self);
|
15
|
-
VALUE ph_bridge_get_data_rate_min(VALUE self);
|
16
|
-
VALUE ph_bridge_get_data_rate_max(VALUE self);
|
17
|
-
VALUE ph_bridge_set_data_rate(VALUE self, VALUE milliseconds);
|
18
|
-
|
19
|
-
#ifdef PH_CALLBACK
|
20
|
-
VALUE ph_bridge_set_on_bridge_data_handler(VALUE self, VALUE handler);
|
21
|
-
int ph_bridge_on_bridge_data(CPhidgetBridgeHandle phid, void *userPtr, int index, double value);
|
22
|
-
#endif
|
23
|
-
|
24
|
-
|
25
|
-
void Init_bridge() {
|
26
|
-
VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
|
27
|
-
VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
|
28
|
-
VALUE ph_bridge = rb_define_class_under(ph_module, "Bridge", ph_common);
|
29
|
-
|
30
|
-
rb_define_const(ph_bridge, "GAIN_1", INT2FIX(PHIDGET_BRIDGE_GAIN_1));
|
31
|
-
rb_define_const(ph_bridge, "GAIN_8", INT2FIX(PHIDGET_BRIDGE_GAIN_8));
|
32
|
-
rb_define_const(ph_bridge, "GAIN_16", INT2FIX(PHIDGET_BRIDGE_GAIN_16));
|
33
|
-
rb_define_const(ph_bridge, "GAIN_32", INT2FIX(PHIDGET_BRIDGE_GAIN_32));
|
34
|
-
rb_define_const(ph_bridge, "GAIN_64", INT2FIX(PHIDGET_BRIDGE_GAIN_64));
|
35
|
-
rb_define_const(ph_bridge, "GAIN_128", INT2FIX(PHIDGET_BRIDGE_GAIN_128));
|
36
|
-
rb_define_const(ph_bridge, "GAIN_UNKNOWN", INT2FIX(PHIDGET_BRIDGE_GAIN_UNKNOWN));
|
37
|
-
|
38
|
-
/* Document-method: new
|
39
|
-
* call-seq: new
|
40
|
-
*
|
41
|
-
* Creates a Phidget Bridge object.
|
42
|
-
*/
|
43
|
-
rb_define_method(ph_bridge, "initialize", ph_bridge_init, 0);
|
44
|
-
|
45
|
-
/* Document-method: getInputCount
|
46
|
-
* call-seq: getInputCount -> count
|
47
|
-
*
|
48
|
-
* Gets the number of inputs supported by this phidget bridge.
|
49
|
-
*/
|
50
|
-
rb_define_method(ph_bridge, "getInputCount", ph_bridge_get_input_count, 0);
|
51
|
-
|
52
|
-
/* Document-method: getBridgeValue
|
53
|
-
* call-seq: getBridgeValue(index) -> value
|
54
|
-
*
|
55
|
-
* Gets the current value of a bridge input, in mV/V.
|
56
|
-
*/
|
57
|
-
rb_define_method(ph_bridge, "getBridgeValue", ph_bridge_get_bridge_value, 1);
|
58
|
-
|
59
|
-
/* Document-method: getBridgeMin
|
60
|
-
* call-seq: getBridgeMin(index) -> min
|
61
|
-
*
|
62
|
-
* Gets the minimum value supported by a bridge input, in mV/V. This is affected by Gain.
|
63
|
-
*/
|
64
|
-
rb_define_method(ph_bridge, "getBridgeMin", ph_bridge_get_bridge_min, 1);
|
65
|
-
|
66
|
-
/* Document-method: getBridgeMax
|
67
|
-
* call-seq: getBridgeMax(index) -> max
|
68
|
-
*
|
69
|
-
* Gets the maximum value supported by a bridge input, in mV/V. This is affected by Gain.
|
70
|
-
*/
|
71
|
-
rb_define_method(ph_bridge, "getBridgeMax", ph_bridge_get_bridge_max, 1);
|
72
|
-
|
73
|
-
/* Document-method: getEnabled
|
74
|
-
* call-seq: getEnabled(index) -> true or false
|
75
|
-
*
|
76
|
-
* Gets the enabled state for an input.
|
77
|
-
*/
|
78
|
-
rb_define_method(ph_bridge, "getEnabled", ph_bridge_get_enabled, 1);
|
79
|
-
|
80
|
-
/* Document-method: setEnabled
|
81
|
-
* call-seq: setEnabled(index, enabled_state)
|
82
|
-
*
|
83
|
-
* Sets the enabled state for an input.
|
84
|
-
*/
|
85
|
-
rb_define_method(ph_bridge, "setEnabled", ph_bridge_set_enabled, 2);
|
86
|
-
|
87
|
-
/* Document-method: getGain
|
88
|
-
* call-seq: getGain(index) -> gain
|
89
|
-
*
|
90
|
-
* Gets the the Gain for an input.
|
91
|
-
*/
|
92
|
-
rb_define_method(ph_bridge, "getGain", ph_bridge_get_gain, 1);
|
93
|
-
|
94
|
-
/* Document-method: setGain
|
95
|
-
* call-seq: setGain(index, gain)
|
96
|
-
*
|
97
|
-
* Sets the Gain for an input.
|
98
|
-
*/
|
99
|
-
rb_define_method(ph_bridge, "setGain", ph_bridge_set_enabled, 2);
|
100
|
-
|
101
|
-
/* Document-method: getDataRate
|
102
|
-
* call-seq: getDataRate(index) -> milliseconds
|
103
|
-
*
|
104
|
-
* Gets the the data rate for the Phidget Bridge, in milliseconds.
|
105
|
-
*/
|
106
|
-
rb_define_method(ph_bridge, "getDataRate", ph_bridge_get_data_rate, 0);
|
107
|
-
|
108
|
-
/* Document-method: getDataRateMin
|
109
|
-
* call-seq: getDataRateMin(index) -> milliseconds
|
110
|
-
*
|
111
|
-
* Gets the the minimum data rate for the Phidget Bridge, in milliseconds.
|
112
|
-
*/
|
113
|
-
rb_define_method(ph_bridge, "getDataRateMin", ph_bridge_get_data_rate_min, 0);
|
114
|
-
|
115
|
-
/* Document-method: getDataRateMax
|
116
|
-
* call-seq: getDataRateMax(index) -> milliseconds
|
117
|
-
*
|
118
|
-
* Gets the the maximum data rate for the Phidget Bridge, in milliseconds.
|
119
|
-
*/
|
120
|
-
rb_define_method(ph_bridge, "getDataRateMax", ph_bridge_get_data_rate_max, 0);
|
121
|
-
|
122
|
-
/* Document-method: setDataRate
|
123
|
-
* call-seq: setDataRate(index, milliseconds)
|
124
|
-
*
|
125
|
-
* Sets the the data rate for the Phidget Bridge, in milliseconds.
|
126
|
-
*/
|
127
|
-
rb_define_method(ph_bridge, "setDataRate", ph_bridge_set_data_rate, 1);
|
128
|
-
|
129
|
-
#ifdef PH_CALLBACK
|
130
|
-
rb_define_private_method(ph_bridge, "ext_setOnBridgeDataHandler", ph_bridge_set_on_bridge_data_handler, 1);
|
131
|
-
#endif
|
132
|
-
|
133
|
-
rb_define_alias(ph_bridge, "input_count", "getInputCount");
|
134
|
-
rb_define_alias(ph_bridge, "bridge_value", "getBridgeValue");
|
135
|
-
rb_define_alias(ph_bridge, "bridge_min", "getBridgeMin");
|
136
|
-
rb_define_alias(ph_bridge, "bridge_max", "getBridgeMax");
|
137
|
-
rb_define_alias(ph_bridge, "enabled?", "getEnabled");
|
138
|
-
rb_define_alias(ph_bridge, "set_enabled", "setEnabled");
|
139
|
-
rb_define_alias(ph_bridge, "gain", "getGain");
|
140
|
-
rb_define_alias(ph_bridge, "set_gain", "setGain");
|
141
|
-
rb_define_alias(ph_bridge, "data_rate", "getDataRate");
|
142
|
-
rb_define_alias(ph_bridge, "data_rate_min", "getDataRateMin");
|
143
|
-
rb_define_alias(ph_bridge, "data_rate_max", "getDataRateMax");
|
144
|
-
rb_define_alias(ph_bridge, "data_rate=", "setDataRate");
|
145
|
-
}
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
VALUE ph_bridge_init(VALUE self) {
|
150
|
-
ph_data_t *ph = get_ph_data(self);
|
151
|
-
ph_raise(CPhidgetBridge_create((CPhidgetBridgeHandle *)(&(ph->handle))));
|
152
|
-
return self;
|
153
|
-
}
|
154
|
-
|
155
|
-
VALUE ph_bridge_get_input_count(VALUE self) {
|
156
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
157
|
-
int count;
|
158
|
-
ph_raise(CPhidgetBridge_getInputCount(handle, &count));
|
159
|
-
return INT2FIX(count);
|
160
|
-
}
|
161
|
-
|
162
|
-
VALUE ph_bridge_get_bridge_value(VALUE self, VALUE index) {
|
163
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
164
|
-
double value;
|
165
|
-
ph_raise(CPhidgetBridge_getBridgeValue(handle, FIX2INT(index), &value));
|
166
|
-
return rb_float_new(value);
|
167
|
-
}
|
168
|
-
|
169
|
-
VALUE ph_bridge_get_bridge_min(VALUE self, VALUE index) {
|
170
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
171
|
-
double value;
|
172
|
-
ph_raise(CPhidgetBridge_getBridgeMin(handle, FIX2INT(index), &value));
|
173
|
-
return rb_float_new(value);
|
174
|
-
}
|
175
|
-
|
176
|
-
VALUE ph_bridge_get_bridge_max(VALUE self, VALUE index) {
|
177
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
178
|
-
double value;
|
179
|
-
ph_raise(CPhidgetBridge_getBridgeMax(handle, FIX2INT(index), &value));
|
180
|
-
return rb_float_new(value);
|
181
|
-
}
|
182
|
-
|
183
|
-
VALUE ph_bridge_get_enabled(VALUE self, VALUE index) {
|
184
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
185
|
-
int value;
|
186
|
-
ph_raise(CPhidgetBridge_getEnabled(handle, FIX2INT(index), &value));
|
187
|
-
return value == PTRUE ? Qtrue : Qfalse;
|
188
|
-
}
|
189
|
-
|
190
|
-
VALUE ph_bridge_set_enabled(VALUE self, VALUE index, VALUE state) {
|
191
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
192
|
-
ph_raise(CPhidgetBridge_setEnabled(handle, FIX2INT(index), TYPE(state) == T_TRUE ? PTRUE : PFALSE));
|
193
|
-
return Qnil;
|
194
|
-
}
|
195
|
-
|
196
|
-
VALUE ph_bridge_get_gain(VALUE self, VALUE index) {
|
197
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
198
|
-
CPhidgetBridge_Gain value;
|
199
|
-
ph_raise(CPhidgetBridge_getGain(handle, FIX2INT(index), &value));
|
200
|
-
return INT2FIX(value);
|
201
|
-
}
|
202
|
-
|
203
|
-
VALUE ph_bridge_set_gain(VALUE self, VALUE index, VALUE gain) {
|
204
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
205
|
-
ph_raise(CPhidgetBridge_setGain(handle, FIX2INT(index), FIX2INT(gain)));
|
206
|
-
return Qnil;
|
207
|
-
}
|
208
|
-
|
209
|
-
VALUE ph_bridge_get_data_rate(VALUE self) {
|
210
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
211
|
-
int value;
|
212
|
-
ph_raise(CPhidgetBridge_getDataRate(handle, &value));
|
213
|
-
return INT2FIX(value);
|
214
|
-
}
|
215
|
-
|
216
|
-
VALUE ph_bridge_get_data_rate_min(VALUE self) {
|
217
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
218
|
-
int value;
|
219
|
-
ph_raise(CPhidgetBridge_getDataRateMin(handle, &value));
|
220
|
-
return INT2FIX(value);
|
221
|
-
}
|
222
|
-
|
223
|
-
VALUE ph_bridge_get_data_rate_max(VALUE self) {
|
224
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
225
|
-
int value;
|
226
|
-
ph_raise(CPhidgetBridge_getDataRateMax(handle, &value));
|
227
|
-
return INT2FIX(value);
|
228
|
-
}
|
229
|
-
|
230
|
-
VALUE ph_bridge_set_data_rate(VALUE self, VALUE milliseconds) {
|
231
|
-
CPhidgetBridgeHandle handle = (CPhidgetBridgeHandle)get_ph_handle(self);
|
232
|
-
ph_raise(CPhidgetBridge_setDataRate(handle, FIX2INT(milliseconds)));
|
233
|
-
return Qnil;
|
234
|
-
}
|
235
|
-
|
236
|
-
|
237
|
-
#ifdef PH_CALLBACK
|
238
|
-
VALUE ph_bridge_set_on_bridge_data_handler(VALUE self, VALUE handler) {
|
239
|
-
ph_data_t *ph = get_ph_data(self);
|
240
|
-
ph_callback_data_t *callback_data = &ph->dev_callback_1;
|
241
|
-
if( TYPE(handler) == T_NIL ) {
|
242
|
-
callback_data->exit = true;
|
243
|
-
ph_raise(CPhidgetBridge_set_OnBridgeData_Handler((CPhidgetBridgeHandle)ph->handle, NULL, (void *)NULL));
|
244
|
-
} else {
|
245
|
-
callback_data->called = false;
|
246
|
-
callback_data->exit = false;
|
247
|
-
callback_data->phidget = self;
|
248
|
-
callback_data->callback = handler;
|
249
|
-
ph_raise(CPhidgetBridge_set_OnBridgeData_Handler((CPhidgetBridgeHandle)ph->handle, ph_bridge_on_bridge_data, (void *)callback_data));
|
250
|
-
ph_callback_thread(callback_data);
|
251
|
-
}
|
252
|
-
return Qnil;
|
253
|
-
}
|
254
|
-
|
255
|
-
|
256
|
-
int ph_bridge_on_bridge_data(CPhidgetBridgeHandle phid, void *userPtr, int index, double value) {
|
257
|
-
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
258
|
-
callback_data->called = true;
|
259
|
-
return EPHIDGET_OK;
|
260
|
-
}
|
261
|
-
|
262
|
-
#endif
|
263
|
-
|
@@ -1,340 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "phidgets.h"
|
3
|
-
|
4
|
-
|
5
|
-
VALUE ph_ifkit_init(VALUE self);
|
6
|
-
VALUE ph_ifkit_get_input_count(VALUE self);
|
7
|
-
VALUE ph_ifkit_get_input_state(VALUE self, VALUE index);
|
8
|
-
VALUE ph_ifkit_get_output_count(VALUE self);
|
9
|
-
VALUE ph_ifkit_get_output_state(VALUE self, VALUE index);
|
10
|
-
VALUE ph_ifkit_set_output_state(VALUE self, VALUE index, VALUE state);
|
11
|
-
VALUE ph_ifkit_get_sensor_count(VALUE self);
|
12
|
-
VALUE ph_ifkit_get_sensor_value(VALUE self, VALUE index);
|
13
|
-
VALUE ph_ifkit_get_sensor_raw_value(VALUE self, VALUE index);
|
14
|
-
VALUE ph_ifkit_get_ratiometric(VALUE self);
|
15
|
-
VALUE ph_ifkit_set_ratiometric(VALUE self, VALUE ratiometric);
|
16
|
-
VALUE ph_ifkit_get_data_rate(VALUE self, VALUE index);
|
17
|
-
VALUE ph_ifkit_get_data_rate_min(VALUE self, VALUE index);
|
18
|
-
VALUE ph_ifkit_get_data_rate_max(VALUE self, VALUE index);
|
19
|
-
VALUE ph_ifkit_set_data_rate(VALUE self, VALUE index, VALUE rate);
|
20
|
-
|
21
|
-
#ifdef PH_CALLBACK
|
22
|
-
VALUE ph_ifkit_set_on_input_change_handler(VALUE self, VALUE handler);
|
23
|
-
VALUE ph_ifkit_set_on_output_change_handler(VALUE self, VALUE handler);
|
24
|
-
VALUE ph_ifkit_set_on_sensor_change_handler(VALUE self, VALUE handler);
|
25
|
-
int ph_ifkit_on_input_change(CPhidgetInterfaceKitHandle phid, void *userPtr, int index, int state);
|
26
|
-
int ph_ifkit_on_output_change(CPhidgetInterfaceKitHandle phid, void *userPtr, int index, int state);
|
27
|
-
int ph_ifkit_on_sensor_change(CPhidgetInterfaceKitHandle phid, void *userPtr, int index, int value);
|
28
|
-
#endif
|
29
|
-
|
30
|
-
|
31
|
-
void Init_interface_kit() {
|
32
|
-
VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
|
33
|
-
VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
|
34
|
-
VALUE ph_ifkit = rb_define_class_under(ph_module, "InterfaceKit", ph_common);
|
35
|
-
|
36
|
-
/* Document-method: new
|
37
|
-
* call-seq: new
|
38
|
-
*
|
39
|
-
* Creates a Phidget InterfaceKit object.
|
40
|
-
*/
|
41
|
-
rb_define_method(ph_ifkit, "initialize", ph_ifkit_init, 0);
|
42
|
-
|
43
|
-
/* Document-method: getInputCount
|
44
|
-
* call-seq: getInputCount -> count
|
45
|
-
*
|
46
|
-
* Gets the number of digital inputs supported by this board.
|
47
|
-
*/
|
48
|
-
rb_define_method(ph_ifkit, "getInputCount", ph_ifkit_get_input_count, 0);
|
49
|
-
|
50
|
-
/* Document-method: getInputState
|
51
|
-
* call-seq: getInputState(index) -> true or false
|
52
|
-
*
|
53
|
-
* Gets the state of a digital input.
|
54
|
-
*/
|
55
|
-
rb_define_method(ph_ifkit, "getInputState", ph_ifkit_get_input_state, 1);
|
56
|
-
|
57
|
-
/* Document-method: getOutputCount
|
58
|
-
* call-seq: getOutputCount -> count
|
59
|
-
*
|
60
|
-
* Gets the number of digital outputs supported by this board.
|
61
|
-
*/
|
62
|
-
rb_define_method(ph_ifkit, "getOutputCount", ph_ifkit_get_output_count, 0);
|
63
|
-
|
64
|
-
/* Document-method: getOutputState
|
65
|
-
* call-seq: getOutputState(index) -> true or false
|
66
|
-
*
|
67
|
-
* Gets the state of a digital output.
|
68
|
-
*/
|
69
|
-
rb_define_method(ph_ifkit, "getOutputState", ph_ifkit_get_output_state, 1);
|
70
|
-
|
71
|
-
/* Document-method: setOutputState
|
72
|
-
* call-seq: setOutputState(index, state)
|
73
|
-
*
|
74
|
-
* Sets the state of a digital output.
|
75
|
-
*/
|
76
|
-
rb_define_method(ph_ifkit, "setOutputState", ph_ifkit_set_output_state, 2);
|
77
|
-
|
78
|
-
/* Document-method: getSensorCount
|
79
|
-
* call-seq: getSensorCount -> count
|
80
|
-
*
|
81
|
-
* Gets the number of sensor (analog) inputs supported by this board.
|
82
|
-
*/
|
83
|
-
rb_define_method(ph_ifkit, "getSensorCount", ph_ifkit_get_sensor_count, 0);
|
84
|
-
|
85
|
-
/* Document-method: getSensorValue
|
86
|
-
* call-seq: getSensorValue(index) -> value
|
87
|
-
*
|
88
|
-
* Gets a sensor value (0-1000).
|
89
|
-
*/
|
90
|
-
rb_define_method(ph_ifkit, "getSensorValue", ph_ifkit_get_sensor_value, 1);
|
91
|
-
|
92
|
-
/* Document-method: getSensorRawValue
|
93
|
-
* call-seq: getSensorRawValue(index) -> value
|
94
|
-
*
|
95
|
-
* Gets a sensor raw value (12-bit).
|
96
|
-
*/
|
97
|
-
rb_define_method(ph_ifkit, "getSensorRawValue", ph_ifkit_get_sensor_raw_value, 1);
|
98
|
-
|
99
|
-
/* Document-method: getRatiometric
|
100
|
-
* call-seq: getRatiometric -> true or false
|
101
|
-
*
|
102
|
-
* Gets the ratiometric state for this board.
|
103
|
-
*/
|
104
|
-
rb_define_method(ph_ifkit, "getRatiometric", ph_ifkit_get_ratiometric, 0);
|
105
|
-
|
106
|
-
/* Document-method: setRatiometric
|
107
|
-
* call-seq: setRatiometric(state)
|
108
|
-
*
|
109
|
-
* Sets the ratiometric state for this board.
|
110
|
-
*/
|
111
|
-
rb_define_method(ph_ifkit, "setRatiometric", ph_ifkit_set_ratiometric, 1);
|
112
|
-
|
113
|
-
/* Document-method: getDataRate
|
114
|
-
* call-seq: getDataRate(index) -> milliseconds
|
115
|
-
*
|
116
|
-
* Gets the Data Rate for an analog input.
|
117
|
-
*/
|
118
|
-
rb_define_method(ph_ifkit, "getDataRate", ph_ifkit_get_data_rate, 1);
|
119
|
-
|
120
|
-
/* Document-method: getDataRateMin
|
121
|
-
* call-seq: getDataRateMin(index) -> milliseconds
|
122
|
-
*
|
123
|
-
* Gets the minimum supported data rate for an analog input
|
124
|
-
*/
|
125
|
-
rb_define_method(ph_ifkit, "getDataRateMin", ph_ifkit_get_data_rate_min, 1);
|
126
|
-
|
127
|
-
/* Document-method: getDataRateMax
|
128
|
-
* call-seq: getDataRateMax(index) -> milliseconds
|
129
|
-
*
|
130
|
-
* Gets the maximum supported data rate for an analog input
|
131
|
-
*/
|
132
|
-
rb_define_method(ph_ifkit, "getDataRateMax", ph_ifkit_get_data_rate_max, 1);
|
133
|
-
|
134
|
-
/* Document-method: setDataRate
|
135
|
-
* call-seq: setDataRate(index, milliseconds)
|
136
|
-
*
|
137
|
-
* Gets the maximum supported data rate for an analog input
|
138
|
-
*/
|
139
|
-
rb_define_method(ph_ifkit, "setDataRate", ph_ifkit_set_data_rate, 2);
|
140
|
-
|
141
|
-
#ifdef PH_CALLBACK
|
142
|
-
rb_define_private_method(ph_ifkit, "ext_setOnInputChangeHandler", ph_ifkit_set_on_input_change_handler, 1);
|
143
|
-
rb_define_private_method(ph_ifkit, "ext_setOnOutputChangeHandler", ph_ifkit_set_on_output_change_handler, 1);
|
144
|
-
rb_define_private_method(ph_ifkit, "ext_setOnSensorChangeHandler", ph_ifkit_set_on_sensor_change_handler, 1);
|
145
|
-
#endif
|
146
|
-
|
147
|
-
rb_define_alias(ph_ifkit, "input_count", "getInputCount");
|
148
|
-
rb_define_alias(ph_ifkit, "input_state", "getInputState");
|
149
|
-
rb_define_alias(ph_ifkit, "output_count", "getOutputCount");
|
150
|
-
rb_define_alias(ph_ifkit, "output_state", "getOutputState");
|
151
|
-
rb_define_alias(ph_ifkit, "set_output_state", "setOutputState");
|
152
|
-
rb_define_alias(ph_ifkit, "sensor_count", "getSensorCount");
|
153
|
-
rb_define_alias(ph_ifkit, "sensor_value", "getSensorValue");
|
154
|
-
rb_define_alias(ph_ifkit, "sensor_raw_value", "getSensorRawValue");
|
155
|
-
rb_define_alias(ph_ifkit, "ratiometric?", "getRatiometric");
|
156
|
-
rb_define_alias(ph_ifkit, "ratiometric=", "setRatiometric");
|
157
|
-
rb_define_alias(ph_ifkit, "data_rate", "getDataRate");
|
158
|
-
rb_define_alias(ph_ifkit, "data_rate_min", "getDataRateMin");
|
159
|
-
rb_define_alias(ph_ifkit, "data_rate_max", "getDataRateMax");
|
160
|
-
rb_define_alias(ph_ifkit, "set_data_rate", "setDataRate");
|
161
|
-
}
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
VALUE ph_ifkit_init(VALUE self) {
|
166
|
-
ph_data_t *ph = get_ph_data(self);
|
167
|
-
ph_raise(CPhidgetInterfaceKit_create((CPhidgetInterfaceKitHandle *)(&(ph->handle))));
|
168
|
-
return self;
|
169
|
-
}
|
170
|
-
|
171
|
-
VALUE ph_ifkit_get_input_count(VALUE self) {
|
172
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
173
|
-
int count;
|
174
|
-
ph_raise(CPhidgetInterfaceKit_getInputCount(handle, &count));
|
175
|
-
return INT2FIX(count);
|
176
|
-
}
|
177
|
-
|
178
|
-
VALUE ph_ifkit_get_input_state(VALUE self, VALUE index) {
|
179
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
180
|
-
int state;
|
181
|
-
ph_raise(CPhidgetInterfaceKit_getInputState(handle, FIX2INT(index), &state));
|
182
|
-
return state == PTRUE ? Qtrue : Qfalse;
|
183
|
-
}
|
184
|
-
|
185
|
-
VALUE ph_ifkit_get_output_count(VALUE self) {
|
186
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
187
|
-
int count;
|
188
|
-
ph_raise(CPhidgetInterfaceKit_getOutputCount(handle, &count));
|
189
|
-
return INT2FIX(count);
|
190
|
-
}
|
191
|
-
|
192
|
-
VALUE ph_ifkit_get_output_state(VALUE self, VALUE index) {
|
193
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
194
|
-
int state;
|
195
|
-
ph_raise(CPhidgetInterfaceKit_getOutputState(handle, FIX2INT(index), &state));
|
196
|
-
return state == PTRUE ? Qtrue : Qfalse;
|
197
|
-
}
|
198
|
-
|
199
|
-
VALUE ph_ifkit_set_output_state(VALUE self, VALUE index, VALUE state) {
|
200
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
201
|
-
ph_raise(CPhidgetInterfaceKit_setOutputState(handle, FIX2INT(index), TYPE(state) == T_TRUE ? PTRUE : PFALSE));
|
202
|
-
return Qnil;
|
203
|
-
}
|
204
|
-
|
205
|
-
VALUE ph_ifkit_get_sensor_count(VALUE self) {
|
206
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
207
|
-
int count;
|
208
|
-
ph_raise(CPhidgetInterfaceKit_getSensorCount(handle, &count));
|
209
|
-
return INT2FIX(count);
|
210
|
-
}
|
211
|
-
|
212
|
-
VALUE ph_ifkit_get_sensor_value(VALUE self, VALUE index) {
|
213
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
214
|
-
int value;
|
215
|
-
ph_raise(CPhidgetInterfaceKit_getSensorValue(handle, FIX2INT(index), &value));
|
216
|
-
return INT2FIX(value);
|
217
|
-
}
|
218
|
-
|
219
|
-
VALUE ph_ifkit_get_sensor_raw_value(VALUE self, VALUE index) {
|
220
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
221
|
-
int value;
|
222
|
-
ph_raise(CPhidgetInterfaceKit_getSensorRawValue(handle, FIX2INT(index), &value));
|
223
|
-
return INT2FIX(value);
|
224
|
-
}
|
225
|
-
|
226
|
-
VALUE ph_ifkit_get_ratiometric(VALUE self) {
|
227
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
228
|
-
int ratiometric;
|
229
|
-
ph_raise(CPhidgetInterfaceKit_getRatiometric(handle, &ratiometric));
|
230
|
-
return ratiometric == PTRUE ? Qtrue : Qfalse;
|
231
|
-
}
|
232
|
-
|
233
|
-
VALUE ph_ifkit_set_ratiometric(VALUE self, VALUE ratiometric) {
|
234
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
235
|
-
ph_raise(CPhidgetInterfaceKit_setRatiometric(handle, TYPE(ratiometric) == T_TRUE ? PTRUE : PFALSE));
|
236
|
-
return Qnil;
|
237
|
-
}
|
238
|
-
|
239
|
-
VALUE ph_ifkit_get_data_rate(VALUE self, VALUE index) {
|
240
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
241
|
-
int rate;
|
242
|
-
ph_raise(CPhidgetInterfaceKit_getDataRate(handle, FIX2INT(index), &rate));
|
243
|
-
return INT2FIX(rate);
|
244
|
-
}
|
245
|
-
|
246
|
-
VALUE ph_ifkit_get_data_rate_min(VALUE self, VALUE index) {
|
247
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
248
|
-
int rate;
|
249
|
-
ph_raise(CPhidgetInterfaceKit_getDataRateMin(handle, FIX2INT(index), &rate));
|
250
|
-
return INT2FIX(rate);
|
251
|
-
}
|
252
|
-
|
253
|
-
VALUE ph_ifkit_get_data_rate_max(VALUE self, VALUE index) {
|
254
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
255
|
-
int rate;
|
256
|
-
ph_raise(CPhidgetInterfaceKit_getDataRateMax(handle, FIX2INT(index), &rate));
|
257
|
-
return INT2FIX(rate);
|
258
|
-
}
|
259
|
-
|
260
|
-
VALUE ph_ifkit_set_data_rate(VALUE self, VALUE index, VALUE rate) {
|
261
|
-
CPhidgetInterfaceKitHandle handle = (CPhidgetInterfaceKitHandle)get_ph_handle(self);
|
262
|
-
ph_raise(CPhidgetInterfaceKit_setDataRate(handle, FIX2INT(index), FIX2INT(rate)));
|
263
|
-
return Qnil;
|
264
|
-
}
|
265
|
-
|
266
|
-
#ifdef PH_CALLBACK
|
267
|
-
VALUE ph_ifkit_set_on_input_change_handler(VALUE self, VALUE handler) {
|
268
|
-
ph_data_t *ph = get_ph_data(self);
|
269
|
-
ph_callback_data_t *callback_data = &ph->dev_callback_1;
|
270
|
-
if( TYPE(handler) == T_NIL ) {
|
271
|
-
callback_data->exit = true;
|
272
|
-
ph_raise(CPhidgetInterfaceKit_set_OnInputChange_Handler((CPhidgetInterfaceKitHandle)ph->handle, NULL, (void *)NULL));
|
273
|
-
} else {
|
274
|
-
callback_data->called = false;
|
275
|
-
callback_data->exit = false;
|
276
|
-
callback_data->phidget = self;
|
277
|
-
callback_data->callback = handler;
|
278
|
-
ph_raise(CPhidgetInterfaceKit_set_OnInputChange_Handler((CPhidgetInterfaceKitHandle)ph->handle, ph_ifkit_on_input_change, (void *)callback_data));
|
279
|
-
ph_callback_thread(callback_data);
|
280
|
-
}
|
281
|
-
return Qnil;
|
282
|
-
}
|
283
|
-
|
284
|
-
VALUE ph_ifkit_set_on_output_change_handler(VALUE self, VALUE handler) {
|
285
|
-
ph_data_t *ph = get_ph_data(self);
|
286
|
-
ph_callback_data_t *callback_data = &ph->dev_callback_2;
|
287
|
-
if( TYPE(handler) == T_NIL ) {
|
288
|
-
callback_data->exit = true;
|
289
|
-
ph_raise(CPhidgetInterfaceKit_set_OnOutputChange_Handler((CPhidgetInterfaceKitHandle)ph->handle, NULL, (void *)NULL));
|
290
|
-
} else {
|
291
|
-
callback_data->called = false;
|
292
|
-
callback_data->exit = false;
|
293
|
-
callback_data->phidget = self;
|
294
|
-
callback_data->callback = handler;
|
295
|
-
ph_raise(CPhidgetInterfaceKit_set_OnOutputChange_Handler((CPhidgetInterfaceKitHandle)ph->handle, ph_ifkit_on_output_change, (void *)callback_data));
|
296
|
-
ph_callback_thread(callback_data);
|
297
|
-
}
|
298
|
-
return Qnil;
|
299
|
-
}
|
300
|
-
|
301
|
-
VALUE ph_ifkit_set_on_sensor_change_handler(VALUE self, VALUE handler) {
|
302
|
-
ph_data_t *ph = get_ph_data(self);
|
303
|
-
ph_callback_data_t *callback_data = &ph->dev_callback_3;
|
304
|
-
if( TYPE(handler) == T_NIL ) {
|
305
|
-
callback_data->exit = true;
|
306
|
-
ph_raise(CPhidgetInterfaceKit_set_OnSensorChange_Handler((CPhidgetInterfaceKitHandle)ph->handle, NULL, (void *)NULL));
|
307
|
-
} else {
|
308
|
-
callback_data->called = false;
|
309
|
-
callback_data->exit = false;
|
310
|
-
callback_data->phidget = self;
|
311
|
-
callback_data->callback = handler;
|
312
|
-
ph_raise(CPhidgetInterfaceKit_set_OnSensorChange_Handler((CPhidgetInterfaceKitHandle)ph->handle, ph_ifkit_on_sensor_change, (void *)callback_data));
|
313
|
-
ph_callback_thread(callback_data);
|
314
|
-
}
|
315
|
-
return Qnil;
|
316
|
-
}
|
317
|
-
|
318
|
-
|
319
|
-
int ph_ifkit_on_input_change(CPhidgetInterfaceKitHandle phid, void *userPtr, int index, int state) {
|
320
|
-
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
321
|
-
callback_data->called = true;
|
322
|
-
return EPHIDGET_OK;
|
323
|
-
}
|
324
|
-
|
325
|
-
|
326
|
-
int ph_ifkit_on_output_change(CPhidgetInterfaceKitHandle phid, void *userPtr, int index, int state) {
|
327
|
-
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
328
|
-
callback_data->called = true;
|
329
|
-
return EPHIDGET_OK;
|
330
|
-
}
|
331
|
-
|
332
|
-
|
333
|
-
int ph_ifkit_on_sensor_change(CPhidgetInterfaceKitHandle phid, void *userPtr, int index, int value) {
|
334
|
-
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
335
|
-
callback_data->called = true;
|
336
|
-
return EPHIDGET_OK;
|
337
|
-
}
|
338
|
-
#endif
|
339
|
-
|
340
|
-
|