Class: PhidgetsNative::InterfaceKit

Inherits:
Device
  • Object
show all
Defined in:
ext/phidgets_native/interfacekit_ruby.c,
ext/phidgets_native/interfacekit_ruby.c

Overview

This class provides functionality specific to the “InterfaceKit” device class. Primarily, this phidget reports the values of analog and digital inputs, and provides interfaces for outputing to analog and digital components.

Instance Method Summary collapse

Constructor Details

#new(serial_number) ⇒ Object

All phidget objects are created from the device serial number. Serial numbers are required to be Fixnums (aka “unsigned integers”).

Instance Method Details

#change_trigger(Fixnumindex, Fixnumthreshold) ⇒ Fixnum

This method sets the change trigger for the analog sensor at the provided index the specified threshold. This threshould must be between 1 and 1000. The return value is simply what was specified for the rate. Keep in mind that setting a data rate, reverts the data_rate for that input to nil. For more information on how analog inputs are polled, you can read up on the Phidget Analog Input Primer

Returns:

  • (Fixnum)

#change_triggersArray

Returns an array of either ints or nils, which specify the current change_trigger threshold for each analog input sensor. A nil indicates that this input is in data_rate mode. If the whole return value is nil, this means that the device hasn’t been connected yet.

Returns:

  • (Array)

#closenil

This method will unregister the phidget event handlers, and free up all API resources associated with the phidget. This is an optional, but useful way to remove the object’s overhead before the GC kicks in and actually frees the resource.

Returns:

  • (nil)

#data_rate(Fixnumindex, Fixnumrate) ⇒ Fixnum

This method sets the data rate for the analog sensor at the provided index to the rate specified. This rate must be between data_rate_min and data_rate_max. The return value is simply what was specified for the rate. Keep in mind that setting a data rate, reverts the change_trigger for that input to nil. For more information on how analog inputs are polled, you can read up on the Phidget Analog Input Primer

Returns:

  • (Fixnum)

#data_ratesArray

Returns an array of either ints or nils, which specify the current data_rate for each analog input sensor. A nil indicates that this input is in change_trigger mode. If the whole return value is nil, this means that the device hasn’t been connected yet.

Returns:

  • (Array)

#data_rates_maxArray

Returns an array of ints which specify the maximum data_rate value that can be configured on each analog input sensor, or nil if the device has yet to be connected.

Returns:

  • (Array)

#data_rates_minArray

Returns an array of ints which specify the minimum data_rate value that can be configured on each analog input sensor, or nil if the device has yet to be connected.

Returns:

  • (Array)

#input_countFixnum

Returns an integer which represents the number of digital inputs provided by this interface kit, or nil if the device has yet to be connected.

Returns:

  • (Fixnum)

#input_sample_ratesArray

The interface kit object tracks the sample rate of each input individually. This method returns an array containing the sample rates of each digital sensor.

Returns:

  • (Array)

#inputsArray

Returns an array of bools, which specify the current digital input states. A return of nil indicates that this device is unplugged

Returns:

  • (Array)

#output(Fixnum, Boolean) ⇒ Boolean

This method sets the value of the specified digital output at the provided Fixnum offset to the Boolean state (true is on, false is off). The return value is simply what was specified for the input state. For more information on output control, you can read up on the CPhidgetInterfaceKit_setOutputState function.

Returns:

  • (Boolean)

#output_countFixnum

Returns an integer which represents the number of digital outputs provided by this interface kit, or nil if the device has yet to be connected.

Returns:

  • (Fixnum)

#outputsArray

Returns an array of bools, which specify the current digital output states. A return of nil indicates that this device is unplugged

Returns:

  • (Array)

#ratiometric=(Booleanstate) ⇒ Boolean

Sets the analog sensor voltage reference to ratiometric mode on true, or stable on false. Read more about this feature in the Analog Inputs Primer

Returns:

  • (Boolean)

#ratiometric?Boolean

Returns true if the analog sensors are currently in ratiometric mode. False if the controller is set to a stable voltage reference. Read more about this feature in the Analog Inputs Primer

Returns:

  • (Boolean)

#sensor_countFixnum

Returns an integer which represents the number of analog inputs provided by this interface kit, or nil if the device has yet to be connected.

Returns:

  • (Fixnum)

#sensor_raw(Fixnum) ⇒ Fixnum

This method returns the “raw” value of the sensor at the provided offset. For more information on raw sensor values read up on the CPhidgetInterfaceKit_getSensorRawValue function.

Returns:

  • (Fixnum)

#sensor_sample_ratesArray

The interface kit object tracks the sample rate of each sensor individually. This method returns an array containing the sample rates of each analog sensor.

Returns:

  • (Array)

#sensorsArray

Returns an array of ints, which specify the current analog sensor states. A return of nil indicates that this device is unplugged

Returns:

  • (Array)