Class: Phidgets::DigitalOutput

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

Constant Summary collapse

LED_FORWARD_VOLTAGE_1_7V =
INT2NUM(LED_FORWARD_VOLTAGE_1_7V)
LED_FORWARD_VOLTAGE_2_75V =
INT2NUM(LED_FORWARD_VOLTAGE_2_75V)
LED_FORWARD_VOLTAGE_3_2V =
INT2NUM(LED_FORWARD_VOLTAGE_3_2V)
LED_FORWARD_VOLTAGE_3_9V =
INT2NUM(LED_FORWARD_VOLTAGE_3_9V)
LED_FORWARD_VOLTAGE_4_0V =
INT2NUM(LED_FORWARD_VOLTAGE_4_0V)
LED_FORWARD_VOLTAGE_4_8V =
INT2NUM(LED_FORWARD_VOLTAGE_4_8V)
LED_FORWARD_VOLTAGE_5_0V =
INT2NUM(LED_FORWARD_VOLTAGE_5_0V)
LED_FORWARD_VOLTAGE_5_6V =
INT2NUM(LED_FORWARD_VOLTAGE_5_6V)

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 DigitalOutput object.



9
10
11
12
13
# File 'ext/phidgets/phidgets_digital_output.c', line 9

VALUE ph_digital_output_init(VALUE self) {
  ph_data_t *ph = get_ph_data(self);
  ph_raise(PhidgetDigitalOutput_create((PhidgetDigitalOutputHandle *)(&(ph->handle))));
  return self;
}

Instance Method Details

#getDutyCycleObject Also known as: duty_cycle

The DutyCycle represents the fraction of time the output is on (high). A DutyCycle of 1.0 translates to a high output, a DutyCycle of 0 translates to a low output. A DutyCycle of 0.5 translates to an output that is high half the time, which results in an average output voltage of (output voltage x 0.5) You can use the DutyCycle to create a dimming effect on LEDs.



15
16
17
# File 'ext/phidgets/phidgets_digital_output.c', line 15

VALUE ph_digital_output_get_duty_cycle(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetDigitalOutput_getDutyCycle);
}

#getLEDCurrentLimitObject Also known as: led_current_limit

The LEDCurrentLimit is the maximum amount of current that the controller will provide to the output. Reference the data sheet of the LED you are using before setting this value.



32
33
34
# File 'ext/phidgets/phidgets_digital_output.c', line 32

VALUE ph_digital_output_get_led_current_limit(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetDigitalOutput_getLEDCurrentLimit);
}

#getLEDForwardVoltageObject Also known as: led_forward_voltage

The LEDForwardVoltage is the voltage that will be available to your LED. Reference the data sheet of the LED you are using before setting this value. Choose the LEDForwardVoltage that is closest to the forward voltage specified in the data sheet. This forward voltage is shared for all channels on this device. Setting the LEDForwardVoltage on any channel will set the LEDForwardVoltage for all channels on the device.



49
50
51
# File 'ext/phidgets/phidgets_digital_output.c', line 49

VALUE ph_digital_output_get_led_forward_voltage(VALUE self) {
  return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetDigitalOutput_getLEDForwardVoltage);
}

#getMaxDutyCycleObject Also known as: max_duty_cycle

The maximum value that DutyCycle can be set to.



28
29
30
# File 'ext/phidgets/phidgets_digital_output.c', line 28

VALUE ph_digital_output_get_max_duty_cycle(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetDigitalOutput_getMaxDutyCycle);
}

#getMaxLEDCurrentLimitObject Also known as: max_led_current_limit

The maximum value that LEDCurrentLimit can be set to.



45
46
47
# File 'ext/phidgets/phidgets_digital_output.c', line 45

VALUE ph_digital_output_get_max_led_current_limit(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetDigitalOutput_getMaxLEDCurrentLimit);
}

#getMinDutyCycleObject Also known as: min_duty_cycle

The minimum value that DutyCycle can be set to.



24
25
26
# File 'ext/phidgets/phidgets_digital_output.c', line 24

VALUE ph_digital_output_get_min_duty_cycle(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetDigitalOutput_getMinDutyCycle);
}

#getMinLEDCurrentLimitObject Also known as: min_led_current_limit

The minimum value that LEDCurrentLimit can be set to.



41
42
43
# File 'ext/phidgets/phidgets_digital_output.c', line 41

VALUE ph_digital_output_get_min_led_current_limit(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetDigitalOutput_getMinLEDCurrentLimit);
}

#getStateObject Also known as: state

The State will indicate whether the output is high (true) or low (false). If a DutyCycle has been set, the state will return as true if the DutyCycle is above 0.5, or false otherwise.



58
59
60
# File 'ext/phidgets/phidgets_digital_output.c', line 58

VALUE ph_digital_output_get_state(VALUE self) {
  return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetDigitalOutput_getState);
}

#setDutyCycle(duty_cycle) ⇒ Object Also known as: duty_cycle=

The DutyCycle represents the fraction of time the output is on (high). This will override the State setting on the channel. A DutyCycle of 1.0 translates to a high output, a DutyCycle of 0 translates to a low output. This is equivalent to setting a State of TRUE and FALSE respectively. A DutyCycle of 0.5 translates to an output that is high half the time, which results in an average output voltage of (output voltage x 0.5) You can use the DutyCycle to create a dimming effect on LEDs. If the DigitalOutput channel you are using does not support PWM, then this value may only be set to 1.0 or 0.0.



