Class: Phidgets::Accelerometer
- Defined in:
- lib/phidgets/accelerometer.rb,
ext/phidgets/phidgets_accelerometer.c
Instance Method Summary collapse
-
#getAcceleration ⇒ Object
(also: #acceleration)
The most recent acceleration value that the channel has reported.
-
#getAccelerationChangeTrigger ⇒ Object
(also: #acceleration_change_trigger)
The channel will not issue a AccelerationChange event until the acceleration value has changed by the amount specified by the AccelerationChangeTrigger.
-
#getAxisCount ⇒ Object
(also: #axis_count)
The number of axes the channel can measure acceleration on.
-
#getDataInterval ⇒ Object
(also: #data_interval)
The DataInterval is the time that must elapse before the channel will fire another Phidget_OnAccelerationChangeCallback event.
-
#getMaxAcceleration ⇒ Object
(also: #max_acceleration)
The maximum value the AccelerationChange event will report.
-
#getMaxAccelerationChangeTrigger ⇒ Object
(also: #max_acceleration_change_trigger)
The maximum value that AccelerationChangeTrigger can be set to.
-
#getMaxDataInterval ⇒ Object
(also: #max_data_interval)
The maximum value that DataInterval can be set to.
-
#getMinAcceleration ⇒ Object
(also: #min_acceleration)
The minimum value the AccelerationChange event will report.
-
#getMinAccelerationChangeTrigger ⇒ Object
(also: #min_acceleration_change_trigger)
The minimum value that AccelerationChangeTrigger can be set to.
-
#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 Accelerometer object.
-
#setAccelerationChangeTrigger(trigger) ⇒ Object
(also: #acceleration_change_trigger=)
The channel will not issue a AccelerationChange event until the acceleration value has changed by the amount specified by the AccelerationChangeTrigger.
-
#setDataInterval(interval) ⇒ Object
(also: #data_interval=)
The DataInterval is the time that must elapse before the channel will fire another Phidget_OnAccelerationChangeCallback event.
-
#setOnAccelerationChangeHandler(cb_proc = nil, &cb_block) ⇒ Object
(also: #on_acceleration_change)
call-seq: setOnAccelerationChangeHandler(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 Accelerometer object.
7 8 9 10 11 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 7
VALUE ph_accel_init(VALUE self) {
ph_data_t *ph = get_ph_data(self);
ph_raise(PhidgetAccelerometer_create((PhidgetAccelerometerHandle *)(&(ph->handle))));
return self;
}
|
Instance Method Details
#getAcceleration ⇒ Object Also known as: acceleration
The most recent acceleration value that the channel has reported. This value will always be between MinAcceleration and MaxAcceleration.
19 20 21 22 23 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 19
VALUE ph_accel_get_acceleration(VALUE self) {
double accel[3];
ph_raise(PhidgetAccelerometer_getAcceleration((PhidgetAccelerometerHandle)get_ph_handle(self), &accel));
return rb_ary_new3(3, DBL2NUM(accel[0]), DBL2NUM(accel[1]), DBL2NUM(accel[2]));
}
|
#getAccelerationChangeTrigger ⇒ Object Also known as: acceleration_change_trigger
The channel will not issue a AccelerationChange event until the acceleration value has changed by the amount specified by the AccelerationChangeTrigger. Setting the AccelerationChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
40 41 42 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 40
VALUE ph_accel_get_acceleration_change_trigger(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetAccelerometer_getAccelerationChangeTrigger);
}
|
#getAxisCount ⇒ Object Also known as: axis_count
The number of axes the channel can measure acceleration on. See your device’s User Guide for more information about the number of axes and their orientation.
14 15 16 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 14
VALUE ph_accel_get_axis_count(VALUE self) {
return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetAccelerometer_getAxisCount);
}
|
#getDataInterval ⇒ Object Also known as: data_interval
The DataInterval is the time that must elapse before the channel will fire another Phidget_OnAccelerationChangeCallback event. The data interval is bounded by MinDataInterval and MaxDataInterval. The timing between AccelerationChange events can also be affected by the AccelerationChangeTrigger.
61 62 63 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 61
VALUE ph_accel_get_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetAccelerometer_getDataInterval);
}
|
#getMaxAcceleration ⇒ Object Also known as: max_acceleration
The maximum value the AccelerationChange event will report.
33 34 35 36 37 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 33
VALUE ph_accel_get_max_acceleration(VALUE self) {
double accel[3];
ph_raise(PhidgetAccelerometer_getMaxAcceleration((PhidgetAccelerometerHandle)get_ph_handle(self), &accel));
return rb_ary_new3(3, DBL2NUM(accel[0]), DBL2NUM(accel[1]), DBL2NUM(accel[2]));
}
|
#getMaxAccelerationChangeTrigger ⇒ Object Also known as: max_acceleration_change_trigger
The maximum value that AccelerationChangeTrigger can be set to.
56 57 58 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 56
VALUE ph_accel_get_max_acceleration_change_trigger(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetAccelerometer_getMaxAccelerationChangeTrigger);
}
|
#getMaxDataInterval ⇒ Object Also known as: max_data_interval
The maximum value that DataInterval can be set to.
77 78 79 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 77
VALUE ph_accel_get_max_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetAccelerometer_getMaxDataInterval);
}
|
#getMinAcceleration ⇒ Object Also known as: min_acceleration
The minimum value the AccelerationChange event will report.
26 27 28 29 30 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 26
VALUE ph_accel_get_min_acceleration(VALUE self) {
double accel[3];
ph_raise(PhidgetAccelerometer_getMinAcceleration((PhidgetAccelerometerHandle)get_ph_handle(self), &accel));
return rb_ary_new3(3, DBL2NUM(accel[0]), DBL2NUM(accel[1]), DBL2NUM(accel[2]));
}
|
#getMinAccelerationChangeTrigger ⇒ Object Also known as: min_acceleration_change_trigger
The minimum value that AccelerationChangeTrigger can be set to.
51 52 53 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 51
VALUE ph_accel_get_min_acceleration_change_trigger(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetAccelerometer_getMinAccelerationChangeTrigger);
}
|
#getMinDataInterval ⇒ Object Also known as: min_data_interval
The minimum value that DataInterval can be set to.
72 73 74 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 72
VALUE ph_accel_get_min_data_interval(VALUE self) {
return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetAccelerometer_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.
82 83 84 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 82
VALUE ph_accel_get_timestamp(VALUE self) {
return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetAccelerometer_getTimestamp);
}
|
#setAccelerationChangeTrigger(trigger) ⇒ Object Also known as: acceleration_change_trigger=
The channel will not issue a AccelerationChange event until the acceleration value has changed by the amount specified by the AccelerationChangeTrigger. Setting the AccelerationChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.
45 46 47 48 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 45
VALUE ph_accel_set_acceleration_change_trigger(VALUE self, VALUE trigger) {
ph_raise(PhidgetAccelerometer_setAccelerationChangeTrigger((PhidgetAccelerometerHandle)get_ph_handle(self), NUM2DBL(trigger)));
return Qnil;
}
|
#setDataInterval(interval) ⇒ Object Also known as: data_interval=
The DataInterval is the time that must elapse before the channel will fire another Phidget_OnAccelerationChangeCallback event. The data interval is bounded by MinDataInterval and MaxDataInterval. The timing between AccelerationChange events can also be affected by the AccelerationChangeTrigger.
66 67 68 69 |
# File 'ext/phidgets/phidgets_accelerometer.c', line 66
VALUE ph_accel_set_data_interval(VALUE self, VALUE interval) {
ph_raise(PhidgetAccelerometer_setDataInterval((PhidgetAccelerometerHandle)get_ph_handle(self), NUM2UINT(interval)));
return Qnil;
}
|
#setOnAccelerationChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_acceleration_change
call-seq:
setOnAccelerationChangeHandler(proc=nil, &block)
Sets an acceleration change event handler. This is called when the acceleration changes by more then the change trigger.
11 12 13 14 15 |
# File 'lib/phidgets/accelerometer.rb', line 11 def setOnAccelerationChangeHandler(cb_proc = nil, &cb_block) @on_acceleration_change_thread.kill if defined? @on_acceleration_change_thread and @on_acceleration_change_thread.alive? callback = cb_proc || cb_block @on_acceleration_change_thread = Thread.new {ext_setOnAccelerationChangeHandler(callback)} end |