Class: Phidgets::Gyroscope
- Defined in:
- lib/phidgets/gyroscope.rb,
ext/phidgets/phidgets_gyroscope.c
Instance Method Summary collapse
-
#getAngularRate ⇒ Object
(also: #angular_rate)
The most recent angular rate value that the channel has reported.
-
#getAxisCount ⇒ Object
(also: #axis_count)
The number of axes the channel can measure angular rate on.
-
#getDataInterval ⇒ Object
(also: #data_interval)
The DataInterval is the time that must elapse before the channel will fire another AngularRateUpdate event.
-
#getMaxAngularRate ⇒ Object
(also: #max_angular_rate)
The maximum value the AngularRateUpdate event will report.
-
#getMaxDataInterval ⇒ Object
(also: #max_data_interval)
The maximum value that DataInterval can be set to.
-
#getMinAngularRate ⇒ Object
(also: #min_angular_rate)
The minimum value the AngularRateUpdate event will report.
-
#getMinDataInterval ⇒ Object
(also: #min_data_interval)
The minimum value that DataInterval can be set to.
-
#getTimestamp ⇒ Object
(also: #timestamp)
The most recent timestamp value that the channel has reported.
-
#new ⇒ Object
constructor
Creates a Phidget Gyroscope object.
-
#setDataInterval(interval) ⇒ Object
(also: #data_interval=)
The DataInterval is the time that must elapse before the channel will fire another AngularRateUpdate event.
-
#setOnAngularRateUpdateHandler(cb_proc = nil, &cb_block) ⇒ Object
(also: #on_angular_rate_update)
call-seq: setOnAngularRateUpdateHandler(proc=nil, &block).
Methods inherited from Common
#close, #getAttached, #getChannel, #getChannelClass, #getChannelClassName, #getChannelName, #getChannelSubclass, #getDeviceChannelCount, #getDeviceClass, #getDeviceClassName, #getDeviceID, #getDeviceLabel, #getDeviceName, #getDeviceSKU, #getDeviceSerialNumber, #getDeviceVersion, #getHubPort, #getHubPortCount, #getIsChannel, #getIsHubPortDevice, #getIsLocal, #getIsRemote, #getServerHostname, #getServerName, #getServerPeerName, #getServerUniqueName, #open, #openWaitForAttachment, #setChannel, #setDeviceLabel, #setDeviceSerialNumber, #setHubPort, #setIsHubPortDevice, #setIsLocal, #setIsRemote, #setOnAttachHandler, #setOnDetachHandler, #setOnErrorHandler, #setOnPropertyChangeHandler, #setServerName, #writeDeviceLabel
Constructor Details
#new ⇒ Object
Creates a Phidget Gyroscope object.
7 8 9 10 11 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 7
VALUE ph_gyroscope_init(VALUE self) {
ph_data_t *ph = get_ph_data(self);
ph_raise(PhidgetGyroscope_create((PhidgetGyroscopeHandle *)(&(ph->handle))));
return self;
}
|
Instance Method Details
#getAngularRate ⇒ Object Also known as: angular_rate
The most recent angular rate value that the channel has reported. This value will always be between MinAngularRate and MaxAngularRate.
13 14 15 16 17 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 13
VALUE ph_gyroscope_get_angular_rate(VALUE self) {
double angular_rate[3];
ph_raise(PhidgetGyroscope_getAngularRate((PhidgetGyroscopeHandle)get_ph_handle(self), &angular_rate));
return rb_ary_new3(3, DBL2NUM(angular_rate[0]), DBL2NUM(angular_rate[1]), DBL2NUM(angular_rate[2]));
}
|
#getAxisCount ⇒ Object Also known as: axis_count
The number of axes the channel can measure angular rate on. See your device’s User Guide for more information about the number of axes and their orientation.
31 32 33 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 31
VALUE ph_gyroscope_get_axis_count(VALUE self) {
return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetGyroscope_getAxisCount);
}
|
#getDataInterval ⇒ Object Also known as: data_interval
The DataInterval is the time that must elapse before the channel will fire another AngularRateUpdate event. The data interval is bounded by MinDataInterval and MaxDataInterval.
35 36 37 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 35
VALUE ph_gyroscope_get_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetGyroscope_getDataInterval);
}
|
#getMaxAngularRate ⇒ Object Also known as: max_angular_rate
The maximum value the AngularRateUpdate event will report.
25 26 27 28 29 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 25
VALUE ph_gyroscope_get_max_angular_rate(VALUE self) {
double angular_rate[3];
ph_raise(PhidgetGyroscope_getMaxAngularRate((PhidgetGyroscopeHandle)get_ph_handle(self), &angular_rate));
return rb_ary_new3(3, DBL2NUM(angular_rate[0]), DBL2NUM(angular_rate[1]), DBL2NUM(angular_rate[2]));
}
|
#getMaxDataInterval ⇒ Object Also known as: max_data_interval
The maximum value that DataInterval can be set to.
48 49 50 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 48
VALUE ph_gyroscope_get_max_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetGyroscope_getMaxDataInterval);
}
|
#getMinAngularRate ⇒ Object Also known as: min_angular_rate
The minimum value the AngularRateUpdate event will report.
19 20 21 22 23 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 19
VALUE ph_gyroscope_get_min_angular_rate(VALUE self) {
double angular_rate[3];
ph_raise(PhidgetGyroscope_getMinAngularRate((PhidgetGyroscopeHandle)get_ph_handle(self), &angular_rate));
return rb_ary_new3(3, DBL2NUM(angular_rate[0]), DBL2NUM(angular_rate[1]), DBL2NUM(angular_rate[2]));
}
|
#getMinDataInterval ⇒ Object Also known as: min_data_interval
The minimum value that DataInterval can be set to.
44 45 46 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 44
VALUE ph_gyroscope_get_min_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetGyroscope_getMinDataInterval);
}
|
#getTimestamp ⇒ Object Also known as: timestamp
The most recent timestamp value that the channel has reported. This is an extremely accurate time measurement streamed from the device. If your application requires a time measurement, you should use this value over a local software timestamp.
52 53 54 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 52
VALUE ph_gyroscope_get_timestamp(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetGyroscope_getTimestamp);
}
|
#setDataInterval(interval) ⇒ Object Also known as: data_interval=
The DataInterval is the time that must elapse before the channel will fire another AngularRateUpdate event. The data interval is bounded by MinDataInterval and MaxDataInterval.
39 40 41 42 |
# File 'ext/phidgets/phidgets_gyroscope.c', line 39
VALUE ph_gyroscope_set_data_interval(VALUE self, VALUE interval) {
ph_raise(PhidgetGyroscope_setDataInterval((PhidgetGyroscopeHandle)get_ph_handle(self), NUM2UINT(interval)));
return Qnil;
}
|
#setOnAngularRateUpdateHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_angular_rate_update
call-seq:
setOnAngularRateUpdateHandler(proc=nil, &block)
Assigns a handler that will be called when the AngularRateUpdate event occurs.
11 12 13 14 15 |
# File 'lib/phidgets/gyroscope.rb', line 11 def setOnAngularRateUpdateHandler(cb_proc = nil, &cb_block) @on_angular_rate_update_thread.kill if defined? @on_angular_rate_update_thread and @on_angular_rate_update_thread.alive? callback = cb_proc || cb_block @on_angular_rate_update_thread = Thread.new {ext_setOnAngularRateUpdateHandler(callback)} end |