Class: Phidgets::DigitalInput

Inherits:
Common
  • Object
show all
Defined in:
lib/phidgets/digital_input.rb,
ext/phidgets/phidgets_digital_input.c

Instance Method Summary collapse

Methods inherited from Common

#close, #getAttached, #getChannel, #getChannelClass, #getChannelClassName, #getChannelName, #getChannelSubclass, #getDataInterval, #getDeviceChannelCount, #getDeviceClass, #getDeviceClassName, #getDeviceID, #getDeviceLabel, #getDeviceName, #getDeviceSKU, #getDeviceSerialNumber, #getDeviceVersion, #getHubPort, #getHubPortCount, #getIsChannel, #getIsHubPortDevice, #getIsLocal, #getIsRemote, #getServerHostname, #getServerName, #getServerPeerName, #getServerUniqueName, #open, #openWaitForAttachment, #setChannel, #setDataInterval, #setDeviceLabel, #setDeviceSerialNumber, #setHubPort, #setIsHubPortDevice, #setIsLocal, #setIsRemote, #setOnAttachHandler, #setOnDetachHandler, #setOnErrorHandler, #setOnPropertyChangeHandler, #setServerName, #writeDeviceLabel

Constructor Details

#newObject

Creates a Phidget DigitalInput object.



7
8
9
10
11
# File 'ext/phidgets/phidgets_digital_input.c', line 7

VALUE ph_digital_input_init(VALUE self) {
  ph_data_t *ph = get_ph_data(self);
  ph_raise(PhidgetDigitalInput_create((PhidgetDigitalInputHandle *)(&(ph->handle))));
  return self;
}

Instance Method Details

#getInputModeObject Also known as: input_mode

The input polarity mode for your channel. See your device’s User Guide for more information about what value to chooose for the InputMode.



13
14
15
# File 'ext/phidgets/phidgets_digital_input.c', line 13

VALUE ph_digital_input_get_input_mode(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetDigitalInput_getInputMode);
}

#getPowerSupplyObject Also known as: power_supply

Choose the power supply voltage. Set this to the voltage specified in the attached sensor’s data sheet to power it. Set to POWER_SUPPLY_OFF to turn off the supply to save power.



22
23
24
# File 'ext/phidgets/phidgets_digital_input.c', line 22

VALUE ph_digital_input_get_power_supply(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetDigitalInput_getPowerSupply);
}

#getStateObject Also known as: state

The most recent state value that the channel has reported.



31
32
33
# File 'ext/phidgets/phidgets_digital_input.c', line 31

VALUE ph_digital_input_get_state(VALUE self) {
  return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetDigitalInput_getState);
}

#setInputMode(mode) ⇒ Object Also known as: input_mode=

The input polarity mode for your channel. See your device’s User Guide for more information about what value to chooose for the InputMode.



17
18
19
20
# File 'ext/phidgets/phidgets_digital_input.c', line 17

VALUE ph_digital_input_set_input_mode(VALUE self, VALUE mode) {
  ph_raise(PhidgetDigitalInput_setInputMode((PhidgetDigitalInputHandle)get_ph_handle(self), NUM2INT(mode)));
  return Qnil;
}

#setOnStateChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_state_change

call-seq:

setOnStateChangeHandler(proc=nil, &block)

Set a digital input change handler. This is called when a digital input changes.



11
12
13
14
15
# File 'lib/phidgets/digital_input.rb', line 11

def setOnStateChangeHandler(cb_proc = nil, &cb_block)
  @on_state_change_thread.kill if defined? @on_state_change_thread and @on_state_change_thread.alive?
  callback = cb_proc || cb_block
  @on_state_change_thread = Thread.new {ext_setOnStateChangeHandler(callback)}
end

#setPowerSupply(power_supply) ⇒ Object Also known as: power_supply=

Choose the power supply voltage. Set this to the voltage specified in the attached sensor’s data sheet to power it. Set to POWER_SUPPLY_OFF to turn off the supply to save power.



26
27
28
29
# File 'ext/phidgets/phidgets_digital_input.c', line 26

VALUE ph_digital_input_set_power_supply(VALUE self, VALUE power_supply) {
  ph_raise(PhidgetDigitalInput_setPowerSupply((PhidgetDigitalInputHandle)get_ph_handle(self), NUM2INT(power_supply)));
  return Qnil;
}