phidgets 0.0.5 → 0.1.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.
- data/History.txt +10 -2
- data/README.rdoc +41 -18
- data/Rakefile +31 -20
- data/bin/phidget +29 -44
- data/ext/phidgets/extconf.rb +14 -0
- data/ext/phidgets/phidgets.c +272 -0
- data/ext/phidgets/phidgets.h +82 -0
- data/ext/phidgets/phidgets_accelerometer.c +165 -0
- data/ext/phidgets/phidgets_advanced_servo.c +567 -0
- data/ext/phidgets/phidgets_analog.c +139 -0
- data/ext/phidgets/phidgets_bridge.c +263 -0
- data/ext/phidgets/phidgets_common.c +454 -0
- data/ext/phidgets/phidgets_dictionary.c +279 -0
- data/ext/phidgets/phidgets_encoder.c +249 -0
- data/ext/phidgets/phidgets_frequency_counter.c +241 -0
- data/ext/phidgets/phidgets_gps.c +235 -0
- data/ext/phidgets/phidgets_interface_kit.c +340 -0
- data/ext/phidgets/phidgets_ir.c +251 -0
- data/ext/phidgets/phidgets_led.c +178 -0
- data/ext/phidgets/phidgets_manager.c +366 -0
- data/ext/phidgets/phidgets_motor_control.c +642 -0
- data/ext/phidgets/phidgets_phsensor.c +208 -0
- data/ext/phidgets/phidgets_rfid.c +281 -0
- data/ext/phidgets/phidgets_servo.c +276 -0
- data/ext/phidgets/phidgets_spatial.c +369 -0
- data/ext/phidgets/phidgets_stepper.c +560 -0
- data/ext/phidgets/phidgets_temp_sensor.c +295 -0
- data/ext/phidgets/phidgets_text_lcd.c +381 -0
- data/ext/phidgets/phidgets_text_led.c +107 -0
- data/ext/phidgets/phidgets_weight_sensor.c +113 -0
- data/lib/phidgets/accelerometer.rb +25 -0
- data/lib/phidgets/advanced_servo.rb +49 -0
- data/lib/phidgets/analog.rb +8 -0
- data/lib/phidgets/bridge.rb +25 -0
- data/lib/phidgets/common.rb +75 -190
- data/lib/phidgets/dictionary.rb +53 -0
- data/lib/phidgets/encoder.rb +49 -0
- data/lib/phidgets/frequency_counter.rb +25 -0
- data/lib/phidgets/gps.rb +37 -0
- data/lib/phidgets/interfacekit.rb +38 -128
- data/lib/phidgets/ir.rb +50 -0
- data/lib/phidgets/led.rb +8 -0
- data/lib/phidgets/manager.rb +67 -119
- data/lib/phidgets/motor_control.rb +110 -0
- data/lib/phidgets/ph_sensor.rb +25 -0
- data/lib/phidgets/rfid.rb +38 -111
- data/lib/phidgets/servo.rb +12 -95
- data/lib/phidgets/spatial.rb +25 -0
- data/lib/phidgets/stepper.rb +61 -0
- data/lib/phidgets/temperature_sensor.rb +25 -0
- data/lib/phidgets/text_lcd.rb +8 -0
- data/lib/phidgets/text_led.rb +8 -0
- data/lib/phidgets/weight_sensor.rb +25 -0
- data/lib/phidgets.rb +22 -3
- data/phidgets.gemspec +42 -0
- data/test/test_accelerometer.rb +47 -0
- data/test/test_advanced_servo.rb +152 -0
- data/test/test_analog.rb +45 -0
- data/test/test_bridge.rb +77 -0
- data/test/test_common.rb +167 -0
- data/test/test_dictionary.rb +82 -0
- data/test/test_encoder.rb +67 -0
- data/test/test_frequency_counter.rb +67 -0
- data/test/test_gps.rb +67 -0
- data/test/test_helper.rb +1 -0
- data/test/test_interfacekit.rb +86 -182
- data/test/test_ir.rb +57 -0
- data/test/test_led.rb +55 -0
- data/test/test_manager.rb +94 -0
- data/test/test_motor_control.rb +172 -0
- data/test/test_phidgets.rb +14 -6
- data/test/test_phsensor.rb +62 -0
- data/test/test_rfid.rb +77 -0
- data/test/test_servo.rb +67 -0
- data/test/test_spatial.rb +112 -0
- data/test/test_stepper.rb +163 -0
- data/test/test_temp_sensor.rb +87 -0
- data/test/test_text_lcd.rb +115 -0
- data/test/test_text_led.rb +35 -0
- data/test/test_weight_sensor.rb +32 -0
- metadata +165 -75
- data/Manifest.txt +0 -21
- data/PostInstall.txt +0 -3
- data/README.txt +0 -87
- data/lib/phidgets/phidgets.rb +0 -225
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
@@ -0,0 +1,139 @@
|
|
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
|
+
VALUE Init_phidgets_analog(VALUE ph_module, VALUE ph_common) {
|
16
|
+
VALUE ph_analog = rb_define_class_under(ph_module, "Analog", ph_common);
|
17
|
+
|
18
|
+
/* Document-method: new
|
19
|
+
* call-seq: new
|
20
|
+
*
|
21
|
+
* Creates a Phidget Analog object.
|
22
|
+
*/
|
23
|
+
rb_define_method(ph_analog, "initialize", ph_analog_init, 0);
|
24
|
+
|
25
|
+
/* Document-method: getOutputCount
|
26
|
+
* call-seq: getOutputCount -> output_count
|
27
|
+
*
|
28
|
+
* Gets the number of outputs supported by this phidget analog.
|
29
|
+
*/
|
30
|
+
rb_define_method(ph_analog, "getOutputCount", ph_analog_get_output_count, 0);
|
31
|
+
|
32
|
+
/* Document-method: getVoltage
|
33
|
+
* call-seq: getVoltage(index) -> voltage
|
34
|
+
*
|
35
|
+
* Gets the currently set voltage for an output, in V.
|
36
|
+
*/
|
37
|
+
rb_define_method(ph_analog, "getVoltage", ph_analog_get_voltage, 1);
|
38
|
+
|
39
|
+
/* Document-method: getVoltageMin
|
40
|
+
* call-seq: getVoltageMin(index) -> min
|
41
|
+
*
|
42
|
+
* Gets the minimum settable output voltage, in V.
|
43
|
+
*/
|
44
|
+
rb_define_method(ph_analog, "getVoltageMin", ph_analog_get_voltage_min, 1);
|
45
|
+
|
46
|
+
/* Document-method: getVoltageMax
|
47
|
+
* call-seq: getVoltageMax(index) -> max
|
48
|
+
*
|
49
|
+
* Gets the maximum settable output voltage, in V.
|
50
|
+
*/
|
51
|
+
rb_define_method(ph_analog, "getVoltageMax", ph_analog_get_voltage_max, 1);
|
52
|
+
|
53
|
+
/* Document-method: setVoltage
|
54
|
+
* call-seq: setVoltage(index, voltage)
|
55
|
+
*
|
56
|
+
* Sets the voltage of an output, in V.
|
57
|
+
*/
|
58
|
+
rb_define_method(ph_analog, "setVoltage", ph_analog_set_voltage, 2);
|
59
|
+
|
60
|
+
/* Document-method: getEnabled
|
61
|
+
* call-seq: getEnabled(index) -> true or false
|
62
|
+
*
|
63
|
+
* Gets the enabled state for an output.
|
64
|
+
*/
|
65
|
+
rb_define_method(ph_analog, "getEnabled", ph_analog_get_enabled, 1);
|
66
|
+
|
67
|
+
/* Document-method: setEnabled
|
68
|
+
* call-seq: setEnabled(index, enabled)
|
69
|
+
*
|
70
|
+
* Sets the enabled state for an output.
|
71
|
+
*/
|
72
|
+
rb_define_method(ph_analog, "setEnabled", ph_analog_set_enabled, 2);
|
73
|
+
|
74
|
+
rb_define_alias(ph_analog, "output_count", "getOutputCount");
|
75
|
+
rb_define_alias(ph_analog, "voltage", "getVoltage");
|
76
|
+
rb_define_alias(ph_analog, "voltage_min", "getVoltageMin");
|
77
|
+
rb_define_alias(ph_analog, "voltage_max", "getVoltageMax");
|
78
|
+
rb_define_alias(ph_analog, "set_voltage", "setVoltage");
|
79
|
+
rb_define_alias(ph_analog, "enabled?", "getEnabled");
|
80
|
+
rb_define_alias(ph_analog, "set_enabled", "setEnabled");
|
81
|
+
|
82
|
+
return ph_analog;
|
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
|
+
|
@@ -0,0 +1,263 @@
|
|
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
|
+
VALUE Init_phidgets_bridge(VALUE ph_module, VALUE ph_common) {
|
26
|
+
VALUE ph_bridge = rb_define_class_under(ph_module, "Bridge", ph_common);
|
27
|
+
|
28
|
+
rb_define_const(ph_bridge, "GAIN_1", INT2FIX(PHIDGET_BRIDGE_GAIN_1));
|
29
|
+
rb_define_const(ph_bridge, "GAIN_8", INT2FIX(PHIDGET_BRIDGE_GAIN_8));
|
30
|
+
rb_define_const(ph_bridge, "GAIN_16", INT2FIX(PHIDGET_BRIDGE_GAIN_16));
|
31
|
+
rb_define_const(ph_bridge, "GAIN_32", INT2FIX(PHIDGET_BRIDGE_GAIN_32));
|
32
|
+
rb_define_const(ph_bridge, "GAIN_64", INT2FIX(PHIDGET_BRIDGE_GAIN_64));
|
33
|
+
rb_define_const(ph_bridge, "GAIN_128", INT2FIX(PHIDGET_BRIDGE_GAIN_128));
|
34
|
+
rb_define_const(ph_bridge, "GAIN_UNKNOWN", INT2FIX(PHIDGET_BRIDGE_GAIN_UNKNOWN));
|
35
|
+
|
36
|
+
/* Document-method: new
|
37
|
+
* call-seq: new
|
38
|
+
*
|
39
|
+
* Creates a Phidget Bridge object.
|
40
|
+
*/
|
41
|
+
rb_define_method(ph_bridge, "initialize", ph_bridge_init, 0);
|
42
|
+
|
43
|
+
/* Document-method: getInputCount
|
44
|
+
* call-seq: getInputCount -> count
|
45
|
+
*
|
46
|
+
* Gets the number of inputs supported by this phidget bridge.
|
47
|
+
*/
|
48
|
+
rb_define_method(ph_bridge, "getInputCount", ph_bridge_get_input_count, 0);
|
49
|
+
|
50
|
+
/* Document-method: getBridgeValue
|
51
|
+
* call-seq: getBridgeValue(index) -> value
|
52
|
+
*
|
53
|
+
* Gets the current value of a bridge input, in mV/V.
|
54
|
+
*/
|
55
|
+
rb_define_method(ph_bridge, "getBridgeValue", ph_bridge_get_bridge_value, 1);
|
56
|
+
|
57
|
+
/* Document-method: getBridgeMin
|
58
|
+
* call-seq: getBridgeMin(index) -> min
|
59
|
+
*
|
60
|
+
* Gets the minimum value supported by a bridge input, in mV/V. This is affected by Gain.
|
61
|
+
*/
|
62
|
+
rb_define_method(ph_bridge, "getBridgeMin", ph_bridge_get_bridge_min, 1);
|
63
|
+
|
64
|
+
/* Document-method: getBridgeMax
|
65
|
+
* call-seq: getBridgeMax(index) -> max
|
66
|
+
*
|
67
|
+
* Gets the maximum value supported by a bridge input, in mV/V. This is affected by Gain.
|
68
|
+
*/
|
69
|
+
rb_define_method(ph_bridge, "getBridgeMax", ph_bridge_get_bridge_max, 1);
|
70
|
+
|
71
|
+
/* Document-method: getEnabled
|
72
|
+
* call-seq: getEnabled(index) -> true or false
|
73
|
+
*
|
74
|
+
* Gets the enabled state for an input.
|
75
|
+
*/
|
76
|
+
rb_define_method(ph_bridge, "getEnabled", ph_bridge_get_enabled, 1);
|
77
|
+
|
78
|
+
/* Document-method: setEnabled
|
79
|
+
* call-seq: setEnabled(index, enabled_state)
|
80
|
+
*
|
81
|
+
* Sets the enabled state for an input.
|
82
|
+
*/
|
83
|
+
rb_define_method(ph_bridge, "setEnabled", ph_bridge_set_enabled, 2);
|
84
|
+
|
85
|
+
/* Document-method: getGain
|
86
|
+
* call-seq: getGain(index) -> gain
|
87
|
+
*
|
88
|
+
* Gets the the Gain for an input.
|
89
|
+
*/
|
90
|
+
rb_define_method(ph_bridge, "getGain", ph_bridge_get_gain, 1);
|
91
|
+
|
92
|
+
/* Document-method: setGain
|
93
|
+
* call-seq: setGain(index, gain)
|
94
|
+
*
|
95
|
+
* Sets the Gain for an input.
|
96
|
+
*/
|
97
|
+
rb_define_method(ph_bridge, "setGain", ph_bridge_set_enabled, 2);
|
98
|
+
|
99
|
+
/* Document-method: getDataRate
|
100
|
+
* call-seq: getDataRate(index) -> milliseconds
|
101
|
+
*
|
102
|
+
* Gets the the data rate for the Phidget Bridge, in milliseconds.
|
103
|
+
*/
|
104
|
+
rb_define_method(ph_bridge, "getDataRate", ph_bridge_get_data_rate, 0);
|
105
|
+
|
106
|
+
/* Document-method: getDataRateMin
|
107
|
+
* call-seq: getDataRateMin(index) -> milliseconds
|
108
|
+
*
|
109
|
+
* Gets the the minimum data rate for the Phidget Bridge, in milliseconds.
|
110
|
+
*/
|
111
|
+
rb_define_method(ph_bridge, "getDataRateMin", ph_bridge_get_data_rate_min, 0);
|
112
|
+
|
113
|
+
/* Document-method: getDataRateMax
|
114
|
+
* call-seq: getDataRateMax(index) -> milliseconds
|
115
|
+
*
|
116
|
+
* Gets the the maximum data rate for the Phidget Bridge, in milliseconds.
|
117
|
+
*/
|
118
|
+
rb_define_method(ph_bridge, "getDataRateMax", ph_bridge_get_data_rate_max, 0);
|
119
|
+
|
120
|
+
/* Document-method: setDataRate
|
121
|
+
* call-seq: setDataRate(index, milliseconds)
|
122
|
+
*
|
123
|
+
* Sets the the data rate for the Phidget Bridge, in milliseconds.
|
124
|
+
*/
|
125
|
+
rb_define_method(ph_bridge, "setDataRate", ph_bridge_set_data_rate, 1);
|
126
|
+
|
127
|
+
#ifdef PH_CALLBACK
|
128
|
+
rb_define_private_method(ph_bridge, "ext_setOnBridgeDataHandler", ph_bridge_set_on_bridge_data_handler, 1);
|
129
|
+
#endif
|
130
|
+
|
131
|
+
rb_define_alias(ph_bridge, "input_count", "getInputCount");
|
132
|
+
rb_define_alias(ph_bridge, "bridge_value", "getBridgeValue");
|
133
|
+
rb_define_alias(ph_bridge, "bridge_min", "getBridgeMin");
|
134
|
+
rb_define_alias(ph_bridge, "bridge_max", "getBridgeMax");
|
135
|
+
rb_define_alias(ph_bridge, "enabled?", "getEnabled");
|
136
|
+
rb_define_alias(ph_bridge, "set_enabled", "setEnabled");
|
137
|
+
rb_define_alias(ph_bridge, "gain", "getGain");
|
138
|
+
rb_define_alias(ph_bridge, "set_gain", "setGain");
|
139
|
+
rb_define_alias(ph_bridge, "data_rate", "getDataRate");
|
140
|
+
rb_define_alias(ph_bridge, "data_rate_min", "getDataRateMin");
|
141
|
+
rb_define_alias(ph_bridge, "data_rate_max", "getDataRateMax");
|
142
|
+
rb_define_alias(ph_bridge, "data_rate=", "setDataRate");
|
143
|
+
|
144
|
+
return ph_bridge;
|
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
|
+
|