phidgets-ffi 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/LICENSE +1 -1
- data/README.rdoc +92 -42
- data/examples/accelerometer.rb +39 -0
- data/examples/advanced_servo.rb +94 -0
- data/examples/analog.rb +43 -0
- data/examples/bridge.rb +57 -0
- data/examples/dictionary.rb +46 -31
- data/examples/encoder.rb +59 -0
- data/examples/frequency_counter.rb +63 -0
- data/examples/gps.rb +91 -0
- data/examples/interface_kit_with_block.rb +68 -0
- data/examples/interface_kit_without_block.rb +60 -0
- data/examples/ir.rb +157 -0
- data/examples/led.rb +36 -0
- data/examples/manager.rb +16 -10
- data/examples/motor_control.rb +108 -0
- data/examples/{ffi → raw-ffi}/dictionary.rb +11 -1
- data/examples/{ffi → raw-ffi}/interface_kit.rb +19 -2
- data/examples/{ffi → raw-ffi}/library_version.rb +0 -0
- data/examples/{ffi → raw-ffi}/log.rb +0 -0
- data/examples/{ffi → raw-ffi}/manager.rb +6 -3
- data/examples/rfid.rb +63 -0
- data/examples/servo.rb +45 -30
- data/examples/spatial.rb +75 -0
- data/examples/stepper.rb +87 -0
- data/examples/temperature_sensor.rb +49 -0
- data/examples/text_lcd.rb +101 -0
- data/lib/phidgets-ffi.rb +34 -3
- data/lib/phidgets-ffi/accelerometer.rb +122 -0
- data/lib/phidgets-ffi/advanced_servo.rb +304 -0
- data/lib/phidgets-ffi/analog.rb +111 -0
- data/lib/phidgets-ffi/bridge.rb +167 -0
- data/lib/phidgets-ffi/common.rb +506 -103
- data/lib/phidgets-ffi/dictionary.rb +136 -23
- data/lib/phidgets-ffi/encoder.rb +196 -0
- data/lib/phidgets-ffi/error.rb +8 -3
- data/lib/phidgets-ffi/ffi/accelerometer.rb +30 -0
- data/lib/phidgets-ffi/ffi/advanced_servo.rb +73 -0
- data/lib/phidgets-ffi/ffi/analog.rb +29 -0
- data/lib/phidgets-ffi/ffi/bridge.rb +44 -0
- data/lib/phidgets-ffi/ffi/common.rb +51 -34
- data/lib/phidgets-ffi/ffi/constants.rb +3 -1
- data/lib/phidgets-ffi/ffi/dictionary.rb +25 -20
- data/lib/phidgets-ffi/ffi/encoder.rb +32 -0
- data/lib/phidgets-ffi/ffi/frequency_counter.rb +38 -0
- data/lib/phidgets-ffi/ffi/gps.rb +32 -0
- data/lib/phidgets-ffi/ffi/interface_kit.rb +26 -23
- data/lib/phidgets-ffi/ffi/ir.rb +50 -0
- data/lib/phidgets-ffi/ffi/led.rb +40 -0
- data/lib/phidgets-ffi/ffi/log.rb +7 -6
- data/lib/phidgets-ffi/ffi/manager.rb +35 -20
- data/lib/phidgets-ffi/ffi/motor_control.rb +66 -0
- data/lib/phidgets-ffi/ffi/rfid.rb +36 -0
- data/lib/phidgets-ffi/ffi/servo.rb +16 -15
- data/lib/phidgets-ffi/ffi/spatial.rb +40 -0
- data/lib/phidgets-ffi/ffi/stepper.rb +56 -0
- data/lib/phidgets-ffi/ffi/temperature_sensor.rb +42 -0
- data/lib/phidgets-ffi/ffi/text_lcd.rb +55 -0
- data/lib/phidgets-ffi/frequency_counter.rb +148 -0
- data/lib/phidgets-ffi/gps.rb +181 -0
- data/lib/phidgets-ffi/interface_kit.rb +205 -92
- data/lib/phidgets-ffi/ir.rb +290 -0
- data/lib/phidgets-ffi/led.rb +112 -0
- data/lib/phidgets-ffi/log.rb +14 -2
- data/lib/phidgets-ffi/manager.rb +143 -26
- data/lib/phidgets-ffi/motor_control.rb +497 -0
- data/lib/phidgets-ffi/phidgets-ffi.rb +15 -2
- data/lib/phidgets-ffi/rfid.rb +220 -0
- data/lib/phidgets-ffi/servo.rb +103 -61
- data/lib/phidgets-ffi/spatial.rb +306 -0
- data/lib/phidgets-ffi/stepper.rb +370 -0
- data/lib/phidgets-ffi/temperature_sensor.rb +157 -0
- data/lib/phidgets-ffi/text_lcd.rb +298 -0
- data/lib/phidgets-ffi/version.rb +1 -1
- data/phidgets-ffi.gemspec +2 -2
- metadata +89 -76
- data/examples/ffi/servo.rb +0 -67
- data/examples/interface_kit.rb +0 -20
data/lib/phidgets-ffi/error.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
module Phidgets
|
2
2
|
module Error
|
3
3
|
@errors = {}
|
4
|
+
|
4
5
|
Phidgets::FFI::ErrorCodes.to_hash.each_pair do |sym, num|
|
5
|
-
|
6
|
+
eval "@errors[num] = (#{sym.to_s.split("_").map(&:capitalize).join} = Class.new(Exception))"
|
6
7
|
end
|
7
|
-
|
8
|
-
|
8
|
+
|
9
|
+
# Returns the error description corresponding to the error code, or raises an error.
|
10
|
+
# @param [Integer] error_code error code
|
11
|
+
# @return [String] the error description, or raises an error.
|
12
|
+
def self.exception_for(error_code)
|
13
|
+
@errors[error_code]
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Phidgets
|
2
|
+
module FFI
|
3
|
+
|
4
|
+
attach_function :CPhidgetAccelerometer_create, [:phid], :int
|
5
|
+
attach_function :CPhidgetAccelerometer_getAxisCount, [:phid, :pointer], :int
|
6
|
+
attach_function :CPhidgetAccelerometer_getAcceleration, [:phid, :int, :pointer], :int
|
7
|
+
attach_function :CPhidgetAccelerometer_getAccelerationMax, [:phid, :int, :pointer], :int
|
8
|
+
attach_function :CPhidgetAccelerometer_getAccelerationMin, [:phid, :int, :pointer], :int
|
9
|
+
attach_function :CPhidgetAccelerometer_getAccelerationChangeTrigger, [:phid, :int, :pointer], :int
|
10
|
+
attach_function :CPhidgetAccelerometer_setAccelerationChangeTrigger, [:phid, :int, :double], :int
|
11
|
+
|
12
|
+
callback :CPhidgetAccelerometer_set_OnAccelerationChange_Callback, [:phid, :user_ptr, :int, :double], :int
|
13
|
+
attach_function :CPhidgetAccelerometer_set_OnAccelerationChange_Handler, [:phid, :CPhidgetAccelerometer_set_OnAccelerationChange_Callback, :user_ptr], :int
|
14
|
+
|
15
|
+
module CPhidgetAccelerometer
|
16
|
+
def self.method_missing(method, *args, &block)
|
17
|
+
if ::Phidgets::FFI.respond_to?("CPhidgetAccelerometer_#{method}".to_sym)
|
18
|
+
if (rs = ::Phidgets::FFI.send("CPhidgetAccelerometer_#{method}".to_sym, *args, &block)) != 0
|
19
|
+
raise Phidgets::Error.exception_for(rs), Phidgets::FFI.error_description(rs)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
super(method, *args, &block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Phidgets
|
2
|
+
module FFI
|
3
|
+
|
4
|
+
AdvancedServoType = enum(
|
5
|
+
:default, 1,
|
6
|
+
:raw_us_mode,
|
7
|
+
:hitec_hs322hd,
|
8
|
+
:hitec_hS5245mg,
|
9
|
+
:hitec_805bb,
|
10
|
+
:hitec_hs422,
|
11
|
+
:towerpro_mg90,
|
12
|
+
:hitec_hsr1425cr,
|
13
|
+
:hitec_hs785hb,
|
14
|
+
:hitec_hs485hb,
|
15
|
+
:hitec_hs645mg,
|
16
|
+
:hitec_815bb,
|
17
|
+
:firgelli_l12_30_50_06_r,
|
18
|
+
:firgelli_l12_50_100_06_r,
|
19
|
+
:firgelli_l12_50_210_06_r,
|
20
|
+
:firgelli_l12_100_50_06_r,
|
21
|
+
:firgelli_l12_100_100_06_r,
|
22
|
+
:user_defined
|
23
|
+
)
|
24
|
+
|
25
|
+
attach_function :CPhidgetAdvancedServo_create, [:phid], :int
|
26
|
+
attach_function :CPhidgetAdvancedServo_getMotorCount, [:phid, :pointer], :int
|
27
|
+
attach_function :CPhidgetAdvancedServo_getAcceleration, [:phid, :int, :pointer], :int
|
28
|
+
attach_function :CPhidgetAdvancedServo_setAcceleration, [:phid, :int, :double], :int
|
29
|
+
attach_function :CPhidgetAdvancedServo_getAccelerationMax, [:phid, :int, :pointer], :int
|
30
|
+
attach_function :CPhidgetAdvancedServo_getAccelerationMin, [:phid, :int, :pointer], :int
|
31
|
+
attach_function :CPhidgetAdvancedServo_getVelocityLimit, [:phid, :int, :pointer], :int
|
32
|
+
attach_function :CPhidgetAdvancedServo_setVelocityLimit, [:phid, :int, :double], :int
|
33
|
+
attach_function :CPhidgetAdvancedServo_getVelocity, [:phid, :int, :pointer], :int
|
34
|
+
attach_function :CPhidgetAdvancedServo_getVelocityMax, [:phid, :int, :pointer], :int
|
35
|
+
attach_function :CPhidgetAdvancedServo_getVelocityMin, [:phid, :int, :pointer], :int
|
36
|
+
attach_function :CPhidgetAdvancedServo_getPosition, [:phid, :int, :pointer], :int
|
37
|
+
attach_function :CPhidgetAdvancedServo_setPosition, [:phid, :int, :double], :int
|
38
|
+
attach_function :CPhidgetAdvancedServo_getPositionMax, [:phid, :int, :pointer], :int
|
39
|
+
attach_function :CPhidgetAdvancedServo_setPositionMax, [:phid, :int, :double], :int
|
40
|
+
attach_function :CPhidgetAdvancedServo_getPositionMin, [:phid, :int, :pointer], :int
|
41
|
+
attach_function :CPhidgetAdvancedServo_setPositionMin, [:phid, :int, :double], :int
|
42
|
+
attach_function :CPhidgetAdvancedServo_getCurrent, [:phid, :int, :pointer], :int
|
43
|
+
attach_function :CPhidgetAdvancedServo_getSpeedRampingOn, [:phid, :int, :pointer], :int
|
44
|
+
attach_function :CPhidgetAdvancedServo_setSpeedRampingOn, [:phid, :int, :int], :int
|
45
|
+
attach_function :CPhidgetAdvancedServo_getEngaged, [:phid, :int, :pointer], :int
|
46
|
+
attach_function :CPhidgetAdvancedServo_setEngaged, [:phid, :int, :int], :int
|
47
|
+
attach_function :CPhidgetAdvancedServo_getStopped, [:phid, :int, :pointer], :int
|
48
|
+
attach_function :CPhidgetAdvancedServo_getServoType, [:phid, :int, :pointer], :int
|
49
|
+
attach_function :CPhidgetAdvancedServo_setServoType, [:phid, :int, AdvancedServoType], :int
|
50
|
+
attach_function :CPhidgetAdvancedServo_setServoParameters, [:phid, :int, :double, :double, :double, :double], :int
|
51
|
+
|
52
|
+
callback :CPhidgetAdvancedServo_set_OnVelocityChange_Callback, [:phid, :user_ptr, :int, :double], :int
|
53
|
+
attach_function :CPhidgetAdvancedServo_set_OnVelocityChange_Handler, [:phid, :CPhidgetAdvancedServo_set_OnVelocityChange_Callback, :user_ptr], :int
|
54
|
+
|
55
|
+
callback :CPhidgetAdvancedServo_set_OnPositionChange_Callback, [:phid, :user_ptr, :int, :double], :int
|
56
|
+
attach_function :CPhidgetAdvancedServo_set_OnPositionChange_Handler, [:phid, :CPhidgetAdvancedServo_set_OnPositionChange_Callback, :user_ptr], :int
|
57
|
+
|
58
|
+
callback :CPhidgetAdvancedServo_set_OnCurrentChange_Callback, [:phid, :user_ptr, :int, :double], :int
|
59
|
+
attach_function :CPhidgetAdvancedServo_set_OnCurrentChange_Handler, [:phid, :CPhidgetAdvancedServo_set_OnCurrentChange_Callback, :user_ptr], :int
|
60
|
+
|
61
|
+
module CPhidgetAdvancedServo
|
62
|
+
def self.method_missing(method, *args, &block)
|
63
|
+
if ::Phidgets::FFI.respond_to?("CPhidgetAdvancedServo_#{method}".to_sym)
|
64
|
+
if (rs = ::Phidgets::FFI.send("CPhidgetAdvancedServo_#{method}".to_sym, *args, &block)) != 0
|
65
|
+
raise Phidgets::Error.exception_for(rs), Phidgets::FFI.error_description(rs)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
super(method, *args, &block)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Phidgets
|
2
|
+
module FFI
|
3
|
+
|
4
|
+
attach_function :CPhidgetAnalog_create, [:phid], :int
|
5
|
+
attach_function :CPhidgetAnalog_getOutputCount, [:phid, :pointer], :int
|
6
|
+
attach_function :CPhidgetAnalog_getVoltage, [:phid, :int, :pointer], :int
|
7
|
+
attach_function :CPhidgetAnalog_setVoltage, [:phid, :int, :double], :int
|
8
|
+
attach_function :CPhidgetAnalog_getVoltageMax, [:phid, :int, :pointer], :int
|
9
|
+
attach_function :CPhidgetAnalog_getVoltageMin, [:phid, :int, :pointer], :int
|
10
|
+
attach_function :CPhidgetAnalog_getEnabled, [:phid, :int, :pointer], :int
|
11
|
+
attach_function :CPhidgetAnalog_setEnabled, [:phid, :int, :int], :int
|
12
|
+
|
13
|
+
module CPhidgetAnalog
|
14
|
+
def self.method_missing(method, *args, &block)
|
15
|
+
if ::Phidgets::FFI.respond_to?("CPhidgetAnalog_#{method}".to_sym)
|
16
|
+
if (rs = ::Phidgets::FFI.send("CPhidgetAnalog_#{method}".to_sym, *args, &block)) != 0
|
17
|
+
|
18
|
+
raise Phidgets::Error.exception_for(rs), Phidgets::FFI.error_description(rs)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
super(method, *args, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Phidgets
|
2
|
+
module FFI
|
3
|
+
|
4
|
+
BridgeGains = enum(
|
5
|
+
:gain_1, 1,
|
6
|
+
:gain_8,
|
7
|
+
:gain_16,
|
8
|
+
:gain_32,
|
9
|
+
:gain_64,
|
10
|
+
:gain_128,
|
11
|
+
:gain_unknown
|
12
|
+
)
|
13
|
+
|
14
|
+
attach_function :CPhidgetBridge_create, [:phid], :int
|
15
|
+
attach_function :CPhidgetBridge_getInputCount, [:phid, :pointer], :int
|
16
|
+
attach_function :CPhidgetBridge_getBridgeValue, [:phid, :int, :pointer], :int
|
17
|
+
attach_function :CPhidgetBridge_getBridgeMax, [:phid, :int, :pointer], :int
|
18
|
+
attach_function :CPhidgetBridge_getBridgeMin, [:phid, :int, :pointer], :int
|
19
|
+
attach_function :CPhidgetBridge_setEnabled, [:phid, :int, :int], :int
|
20
|
+
attach_function :CPhidgetBridge_getEnabled, [:phid, :int, :pointer], :int
|
21
|
+
attach_function :CPhidgetBridge_getGain, [:phid, :int, :pointer], :int
|
22
|
+
attach_function :CPhidgetBridge_setGain, [:phid, :int, BridgeGains], :int
|
23
|
+
attach_function :CPhidgetBridge_getDataRate, [:phid, :pointer], :int
|
24
|
+
attach_function :CPhidgetBridge_setDataRate, [:phid, :int], :int
|
25
|
+
attach_function :CPhidgetBridge_getDataRateMax, [:phid, :pointer], :int
|
26
|
+
attach_function :CPhidgetBridge_getDataRateMin, [:phid, :pointer], :int
|
27
|
+
attach_function :CPhidgetBridge_getBridgeValue, [:phid, :int, :pointer], :int
|
28
|
+
|
29
|
+
callback :CPhidgetBridge_set_OnBridgeData_Callback, [:phid, :user_ptr, :int, :double], :int
|
30
|
+
attach_function :CPhidgetBridge_set_OnBridgeData_Handler, [:phid, :CPhidgetBridge_set_OnBridgeData_Callback, :user_ptr], :int
|
31
|
+
|
32
|
+
module CPhidgetBridge
|
33
|
+
def self.method_missing(method, *args, &block)
|
34
|
+
if ::Phidgets::FFI.respond_to?("CPhidgetBridge_#{method}".to_sym)
|
35
|
+
if (rs = ::Phidgets::FFI.send("CPhidgetBridge_#{method}".to_sym, *args, &block)) != 0
|
36
|
+
raise Phidgets::Error.exception_for(rs), Phidgets::FFI.error_description(rs)
|
37
|
+
end
|
38
|
+
else
|
39
|
+
super(method, *args, &block)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,45 +1,62 @@
|
|
1
1
|
module Phidgets
|
2
2
|
module FFI
|
3
3
|
class Error < Exception; end
|
4
|
-
|
5
|
-
|
6
|
-
attach_function :
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
attach_function :
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
attach_function :
|
16
|
-
|
17
|
-
attach_function :CPhidget_set_OnError_Handler, [:phid, :CPhidget_set_OnError_Callback, :user_ptr], :int #int CPhidget_set_OnError_Handler(CPhidgetHandle phid, int( *fptr)(CPhidgetHandle phid, void *userPtr, int errorCode, const char *errorString), void *userPtr);
|
18
|
-
attach_function :CPhidget_getDeviceName, [:phid, :pointer], :int #int CPhidget_getDeviceName(CPhidgetHandle phid, const char **deviceName);
|
19
|
-
attach_function :CPhidget_getSerialNumber, [:phid, :pointer], :int #int CPhidget_getSerialNumber(CPhidgetHandle phid, int *serialNumber);
|
20
|
-
attach_function :CPhidget_getDeviceVersion, [:phid, :pointer], :int #int CPhidget_getDeviceVersion(CPhidgetHandle phid, int *deviceVersion);
|
21
|
-
attach_function :CPhidget_getDeviceStatus, [:phid, :pointer], :int #int CPhidget_getDeviceStatus(CPhidgetHandle phid, int *deviceStatus);
|
4
|
+
|
5
|
+
attach_function :CPhidget_open, [:phid, :int], :int
|
6
|
+
attach_function :CPhidget_openRemote, [:phid, :int, :string, :string], :int
|
7
|
+
attach_function :CPhidget_openRemoteIP, [:phid, :int, :string, :int, :string], :int
|
8
|
+
attach_function :CPhidget_openLabelRemote, [:phid, :string, :string, :string], :int
|
9
|
+
attach_function :CPhidget_openLabelRemoteIP, [:phid, :string, :string, :int, :string], :int
|
10
|
+
attach_function :CPhidget_openLabel, [:phid, :string], :int
|
11
|
+
attach_function :CPhidget_close, [:phid], :int
|
12
|
+
attach_function :CPhidget_delete, [:phid], :int
|
13
|
+
attach_function :CPhidget_getDeviceName, [:phid, :pointer], :int
|
14
|
+
attach_function :CPhidget_getSerialNumber, [:phid, :pointer], :int
|
15
|
+
attach_function :CPhidget_getDeviceVersion, [:phid, :pointer], :int
|
16
|
+
attach_function :CPhidget_getDeviceStatus, [:phid, :pointer], :int
|
22
17
|
attach_function :CPhidget_getLibraryVersion, [:pointer], :int
|
23
|
-
attach_function :CPhidget_getDeviceType, [:phid, :pointer], :int
|
24
|
-
attach_function :CPhidget_getDeviceLabel, [:phid, :pointer], :int
|
25
|
-
attach_function :CPhidget_setDeviceLabel, [:phid, :string], :int
|
26
|
-
attach_function :CPhidget_getErrorDescription, [:int, :pointer], :int
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
attach_function :
|
33
|
-
|
34
|
-
attach_function :
|
35
|
-
|
36
|
-
|
18
|
+
attach_function :CPhidget_getDeviceType, [:phid, :pointer], :int
|
19
|
+
attach_function :CPhidget_getDeviceLabel, [:phid, :pointer], :int
|
20
|
+
attach_function :CPhidget_setDeviceLabel, [:phid, :string], :int
|
21
|
+
attach_function :CPhidget_getErrorDescription, [:int, :pointer], :int
|
22
|
+
|
23
|
+
@blocking = true
|
24
|
+
attach_function :CPhidget_waitForAttachment, [:phid, :int], :int, :blocking => true
|
25
|
+
|
26
|
+
attach_function :CPhidget_getServerID, [:phid, :pointer], :int
|
27
|
+
attach_function :CPhidget_getServerAddress, [:phid, :pointer, :pointer], :int
|
28
|
+
attach_function :CPhidget_getServerStatus, [:phid, :pointer], :int
|
29
|
+
attach_function :CPhidget_getDeviceID, [:phid, :pointer], :int
|
30
|
+
attach_function :CPhidget_getDeviceClass, [:phid, :pointer], :int
|
31
|
+
|
32
|
+
callback :CPhidget_set_OnDetach_Callback, [:phid, :user_ptr], :int
|
33
|
+
attach_function :CPhidget_set_OnDetach_Handler, [:phid, :CPhidget_set_OnDetach_Callback, :user_ptr], :int
|
34
|
+
|
35
|
+
callback :CPhidget_set_OnAttach_Callback, [:phid, :user_ptr], :int
|
36
|
+
attach_function :CPhidget_set_OnAttach_Handler, [:phid, :CPhidget_set_OnAttach_Callback, :user_ptr], :int
|
37
|
+
|
38
|
+
callback :CPhidget_set_OnServerConnect_Callback, [:phid, :user_ptr], :int
|
39
|
+
attach_function :CPhidget_set_OnServerConnect_Handler, [:phid, :CPhidget_set_OnServerConnect_Callback, :user_ptr], :int
|
40
|
+
|
41
|
+
callback :CPhidget_set_OnServerDisconnect_Callback, [:phid, :user_ptr], :int
|
42
|
+
attach_function :CPhidget_set_OnServerDisconnect_Handler, [:phid, :CPhidget_set_OnServerDisconnect_Callback, :user_ptr], :int
|
43
|
+
|
44
|
+
callback :CPhidget_set_OnError_Callback, [:phid, :user_ptr, :int, :string], :int
|
45
|
+
attach_function :CPhidget_set_OnError_Handler, [:phid, :CPhidget_set_OnError_Callback, :user_ptr], :int
|
46
|
+
|
37
47
|
|
48
|
+
if Config::CONFIG['target_os'] =~ /darwin/ #Mac OS X
|
49
|
+
callback :CPhidget_set_OnWillSleep_Callback, [:user_ptr], :int
|
50
|
+
attach_function :CPhidget_set_OnWillSleep_Handler, [:CPhidget_set_OnWillSleep_Callback, :user_ptr], :int
|
51
|
+
callback :CPhidget_set_OnWakeup_Callback, [:user_ptr], :int
|
52
|
+
attach_function :CPhidget_set_OnWakeup_Handler, [:CPhidget_set_OnWakeup_Callback, :user_ptr], :int
|
53
|
+
end
|
54
|
+
|
38
55
|
module Common
|
39
56
|
def self.method_missing(method, *args, &block)
|
40
57
|
if ::Phidgets::FFI.respond_to?("CPhidget_#{method}".to_sym)
|
41
|
-
|
42
|
-
|
58
|
+
if (rs = ::Phidgets::FFI.send("CPhidget_#{method}".to_sym, *args, &block)) != 0
|
59
|
+
raise Phidgets::Error.exception_for(rs), Phidgets::FFI.error_description(rs)
|
43
60
|
end
|
44
61
|
else
|
45
62
|
super(method, *args, &block)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Phidgets
|
2
2
|
module FFI
|
3
|
+
|
3
4
|
typedef :pointer, :phid
|
4
5
|
typedef :pointer, :user_ptr
|
5
6
|
|
@@ -65,7 +66,7 @@ module Phidgets
|
|
65
66
|
:spatial_accel_gyro_compass, 0x033,
|
66
67
|
:temperature_sensor, 0x070,
|
67
68
|
:temperature_sensor_4, 0x032,
|
68
|
-
|
69
|
+
:temperature_sensor_ir, 0x03C,
|
69
70
|
:textlcd_2x20_w_8_8_8, 0x17D,
|
70
71
|
:textlcd_adapter, 0x03D,
|
71
72
|
:unipolar_stepper_4motor, 0x07A,
|
@@ -110,5 +111,6 @@ module Phidgets
|
|
110
111
|
:bad_version,
|
111
112
|
:error_code_count
|
112
113
|
)
|
114
|
+
|
113
115
|
end
|
114
116
|
end
|
@@ -9,27 +9,32 @@ module Phidgets
|
|
9
9
|
:unchanged
|
10
10
|
)
|
11
11
|
|
12
|
-
attach_function :CPhidgetDictionary_create, [:dict], :int
|
13
|
-
attach_function :CPhidgetDictionary_openRemote, [:dict, :string, :string], :int
|
14
|
-
attach_function :CPhidgetDictionary_openRemoteIP, [:dict, :string, :int, :string], :int
|
15
|
-
attach_function :CPhidgetDictionary_close, [:dict], :int
|
16
|
-
attach_function :CPhidgetDictionary_delete, [:dict], :int
|
12
|
+
attach_function :CPhidgetDictionary_create, [:dict], :int
|
13
|
+
attach_function :CPhidgetDictionary_openRemote, [:dict, :string, :string], :int
|
14
|
+
attach_function :CPhidgetDictionary_openRemoteIP, [:dict, :string, :int, :string], :int
|
15
|
+
attach_function :CPhidgetDictionary_close, [:dict], :int
|
16
|
+
attach_function :CPhidgetDictionary_delete, [:dict], :int
|
17
|
+
attach_function :CPhidgetDictionary_addKey, [:dict, :string, :string, :int], :int
|
18
|
+
attach_function :CPhidgetDictionary_removeKey, [:dict, :string], :int
|
19
|
+
attach_function :CPhidgetDictionary_getKey, [:dict, :string, :pointer, :int], :int
|
20
|
+
attach_function :CPhidgetDictionary_getServerID, [:dict, :pointer], :int
|
21
|
+
attach_function :CPhidgetDictionary_getServerAddress, [:dict, :pointer, :pointer], :int
|
22
|
+
attach_function :CPhidgetDictionary_getServerStatus, [:dict, :pointer], :int
|
23
|
+
|
17
24
|
callback :CPhidgetDictionary_set_OnError_Callback, [:dict, :pointer, :int, :string], :int
|
18
|
-
attach_function :CPhidgetDictionary_set_OnError_Handler, [:dict, :CPhidgetDictionary_set_OnError_Callback, :pointer], :int
|
19
|
-
|
20
|
-
|
21
|
-
attach_function :
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
attach_function :
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
attach_function :CPhidgetDictionary_remove_OnKeyChange_Handler, [:dict], :int #int CPhidgetDictionary_remove_OnKeyChange_Handler(CPhidgetDictionaryListenerHandle dictlistener);
|
32
|
-
|
25
|
+
attach_function :CPhidgetDictionary_set_OnError_Handler, [:dict, :CPhidgetDictionary_set_OnError_Callback, :pointer], :int
|
26
|
+
|
27
|
+
callback :CPhidgetDictionary_set_OnServerConnect_Callback, [:dict, :pointer], :int
|
28
|
+
attach_function :CPhidgetDictionary_set_OnServerConnect_Handler, [:dict, :CPhidgetDictionary_set_OnServerConnect_Callback, :pointer], :int
|
29
|
+
|
30
|
+
callback :CPhidgetDictionary_set_OnServerDisconnect_Callback, [:dict, :pointer], :int
|
31
|
+
attach_function :CPhidgetDictionary_set_OnServerDisconnect_Handler, [:dict, :CPhidgetDictionary_set_OnServerDisconnect_Callback, :pointer], :int
|
32
|
+
|
33
|
+
callback :CPhidgetDictionary_set_OnKeyChange_Callback, [:dict, :pointer, :string, :string, KeyChangeReason], :int
|
34
|
+
attach_function :CPhidgetDictionary_set_OnKeyChange_Handler, [:dict, :pointer, :string, :CPhidgetDictionary_set_OnKeyChange_Callback, :pointer], :int
|
35
|
+
|
36
|
+
attach_function :CPhidgetDictionary_remove_OnKeyChange_Handler, [:dict], :int
|
37
|
+
|
33
38
|
module CPhidgetDictionary
|
34
39
|
def self.method_missing(method, *args, &block)
|
35
40
|
if ::Phidgets::FFI.respond_to?("CPhidgetDictionary_#{method}".to_sym)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Phidgets
|
2
|
+
module FFI
|
3
|
+
|
4
|
+
attach_function :CPhidgetEncoder_create, [:phid], :int
|
5
|
+
attach_function :CPhidgetEncoder_getInputCount, [:phid, :pointer], :int
|
6
|
+
attach_function :CPhidgetEncoder_getInputState, [:phid, :int, :pointer], :int
|
7
|
+
attach_function :CPhidgetEncoder_getEncoderCount, [:phid, :pointer], :int
|
8
|
+
attach_function :CPhidgetEncoder_getPosition, [:phid, :int, :pointer], :int
|
9
|
+
attach_function :CPhidgetEncoder_setPosition, [:phid, :int, :int], :int
|
10
|
+
attach_function :CPhidgetEncoder_getIndexPosition, [:phid, :int, :pointer], :int
|
11
|
+
attach_function :CPhidgetEncoder_getEnabled, [:phid, :int, :pointer], :int
|
12
|
+
attach_function :CPhidgetEncoder_setEnabled, [:phid, :int, :int], :int
|
13
|
+
|
14
|
+
callback :CPhidgetEncoder_set_OnInputChange_Callback, [:phid, :user_ptr, :int, :int], :int
|
15
|
+
attach_function :CPhidgetEncoder_set_OnInputChange_Handler, [:phid, :CPhidgetEncoder_set_OnInputChange_Callback, :user_ptr], :int
|
16
|
+
|
17
|
+
callback :CPhidgetEncoder_set_OnPositionChange_Callback, [:phid, :user_ptr, :int, :int, :int], :int
|
18
|
+
attach_function :CPhidgetEncoder_set_OnPositionChange_Handler, [:phid, :CPhidgetEncoder_set_OnPositionChange_Callback, :user_ptr], :int
|
19
|
+
|
20
|
+
module CPhidgetEncoder
|
21
|
+
def self.method_missing(method, *args, &block)
|
22
|
+
if ::Phidgets::FFI.respond_to?("CPhidgetEncoder_#{method}".to_sym)
|
23
|
+
if (rs = ::Phidgets::FFI.send("CPhidgetEncoder_#{method}".to_sym, *args, &block)) != 0
|
24
|
+
raise Phidgets::Error.exception_for(rs), Phidgets::FFI.error_description(rs)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
super(method, *args, &block)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Phidgets
|
2
|
+
module FFI
|
3
|
+
|
4
|
+
FrequencyCounterFilterTypes = enum(
|
5
|
+
:filter_type_zero_crossing, 1,
|
6
|
+
:filter_type_logic_level,
|
7
|
+
:filter_type_unknown
|
8
|
+
)
|
9
|
+
|
10
|
+
attach_function :CPhidgetFrequencyCounter_create, [:phid], :int
|
11
|
+
attach_function :CPhidgetFrequencyCounter_getFrequencyInputCount, [:phid, :pointer], :int
|
12
|
+
attach_function :CPhidgetFrequencyCounter_getFrequency, [:phid, :int, :pointer], :int
|
13
|
+
attach_function :CPhidgetFrequencyCounter_getTotalTime, [:phid, :int, :pointer], :int
|
14
|
+
attach_function :CPhidgetFrequencyCounter_getTotalCount, [:phid, :int, :pointer], :int
|
15
|
+
attach_function :CPhidgetFrequencyCounter_setTimeout, [:phid, :int, :int], :int
|
16
|
+
attach_function :CPhidgetFrequencyCounter_getTimeout, [:phid, :int, :pointer], :int
|
17
|
+
attach_function :CPhidgetFrequencyCounter_setEnabled, [:phid, :int, :int], :int
|
18
|
+
attach_function :CPhidgetFrequencyCounter_getEnabled, [:phid, :int, :pointer], :int
|
19
|
+
attach_function :CPhidgetFrequencyCounter_getFilter, [:phid, :int, :pointer], :int
|
20
|
+
attach_function :CPhidgetFrequencyCounter_setFilter, [:phid, :int, FrequencyCounterFilterTypes], :int
|
21
|
+
attach_function :CPhidgetFrequencyCounter_reset, [:phid, :int], :int
|
22
|
+
|
23
|
+
callback :CPhidgetFrequencyCounter_set_OnCount_Callback, [:phid, :user_ptr, :int, :int, :int], :int
|
24
|
+
attach_function :CPhidgetFrequencyCounter_set_OnCount_Handler, [:phid, :CPhidgetFrequencyCounter_set_OnCount_Callback, :user_ptr], :int
|
25
|
+
|
26
|
+
module CPhidgetFrequencyCounter
|
27
|
+
def self.method_missing(method, *args, &block)
|
28
|
+
if ::Phidgets::FFI.respond_to?("CPhidgetFrequencyCounter_#{method}".to_sym)
|
29
|
+
if (rs = ::Phidgets::FFI.send("CPhidgetFrequencyCounter_#{method}".to_sym, *args, &block)) != 0
|
30
|
+
raise Phidgets::Error.exception_for(rs), Phidgets::FFI.error_description(rs)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
super(method, *args, &block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|