Class: Tinkerforge::BrickletUVLight
- Defined in:
- lib/tinkerforge/bricklet_uv_light.rb
Overview
Measures UV light
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
265
- DEVICE_DISPLAY_NAME =
:nodoc:
'UV Light Bricklet'
- CALLBACK_UV_LIGHT =
This callback is triggered periodically with the period that is set by BrickletUVLight#set_uv_light_callback_period. The parameter is the UV Light intensity of the sensor.
The CALLBACK_UV_LIGHT callback is only triggered if the intensity has changed since the last triggering.
8
- CALLBACK_UV_LIGHT_REACHED =
This callback is triggered when the threshold as set by BrickletUVLight#set_uv_light_callback_threshold is reached. The parameter is the UV Light intensity of the sensor.
If the threshold keeps being reached, the callback is triggered periodically with the period as set by BrickletUVLight#set_debounce_period.
9
- FUNCTION_GET_UV_LIGHT =
:nodoc:
1
- FUNCTION_SET_UV_LIGHT_CALLBACK_PERIOD =
:nodoc:
2
- FUNCTION_GET_UV_LIGHT_CALLBACK_PERIOD =
:nodoc:
3
- FUNCTION_SET_UV_LIGHT_CALLBACK_THRESHOLD =
:nodoc:
4
- FUNCTION_GET_UV_LIGHT_CALLBACK_THRESHOLD =
:nodoc:
5
- FUNCTION_SET_DEBOUNCE_PERIOD =
:nodoc:
6
- FUNCTION_GET_DEBOUNCE_PERIOD =
:nodoc:
7
- FUNCTION_GET_IDENTITY =
:nodoc:
255
- THRESHOLD_OPTION_OFF =
:nodoc:
'x'
- THRESHOLD_OPTION_OUTSIDE =
:nodoc:
'o'
- THRESHOLD_OPTION_INSIDE =
:nodoc:
'i'
- THRESHOLD_OPTION_SMALLER =
:nodoc:
'<'
- THRESHOLD_OPTION_GREATER =
:nodoc:
'>'
Constants inherited from Device
Device::DEVICE_IDENTIFIER_CHECK_MATCH, Device::DEVICE_IDENTIFIER_CHECK_MISMATCH, Device::DEVICE_IDENTIFIER_CHECK_PENDING, Device::RESPONSE_EXPECTED_ALWAYS_TRUE, Device::RESPONSE_EXPECTED_FALSE, Device::RESPONSE_EXPECTED_INVALID_FUNCTION_ID, Device::RESPONSE_EXPECTED_TRUE
Instance Attribute Summary
Attributes inherited from Device
#callback_formats, #expected_response_function_id, #expected_response_sequence_number, #high_level_callbacks, #registered_callbacks, #replaced, #uid
Instance Method Summary collapse
-
#get_debounce_period ⇒ Object
Returns the debounce period as set by BrickletUVLight#set_debounce_period.
-
#get_identity ⇒ Object
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
-
#get_uv_light ⇒ Object
Returns the UV light intensity of the sensor.
-
#get_uv_light_callback_period ⇒ Object
Returns the period as set by BrickletUVLight#set_uv_light_callback_period.
-
#get_uv_light_callback_threshold ⇒ Object
Returns the threshold as set by BrickletUVLight#set_uv_light_callback_threshold.
-
#initialize(uid, ipcon) ⇒ BrickletUVLight
constructor
Creates an object with the unique device ID
uid
and adds it to the IP Connectionipcon
. -
#register_callback(id, &block) ⇒ Object
Registers a callback with ID
id
to the blockblock
. -
#set_debounce_period(debounce) ⇒ Object
Sets the period with which the threshold callbacks.
-
#set_uv_light_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_UV_LIGHT callback is triggered periodically.
-
#set_uv_light_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_UV_LIGHT_REACHED callback.
Methods inherited from Device
#check_validity, #dequeue_response, #enqueue_response, #get_api_version, #get_response_expected, #send_request, #set_response_expected, #set_response_expected_all
Constructor Details
#initialize(uid, ipcon) ⇒ BrickletUVLight
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
Instance Method Details
#get_debounce_period ⇒ Object
Returns the debounce period as set by BrickletUVLight#set_debounce_period.
147 148 149 150 151 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 147 def get_debounce_period check_validity send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L' end |
#get_identity ⇒ Object
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’ or ‘h’ (Bricklet Port). A Bricklet connected to an :ref:‘Isolator Bricklet <isolator_bricklet>` is always at position ’z’.
The device identifier numbers can be found :ref:‘here <device_identifier>`. |device_identifier_constant|
163 164 165 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 163 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end |
#get_uv_light ⇒ Object
Returns the UV light intensity of the sensor. The sensor has already weighted the intensity with the erythemal action spectrum to get the skin-affecting irradiation.
To get UV index you just have to divide the value by 250. For example, a UV light intensity of 500 is equivalent to an UV index of 2.
If you want to get the intensity periodically, it is recommended to use the CALLBACK_UV_LIGHT callback and set the period with BrickletUVLight#set_uv_light_callback_period.
83 84 85 86 87 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 83 def get_uv_light check_validity send_request FUNCTION_GET_UV_LIGHT, [], '', 12, 'L' end |
#get_uv_light_callback_period ⇒ Object
Returns the period as set by BrickletUVLight#set_uv_light_callback_period.
101 102 103 104 105 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 101 def get_uv_light_callback_period check_validity send_request FUNCTION_GET_UV_LIGHT_CALLBACK_PERIOD, [], '', 12, 'L' end |
#get_uv_light_callback_threshold ⇒ Object
Returns the threshold as set by BrickletUVLight#set_uv_light_callback_threshold.
125 126 127 128 129 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 125 def get_uv_light_callback_threshold check_validity send_request FUNCTION_GET_UV_LIGHT_CALLBACK_THRESHOLD, [], '', 17, 'k L L' end |
#register_callback(id, &block) ⇒ Object
Registers a callback with ID id
to the block block
.
168 169 170 171 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 168 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end |
#set_debounce_period(debounce) ⇒ Object
Sets the period with which the threshold callbacks
-
CALLBACK_UV_LIGHT_REACHED,
are triggered, if the thresholds
-
BrickletUVLight#set_uv_light_callback_threshold,
keep being reached.
140 141 142 143 144 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 140 def set_debounce_period(debounce) check_validity send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, '' end |
#set_uv_light_callback_period(period) ⇒ Object
Sets the period with which the CALLBACK_UV_LIGHT callback is triggered periodically. A value of 0 turns the callback off.
The CALLBACK_UV_LIGHT callback is only triggered if the intensity has changed since the last triggering.
94 95 96 97 98 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 94 def set_uv_light_callback_period(period) check_validity send_request FUNCTION_SET_UV_LIGHT_CALLBACK_PERIOD, [period], 'L', 8, '' end |
#set_uv_light_callback_threshold(option, min, max) ⇒ Object
Sets the thresholds for the CALLBACK_UV_LIGHT_REACHED callback.
The following options are possible:
"Option", "Description"
"'x'", "Callback is turned off"
"'o'", "Callback is triggered when the intensity is *outside* the min and max values"
"'i'", "Callback is triggered when the intensity is *inside* the min and max values"
"'<'", "Callback is triggered when the intensity is smaller than the min value (max is ignored)"
"'>'", "Callback is triggered when the intensity is greater than the min value (max is ignored)"
118 119 120 121 122 |
# File 'lib/tinkerforge/bricklet_uv_light.rb', line 118 def set_uv_light_callback_threshold(option, min, max) check_validity send_request FUNCTION_SET_UV_LIGHT_CALLBACK_THRESHOLD, [option, min, max], 'k L L', 8, '' end |