phidgets 0.1.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +3 -0
  3. data/README.rdoc +32 -43
  4. data/Rakefile +4 -2
  5. data/bin/phidget +18 -72
  6. data/ext/phidgets/extconf.rb +5 -8
  7. data/ext/phidgets/phidgets.c +708 -173
  8. data/ext/phidgets/phidgets.h +54 -35
  9. data/ext/phidgets/phidgets_accelerometer.c +193 -109
  10. data/ext/phidgets/phidgets_bldc_motor.c +529 -0
  11. data/ext/phidgets/phidgets_capacitive_touch.c +302 -0
  12. data/ext/phidgets/phidgets_common.c +570 -315
  13. data/ext/phidgets/phidgets_current_input.c +229 -0
  14. data/ext/phidgets/phidgets_dc_motor.c +562 -0
  15. data/ext/phidgets/phidgets_dictionary.c +154 -213
  16. data/ext/phidgets/phidgets_digital_input.c +127 -0
  17. data/ext/phidgets/phidgets_digital_output.c +288 -0
  18. data/ext/phidgets/phidgets_distance_sensor.c +295 -0
  19. data/ext/phidgets/phidgets_encoder.c +211 -192
  20. data/ext/phidgets/phidgets_frequency_counter.c +310 -177
  21. data/ext/phidgets/phidgets_gps.c +226 -164
  22. data/ext/phidgets/phidgets_gyroscope.c +195 -0
  23. data/ext/phidgets/phidgets_hub.c +39 -0
  24. data/ext/phidgets/phidgets_humidity_sensor.c +200 -0
  25. data/ext/phidgets/phidgets_ir.c +211 -171
  26. data/ext/phidgets/phidgets_lcd.c +512 -0
  27. data/ext/phidgets/phidgets_light_sensor.c +200 -0
  28. data/ext/phidgets/phidgets_log.c +263 -0
  29. data/ext/phidgets/phidgets_magnetometer.c +279 -0
  30. data/ext/phidgets/phidgets_manager.c +86 -297
  31. data/ext/phidgets/phidgets_motor_position_controller.c +787 -0
  32. data/ext/phidgets/phidgets_phsensor.c +200 -152
  33. data/ext/phidgets/phidgets_power_guard.c +144 -0
  34. data/ext/phidgets/phidgets_pressure_sensor.c +200 -0
  35. data/ext/phidgets/phidgets_rc_servo.c +672 -0
  36. data/ext/phidgets/phidgets_resistance_input.c +227 -0
  37. data/ext/phidgets/phidgets_rfid.c +107 -221
  38. data/ext/phidgets/phidgets_sound_sensor.c +284 -0
  39. data/ext/phidgets/phidgets_spatial.c +124 -318
  40. data/ext/phidgets/phidgets_stepper.c +457 -430
  41. data/ext/phidgets/phidgets_temp_sensor.c +223 -228
  42. data/ext/phidgets/phidgets_voltage_input.c +428 -0
  43. data/ext/phidgets/phidgets_voltage_output.c +167 -0
  44. data/ext/phidgets/phidgets_voltage_ratio_input.c +435 -0
  45. data/lib/phidgets.rb +21 -14
  46. data/lib/phidgets/accelerometer.rb +11 -15
  47. data/lib/phidgets/bldc_motor.rb +45 -0
  48. data/lib/phidgets/capacitive_touch.rb +33 -0
  49. data/lib/phidgets/common.rb +40 -69
  50. data/lib/phidgets/current_input.rb +21 -0
  51. data/lib/phidgets/dc_motor.rb +45 -0
  52. data/lib/phidgets/dictionary.rb +30 -39
  53. data/lib/phidgets/digital_input.rb +21 -0
  54. data/lib/phidgets/digital_output.rb +56 -0
  55. data/lib/phidgets/distance_sensor.rb +33 -0
  56. data/lib/phidgets/encoder.rb +1 -29
  57. data/lib/phidgets/frequency_counter.rb +23 -14
  58. data/lib/phidgets/gps.rb +34 -26
  59. data/lib/phidgets/gyroscope.rb +21 -0
  60. data/lib/phidgets/humidity_sensor.rb +21 -0
  61. data/lib/phidgets/ir.rb +34 -39
  62. data/lib/phidgets/light_sensor.rb +21 -0
  63. data/lib/phidgets/magnetometer.rb +21 -0
  64. data/lib/phidgets/manager.rb +18 -66
  65. data/lib/phidgets/motor_position_controller.rb +45 -0
  66. data/lib/phidgets/ph_sensor.rb +2 -6
  67. data/lib/phidgets/pressure_sensor.rb +21 -0
  68. data/lib/phidgets/rc_servo.rb +58 -0
  69. data/lib/phidgets/resistance_input.rb +21 -0
  70. data/lib/phidgets/rfid.rb +22 -38
  71. data/lib/phidgets/sound_sensor.rb +21 -0
  72. data/lib/phidgets/spatial.rb +11 -15
  73. data/lib/phidgets/stepper.rb +48 -50
  74. data/lib/phidgets/temperature_sensor.rb +11 -15
  75. data/lib/phidgets/version.rb +5 -0
  76. data/lib/phidgets/voltage_input.rb +34 -0
  77. data/lib/phidgets/voltage_output.rb +23 -0
  78. data/lib/phidgets/voltage_ratio_input.rb +34 -0
  79. data/phidgets.gemspec +3 -22
  80. data/test/test_accelerometer.rb +42 -23
  81. data/test/test_bldc_motor.rb +134 -0
  82. data/test/test_capacitive_touch.rb +82 -0
  83. data/test/test_common.rb +125 -108
  84. data/test/test_current_input.rb +62 -0
  85. data/test/test_dc_motor.rb +146 -0
  86. data/test/test_dictionary.rb +22 -54
  87. data/test/test_digital_input.rb +30 -0
  88. data/test/test_digital_output.rb +70 -0
  89. data/test/test_distance_sensor.rb +76 -0
  90. data/test/test_encoder.rb +45 -38
  91. data/test/test_frequency_counter.rb +71 -36
  92. data/test/test_gps.rb +29 -38
  93. data/test/test_gyroscope.rb +54 -0
  94. data/test/test_helper.rb +0 -1
  95. data/test/test_hub.rb +14 -0
  96. data/test/test_humidity_sensor.rb +58 -0
  97. data/test/test_ir.rb +34 -34
  98. data/test/test_lcd.rb +146 -0
  99. data/test/test_light_sensor.rb +58 -0
  100. data/test/test_magnetometer.rb +78 -0
  101. data/test/test_manager.rb +10 -79
  102. data/test/test_motor_control.rb +146 -108
  103. data/test/test_phidgets.rb +2 -14
  104. data/test/test_phsensor.rb +46 -34
  105. data/test/test_power_guard.rb +42 -0
  106. data/test/test_pressure_sensor.rb +58 -0
  107. data/test/test_rc_servo.rb +174 -0
  108. data/test/test_resistance_input.rb +66 -0
  109. data/test/test_rfid.rb +15 -54
  110. data/test/test_sound_sensor.rb +78 -0
  111. data/test/test_spatial.rb +19 -85
  112. data/test/test_stepper.rb +89 -98
  113. data/test/test_temp_sensor.rb +42 -47
  114. data/test/test_voltage_input.rb +102 -0
  115. data/test/test_voltage_output.rb +46 -0
  116. data/test/test_voltage_ratio_input.rb +102 -0
  117. metadata +72 -89
  118. data/ext/phidgets/phidgets_advanced_servo.c +0 -567
  119. data/ext/phidgets/phidgets_analog.c +0 -139
  120. data/ext/phidgets/phidgets_bridge.c +0 -263
  121. data/ext/phidgets/phidgets_interface_kit.c +0 -340
  122. data/ext/phidgets/phidgets_led.c +0 -178
  123. data/ext/phidgets/phidgets_motor_control.c +0 -642
  124. data/ext/phidgets/phidgets_servo.c +0 -276
  125. data/ext/phidgets/phidgets_text_lcd.c +0 -381
  126. data/ext/phidgets/phidgets_text_led.c +0 -107
  127. data/ext/phidgets/phidgets_weight_sensor.c +0 -113
  128. data/lib/phidgets/advanced_servo.rb +0 -49
  129. data/lib/phidgets/analog.rb +0 -8
  130. data/lib/phidgets/bridge.rb +0 -25
  131. data/lib/phidgets/interfacekit.rb +0 -49
  132. data/lib/phidgets/led.rb +0 -8
  133. data/lib/phidgets/motor_control.rb +0 -110
  134. data/lib/phidgets/servo.rb +0 -23
  135. data/lib/phidgets/text_lcd.rb +0 -8
  136. data/lib/phidgets/text_led.rb +0 -8
  137. data/lib/phidgets/weight_sensor.rb +0 -25
  138. data/test/test_advanced_servo.rb +0 -152
  139. data/test/test_analog.rb +0 -45
  140. data/test/test_bridge.rb +0 -77
  141. data/test/test_interfacekit.rb +0 -97
  142. data/test/test_led.rb +0 -55
  143. data/test/test_servo.rb +0 -67
  144. data/test/test_text_lcd.rb +0 -115
  145. data/test/test_text_led.rb +0 -35
  146. data/test/test_weight_sensor.rb +0 -32
