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,567 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "phidgets.h"
|
3
|
-
|
4
|
-
|
5
|
-
VALUE ph_advservo_init(VALUE self);
|
6
|
-
VALUE ph_advservo_get_motor_count(VALUE self);
|
7
|
-
VALUE ph_advservo_get_acceleration(VALUE self, VALUE index);
|
8
|
-
VALUE ph_advservo_get_acceleration_min(VALUE self, VALUE index);
|
9
|
-
VALUE ph_advservo_get_acceleration_max(VALUE self, VALUE index);
|
10
|
-
VALUE ph_advservo_set_acceleration(VALUE self, VALUE index, VALUE accel);
|
11
|
-
VALUE ph_advservo_get_velocity(VALUE self, VALUE index);
|
12
|
-
VALUE ph_advservo_get_velocity_min(VALUE self, VALUE index);
|
13
|
-
VALUE ph_advservo_get_velocity_max(VALUE self, VALUE index);
|
14
|
-
VALUE ph_advservo_get_velocity_limit(VALUE self, VALUE index);
|
15
|
-
VALUE ph_advservo_set_velocity_limit(VALUE self, VALUE index, VALUE limit);
|
16
|
-
VALUE ph_advservo_get_position(VALUE self, VALUE index);
|
17
|
-
VALUE ph_advservo_get_position_min(VALUE self, VALUE index);
|
18
|
-
VALUE ph_advservo_get_position_max(VALUE self, VALUE index);
|
19
|
-
VALUE ph_advservo_set_position(VALUE self, VALUE index, VALUE position);
|
20
|
-
VALUE ph_advservo_set_position_min(VALUE self, VALUE index, VALUE min);
|
21
|
-
VALUE ph_advservo_set_position_max(VALUE self, VALUE index, VALUE max);
|
22
|
-
VALUE ph_advservo_get_current(VALUE self, VALUE index);
|
23
|
-
VALUE ph_advservo_get_speed_ramping_on(VALUE self, VALUE index);
|
24
|
-
VALUE ph_advservo_set_speed_ramping_on(VALUE self, VALUE index, VALUE state);
|
25
|
-
VALUE ph_advservo_get_engaged(VALUE self, VALUE index);
|
26
|
-
VALUE ph_advservo_set_engaged(VALUE self, VALUE index, VALUE state);
|
27
|
-
VALUE ph_advservo_get_stopped(VALUE self, VALUE index);
|
28
|
-
VALUE ph_advservo_get_servo_type(VALUE self, VALUE index);
|
29
|
-
VALUE ph_advservo_set_servo_type(VALUE self, VALUE index, VALUE type);
|
30
|
-
VALUE ph_advservo_set_servo_parameters(VALUE self, VALUE index, VALUE min_us, VALUE max_us, VALUE degrees, VALUE velocity_max);
|
31
|
-
|
32
|
-
#ifdef PH_CALLBACK
|
33
|
-
VALUE ph_advservo_set_on_velocity_change_handler(VALUE self, VALUE handler);
|
34
|
-
VALUE ph_advservo_set_on_position_change_handler(VALUE self, VALUE handler);
|
35
|
-
VALUE ph_advservo_set_on_current_change_handler(VALUE self, VALUE handler);
|
36
|
-
int ph_advservo_on_velocity_change(CPhidgetAdvancedServoHandle phid, void *userPtr, int index, double velocity);
|
37
|
-
int ph_advservo_on_position_change(CPhidgetAdvancedServoHandle phid, void *userPtr, int index, double position);
|
38
|
-
int ph_advservo_on_current_change(CPhidgetAdvancedServoHandle phid, void *userPtr, int index, double current);
|
39
|
-
#endif
|
40
|
-
|
41
|
-
|
42
|
-
void Init_advanced_servo() {
|
43
|
-
VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
|
44
|
-
VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
|
45
|
-
VALUE ph_advservo = rb_define_class_under(ph_module, "AdvancedServo", ph_common);
|
46
|
-
|
47
|
-
/* Default - This is what the servo API been historically used, originally based on the Futaba FP-S148 */
|
48
|
-
rb_define_const(ph_advservo, "DEFAULT", INT2FIX(PHIDGET_SERVO_DEFAULT));
|
49
|
-
/* Raw us mode - all position, velocity, acceleration functions are specified in microseconds rather then degrees */
|
50
|
-
rb_define_const(ph_advservo, "RAW_US_MODE", INT2FIX(PHIDGET_SERVO_RAW_us_MODE));
|
51
|
-
/* HiTec HS-322HD Standard \Servo */
|
52
|
-
rb_define_const(ph_advservo, "HITEC_HS322HD", INT2FIX(PHIDGET_SERVO_HITEC_HS322HD));
|
53
|
-
/* HiTec HS-5245MG Digital Mini \Servo */
|
54
|
-
rb_define_const(ph_advservo, "HITEC_HS5245MG", INT2FIX(PHIDGET_SERVO_HITEC_HS5245MG));
|
55
|
-
/* HiTec HS-805BB Mega Quarter Scale \Servo */
|
56
|
-
rb_define_const(ph_advservo, "HITEC_805BB", INT2FIX(PHIDGET_SERVO_HITEC_805BB));
|
57
|
-
/* HiTec HS-422 Standard \Servo */
|
58
|
-
rb_define_const(ph_advservo, "HITEC_HS422", INT2FIX(PHIDGET_SERVO_HITEC_HS422));
|
59
|
-
/* Tower Pro MG90 Micro \Servo */
|
60
|
-
rb_define_const(ph_advservo, "TOWERPRO_MG90", INT2FIX(PHIDGET_SERVO_TOWERPRO_MG90));
|
61
|
-
/* HiTec HSR-1425CR Continuous Rotation \Servo */
|
62
|
-
rb_define_const(ph_advservo, "HITEC_HSR1425CR", INT2FIX(PHIDGET_SERVO_HITEC_HSR1425CR));
|
63
|
-
/* HiTec HS-785HB Sail Winch \Servo */
|
64
|
-
rb_define_const(ph_advservo, "HITEC_HS785HB", INT2FIX(PHIDGET_SERVO_HITEC_HS785HB));
|
65
|
-
/* HiTec HS-485HB Deluxe \Servo */
|
66
|
-
rb_define_const(ph_advservo, "HITEC_HS485HB", INT2FIX(PHIDGET_SERVO_HITEC_HS485HB));
|
67
|
-
/* HiTec HS-645MG Ultra Torque \Servo */
|
68
|
-
rb_define_const(ph_advservo, "HITEC_HS645MG", INT2FIX(PHIDGET_SERVO_HITEC_HS645MG));
|
69
|
-
/* HiTec HS-815BB Mega Sail \Servo */
|
70
|
-
rb_define_const(ph_advservo, "HITEC_815BB", INT2FIX(PHIDGET_SERVO_HITEC_815BB));
|
71
|
-
/* Document-const:
|
72
|
-
* Firgelli L12 Linear Actuator 30mm 50\:1 */
|
73
|
-
rb_define_const(ph_advservo, "FIRGELLI_L12_30_50_06_R", INT2FIX(PHIDGET_SERVO_FIRGELLI_L12_30_50_06_R));
|
74
|
-
/* Document-const:
|
75
|
-
* Firgelli L12 Linear Actuator 50mm 100\:1 */
|
76
|
-
rb_define_const(ph_advservo, "FIRGELLI_L12_50_100_06_R", INT2FIX(PHIDGET_SERVO_FIRGELLI_L12_50_100_06_R));
|
77
|
-
/* Document-const:
|
78
|
-
* Firgelli L12 Linear Actuator 50mm 210\:1 */
|
79
|
-
rb_define_const(ph_advservo, "FIRGELLI_L12_50_210_06_R", INT2FIX(PHIDGET_SERVO_FIRGELLI_L12_50_210_06_R));
|
80
|
-
/* Document-const:
|
81
|
-
* Firgelli L12 Linear Actuator 100mm 50\:1 */
|
82
|
-
rb_define_const(ph_advservo, "FIRGELLI_L12_100_50_06_R", INT2FIX(PHIDGET_SERVO_FIRGELLI_L12_100_50_06_R));
|
83
|
-
/* Document-const:
|
84
|
-
* Firgelli L12 Linear Actuator 100mm 100\:1 */
|
85
|
-
rb_define_const(ph_advservo, "FIRGELLI_L12_100_100_06_R", INT2FIX(PHIDGET_SERVO_FIRGELLI_L12_100_100_06_R));
|
86
|
-
/* SpringRC SM-S2313M Micro \Servo */
|
87
|
-
rb_define_const(ph_advservo, "SPRINGRC_SM_S2313M", INT2FIX(PHIDGET_SERVO_SPRINGRC_SM_S2313M));
|
88
|
-
/* SpringRC SM-S3317M Small \Servo */
|
89
|
-
rb_define_const(ph_advservo, "SPRINGRC_SM_S3317M", INT2FIX(PHIDGET_SERVO_SPRINGRC_SM_S3317M));
|
90
|
-
/* SpringRC SM-S3317SR Small Continuous Rotation \Servo */
|
91
|
-
rb_define_const(ph_advservo, "SPRINGRC_SM_S3317SR", INT2FIX(PHIDGET_SERVO_SPRINGRC_SM_S3317SR));
|
92
|
-
/* SpringRC SM-S4303R Standard Continuous Rotation \Servo */
|
93
|
-
rb_define_const(ph_advservo, "SPRINGRC_SM_S4303R", INT2FIX(PHIDGET_SERVO_SPRINGRC_SM_S4303R));
|
94
|
-
/* SpringRC SM-S4315M High Torque \Servo */
|
95
|
-
rb_define_const(ph_advservo, "SPRINGRC_SM_S4315M", INT2FIX(PHIDGET_SERVO_SPRINGRC_SM_S4315M));
|
96
|
-
/* SpringRC SM-S4315R High Torque Continuous Rotation \Servo */
|
97
|
-
rb_define_const(ph_advservo, "SPRINGRC_SM_S4315R", INT2FIX(PHIDGET_SERVO_SPRINGRC_SM_S4315R));
|
98
|
-
/* SpringRC SM-S4505B Standard \Servo */
|
99
|
-
rb_define_const(ph_advservo, "SPRINGRC_SM_S4505B", INT2FIX(PHIDGET_SERVO_SPRINGRC_SM_S4505B));
|
100
|
-
|
101
|
-
|
102
|
-
/* Document-method: new
|
103
|
-
* call-seq: new
|
104
|
-
*
|
105
|
-
* Creates a Phidget AdvancedServo object.
|
106
|
-
*/
|
107
|
-
rb_define_method(ph_advservo, "initialize", ph_advservo_init, 0);
|
108
|
-
|
109
|
-
/* Document-method: getMotorCount
|
110
|
-
* call-seq: getMotorCount -> count
|
111
|
-
*
|
112
|
-
* Gets the number of motors supported by this controller
|
113
|
-
*/
|
114
|
-
rb_define_method(ph_advservo, "getMotorCount", ph_advservo_get_motor_count, 0);
|
115
|
-
|
116
|
-
/* Document-method: getAcceleration
|
117
|
-
* call-seq: getAcceleration(index) -> acceleration
|
118
|
-
*
|
119
|
-
* Gets the last set acceleration for a motor.
|
120
|
-
*/
|
121
|
-
rb_define_method(ph_advservo, "getAcceleration", ph_advservo_get_acceleration, 1);
|
122
|
-
|
123
|
-
/* Document-method: getAccelerationMin
|
124
|
-
* call-seq: getAccelerationMin(index) -> min
|
125
|
-
*
|
126
|
-
* Gets the minimum acceleration supported by a motor.
|
127
|
-
*/
|
128
|
-
rb_define_method(ph_advservo, "getAccelerationMin", ph_advservo_get_acceleration_min, 1);
|
129
|
-
|
130
|
-
/* Document-method: getAccelerationMax
|
131
|
-
* call-seq: getAccelerationMax(index) -> max
|
132
|
-
*
|
133
|
-
* Gets the maximum acceleration supported by a motor
|
134
|
-
*/
|
135
|
-
rb_define_method(ph_advservo, "getAccelerationMax", ph_advservo_get_acceleration_max, 1);
|
136
|
-
|
137
|
-
/* Document-method: setAcceleration
|
138
|
-
* call-seq: setAcceleration(index, acceleration)
|
139
|
-
*
|
140
|
-
* Sets the acceleration for a motor.
|
141
|
-
*/
|
142
|
-
rb_define_method(ph_advservo, "setAcceleration", ph_advservo_set_acceleration, 2);
|
143
|
-
|
144
|
-
/* Document-method: getVelocity
|
145
|
-
* call-seq: getVelocity(index) -> velocity
|
146
|
-
*
|
147
|
-
* Gets the current velocity of a motor.
|
148
|
-
*/
|
149
|
-
rb_define_method(ph_advservo, "getVelocity", ph_advservo_get_velocity, 1);
|
150
|
-
|
151
|
-
/* Document-method: getVelocityMin
|
152
|
-
* call-seq: getVelocityMin(index) -> min
|
153
|
-
*
|
154
|
-
* Gets the minimum velocity that can be set for a motor.
|
155
|
-
*/
|
156
|
-
rb_define_method(ph_advservo, "getVelocityMin", ph_advservo_get_velocity_min, 1);
|
157
|
-
|
158
|
-
/* Document-method: getVelocityMax
|
159
|
-
* call-seq: getVelocityMax(index) -> max
|
160
|
-
*
|
161
|
-
* Gets the maximum velocity that can be set for a motor.
|
162
|
-
*/
|
163
|
-
rb_define_method(ph_advservo, "getVelocityMax", ph_advservo_get_velocity_max, 1);
|
164
|
-
|
165
|
-
/* Document-method: getVelocityLimit
|
166
|
-
* call-seq: getVelocityLimit(index) -> limit
|
167
|
-
*
|
168
|
-
* Gets the last set velocity limit for a motor.
|
169
|
-
*/
|
170
|
-
rb_define_method(ph_advservo, "getVelocityLimit", ph_advservo_get_velocity_limit, 1);
|
171
|
-
|
172
|
-
/* Document-method: setVelocityLimit
|
173
|
-
* call-seq: setVelocityLimit(index, limit)
|
174
|
-
*
|
175
|
-
* Sets the velocity limit for a motor.
|
176
|
-
*/
|
177
|
-
rb_define_method(ph_advservo, "setVelocityLimit", ph_advservo_set_velocity_limit, 2);
|
178
|
-
|
179
|
-
/* Document-method: getPosition
|
180
|
-
* call-seq: getPosition(index) -> position
|
181
|
-
*
|
182
|
-
* Gets the current position of a motor.
|
183
|
-
*/
|
184
|
-
rb_define_method(ph_advservo, "getPosition", ph_advservo_get_position, 1);
|
185
|
-
|
186
|
-
/* Document-method: getPositionMin
|
187
|
-
* call-seq: getPositionMin(index) -> min
|
188
|
-
*
|
189
|
-
* Gets the minimum position that a motor can go to.
|
190
|
-
*/
|
191
|
-
rb_define_method(ph_advservo, "getPositionMin", ph_advservo_get_position_min, 1);
|
192
|
-
|
193
|
-
/* Document-method: getPositionMax
|
194
|
-
* call-seq: getPositionMax(index) -> max
|
195
|
-
*
|
196
|
-
* Gets the maximum position that a motor can go to.
|
197
|
-
*/
|
198
|
-
rb_define_method(ph_advservo, "getPositionMax", ph_advservo_get_position_max, 1);
|
199
|
-
|
200
|
-
/* Document-method: setPosition
|
201
|
-
* call-seq: setPosition(index, position)
|
202
|
-
*
|
203
|
-
* Sets the position of a motor.
|
204
|
-
*/
|
205
|
-
rb_define_method(ph_advservo, "setPosition", ph_advservo_set_position, 2);
|
206
|
-
|
207
|
-
/* Document-method: setPositionMin
|
208
|
-
* call-seq: setPositionMin(index, position)
|
209
|
-
*
|
210
|
-
* Sets the minimum position that a motor can go to.
|
211
|
-
*/
|
212
|
-
rb_define_method(ph_advservo, "setPositionMin", ph_advservo_set_position_min, 2);
|
213
|
-
|
214
|
-
/* Document-method: setPositionMax
|
215
|
-
* call-seq: setPositionMax(index, position)
|
216
|
-
*
|
217
|
-
* Sets the maximum position that a motor can go to.
|
218
|
-
*/
|
219
|
-
rb_define_method(ph_advservo, "setPositionMax", ph_advservo_set_position_max, 2);
|
220
|
-
|
221
|
-
/* Document-method: getCurrent
|
222
|
-
* call-seq: getCurrent(index)
|
223
|
-
*
|
224
|
-
* Gets the current current draw for a motor.
|
225
|
-
*/
|
226
|
-
rb_define_method(ph_advservo, "getCurrent", ph_advservo_get_current, 1);
|
227
|
-
|
228
|
-
/* Document-method: getSpeedRampingOn
|
229
|
-
* call-seq: getSpeedRampingOn(index) -> true or false
|
230
|
-
*
|
231
|
-
* Gets the speed ramping state for a motor. This is whether or not velocity and acceleration are used.
|
232
|
-
*/
|
233
|
-
rb_define_method(ph_advservo, "getSpeedRampingOn", ph_advservo_get_speed_ramping_on, 1);
|
234
|
-
|
235
|
-
/* Document-method: setSpeedRampingOn
|
236
|
-
* call-seq: setSpeedRampingOn(index, ramping_state)
|
237
|
-
*
|
238
|
-
* Sets the speed ramping state for a motor. This is whether or not velocity and acceleration are used.
|
239
|
-
*/
|
240
|
-
rb_define_method(ph_advservo, "setSpeedRampingOn", ph_advservo_set_speed_ramping_on, 2);
|
241
|
-
|
242
|
-
/* Document-method: getEngaged
|
243
|
-
* call-seq: getEngaged(index) -> true or false
|
244
|
-
*
|
245
|
-
* Gets the engaged state of a motor. This is whether the motor is powered or not.
|
246
|
-
*/
|
247
|
-
rb_define_method(ph_advservo, "getEngaged", ph_advservo_get_engaged, 1);
|
248
|
-
|
249
|
-
/* Document-method: setEngaged
|
250
|
-
* call-seq: setEngaged(index, engaged_state)
|
251
|
-
*
|
252
|
-
* Sets the engaged state of a motor. This is whether the motor is powered or not.
|
253
|
-
*/
|
254
|
-
rb_define_method(ph_advservo, "setEngaged", ph_advservo_set_engaged, 2);
|
255
|
-
|
256
|
-
/* Document-method: getStopped
|
257
|
-
* call-seq: getStopped(index) -> true or false
|
258
|
-
*
|
259
|
-
* Gets the stopped state of a motor. This is true when the motor is not moving and there are no outstanding commands.
|
260
|
-
*/
|
261
|
-
rb_define_method(ph_advservo, "getStopped", ph_advservo_get_stopped, 1);
|
262
|
-
|
263
|
-
/* Document-method: getServoType
|
264
|
-
* call-seq: getServoType(index) -> servo_type
|
265
|
-
*
|
266
|
-
* Gets the servo type of a motor.
|
267
|
-
*/
|
268
|
-
rb_define_method(ph_advservo, "getServoType", ph_advservo_get_servo_type, 1);
|
269
|
-
|
270
|
-
/* Document-method: setServoType
|
271
|
-
* call-seq: setServoType(index, servo_type)
|
272
|
-
*
|
273
|
-
* Sets the servo type of a motor.
|
274
|
-
*/
|
275
|
-
rb_define_method(ph_advservo, "setServoType", ph_advservo_set_servo_type, 2);
|
276
|
-
|
277
|
-
/* Document-method: setServoParameters
|
278
|
-
* call-seq: setServoParameters(index, min_us, max_us, degrees, velocity_max)
|
279
|
-
*
|
280
|
-
* Sets the servo parameters of a motor.
|
281
|
-
*/
|
282
|
-
rb_define_method(ph_advservo, "setServoParameters", ph_advservo_set_servo_parameters, 5);
|
283
|
-
|
284
|
-
#ifdef PH_CALLBACK
|
285
|
-
rb_define_private_method(ph_advservo, "ext_setOnVelocityChangeHandler", ph_advservo_set_on_velocity_change_handler, 1);
|
286
|
-
rb_define_private_method(ph_advservo, "ext_setOnPositionChangeHandler", ph_advservo_set_on_position_change_handler, 1);
|
287
|
-
rb_define_private_method(ph_advservo, "ext_setOnCurrentChangeHandler", ph_advservo_set_on_current_change_handler, 1);
|
288
|
-
#endif
|
289
|
-
|
290
|
-
rb_define_alias(ph_advservo, "motor_count", "getMotorCount");
|
291
|
-
rb_define_alias(ph_advservo, "acceleration", "getAcceleration");
|
292
|
-
rb_define_alias(ph_advservo, "acceleration_min", "getAccelerationMin");
|
293
|
-
rb_define_alias(ph_advservo, "acceleration_max", "getAccelerationMax");
|
294
|
-
rb_define_alias(ph_advservo, "set_acceleration", "setAcceleration");
|
295
|
-
rb_define_alias(ph_advservo, "velocity", "getVelocity");
|
296
|
-
rb_define_alias(ph_advservo, "velocity_min", "getVelocityMin");
|
297
|
-
rb_define_alias(ph_advservo, "velocity_max", "getVelocityMax");
|
298
|
-
rb_define_alias(ph_advservo, "velocity_limit", "getVelocityLimit");
|
299
|
-
rb_define_alias(ph_advservo, "set_velocity_limit", "setVelocityLimit");
|
300
|
-
rb_define_alias(ph_advservo, "position", "getPosition");
|
301
|
-
rb_define_alias(ph_advservo, "position_min", "getPositionMin");
|
302
|
-
rb_define_alias(ph_advservo, "position_max", "getPositionMax");
|
303
|
-
rb_define_alias(ph_advservo, "set_position", "setPosition");
|
304
|
-
rb_define_alias(ph_advservo, "set_position_min", "setPositionMin");
|
305
|
-
rb_define_alias(ph_advservo, "set_position_max", "setPositionMax");
|
306
|
-
rb_define_alias(ph_advservo, "current", "getCurrent");
|
307
|
-
rb_define_alias(ph_advservo, "speed_ramping_on?", "getSpeedRampingOn");
|
308
|
-
rb_define_alias(ph_advservo, "set_speed_ramping_on", "setSpeedRampingOn");
|
309
|
-
rb_define_alias(ph_advservo, "engaged?", "getEngaged");
|
310
|
-
rb_define_alias(ph_advservo, "set_engaged", "setEngaged");
|
311
|
-
rb_define_alias(ph_advservo, "stopped?", "getStopped");
|
312
|
-
rb_define_alias(ph_advservo, "servo_type", "getServoType");
|
313
|
-
rb_define_alias(ph_advservo, "set_servo_type", "setServoType");
|
314
|
-
rb_define_alias(ph_advservo, "set_servo_parameters", "setServoParameters");
|
315
|
-
}
|
316
|
-
|
317
|
-
|
318
|
-
VALUE ph_advservo_init(VALUE self) {
|
319
|
-
ph_data_t *ph = get_ph_data(self);
|
320
|
-
ph_raise(CPhidgetAdvancedServo_create((CPhidgetAdvancedServoHandle *)(&(ph->handle))));
|
321
|
-
return self;
|
322
|
-
}
|
323
|
-
|
324
|
-
VALUE ph_advservo_get_motor_count(VALUE self) {
|
325
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
326
|
-
int count;
|
327
|
-
ph_raise(CPhidgetAdvancedServo_getMotorCount(handle, &count));
|
328
|
-
return INT2FIX(count);
|
329
|
-
}
|
330
|
-
|
331
|
-
VALUE ph_advservo_get_acceleration(VALUE self, VALUE index) {
|
332
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
333
|
-
double accel;
|
334
|
-
ph_raise(CPhidgetAdvancedServo_getAcceleration(handle, FIX2INT(index), &accel));
|
335
|
-
return rb_float_new(accel);
|
336
|
-
}
|
337
|
-
|
338
|
-
VALUE ph_advservo_get_acceleration_min(VALUE self, VALUE index) {
|
339
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
340
|
-
double accel;
|
341
|
-
ph_raise(CPhidgetAdvancedServo_getAccelerationMin(handle, FIX2INT(index), &accel));
|
342
|
-
return rb_float_new(accel);
|
343
|
-
}
|
344
|
-
|
345
|
-
VALUE ph_advservo_get_acceleration_max(VALUE self, VALUE index) {
|
346
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
347
|
-
double accel;
|
348
|
-
ph_raise(CPhidgetAdvancedServo_getAccelerationMax(handle, FIX2INT(index), &accel));
|
349
|
-
return rb_float_new(accel);
|
350
|
-
}
|
351
|
-
|
352
|
-
VALUE ph_advservo_set_acceleration(VALUE self, VALUE index, VALUE accel) {
|
353
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
354
|
-
ph_raise(CPhidgetAdvancedServo_setAcceleration(handle, FIX2INT(index), NUM2DBL(accel)));
|
355
|
-
return Qnil;
|
356
|
-
}
|
357
|
-
|
358
|
-
VALUE ph_advservo_get_velocity(VALUE self, VALUE index) {
|
359
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
360
|
-
double velocity;
|
361
|
-
ph_raise(CPhidgetAdvancedServo_getVelocity(handle, FIX2INT(index), &velocity));
|
362
|
-
return rb_float_new(velocity);
|
363
|
-
}
|
364
|
-
|
365
|
-
VALUE ph_advservo_get_velocity_min(VALUE self, VALUE index) {
|
366
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
367
|
-
double velocity;
|
368
|
-
ph_raise(CPhidgetAdvancedServo_getVelocityMin(handle, FIX2INT(index), &velocity));
|
369
|
-
return rb_float_new(velocity);
|
370
|
-
}
|
371
|
-
|
372
|
-
VALUE ph_advservo_get_velocity_max(VALUE self, VALUE index) {
|
373
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
374
|
-
double velocity;
|
375
|
-
ph_raise(CPhidgetAdvancedServo_getVelocityMax(handle, FIX2INT(index), &velocity));
|
376
|
-
return rb_float_new(velocity);
|
377
|
-
}
|
378
|
-
|
379
|
-
VALUE ph_advservo_get_velocity_limit(VALUE self, VALUE index) {
|
380
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
381
|
-
double velocity;
|
382
|
-
ph_raise(CPhidgetAdvancedServo_getVelocityLimit(handle, FIX2INT(index), &velocity));
|
383
|
-
return rb_float_new(velocity);
|
384
|
-
}
|
385
|
-
|
386
|
-
VALUE ph_advservo_set_velocity_limit(VALUE self, VALUE index, VALUE limit) {
|
387
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
388
|
-
ph_raise(CPhidgetAdvancedServo_setVelocityLimit(handle, FIX2INT(index), NUM2DBL(limit)));
|
389
|
-
return Qnil;
|
390
|
-
}
|
391
|
-
|
392
|
-
VALUE ph_advservo_get_position(VALUE self, VALUE index) {
|
393
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
394
|
-
double position;
|
395
|
-
ph_raise(CPhidgetAdvancedServo_getPosition(handle, FIX2INT(index), &position));
|
396
|
-
return rb_float_new(position);
|
397
|
-
}
|
398
|
-
|
399
|
-
VALUE ph_advservo_get_position_min(VALUE self, VALUE index) {
|
400
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
401
|
-
double position;
|
402
|
-
ph_raise(CPhidgetAdvancedServo_getPositionMin(handle, FIX2INT(index), &position));
|
403
|
-
return rb_float_new(position);
|
404
|
-
}
|
405
|
-
|
406
|
-
VALUE ph_advservo_get_position_max(VALUE self, VALUE index) {
|
407
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
408
|
-
double position;
|
409
|
-
ph_raise(CPhidgetAdvancedServo_getPositionMax(handle, FIX2INT(index), &position));
|
410
|
-
return rb_float_new(position);
|
411
|
-
}
|
412
|
-
|
413
|
-
VALUE ph_advservo_set_position(VALUE self, VALUE index, VALUE position) {
|
414
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
415
|
-
ph_raise(CPhidgetAdvancedServo_setPosition(handle, FIX2INT(index), NUM2DBL(position)));
|
416
|
-
return Qnil;
|
417
|
-
}
|
418
|
-
|
419
|
-
VALUE ph_advservo_set_position_min(VALUE self, VALUE index, VALUE min) {
|
420
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
421
|
-
ph_raise(CPhidgetAdvancedServo_setPositionMin(handle, FIX2INT(index), NUM2DBL(min)));
|
422
|
-
return Qnil;
|
423
|
-
}
|
424
|
-
|
425
|
-
VALUE ph_advservo_set_position_max(VALUE self, VALUE index, VALUE max) {
|
426
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
427
|
-
ph_raise(CPhidgetAdvancedServo_setPositionMax(handle, FIX2INT(index), NUM2DBL(max)));
|
428
|
-
return Qnil;
|
429
|
-
}
|
430
|
-
|
431
|
-
VALUE ph_advservo_get_current(VALUE self, VALUE index) {
|
432
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
433
|
-
double current;
|
434
|
-
ph_raise(CPhidgetAdvancedServo_getCurrent(handle, FIX2INT(index), ¤t));
|
435
|
-
return rb_float_new(current);
|
436
|
-
}
|
437
|
-
|
438
|
-
VALUE ph_advservo_get_speed_ramping_on(VALUE self, VALUE index) {
|
439
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
440
|
-
int on;
|
441
|
-
ph_raise(CPhidgetAdvancedServo_getSpeedRampingOn(handle, FIX2INT(index), &on));
|
442
|
-
return on == PTRUE ? Qtrue : Qfalse;
|
443
|
-
}
|
444
|
-
|
445
|
-
VALUE ph_advservo_set_speed_ramping_on(VALUE self, VALUE index, VALUE state) {
|
446
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
447
|
-
ph_raise(CPhidgetAdvancedServo_setSpeedRampingOn(handle, FIX2INT(index), TYPE(state) == T_TRUE ? PTRUE : PFALSE));
|
448
|
-
return Qnil;
|
449
|
-
}
|
450
|
-
|
451
|
-
VALUE ph_advservo_get_engaged(VALUE self, VALUE index) {
|
452
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
453
|
-
int engaged;
|
454
|
-
ph_raise(CPhidgetAdvancedServo_getEngaged(handle, FIX2INT(index), &engaged));
|
455
|
-
return engaged == PTRUE ? Qtrue : Qfalse;
|
456
|
-
}
|
457
|
-
|
458
|
-
VALUE ph_advservo_set_engaged(VALUE self, VALUE index, VALUE state) {
|
459
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
460
|
-
ph_raise(CPhidgetAdvancedServo_setEngaged(handle, FIX2INT(index), TYPE(state) == T_TRUE ? PTRUE : PFALSE));
|
461
|
-
return Qnil;
|
462
|
-
}
|
463
|
-
|
464
|
-
VALUE ph_advservo_get_stopped(VALUE self, VALUE index) {
|
465
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
466
|
-
int stopped;
|
467
|
-
ph_raise(CPhidgetAdvancedServo_getStopped(handle, FIX2INT(index), &stopped));
|
468
|
-
return stopped == PTRUE ? Qtrue : Qfalse;
|
469
|
-
}
|
470
|
-
|
471
|
-
VALUE ph_advservo_get_servo_type(VALUE self, VALUE index) {
|
472
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
473
|
-
CPhidget_ServoType type;
|
474
|
-
ph_raise(CPhidgetAdvancedServo_getServoType(handle, FIX2INT(index), &type));
|
475
|
-
return INT2FIX(type);
|
476
|
-
}
|
477
|
-
|
478
|
-
VALUE ph_advservo_set_servo_type(VALUE self, VALUE index, VALUE type) {
|
479
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
480
|
-
ph_raise(CPhidgetAdvancedServo_setServoType(handle, FIX2INT(index), (CPhidget_ServoType)FIX2INT(type)));
|
481
|
-
return Qnil;
|
482
|
-
}
|
483
|
-
|
484
|
-
VALUE ph_advservo_set_servo_parameters(VALUE self, VALUE index, VALUE min_us, VALUE max_us, VALUE degrees, VALUE velocity_max) {
|
485
|
-
CPhidgetAdvancedServoHandle handle = (CPhidgetAdvancedServoHandle)get_ph_handle(self);
|
486
|
-
ph_raise(CPhidgetAdvancedServo_setServoParameters(handle, FIX2INT(index), NUM2DBL(min_us), NUM2DBL(max_us), NUM2DBL(degrees), NUM2DBL(velocity_max)));
|
487
|
-
return Qnil;
|
488
|
-
}
|
489
|
-
|
490
|
-
|
491
|
-
#ifdef PH_CALLBACK
|
492
|
-
VALUE ph_advservo_set_on_velocity_change_handler(VALUE self, VALUE handler) {
|
493
|
-
ph_data_t *ph = get_ph_data(self);
|
494
|
-
ph_callback_data_t *callback_data = &ph->dev_callback_1;
|
495
|
-
if( TYPE(handler) == T_NIL ) {
|
496
|
-
callback_data->exit = true;
|
497
|
-
ph_raise(CPhidgetAdvancedServo_set_OnVelocityChange_Handler((CPhidgetAdvancedServoHandle)ph->handle, NULL, (void *)NULL));
|
498
|
-
} else {
|
499
|
-
callback_data->called = false;
|
500
|
-
callback_data->exit = false;
|
501
|
-
callback_data->phidget = self;
|
502
|
-
callback_data->callback = handler;
|
503
|
-
ph_raise(CPhidgetAdvancedServo_set_OnVelocityChange_Handler((CPhidgetAdvancedServoHandle)ph->handle, ph_advservo_on_velocity_change, (void *)callback_data));
|
504
|
-
ph_callback_thread(callback_data);
|
505
|
-
}
|
506
|
-
return Qnil;
|
507
|
-
}
|
508
|
-
|
509
|
-
|
510
|
-
VALUE ph_advservo_set_on_position_change_handler(VALUE self, VALUE handler) {
|
511
|
-
ph_data_t *ph = get_ph_data(self);
|
512
|
-
ph_callback_data_t *callback_data = &ph->dev_callback_2;
|
513
|
-
if( TYPE(handler) == T_NIL ) {
|
514
|
-
callback_data->exit = true;
|
515
|
-
ph_raise(CPhidgetAdvancedServo_set_OnPositionChange_Handler((CPhidgetAdvancedServoHandle)ph->handle, NULL, (void *)NULL));
|
516
|
-
} else {
|
517
|
-
callback_data->called = false;
|
518
|
-
callback_data->exit = false;
|
519
|
-
callback_data->phidget = self;
|
520
|
-
callback_data->callback = handler;
|
521
|
-
ph_raise(CPhidgetAdvancedServo_set_OnPositionChange_Handler((CPhidgetAdvancedServoHandle)ph->handle, ph_advservo_on_position_change, (void *)callback_data));
|
522
|
-
ph_callback_thread(callback_data);
|
523
|
-
}
|
524
|
-
return Qnil;
|
525
|
-
}
|
526
|
-
|
527
|
-
|
528
|
-
VALUE ph_advservo_set_on_current_change_handler(VALUE self, VALUE handler) {
|
529
|
-
ph_data_t *ph = get_ph_data(self);
|
530
|
-
ph_callback_data_t *callback_data = &ph->dev_callback_3;
|
531
|
-
if( TYPE(handler) == T_NIL ) {
|
532
|
-
callback_data->exit = true;
|
533
|
-
ph_raise(CPhidgetAdvancedServo_set_OnCurrentChange_Handler((CPhidgetAdvancedServoHandle)ph->handle, NULL, (void *)NULL));
|
534
|
-
} else {
|
535
|
-
callback_data->called = false;
|
536
|
-
callback_data->exit = false;
|
537
|
-
callback_data->phidget = self;
|
538
|
-
callback_data->callback = handler;
|
539
|
-
ph_raise(CPhidgetAdvancedServo_set_OnCurrentChange_Handler((CPhidgetAdvancedServoHandle)ph->handle, ph_advservo_on_current_change, (void *)callback_data));
|
540
|
-
ph_callback_thread(callback_data);
|
541
|
-
}
|
542
|
-
return Qnil;
|
543
|
-
}
|
544
|
-
|
545
|
-
|
546
|
-
int ph_advservo_on_velocity_change(CPhidgetAdvancedServoHandle phid, void *userPtr, int index, double velocity) {
|
547
|
-
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
548
|
-
callback_data->called = true;
|
549
|
-
return EPHIDGET_OK;
|
550
|
-
}
|
551
|
-
|
552
|
-
|
553
|
-
int ph_advservo_on_position_change(CPhidgetAdvancedServoHandle phid, void *userPtr, int index, double position) {
|
554
|
-
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
555
|
-
callback_data->called = true;
|
556
|
-
return EPHIDGET_OK;
|
557
|
-
}
|
558
|
-
|
559
|
-
|
560
|
-
int ph_advservo_on_current_change(CPhidgetAdvancedServoHandle phid, void *userPtr, int index, double current) {
|
561
|
-
ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
|
562
|
-
callback_data->called = true;
|
563
|
-
return EPHIDGET_OK;
|
564
|
-
}
|
565
|
-
|
566
|
-
#endif
|
567
|
-
|