Class: Phidgets::LightSensor

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

Instance Method Summary collapse

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

#newObject

Creates a Phidget LightSensor object.



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

VALUE ph_light_init(VALUE self) {
  ph_data_t *ph = get_ph_data(self);
  ph_raise(PhidgetLightSensor_create((PhidgetLightSensorHandle *)(&(ph->handle))));
  return self;
}

Instance Method Details

#getDataIntervalObject Also known as: data_interval

The DataInterval is the time that must elapse before the channel will fire another IlluminanceChange event. The data interval is bounded by MinDataInterval and MaxDataInterval. The timing between IlluminanceChange events can also affected by the IlluminanceChangeTrigger.



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

VALUE ph_light_get_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetLightSensor_getDataInterval);
}

#getIlluminanceObject Also known as: illuminance

The most recent illuminance value that the channel has reported. This value will always be between MinIlluminance and MaxIlluminance.



30
31
32
# File 'ext/phidgets/phidgets_light_sensor.c', line 30

VALUE ph_light_get_illuminance(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLightSensor_getIlluminance);
}

#getIlluminanceChangeTriggerObject Also known as: illuminance_change_trigger

The channel will not issue a IlluminanceChange event until the illuminance value has changed by the amount specified by the IlluminanceChangeTrigger. Setting the IlluminanceChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.



42
43
44
# File 'ext/phidgets/phidgets_light_sensor.c', line 42

VALUE ph_light_get_illuminance_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLightSensor_getIlluminanceChangeTrigger);
}

#getMaxDataIntervalObject Also known as: max_data_interval

The maximum value that DataInterval can be set to.



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

VALUE ph_light_get_max_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetLightSensor_getMaxDataInterval);
}

#getMaxIlluminanceObject Also known as: max_illuminance

The maximum value that the IlluminanceChange event will report.



38
39
40
# File 'ext/phidgets/phidgets_light_sensor.c', line 38

VALUE ph_light_get_max_illuminance(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLightSensor_getMaxIlluminance);
}

#getMaxIlluminanceChangeTriggerObject Also known as: max_illuminance_change_trigger

The maximum value that IlluminanceChangeTrigger can be set to.



55
56
57
# File 'ext/phidgets/phidgets_light_sensor.c', line 55

VALUE ph_light_get_max_illuminance_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLightSensor_getMaxIlluminanceChangeTrigger);
}

#getMinDataIntervalObject Also known as: min_data_interval

The minimum value that DataInterval can be set to.



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

VALUE ph_light_get_min_data_interval(VALUE self) {
  return ph_get_uint(get_ph_handle(self), (phidget_get_uint_func)PhidgetLightSensor_getMinDataInterval);
}

#getMinIlluminanceObject Also known as: min_illuminance

The minimum value that the IlluminanceChange event will report.



34
35
36
# File 'ext/phidgets/phidgets_light_sensor.c', line 34

VALUE ph_light_get_min_illuminance(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLightSensor_getMinIlluminance);
}

#getMinIlluminanceChangeTriggerObject Also known as: min_illuminance_change_trigger

The minimum value that IlluminanceChangeTrigger can be set to.



51
52
53
# File 'ext/phidgets/phidgets_light_sensor.c', line 51

VALUE ph_light_get_min_illuminance_change_trigger(VALUE self) {
  return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLightSensor_getMinIlluminanceChangeTrigger);
}

#setDataInterval(interval) ⇒ Object Also known as: data_interval=

The DataInterval is the time that must elapse before the channel will fire another IlluminanceChange event. The data interval is bounded by MinDataInterval and MaxDataInterval. The timing between IlluminanceChange events can also affected by the IlluminanceChangeTrigger.



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

VALUE ph_light_set_data_interval(VALUE self, VALUE interval) {
  ph_raise(PhidgetLightSensor_setDataInterval((PhidgetLightSensorHandle)get_ph_handle(self), NUM2UINT(interval)));
  return Qnil;
}

#setIlluminanceChangeTrigger(change_trigger) ⇒ Object Also known as: illuminance_change_trigger=

The channel will not issue a IlluminanceChange event until the illuminance value has changed by the amount specified by the IlluminanceChangeTrigger. Setting the IlluminanceChangeTrigger to 0 will result in the channel firing events every DataInterval. This is useful for applications that implement their own data filtering.



46
47
48
49
# File 'ext/phidgets/phidgets_light_sensor.c', line 46

VALUE ph_light_set_illuminance_change_trigger(VALUE self, VALUE change_trigger) {
  ph_raise(PhidgetLightSensor_setIlluminanceChangeTrigger((PhidgetLightSensorHandle)get_ph_handle(self), NUM2DBL(change_trigger)));
  return Qnil;
}

#setOnIlluminanceChangeHandler(cb_proc = nil, &cb_block) ⇒ Object Also known as: on_illuminance_change

call-seq:

setOnIlluminanceChangeHandler(proc=nil, &block)

Assigns a handler that will be called when the IlluminanceChange event occurs.



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

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