@@ -0,0 +1,435 @@
1
+
2
+ #include "phidgets.h"
3
+
4
+ #define VOLTAGE_RATIO_INPUT_SENSOR_CHANGE_CALLBACK 0
5
+ #define VOLTAGE_RATIO_INPUT_VOLTAGE_RATIO_CHANGE_CALLBACK 1
6
+
7
+
8
+ VALUE ph_voltage_ratio_input_init(VALUE self) {
9
+ ph_data_t *ph = get_ph_data(self);
10
+ ph_raise(PhidgetVoltageRatioInput_create((PhidgetVoltageRatioInputHandle *)(&(ph->handle))));
11
+ return self;
12
+ }
13
+
14
+ VALUE ph_voltage_ratio_input_get_bridge_enabled(VALUE self) {
15
+ return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetVoltageRatioInput_getBridgeEnabled);
16
+ }
17
+
18
+ VALUE ph_voltage_ratio_input_set_bridge_enabled(VALUE self, VALUE enabled) {
19
+ ph_raise(PhidgetVoltageRatioInput_setBridgeEnabled((PhidgetVoltageRatioInputHandle)get_ph_handle(self), TYPE(enabled) == T_TRUE ? PTRUE : PFALSE));
20
+ return Qnil;
21
+ }
22
+
23
+ VALUE ph_voltage_ratio_input_get_bridge_gain(VALUE self) {
24
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetVoltageRatioInput_getBridgeGain);
25
+ }
26
+
27
+ VALUE ph_voltage_ratio_input_set_bridge_gain(VALUE self, VALUE bridge_gain) {
28
+ ph_raise(PhidgetVoltageRatioInput_setBridgeGain((PhidgetVoltageRatioInputHandle)get_ph_handle(self), NUM2INT(bridge_gain)));
29
+ return Qnil;
30
+ }
31
+
32
+ VALUE ph_voltage_ratio_input_get_data_interval(VALUE self) {
33
+ return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageRatioInput_getDataInterval);
34
+ }
35
+
36
+ VALUE ph_voltage_ratio_input_set_data_interval(VALUE self, VALUE interval) {
37
+ ph_raise(PhidgetVoltageRatioInput_setDataInterval((PhidgetVoltageRatioInputHandle)get_ph_handle(self), NUM2UINT(interval)));
38
+ return Qnil;
39
+ }
40
+
41
+ VALUE ph_voltage_ratio_input_get_min_data_interval(VALUE self) {
42
+ return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageRatioInput_getMinDataInterval);
43
+ }
44
+
45
+ VALUE ph_voltage_ratio_input_get_max_data_interval(VALUE self) {
46
+ return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetVoltageRatioInput_getMaxDataInterval);
47
+ }
48
+
49
+ VALUE ph_voltage_ratio_input_get_sensor_type(VALUE self) {
50
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetVoltageRatioInput_getSensorType);
51
+ }
52
+
53
+ VALUE ph_voltage_ratio_input_set_sensor_type(VALUE self, VALUE sensor_type) {
54
+ ph_raise(PhidgetVoltageRatioInput_setSensorType((PhidgetVoltageRatioInputHandle)get_ph_handle(self), NUM2INT(sensor_type)));
55
+ return Qnil;
56
+ }
57
+
58
+ VALUE ph_voltage_ratio_input_get_sensor_unit(VALUE self) {
59
+ VALUE unit_info = rb_hash_new();
60
+ Phidget_UnitInfo sensorUnit;
61
+ ph_raise(PhidgetVoltageRatioInput_getSensorUnit((PhidgetVoltageRatioInputHandle)get_ph_handle(self), &sensorUnit));
62
+ rb_hash_aset(unit_info, rb_str_new2("unit"), INT2NUM(sensorUnit.unit));
63
+ rb_hash_aset(unit_info, rb_str_new2("name"), rb_str_new2(sensorUnit.name));
64
+ rb_hash_aset(unit_info, rb_str_new2("symbol"), rb_str_new2(sensorUnit.symbol));
65
+ return unit_info;
66
+ }
67
+
68
+ VALUE ph_voltage_ratio_input_get_sensor_value(VALUE self) {
69
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getSensorValue);
70
+ }
71
+
72
+ VALUE ph_voltage_ratio_input_get_sensor_value_change_trigger(VALUE self) {
73
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getSensorValueChangeTrigger);
74
+ }
75
+
76
+ VALUE ph_voltage_ratio_input_set_sensor_value_change_trigger(VALUE self, VALUE trigger) {
77
+ ph_raise(PhidgetVoltageRatioInput_setSensorValueChangeTrigger((PhidgetVoltageRatioInputHandle)get_ph_handle(self), NUM2DBL(trigger)));
78
+ return Qnil;
79
+ }
80
+
81
+ VALUE ph_voltage_ratio_input_get_voltage_ratio(VALUE self) {
82
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getVoltageRatio);
83
+ }
84
+
85
+ VALUE ph_voltage_ratio_input_get_min_voltage_ratio(VALUE self) {
86
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getMinVoltageRatio);
87
+ }
88
+
89
+ VALUE ph_voltage_ratio_input_get_max_voltage_ratio(VALUE self) {
90
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getMaxVoltageRatio);
91
+ }
92
+
93
+ VALUE ph_voltage_ratio_input_get_voltage_ratio_change_trigger(VALUE self) {
94
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getVoltageRatioChangeTrigger);
95
+ }
96
+
97
+ VALUE ph_voltage_ratio_input_set_voltage_ratio_change_trigger(VALUE self, VALUE trigger) {
98
+ ph_raise(PhidgetVoltageRatioInput_setVoltageRatioChangeTrigger((PhidgetVoltageRatioInputHandle)get_ph_handle(self), NUM2DBL(trigger)));
99
+ return Qnil;
100
+ }
101
+
102
+ VALUE ph_voltage_ratio_input_get_min_voltage_ratio_change_trigger(VALUE self) {
103
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getMinVoltageRatioChangeTrigger);
104
+ }
105
+
106
+ VALUE ph_voltage_ratio_input_get_max_voltage_ratio_change_trigger(VALUE self) {
107
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetVoltageRatioInput_getMaxVoltageRatioChangeTrigger);
108
+ }
109
+
110
+
111
+ void CCONV ph_voltage_ratio_input_on_sensor_change(PhidgetVoltageRatioInputHandle phid, void *userPtr, double sensor_value, Phidget_UnitInfo *sensor_unit) {
112
+ ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
113
+ while(sem_wait(&callback_data->handler_ready)!=0) {};
114
+ callback_data->arg1 = DBL2NUM(sensor_value);
115
+ callback_data->arg2 = INT2NUM(sensor_unit->unit);
116
+ callback_data->arg3 = rb_str_new2(sensor_unit->name);
117
+ callback_data->arg4 = rb_str_new2(sensor_unit->symbol);
118
+ sem_post(&callback_data->callback_called);
119
+ }
120
+
121
+ VALUE ph_voltage_ratio_input_set_on_sensor_change_handler(VALUE self, VALUE handler) {
122
+ ph_data_t *ph = get_ph_data(self);
123
+ ph_callback_data_t *callback_data = &ph->dev_callbacks[VOLTAGE_RATIO_INPUT_SENSOR_CHANGE_CALLBACK];
124
+ if( TYPE(handler) == T_NIL ) {
125
+ callback_data->callback = T_NIL;
126
+ callback_data->exit = true;
127
+ ph_raise(PhidgetVoltageRatioInput_setOnSensorChangeHandler((PhidgetVoltageRatioInputHandle)ph->handle, NULL, (void *)NULL));
128
+ sem_post(&callback_data->callback_called);
129
+ } else {
130
+ callback_data->exit = false;
131
+ callback_data->phidget = self;
132
+ callback_data->callback = handler;
133
+ ph_raise(PhidgetVoltageRatioInput_setOnSensorChangeHandler((PhidgetVoltageRatioInputHandle)ph->handle, ph_voltage_ratio_input_on_sensor_change, (void *)callback_data));
134
+ ph_callback_thread(callback_data);
135
+ }
136
+ return Qnil;
137
+ }
138
+
139
+
140
+ void CCONV ph_voltage_ratio_input_on_voltage_ratio_change(PhidgetVoltageRatioInputHandle phid, void *userPtr, double voltage_ratio) {
141
+ ph_callback_data_t *callback_data = ((ph_callback_data_t *)userPtr);
142
+ while(sem_wait(&callback_data->handler_ready)!=0) {};
143
+ callback_data->arg1 = DBL2NUM(voltage_ratio);
144
+ callback_data->arg2 = Qnil;
145
+ callback_data->arg3 = Qnil;
146
+ callback_data->arg4 = Qnil;
147
+ sem_post(&callback_data->callback_called);
148
+ }
149
+
150
+ VALUE ph_voltage_ratio_input_set_on_voltage_ratio_change_handler(VALUE self, VALUE handler) {
151
+ ph_data_t *ph = get_ph_data(self);
152
+ ph_callback_data_t *callback_data = &ph->dev_callbacks[VOLTAGE_RATIO_INPUT_VOLTAGE_RATIO_CHANGE_CALLBACK];
153
+ if( TYPE(handler) == T_NIL ) {
154
+ callback_data->callback = T_NIL;
155
+ callback_data->exit = true;
156
+ ph_raise(PhidgetVoltageRatioInput_setOnVoltageRatioChangeHandler((PhidgetVoltageRatioInputHandle)ph->handle, NULL, (void *)NULL));
157
+ sem_post(&callback_data->callback_called);
158
+ } else {
159
+ callback_data->exit = false;
160
+ callback_data->phidget = self;
161
+ callback_data->callback = handler;
162
+ ph_raise(PhidgetVoltageRatioInput_setOnVoltageRatioChangeHandler((PhidgetVoltageRatioInputHandle)ph->handle, ph_voltage_ratio_input_on_voltage_ratio_change, (void *)callback_data));
163
+ ph_callback_thread(callback_data);
164
+ }
165
+ return Qnil;
166
+ }
167
+
168
+
169
+ void Init_voltage_ratio_input() {
170
+ VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
171
+ VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
172
+ VALUE ph_voltage_ratio_input = rb_define_class_under(ph_module, "VoltageRatioInput", ph_common);
173
+
174
+
175
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_VOLTAGERATIO", INT2NUM(SENSOR_TYPE_VOLTAGERATIO));
176
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2D120X", INT2NUM(SENSOR_TYPE_1101_SHARP_2D120X));
177
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2Y0A21", INT2NUM(SENSOR_TYPE_1101_SHARP_2Y0A21));
178
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1101_SHARP_2Y0A02", INT2NUM(SENSOR_TYPE_1101_SHARP_2Y0A02));
179
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1102", INT2NUM(SENSOR_TYPE_1102));
180
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1103", INT2NUM(SENSOR_TYPE_1103));
181
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1104", INT2NUM(SENSOR_TYPE_1104));
182
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1105", INT2NUM(SENSOR_TYPE_1105));
183
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1106", INT2NUM(SENSOR_TYPE_1106));
184
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1107", INT2NUM(SENSOR_TYPE_1107));
185
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1108", INT2NUM(SENSOR_TYPE_1108));
186
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1109", INT2NUM(SENSOR_TYPE_1109));
187
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1110", INT2NUM(SENSOR_TYPE_1110));
188
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1111", INT2NUM(SENSOR_TYPE_1111));
189
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1112", INT2NUM(SENSOR_TYPE_1112));
190
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1113", INT2NUM(SENSOR_TYPE_1113));
191
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1115", INT2NUM(SENSOR_TYPE_1115));
192
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1116", INT2NUM(SENSOR_TYPE_1116));
193
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1118_AC", INT2NUM(SENSOR_TYPE_1118_AC));
194
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1118_DC", INT2NUM(SENSOR_TYPE_1118_DC));
195
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1119_AC", INT2NUM(SENSOR_TYPE_1119_AC));
196
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1119_DC", INT2NUM(SENSOR_TYPE_1119_DC));
197
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1120", INT2NUM(SENSOR_TYPE_1120));
198
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1121", INT2NUM(SENSOR_TYPE_1121));
199
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1122_AC", INT2NUM(SENSOR_TYPE_1122_AC));
200
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1122_DC", INT2NUM(SENSOR_TYPE_1122_DC));
201
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1124", INT2NUM(SENSOR_TYPE_1124));
202
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1125_HUMIDITY", INT2NUM(SENSOR_TYPE_1125_HUMIDITY));
203
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1125_TEMPERATURE", INT2NUM(SENSOR_TYPE_1125_TEMPERATURE));
204
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1126", INT2NUM(SENSOR_TYPE_1126));
205
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1128", INT2NUM(SENSOR_TYPE_1128));
206
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1129", INT2NUM(SENSOR_TYPE_1129));
207
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1131", INT2NUM(SENSOR_TYPE_1131));
208
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1134", INT2NUM(SENSOR_TYPE_1134));
209
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1136", INT2NUM(SENSOR_TYPE_1136));
210
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1137", INT2NUM(SENSOR_TYPE_1137));
211
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1138", INT2NUM(SENSOR_TYPE_1138));
212
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1139", INT2NUM(SENSOR_TYPE_1139));
213
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1140", INT2NUM(SENSOR_TYPE_1140));
214
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1141", INT2NUM(SENSOR_TYPE_1141));
215
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_1146", INT2NUM(SENSOR_TYPE_1146));
216
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3120", INT2NUM(SENSOR_TYPE_3120));
217
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3121", INT2NUM(SENSOR_TYPE_3121));
218
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3122", INT2NUM(SENSOR_TYPE_3122));
219
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3123", INT2NUM(SENSOR_TYPE_3123));
220
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3130", INT2NUM(SENSOR_TYPE_3130));
221
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3520", INT2NUM(SENSOR_TYPE_3520));
222
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3521", INT2NUM(SENSOR_TYPE_3521));
223
+ rb_define_const(ph_voltage_ratio_input, "SENSOR_TYPE_3522", INT2NUM(SENSOR_TYPE_3522));
224
+
225
+ rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_1", INT2NUM(BRIDGE_GAIN_1));
226
+ rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_2", INT2NUM(BRIDGE_GAIN_2));
227
+ rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_4", INT2NUM(BRIDGE_GAIN_4));
228
+ rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_8", INT2NUM(BRIDGE_GAIN_8));
229
+ rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_16", INT2NUM(BRIDGE_GAIN_16));
230
+ rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_32", INT2NUM(BRIDGE_GAIN_32));
231
+ rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_64", INT2NUM(BRIDGE_GAIN_64));
232
+ rb_define_const(ph_voltage_ratio_input, "BRIDGE_GAIN_128", INT2NUM(BRIDGE_GAIN_128));
233
+
234
+
235
+ /* Document-method: new
236
+ * call-seq: new
237
+ *
238
+ * Creates a Phidget VoltageInput object.
239
+ */
240
+ rb_define_method(ph_voltage_ratio_input, "initialize", ph_voltage_ratio_input_init, 0);
241
+
242
+ /* Document-method: getBridgeEnabled
243
+ * call-seq: getBridgeEnabled -> bridge_enabled
244
+ *
245
+ * Enable power to and data from the input by setting BridgeEnabled to true.
246
+ */
247
+ rb_define_method(ph_voltage_ratio_input, "getBridgeEnabled", ph_voltage_ratio_input_get_bridge_enabled, 0);
248
+ rb_define_alias(ph_voltage_ratio_input, "bridge_enabled?", "getBridgeEnabled");
249
+
250
+ /* Document-method: setBridgeEnabled
251
+ * call-seq: setBridgeEnabled(bridge_enabled)
252
+ *
253
+ * Enable power to and data from the input by setting BridgeEnabled to true.
254
+ */
255
+ rb_define_method(ph_voltage_ratio_input, "setBridgeEnabled", ph_voltage_ratio_input_set_bridge_enabled, 1);
256
+ rb_define_alias(ph_voltage_ratio_input, "bridge_enabled=", "setBridgeEnabled");
257
+
258
+ /* Document-method: getBridgeGain
259
+ * call-seq: getBridgeGain -> bridge_gain
260
+ *
261
+ * Choose a BridgeGain that best suits your application.
262
+ * For more information about the range and accuracy of each BridgeGain to decide which best suits your application, see your device's User Guide.
263
+ */
264
+ rb_define_method(ph_voltage_ratio_input, "getBridgeGain", ph_voltage_ratio_input_get_bridge_gain, 0);
265
+ rb_define_alias(ph_voltage_ratio_input, "bridge_gain", "getBridgeGain");
266
+
267
+ /* Document-method: setBridgeGain
268
+ * call-seq: setBridgeGain(bridge_gain)
269
+ *
270
+ * Choose a BridgeGain that best suits your application.
271
+ * For more information about the range and accuracy of each BridgeGain to decide which best suits your application, see your device's User Guide.
272
+ */
273
+ rb_define_method(ph_voltage_ratio_input, "setBridgeGain", ph_voltage_ratio_input_set_bridge_gain, 1);
274
+ rb_define_alias(ph_voltage_ratio_input, "bridge_gain=", "setBridgeGain");
275
+
276
+ /* Document-method: getDataInterval
277
+ * call-seq: getDataInterval -> interval
278
+ *
279
+ * The DataInterval is the time that must elapse before the channel will fire another event.
280
+ * The data interval is bounded by MinDataInterval and MaxDataInterval.
281
+ * The timing between events can also affected by the change trigger values.
282
+ */
283
+ rb_define_method(ph_voltage_ratio_input, "getDataInterval", ph_voltage_ratio_input_get_data_interval, 0);
284
+ rb_define_alias(ph_voltage_ratio_input, "data_interval", "getDataInterval");
285
+
286
+ /* Document-method: setDataInterval
287
+ * call-seq: setDataInterval(interval)
288
+ *
289
+ * The DataInterval is the time that must elapse before the channel will fire another event.
290
+ * The data interval is bounded by MinDataInterval and MaxDataInterval.
291
+ * The timing between events can also affected by the change trigger values.
292
+ */
293
+ rb_define_method(ph_voltage_ratio_input, "setDataInterval", ph_voltage_ratio_input_set_data_interval, 1);
294
+ rb_define_alias(ph_voltage_ratio_input, "data_interval=", "setDataInterval");
295
+
296
+ /* Document-method: getMinDataInterval
297
+ * call-seq: getMinDataInterval -> interval
298
+ *
299
+ * The minimum value that DataInterval can be set to.
300
+ */
301
+ rb_define_method(ph_voltage_ratio_input, "getMinDataInterval", ph_voltage_ratio_input_get_min_data_interval, 0);
302
+ rb_define_alias(ph_voltage_ratio_input, "min_data_interval", "getMinDataInterval");
303
+
304
+ /* Document-method: getMaxDataInterval
305
+ * call-seq: getMaxDataInterval -> interval
306
+ *
307
+ * The maximum value that DataInterval can be set to.
308
+ */
309
+ rb_define_method(ph_voltage_ratio_input, "getMaxDataInterval", ph_voltage_ratio_input_get_max_data_interval, 0);
310
+ rb_define_alias(ph_voltage_ratio_input, "max_data_interval", "getMaxDataInterval");
311
+
312
+ /* Document-method: getSensorType
313
+ * call-seq: getSensorType -> sensor_type
314
+ *
315
+ * We sell a variety of analog sensors that do not have their own API, they simply output a voltage that can be converted to a digital value using a specific formula.
316
+ * By matching the SensorType to your analog sensor, the correct formula will automatically be applied to data when you get the SensorValue or subscribe to the SensorChange event.
317
+ * The SensorChange event has its own change trigger associated with it: SensorValueChangeTrigger.
318
+ * Any data from getting the SensorValue or subscribing to the SensorChange event will have a SensorUnit associated with it.
319
+ * Note: Unlike other properties such as DeviceSerialNumber or Channel, SensorType is set after the device is opened, not before.
320
+ */
321
+ rb_define_method(ph_voltage_ratio_input, "getSensorType", ph_voltage_ratio_input_get_sensor_type, 0);
322
+ rb_define_alias(ph_voltage_ratio_input, "sensor_type", "getSensorType");
323
+
324
+ /* Document-method: setSensorType
325
+ * call-seq: setSensorType(sensor_type)
326
+ *
327
+ * We sell a variety of analog sensors that do not have their own API, they simply output a voltage that can be converted to a digital value using a specific formula.
328
+ * By matching the SensorType to your analog sensor, the correct formula will automatically be applied to data when you get the SensorValue or subscribe to the SensorChange event.
329
+ * The SensorChange event has its own change trigger associated with it: SensorValueChangeTrigger.
330
+ * Any data from getting the SensorValue or subscribing to the SensorChange event will have a SensorUnit associated with it.
331
+ * Note: Unlike other properties such as DeviceSerialNumber or Channel, SensorType is set after the device is opened, not before.
332
+ */
333
+ rb_define_method(ph_voltage_ratio_input, "setSensorType", ph_voltage_ratio_input_set_sensor_type, 1);
334
+ rb_define_alias(ph_voltage_ratio_input, "sensor_type=", "setSensorType");
335
+
336
+ /* Document-method: getSensorUnit
337
+ * call-seq: getSensorUnit -> sensor_unit
338
+ *
339
+ * The unit of measurement that applies to the sensor values of the SensorType that has been selected.
340
+ * Helps keep track of the type of information being calculated from the voltage ratio input.
341
+ */
342
+ rb_define_method(ph_voltage_ratio_input, "getSensorUnit", ph_voltage_ratio_input_get_sensor_unit, 0);
343
+ rb_define_alias(ph_voltage_ratio_input, "sensor_unit", "getSensorUnit");
344
+
345
+ /* Document-method: getSensorValue
346
+ * call-seq: getSensorValue -> sensor_value
347
+ *
348
+ * The most recent sensor value that the channel has reported.
349
+ * Use SensorUnit to get the measurement units that are associated with the SensorValue.
350
+ */
351
+ rb_define_method(ph_voltage_ratio_input, "getSensorValue", ph_voltage_ratio_input_get_sensor_value, 0);
352
+ rb_define_alias(ph_voltage_ratio_input, "sensor_value", "getSensorValue");
353
+
354
+ /* Document-method: getSensorValueChangeTrigger
355
+ * call-seq: getSensorValueChangeTrigger -> trigger
356
+ *
357
+ * The channel will not issue a SensorChange event until the sensor value has changed by the amount specified by the SensorValueChangeTrigger.
358
+ * Setting the SensorChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
359
+ */
360
+ rb_define_method(ph_voltage_ratio_input, "getSensorValueChangeTrigger", ph_voltage_ratio_input_get_sensor_value_change_trigger, 0);
361
+ rb_define_alias(ph_voltage_ratio_input, "sensor_value_change_trigger", "getSensorValueChangeTrigger");
362
+
363
+ /* Document-method: setSensorValueChangeTrigger
364
+ * call-seq: setSensorValueChangeTrigger(trigger)
365
+ *
366
+ * The channel will not issue a SensorChange event until the sensor value has changed by the amount specified by the SensorValueChangeTrigger.
367
+ * Setting the SensorChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
368
+ */
369
+ rb_define_method(ph_voltage_ratio_input, "setSensorValueChangeTrigger", ph_voltage_ratio_input_set_sensor_value_change_trigger, 1);
370
+ rb_define_alias(ph_voltage_ratio_input, "sensor_value_change_trigger=", "setSensorValueChangeTrigger");
371
+
372
+ /* Document-method: getVoltageRatio
373
+ * call-seq: getVoltageRatio -> voltage_ratio
374
+ *
375
+ * The most recent voltage ratio value that the channel has reported.
376
+ * This value will always be between MinVoltageRatio and MaxVoltageRatio.
377
+ */
378
+ rb_define_method(ph_voltage_ratio_input, "getVoltageRatio", ph_voltage_ratio_input_get_voltage_ratio, 0);
379
+ rb_define_alias(ph_voltage_ratio_input, "voltage_ratio", "getVoltageRatio");
380
+
381
+ /* Document-method: getMinVoltageRatio
382
+ * call-seq: getMinVoltageRatio -> voltage_ratio
383
+ *
384
+ * The minimum value the VoltageRatioChange event will report.
385
+ */
386
+ rb_define_method(ph_voltage_ratio_input, "getMinVoltageRatio", ph_voltage_ratio_input_get_min_voltage_ratio, 0);
387
+ rb_define_alias(ph_voltage_ratio_input, "min_voltage_ratio", "getMinVoltageRatio");
388
+
389
+ /* Document-method: getMaxVoltageRatio
390
+ * call-seq: getMaxVoltageRatio -> voltage_ratio
391
+ *
392
+ * The maximum value the VoltageRatioChange event will report.
393
+ */
394
+ rb_define_method(ph_voltage_ratio_input, "getMaxVoltageRatio", ph_voltage_ratio_input_get_max_voltage_ratio, 0);
395
+ rb_define_alias(ph_voltage_ratio_input, "max_voltage_ratio", "getMaxVoltageRatio");
396
+
397
+ /* Document-method: getVoltageRatioChangeTrigger
398
+ * call-seq: getVoltageRatioChangeTrigger -> trigger
399
+ *
400
+ * The channel will not issue a VoltageRatioChange event until the voltage ratio value has changed by the amount specified by the VoltageRatioChangeTrigger.
401
+ * Setting the VoltageRatioChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
402
+ */
403
+ rb_define_method(ph_voltage_ratio_input, "getVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_voltage_ratio_change_trigger, 0);
404
+ rb_define_alias(ph_voltage_ratio_input, "voltage_ratio_change_trigger", "getVoltageRatioChangeTrigger");
405
+
406
+ /* Document-method: setVoltageRatioChangeTrigger
407
+ * call-seq: setVoltageRatioChangeTrigger(trigger)
408
+ *
409
+ * The channel will not issue a VoltageRatioChange event until the voltage value has changed by the amount specified by the VoltageRatioChangeTrigger.
410
+ * Setting the VoltageRatioChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
411
+ */
412
+ rb_define_method(ph_voltage_ratio_input, "setVoltageRatioChangeTrigger", ph_voltage_ratio_input_set_voltage_ratio_change_trigger, 1);
413
+ rb_define_alias(ph_voltage_ratio_input, "voltage_ratio_change_trigger=", "setVoltageRatioChangeTrigger");
414
+
415
+ /* Document-method: getMinVoltageRatioChangeTrigger
416
+ * call-seq: getMinVoltageRatioChangeTrigger -> trigger
417
+ *
418
+ * The minimum value that VoltageRatioChangeTrigger can be set to.
419
+ */
420
+ rb_define_method(ph_voltage_ratio_input, "getMinVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_min_voltage_ratio_change_trigger, 0);
421
+ rb_define_alias(ph_voltage_ratio_input, "min_voltage_ratio_change_trigger", "getMinVoltageRatioChangeTrigger");
422
+
423
+ /* Document-method: getMaxVoltageRatioChangeTrigger
424
+ * call-seq: getMaxVoltageRatioChangeTrigger -> trigger
425
+ *
426
+ * The maximum value that VoltageRatioChangeTrigger can be set to.
427
+ */
428
+ rb_define_method(ph_voltage_ratio_input, "getMaxVoltageRatioChangeTrigger", ph_voltage_ratio_input_get_max_voltage_ratio_change_trigger, 0);
429
+ rb_define_alias(ph_voltage_ratio_input, "max_voltage_ratio_change_trigger", "getMaxVoltageRatioChangeTrigger");
430
+
431
+
432
+ rb_define_private_method(ph_voltage_ratio_input, "ext_setOnSensorChangeHandler", ph_voltage_ratio_input_set_on_sensor_change_handler, 1);
433
+ rb_define_private_method(ph_voltage_ratio_input, "ext_setOnVoltageRatioChangeHandler", ph_voltage_ratio_input_set_on_voltage_ratio_change_handler, 1);
434
+ }
435
+
@@ -1,32 +1,39 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
- require File.dirname(__FILE__) + '/phidgets.so' if FileTest.exists? "#{File.dirname(__FILE__)}/phidgets.so"
4
+ require File.dirname(__FILE__) + '/phidgets.so'
5
5
 
6
6
  require File.dirname(__FILE__) + '/phidgets/dictionary.rb'
7
7
  require File.dirname(__FILE__) + '/phidgets/manager.rb'
8
8
  require File.dirname(__FILE__) + '/phidgets/common.rb'
9
9
  require File.dirname(__FILE__) + '/phidgets/accelerometer.rb'
10
- require File.dirname(__FILE__) + '/phidgets/advanced_servo.rb'
11
- require File.dirname(__FILE__) + '/phidgets/analog.rb'
12
- require File.dirname(__FILE__) + '/phidgets/bridge.rb'
10
+ require File.dirname(__FILE__) + '/phidgets/bldc_motor.rb'
11
+ require File.dirname(__FILE__) + '/phidgets/capacitive_touch.rb'
12
+ require File.dirname(__FILE__) + '/phidgets/current_input.rb'
13
+ require File.dirname(__FILE__) + '/phidgets/dc_motor.rb'
14
+ require File.dirname(__FILE__) + '/phidgets/dictionary.rb'
15
+ require File.dirname(__FILE__) + '/phidgets/digital_input.rb'
16
+ require File.dirname(__FILE__) + '/phidgets/digital_output.rb'
17
+ require File.dirname(__FILE__) + '/phidgets/distance_sensor.rb'
13
18
  require File.dirname(__FILE__) + '/phidgets/encoder.rb'
14
19
  require File.dirname(__FILE__) + '/phidgets/frequency_counter.rb'
15
20
  require File.dirname(__FILE__) + '/phidgets/gps.rb'
16
- require File.dirname(__FILE__) + '/phidgets/interfacekit.rb'
21
+ require File.dirname(__FILE__) + '/phidgets/gyroscope.rb'
22
+ require File.dirname(__FILE__) + '/phidgets/humidity_sensor.rb'
17
23
  require File.dirname(__FILE__) + '/phidgets/ir.rb'
18
- require File.dirname(__FILE__) + '/phidgets/led.rb'
19
- require File.dirname(__FILE__) + '/phidgets/motor_control.rb'
24
+ require File.dirname(__FILE__) + '/phidgets/light_sensor.rb'
25
+ require File.dirname(__FILE__) + '/phidgets/magnetometer.rb'
26
+ require File.dirname(__FILE__) + '/phidgets/motor_position_controller.rb'
20
27
  require File.dirname(__FILE__) + '/phidgets/ph_sensor.rb'
28
+ require File.dirname(__FILE__) + '/phidgets/pressure_sensor.rb'
21
29
  require File.dirname(__FILE__) + '/phidgets/rfid.rb'
22
- require File.dirname(__FILE__) + '/phidgets/servo.rb'
30
+ require File.dirname(__FILE__) + '/phidgets/rc_servo.rb'
31
+ require File.dirname(__FILE__) + '/phidgets/resistance_input.rb'
32
+ require File.dirname(__FILE__) + '/phidgets/sound_sensor.rb'
23
33
  require File.dirname(__FILE__) + '/phidgets/spatial.rb'
24
34
  require File.dirname(__FILE__) + '/phidgets/stepper.rb'
25
35
  require File.dirname(__FILE__) + '/phidgets/temperature_sensor.rb'
26
- require File.dirname(__FILE__) + '/phidgets/text_lcd.rb'
27
- require File.dirname(__FILE__) + '/phidgets/text_led.rb'
28
- require File.dirname(__FILE__) + '/phidgets/weight_sensor.rb'
36
+ require File.dirname(__FILE__) + '/phidgets/voltage_input.rb'
37
+ require File.dirname(__FILE__) + '/phidgets/voltage_output.rb'
38
+ require File.dirname(__FILE__) + '/phidgets/voltage_ratio_input.rb'
29
39
 
30
- module Phidgets
31
- VERSION = '0.1.3'
32
- end