19
20
21
22
# File 'ext/phidgets/phidgets_digital_output.c', line 19

VALUE ph_digital_output_set_duty_cycle(VALUE self, VALUE duty_cycle) {
  ph_raise(PhidgetDigitalOutput_setDutyCycle((PhidgetDigitalOutputHandle)get_ph_handle(self), NUM2DBL(duty_cycle)));
  return Qnil;
}

#setDutyCycle_async(duty_cycle, cb_proc = nil, &cb_block) ⇒ Object Also known as: set_duty_cycle_async

call-seq:

setDutyCycle_async(duty_cycle, proc=nil, &block)

The DutyCycle represents the fraction of time the output is on (high). This will override the State setting on the channel. A DutyCycle of 1.0 translates to a high output, a DutyCycle of 0 translates to a low output. This is equivalent to setting a State of TRUE and FALSE respectively. A DutyCycle of 0.5 translates to an output that is high half the time, which results in an average output voltage of (output voltage x 0.5) You can use the DutyCycle to create a dimming effect on LEDs. If the DigitalOutput channel you are using does not support PWM, then this value may only be set to 1.0 or 0.0.



17
18
19
20
21
# File 'lib/phidgets/digital_output.rb', line 17

def setDutyCycle_async(duty_cycle, cb_proc = nil, &cb_block)
  @duty_cycle_async_thread.kill if defined? @duty_cycle_async_thread and @duty_cycle_async_thread.alive?
  callback = cb_proc || cb_block
  @duty_cycle_async_thread = Thread.new {ext_setDutyCycle_async(duty_cycle, callback)}
end

#setLEDCurrentLimit(current_limit) ⇒ Object Also known as: led_current_limit=

The LEDCurrentLimit is the maximum amount of current that the controller will provide to the output. Reference the data sheet of the LED you are using before setting this value.



36
37
38
39
# File 'ext/phidgets/phidgets_digital_output.c', line 36

VALUE ph_digital_output_set_led_current_limit(VALUE self, VALUE current_limit) {
  ph_raise(PhidgetDigitalOutput_setLEDCurrentLimit((PhidgetDigitalOutputHandle)get_ph_handle(self), NUM2DBL(current_limit)));
  return Qnil;
}

#setLEDCurrentLimit_async(current_limit, cb_proc = nil, &cb_block) ⇒ Object Also known as: set_led_current_limit_async

call-seq:

setLEDCurrentLimit_async(duty_cycle, proc=nil, &block)

The LEDCurrentLimit is the maximum amount of current that the controller will provide to the output. Reference the data sheet of the LED you are using before setting this value.



31
32
33
34
35
# File 'lib/phidgets/digital_output.rb', line 31

def setLEDCurrentLimit_async(current_limit, cb_proc = nil, &cb_block)
  @led_current_limit_async_thread.kill if defined? @led_current_limit_async_thread and @led_current_limit_async_thread.alive?
  callback = cb_proc || cb_block
  @led_current_limit_async_thread = Thread.new {ext_setLEDCurrentLimit_async(current_limit, callback)}
end

#setLEDForwardVoltage(forward_voltage) ⇒ Object Also known as: led_forward_voltage=

The LEDForwardVoltage is the voltage that will be available to your LED. Reference the data sheet of the LED you are using before setting this value. Choose the LEDForwardVoltage that is closest to the forward voltage specified in the data sheet. This forward voltage is shared for all channels on this device. Setting the LEDForwardVoltage on any channel will set the LEDForwardVoltage for all channels on the device.



53
54
55
56
# File 'ext/phidgets/phidgets_digital_output.c', line 53

VALUE ph_digital_output_set_led_forward_voltage(VALUE self, VALUE forward_voltage) {
  ph_raise(PhidgetDigitalOutput_setLEDForwardVoltage((PhidgetDigitalOutputHandle)get_ph_handle(self), NUM2INT(forward_voltage)));
  return Qnil;
}

#setState(state) ⇒ Object Also known as: state=

The State will dictate whether the output is constantly high (TRUE) or low (FALSE). This will override any DutyCycle that may have been set on the channel. Setting the State to TRUE is the same as setting DutyCycle to 1.0, and setting the State to FALSE is the same as setting a DutyCycle of 0.0.



62
63
64
65
# File 'ext/phidgets/phidgets_digital_output.c', line 62

VALUE ph_digital_output_set_state(VALUE self, VALUE state) {
  ph_raise(PhidgetDigitalOutput_setState((PhidgetDigitalOutputHandle)get_ph_handle(self), TYPE(state) == T_TRUE ? PTRUE : PFALSE));
  return Qnil;
}

#setState_async(state, cb_proc = nil, &cb_block) ⇒ Object Also known as: set_state_async

call-seq:

setState_async(state, proc=nil, &block)

The State will dictate whether the output is constantly high (TRUE) or low (FALSE). This will override any DutyCycle that may have been set on the channel. Setting the State to TRUE is the same as setting DutyCycle to 1.0, and setting the State to FALSE is the same as setting a DutyCycle of 0.0.



46
47
48
49
50
# File 'lib/phidgets/digital_output.rb', line 46

def setState_async(state, cb_proc = nil, &cb_block)
  @state_async_thread.kill if defined? @state_async_thread and @state_async_thread.alive?
  callback = cb_proc || cb_block
  @state_async_thread = Thread.new {ext_setState_async(state, callback)}
end