tinkerforge 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. data/lib/tinkerforge.rb +5 -0
  2. data/lib/tinkerforge/brick_dc.rb +359 -0
  3. data/lib/tinkerforge/brick_imu.rb +512 -0
  4. data/lib/tinkerforge/brick_master.rb +1120 -0
  5. data/lib/tinkerforge/brick_servo.rb +475 -0
  6. data/lib/tinkerforge/brick_stepper.rb +556 -0
  7. data/lib/tinkerforge/bricklet_ambient_light.rb +246 -0
  8. data/lib/tinkerforge/bricklet_analog_in.rb +273 -0
  9. data/lib/tinkerforge/bricklet_analog_out.rb +90 -0
  10. data/lib/tinkerforge/bricklet_barometer.rb +313 -0
  11. data/lib/tinkerforge/bricklet_current12.rb +274 -0
  12. data/lib/tinkerforge/bricklet_current25.rb +274 -0
  13. data/lib/tinkerforge/bricklet_distance_ir.rb +274 -0
  14. data/lib/tinkerforge/bricklet_dual_relay.rb +127 -0
  15. data/lib/tinkerforge/bricklet_gps.rb +301 -0
  16. data/lib/tinkerforge/bricklet_humidity.rb +245 -0
  17. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +165 -0
  18. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +177 -0
  19. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +177 -0
  20. data/lib/tinkerforge/bricklet_io16.rb +237 -0
  21. data/lib/tinkerforge/bricklet_io4.rb +236 -0
  22. data/lib/tinkerforge/bricklet_joystick.rb +274 -0
  23. data/lib/tinkerforge/bricklet_lcd_16x2.rb +175 -0
  24. data/lib/tinkerforge/bricklet_lcd_20x4.rb +231 -0
  25. data/lib/tinkerforge/bricklet_linear_poti.rb +241 -0
  26. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +84 -0
  27. data/lib/tinkerforge/bricklet_ptc.rb +277 -0
  28. data/lib/tinkerforge/bricklet_rotary_poti.rb +241 -0
  29. data/lib/tinkerforge/bricklet_temperature.rb +188 -0
  30. data/lib/tinkerforge/bricklet_temperature_ir.rb +275 -0
  31. data/lib/tinkerforge/bricklet_voltage.rb +241 -0
  32. data/lib/tinkerforge/bricklet_voltage_current.rb +386 -0
  33. data/lib/tinkerforge/ip_connection.rb +1027 -0
  34. data/lib/tinkerforge/version.rb +4 -0
  35. metadata +98 -0
@@ -0,0 +1,241 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2013-05-16. #
4
+ # #
5
+ # Bindings Version 2.0.7 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generator git on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Device for sensing Rotary Potentiometer input
14
+ class BrickletRotaryPoti < Device
15
+ DEVICE_IDENTIFIER = 215 # :nodoc:
16
+
17
+ # This callback is triggered periodically with the period that is set by
18
+ # BrickletRotaryPoti#set_position_callback_period. The parameter is the position of the
19
+ # Rotary Potentiometer.
20
+ #
21
+ # CALLBACK_POSITION is only triggered if the position has changed since the
22
+ # last triggering.
23
+ CALLBACK_POSITION = 13
24
+
25
+ # This callback is triggered periodically with the period that is set by
26
+ # BrickletRotaryPoti#set_analog_value_callback_period. The parameter is the analog value of the
27
+ # Rotary Potentiometer.
28
+ #
29
+ # CALLBACK_ANALOG_VALUE is only triggered if the position has changed since the
30
+ # last triggering.
31
+ CALLBACK_ANALOG_VALUE = 14
32
+
33
+ # This callback is triggered when the threshold as set by
34
+ # BrickletRotaryPoti#set_position_callback_threshold is reached.
35
+ # The parameter is the position of the Rotary Potentiometer.
36
+ #
37
+ # If the threshold keeps being reached, the callback is triggered periodically
38
+ # with the period as set by BrickletRotaryPoti#set_debounce_period.
39
+ CALLBACK_POSITION_REACHED = 15
40
+
41
+ # This callback is triggered when the threshold as set by
42
+ # BrickletRotaryPoti#set_analog_value_callback_threshold is reached.
43
+ # The parameter is the analog value of the Rotary Potentiometer.
44
+ #
45
+ # If the threshold keeps being reached, the callback is triggered periodically
46
+ # with the period as set by BrickletRotaryPoti#set_debounce_period.
47
+ CALLBACK_ANALOG_VALUE_REACHED = 16
48
+
49
+ FUNCTION_GET_POSITION = 1 # :nodoc:
50
+ FUNCTION_GET_ANALOG_VALUE = 2 # :nodoc:
51
+ FUNCTION_SET_POSITION_CALLBACK_PERIOD = 3 # :nodoc:
52
+ FUNCTION_GET_POSITION_CALLBACK_PERIOD = 4 # :nodoc:
53
+ FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD = 5 # :nodoc:
54
+ FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD = 6 # :nodoc:
55
+ FUNCTION_SET_POSITION_CALLBACK_THRESHOLD = 7 # :nodoc:
56
+ FUNCTION_GET_POSITION_CALLBACK_THRESHOLD = 8 # :nodoc:
57
+ FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD = 9 # :nodoc:
58
+ FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD = 10 # :nodoc:
59
+ FUNCTION_SET_DEBOUNCE_PERIOD = 11 # :nodoc:
60
+ FUNCTION_GET_DEBOUNCE_PERIOD = 12 # :nodoc:
61
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
62
+
63
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
64
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
65
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
66
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
67
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
68
+
69
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
70
+ # the IP Connection <tt>ipcon</tt>.
71
+ def initialize(uid, ipcon)
72
+ super uid, ipcon
73
+
74
+ @api_version = [2, 0, 0]
75
+
76
+ @response_expected[FUNCTION_GET_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
77
+ @response_expected[FUNCTION_GET_ANALOG_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
78
+ @response_expected[FUNCTION_SET_POSITION_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
79
+ @response_expected[FUNCTION_GET_POSITION_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
+ @response_expected[FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
81
+ @response_expected[FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
82
+ @response_expected[FUNCTION_SET_POSITION_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
83
+ @response_expected[FUNCTION_GET_POSITION_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
84
+ @response_expected[FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
85
+ @response_expected[FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
86
+ @response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
87
+ @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
88
+ @response_expected[CALLBACK_POSITION] = RESPONSE_EXPECTED_ALWAYS_FALSE
89
+ @response_expected[CALLBACK_ANALOG_VALUE] = RESPONSE_EXPECTED_ALWAYS_FALSE
90
+ @response_expected[CALLBACK_POSITION_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
91
+ @response_expected[CALLBACK_ANALOG_VALUE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
92
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
93
+
94
+ @callback_formats[CALLBACK_POSITION] = 's'
95
+ @callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
96
+ @callback_formats[CALLBACK_POSITION_REACHED] = 's'
97
+ @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
98
+ end
99
+
100
+ # Returns the position of the Rotary Potentiometer. The value is in degree
101
+ # and between -150° (turned left) and 150° (turned right).
102
+ #
103
+ # If you want to get the position periodically, it is recommended to use the
104
+ # callback CALLBACK_POSITION and set the period with
105
+ # BrickletRotaryPoti#set_position_callback_period.
106
+ def get_position
107
+ send_request(FUNCTION_GET_POSITION, [], '', 2, 's')
108
+ end
109
+
110
+ # Returns the value as read by a 12-bit analog-to-digital converter.
111
+ # The value is between 0 and 4095.
112
+ #
113
+ # .. note::
114
+ # The value returned by BrickletRotaryPoti#get_position is averaged over several samples
115
+ # to yield less noise, while BrickletRotaryPoti#get_analog_value gives back raw
116
+ # unfiltered analog values. The only reason to use BrickletRotaryPoti#get_analog_value is,
117
+ # if you need the full resolution of the analog-to-digital converter.
118
+ #
119
+ # If you want the analog value periodically, it is recommended to use the
120
+ # callback CALLBACK_ANALOG_VALUE and set the period with
121
+ # BrickletRotaryPoti#set_analog_value_callback_period.
122
+ def get_analog_value
123
+ send_request(FUNCTION_GET_ANALOG_VALUE, [], '', 2, 'S')
124
+ end
125
+
126
+ # Sets the period in ms with which the CALLBACK_POSITION callback is triggered
127
+ # periodically. A value of 0 turns the callback off.
128
+ #
129
+ # CALLBACK_POSITION is only triggered if the position has changed since the
130
+ # last triggering.
131
+ #
132
+ # The default value is 0.
133
+ def set_position_callback_period(period)
134
+ send_request(FUNCTION_SET_POSITION_CALLBACK_PERIOD, [period], 'L', 0, '')
135
+ end
136
+
137
+ # Returns the period as set by BrickletRotaryPoti#set_position_callback_period.
138
+ def get_position_callback_period
139
+ send_request(FUNCTION_GET_POSITION_CALLBACK_PERIOD, [], '', 4, 'L')
140
+ end
141
+
142
+ # Sets the period in ms with which the CALLBACK_ANALOG_VALUE callback is triggered
143
+ # periodically. A value of 0 turns the callback off.
144
+ #
145
+ # CALLBACK_ANALOG_VALUE is only triggered if the analog value has changed since the
146
+ # last triggering.
147
+ #
148
+ # The default value is 0.
149
+ def set_analog_value_callback_period(period)
150
+ send_request(FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 0, '')
151
+ end
152
+
153
+ # Returns the period as set by BrickletRotaryPoti#set_analog_value_callback_period.
154
+ def get_analog_value_callback_period
155
+ send_request(FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 4, 'L')
156
+ end
157
+
158
+ # Sets the thresholds for the CALLBACK_POSITION_REACHED callback.
159
+ #
160
+ # The following options are possible:
161
+ #
162
+ # "Option", "Description"
163
+ #
164
+ # "'x'", "Callback is turned off"
165
+ # "'o'", "Callback is triggered when the position is *outside* the min and max values"
166
+ # "'i'", "Callback is triggered when the position is *inside* the min and max values"
167
+ # "'<'", "Callback is triggered when the position is smaller than the min value (max is ignored)"
168
+ # "'>'", "Callback is triggered when the position is greater than the min value (max is ignored)"
169
+ #
170
+ # The default value is ('x', 0, 0).
171
+ def set_position_callback_threshold(option, min, max)
172
+ send_request(FUNCTION_SET_POSITION_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 0, '')
173
+ end
174
+
175
+ # Returns the threshold as set by BrickletRotaryPoti#set_position_callback_threshold.
176
+ def get_position_callback_threshold
177
+ send_request(FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, [], '', 5, 'k s s')
178
+ end
179
+
180
+ # Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
181
+ #
182
+ # The following options are possible:
183
+ #
184
+ # "Option", "Description"
185
+ #
186
+ # "'x'", "Callback is turned off"
187
+ # "'o'", "Callback is triggered when the analog value is *outside* the min and max values"
188
+ # "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
189
+ # "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
190
+ # "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
191
+ #
192
+ # The default value is ('x', 0, 0).
193
+ def set_analog_value_callback_threshold(option, min, max)
194
+ send_request(FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
195
+ end
196
+
197
+ # Returns the threshold as set by BrickletRotaryPoti#set_analog_value_callback_threshold.
198
+ def get_analog_value_callback_threshold
199
+ send_request(FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
200
+ end
201
+
202
+ # Sets the period in ms with which the threshold callbacks
203
+ #
204
+ # CALLBACK_POSITION_REACHED, CALLBACK_ANALOG_VALUE_REACHED
205
+ #
206
+ # are triggered, if the thresholds
207
+ #
208
+ # BrickletRotaryPoti#set_position_callback_threshold, BrickletRotaryPoti#set_analog_value_callback_threshold
209
+ #
210
+ # keep being reached.
211
+ #
212
+ # The default value is 100.
213
+ def set_debounce_period(debounce)
214
+ send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
215
+ end
216
+
217
+ # Returns the debounce period as set by BrickletRotaryPoti#set_debounce_period.
218
+ def get_debounce_period
219
+ send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
220
+ end
221
+
222
+ # Returns the UID, the UID where the Bricklet is connected to,
223
+ # the position, the hardware and firmware version as well as the
224
+ # device identifier.
225
+ #
226
+ # The position can be 'a', 'b', 'c' or 'd'.
227
+ #
228
+ # The device identifiers can be found :ref:`here <device_identifier>`.
229
+ #
230
+ # .. versionadded:: 2.0.0~(Plugin)
231
+ def get_identity
232
+ send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
233
+ end
234
+
235
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
236
+ def register_callback(id, &block)
237
+ callback = block
238
+ @registered_callbacks[id] = callback
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,188 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2013-05-16. #
4
+ # #
5
+ # Bindings Version 2.0.7 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generator git on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Device for sensing Temperature
14
+ class BrickletTemperature < Device
15
+ DEVICE_IDENTIFIER = 216 # :nodoc:
16
+
17
+ # This callback is triggered periodically with the period that is set by
18
+ # BrickletTemperature#set_temperature_callback_period. The parameter is the temperature
19
+ # of the sensor.
20
+ #
21
+ # CALLBACK_TEMPERATURE is only triggered if the temperature has changed since the
22
+ # last triggering.
23
+ CALLBACK_TEMPERATURE = 8
24
+
25
+ # This callback is triggered when the threshold as set by
26
+ # BrickletTemperature#set_temperature_callback_threshold is reached.
27
+ # The parameter is the temperature of the sensor.
28
+ #
29
+ # If the threshold keeps being reached, the callback is triggered periodically
30
+ # with the period as set by BrickletTemperature#set_debounce_period.
31
+ CALLBACK_TEMPERATURE_REACHED = 9
32
+
33
+ FUNCTION_GET_TEMPERATURE = 1 # :nodoc:
34
+ FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD = 2 # :nodoc:
35
+ FUNCTION_GET_TEMPERATURE_CALLBACK_PERIOD = 3 # :nodoc:
36
+ FUNCTION_SET_TEMPERATURE_CALLBACK_THRESHOLD = 4 # :nodoc:
37
+ FUNCTION_GET_TEMPERATURE_CALLBACK_THRESHOLD = 5 # :nodoc:
38
+ FUNCTION_SET_DEBOUNCE_PERIOD = 6 # :nodoc:
39
+ FUNCTION_GET_DEBOUNCE_PERIOD = 7 # :nodoc:
40
+ FUNCTION_SET_I2C_MODE = 10 # :nodoc:
41
+ FUNCTION_GET_I2C_MODE = 11 # :nodoc:
42
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
43
+
44
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
45
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
46
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
47
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
48
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
49
+ I2C_MODE_FAST = 0 # :nodoc:
50
+ I2C_MODE_SLOW = 1 # :nodoc:
51
+
52
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
53
+ # the IP Connection <tt>ipcon</tt>.
54
+ def initialize(uid, ipcon)
55
+ super uid, ipcon
56
+
57
+ @api_version = [2, 0, 0]
58
+
59
+ @response_expected[FUNCTION_GET_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
60
+ @response_expected[FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
61
+ @response_expected[FUNCTION_GET_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
62
+ @response_expected[FUNCTION_SET_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
63
+ @response_expected[FUNCTION_GET_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
64
+ @response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
65
+ @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
66
+ @response_expected[CALLBACK_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_FALSE
67
+ @response_expected[CALLBACK_TEMPERATURE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
68
+ @response_expected[FUNCTION_SET_I2C_MODE] = RESPONSE_EXPECTED_FALSE
69
+ @response_expected[FUNCTION_GET_I2C_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
70
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
71
+
72
+ @callback_formats[CALLBACK_TEMPERATURE] = 's'
73
+ @callback_formats[CALLBACK_TEMPERATURE_REACHED] = 's'
74
+ end
75
+
76
+ # Returns the temperature of the sensor. The value
77
+ # has a range of -2500 to 8500 and is given in °C/100,
78
+ # e.g. a value of 4223 means that a temperature of 42.23 °C is measured.
79
+ #
80
+ # If you want to get the temperature periodically, it is recommended
81
+ # to use the callback CALLBACK_TEMPERATURE and set the period with
82
+ # BrickletTemperature#set_temperature_callback_period.
83
+ def get_temperature
84
+ send_request(FUNCTION_GET_TEMPERATURE, [], '', 2, 's')
85
+ end
86
+
87
+ # Sets the period in ms with which the CALLBACK_TEMPERATURE callback is triggered
88
+ # periodically. A value of 0 turns the callback off.
89
+ #
90
+ # CALLBACK_TEMPERATURE is only triggered if the temperature has changed since the
91
+ # last triggering.
92
+ #
93
+ # The default value is 0.
94
+ def set_temperature_callback_period(period)
95
+ send_request(FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD, [period], 'L', 0, '')
96
+ end
97
+
98
+ # Returns the period as set by BrickletTemperature#set_temperature_callback_period.
99
+ def get_temperature_callback_period
100
+ send_request(FUNCTION_GET_TEMPERATURE_CALLBACK_PERIOD, [], '', 4, 'L')
101
+ end
102
+
103
+ # Sets the thresholds for the CALLBACK_TEMPERATURE_REACHED callback.
104
+ #
105
+ # The following options are possible:
106
+ #
107
+ # "Option", "Description"
108
+ #
109
+ # "'x'", "Callback is turned off"
110
+ # "'o'", "Callback is triggered when the temperature is *outside* the min and max values"
111
+ # "'i'", "Callback is triggered when the temperature is *inside* the min and max values"
112
+ # "'<'", "Callback is triggered when the temperature is smaller than the min value (max is ignored)"
113
+ # "'>'", "Callback is triggered when the temperature is greater than the min value (max is ignored)"
114
+ #
115
+ # The default value is ('x', 0, 0).
116
+ def set_temperature_callback_threshold(option, min, max)
117
+ send_request(FUNCTION_SET_TEMPERATURE_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 0, '')
118
+ end
119
+
120
+ # Returns the threshold as set by BrickletTemperature#set_temperature_callback_threshold.
121
+ def get_temperature_callback_threshold
122
+ send_request(FUNCTION_GET_TEMPERATURE_CALLBACK_THRESHOLD, [], '', 5, 'k s s')
123
+ end
124
+
125
+ # Sets the period in ms with which the threshold callback
126
+ #
127
+ # CALLBACK_TEMPERATURE_REACHED
128
+ #
129
+ # is triggered, if the threshold
130
+ #
131
+ # BrickletTemperature#set_temperature_callback_threshold
132
+ #
133
+ # keeps being reached.
134
+ #
135
+ # The default value is 100.
136
+ def set_debounce_period(debounce)
137
+ send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
138
+ end
139
+
140
+ # Returns the debounce period as set by BrickletTemperature#set_debounce_period.
141
+ def get_debounce_period
142
+ send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
143
+ end
144
+
145
+ # Sets the I2C mode. Possible modes are:
146
+ #
147
+ # * 0: Fast (400kHz, default)
148
+ # * 1: Slow (100kHz)
149
+ #
150
+ # If you have problems with obvious outliers in the
151
+ # Temperature Bricklet measurements, they may be caused by EMI issues.
152
+ # In this case it may be helpful to lower the I2C speed.
153
+ #
154
+ # It is however not recommended to lower the I2C speed in applications where
155
+ # a high throughput needs to be achieved.
156
+ #
157
+ # .. versionadded:: 2.0.1~(Plugin)
158
+ def set_i2c_mode(mode)
159
+ send_request(FUNCTION_SET_I2C_MODE, [mode], 'C', 0, '')
160
+ end
161
+
162
+ # Returns the I2C mode as set by BrickletTemperature#set_i2c_mode.
163
+ #
164
+ # .. versionadded:: 2.0.1~(Plugin)
165
+ def get_i2c_mode
166
+ send_request(FUNCTION_GET_I2C_MODE, [], '', 1, 'C')
167
+ end
168
+
169
+ # Returns the UID, the UID where the Bricklet is connected to,
170
+ # the position, the hardware and firmware version as well as the
171
+ # device identifier.
172
+ #
173
+ # The position can be 'a', 'b', 'c' or 'd'.
174
+ #
175
+ # The device identifiers can be found :ref:`here <device_identifier>`.
176
+ #
177
+ # .. versionadded:: 2.0.0~(Plugin)
178
+ def get_identity
179
+ send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
180
+ end
181
+
182
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
183
+ def register_callback(id, &block)
184
+ callback = block
185
+ @registered_callbacks[id] = callback
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,275 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2013-05-16. #
4
+ # #
5
+ # Bindings Version 2.0.7 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generator git on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Device for non-contact temperature sensing
14
+ class BrickletTemperatureIR < Device
15
+ DEVICE_IDENTIFIER = 217 # :nodoc:
16
+
17
+ # This callback is triggered periodically with the period that is set by
18
+ # BrickletTemperatureIR#set_ambient_temperature_callback_period. The parameter is the ambient
19
+ # temperature of the sensor.
20
+ #
21
+ # CALLBACK_AMBIENT_TEMPERATURE is only triggered if the ambient temperature
22
+ # has changed since the last triggering.
23
+ CALLBACK_AMBIENT_TEMPERATURE = 15
24
+
25
+ # This callback is triggered periodically with the period that is set by
26
+ # BrickletTemperatureIR#set_object_temperature_callback_period. The parameter is the object
27
+ # temperature of the sensor.
28
+ #
29
+ # CALLBACK_OBJECT_TEMPERATURE is only triggered if the object temperature
30
+ # has changed since the last triggering.
31
+ CALLBACK_OBJECT_TEMPERATURE = 16
32
+
33
+ # This callback is triggered when the threshold as set by
34
+ # BrickletTemperatureIR#set_ambient_temperature_callback_threshold is reached.
35
+ # The parameter is the ambient temperature of the sensor.
36
+ #
37
+ # If the threshold keeps being reached, the callback is triggered periodically
38
+ # with the period as set by BrickletTemperatureIR#set_debounce_period.
39
+ CALLBACK_AMBIENT_TEMPERATURE_REACHED = 17
40
+
41
+ # This callback is triggered when the threshold as set by
42
+ # BrickletTemperatureIR#set_object_temperature_callback_threshold is reached.
43
+ # The parameter is the object temperature of the sensor.
44
+ #
45
+ # If the threshold keeps being reached, the callback is triggered periodically
46
+ # with the period as set by BrickletTemperatureIR#set_debounce_period.
47
+ CALLBACK_OBJECT_TEMPERATURE_REACHED = 18
48
+
49
+ FUNCTION_GET_AMBIENT_TEMPERATURE = 1 # :nodoc:
50
+ FUNCTION_GET_OBJECT_TEMPERATURE = 2 # :nodoc:
51
+ FUNCTION_SET_EMISSIVITY = 3 # :nodoc:
52
+ FUNCTION_GET_EMISSIVITY = 4 # :nodoc:
53
+ FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD = 5 # :nodoc:
54
+ FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD = 6 # :nodoc:
55
+ FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_PERIOD = 7 # :nodoc:
56
+ FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_PERIOD = 8 # :nodoc:
57
+ FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD = 9 # :nodoc:
58
+ FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD = 10 # :nodoc:
59
+ FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD = 11 # :nodoc:
60
+ FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD = 12 # :nodoc:
61
+ FUNCTION_SET_DEBOUNCE_PERIOD = 13 # :nodoc:
62
+ FUNCTION_GET_DEBOUNCE_PERIOD = 14 # :nodoc:
63
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
64
+
65
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
66
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
67
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
68
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
69
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
70
+
71
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
72
+ # the IP Connection <tt>ipcon</tt>.
73
+ def initialize(uid, ipcon)
74
+ super uid, ipcon
75
+
76
+ @api_version = [2, 0, 0]
77
+
78
+ @response_expected[FUNCTION_GET_AMBIENT_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
79
+ @response_expected[FUNCTION_GET_OBJECT_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
+ @response_expected[FUNCTION_SET_EMISSIVITY] = RESPONSE_EXPECTED_FALSE
81
+ @response_expected[FUNCTION_GET_EMISSIVITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
82
+ @response_expected[FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
83
+ @response_expected[FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
84
+ @response_expected[FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
85
+ @response_expected[FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
86
+ @response_expected[FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
87
+ @response_expected[FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
88
+ @response_expected[FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
89
+ @response_expected[FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
+ @response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
91
+ @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
92
+ @response_expected[CALLBACK_AMBIENT_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_FALSE
93
+ @response_expected[CALLBACK_OBJECT_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_FALSE
94
+ @response_expected[CALLBACK_AMBIENT_TEMPERATURE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
95
+ @response_expected[CALLBACK_OBJECT_TEMPERATURE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
96
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
97
+
98
+ @callback_formats[CALLBACK_AMBIENT_TEMPERATURE] = 's'
99
+ @callback_formats[CALLBACK_OBJECT_TEMPERATURE] = 's'
100
+ @callback_formats[CALLBACK_AMBIENT_TEMPERATURE_REACHED] = 's'
101
+ @callback_formats[CALLBACK_OBJECT_TEMPERATURE_REACHED] = 's'
102
+ end
103
+
104
+ # Returns the ambient temperature of the sensor. The value
105
+ # has a range of -400 to 1250 and is given in °C/10,
106
+ # e.g. a value of 423 means that an ambient temperature of 42.3 °C is
107
+ # measured.
108
+ #
109
+ # If you want to get the ambient temperature periodically, it is recommended
110
+ # to use the callback CALLBACK_AMBIENT_TEMPERATURE and set the period with
111
+ # BrickletTemperatureIR#set_ambient_temperature_callback_period.
112
+ def get_ambient_temperature
113
+ send_request(FUNCTION_GET_AMBIENT_TEMPERATURE, [], '', 2, 's')
114
+ end
115
+
116
+ # Returns the object temperature of the sensor, i.e. the temperature
117
+ # of the surface of the object the sensor is aimed at. The value
118
+ # has a range of -700 to 3800 and is given in °C/10,
119
+ # e.g. a value of 3001 means that a temperature of 300.1 °C is measured
120
+ # on the surface of the object.
121
+ #
122
+ # The temperature of different materials is dependent on their `emissivity
123
+ # <http://en.wikipedia.org/wiki/Emissivity>`__. The emissivity of the material
124
+ # can be set with BrickletTemperatureIR#set_emissivity.
125
+ #
126
+ # If you want to get the object temperature periodically, it is recommended
127
+ # to use the callback CALLBACK_OBJECT_TEMPERATURE and set the period with
128
+ # BrickletTemperatureIR#set_object_temperature_callback_period.
129
+ def get_object_temperature
130
+ send_request(FUNCTION_GET_OBJECT_TEMPERATURE, [], '', 2, 's')
131
+ end
132
+
133
+ # Sets the `emissivity <http://en.wikipedia.org/wiki/Emissivity>`__ that is
134
+ # used to calculate the surface temperature as returned by
135
+ # BrickletTemperatureIR#get_object_temperature.
136
+ #
137
+ # The emissivity is usually given as a value between 0.0 and 1.0. A list of
138
+ # emissivities of different materials can be found
139
+ # `here <http://www.infrared-thermography.com/material.htm>`__.
140
+ #
141
+ # The parameter of BrickletTemperatureIR#set_emissivity has to be given with a factor of
142
+ # 65535 (16-bit). For example: An emissivity of 0.1 can be set with the
143
+ # value 6553, an emissivity of 0.5 with the value 32767 and so on.
144
+ #
145
+ # .. note::
146
+ # If you need a precise measurement for the object temperature, it is
147
+ # absolutely crucial that you also provide a precise emissivity.
148
+ #
149
+ # The default emissivity is 1.0 (value of 65535) and the minimum emissivity the
150
+ # sensor can handle is 0.1 (value of 6553).
151
+ def set_emissivity(emissivity)
152
+ send_request(FUNCTION_SET_EMISSIVITY, [emissivity], 'S', 0, '')
153
+ end
154
+
155
+ # Returns the emissivity as set by BrickletTemperatureIR#set_emissivity.
156
+ def get_emissivity
157
+ send_request(FUNCTION_GET_EMISSIVITY, [], '', 2, 'S')
158
+ end
159
+
160
+ # Sets the period in ms with which the CALLBACK_AMBIENT_TEMPERATURE callback is triggered
161
+ # periodically. A value of 0 turns the callback off.
162
+ #
163
+ # CALLBACK_AMBIENT_TEMPERATURE is only triggered if the temperature has changed since the
164
+ # last triggering.
165
+ #
166
+ # The default value is 0.
167
+ def set_ambient_temperature_callback_period(period)
168
+ send_request(FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD, [period], 'L', 0, '')
169
+ end
170
+
171
+ # Returns the period as set by BrickletTemperatureIR#set_ambient_temperature_callback_period.
172
+ def get_ambient_temperature_callback_period
173
+ send_request(FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_PERIOD, [], '', 4, 'L')
174
+ end
175
+
176
+ # Sets the period in ms with which the CALLBACK_OBJECT_TEMPERATURE callback is triggered
177
+ # periodically. A value of 0 turns the callback off.
178
+ #
179
+ # CALLBACK_OBJECT_TEMPERATURE is only triggered if the temperature has changed since the
180
+ # last triggering.
181
+ #
182
+ # The default value is 0.
183
+ def set_object_temperature_callback_period(period)
184
+ send_request(FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_PERIOD, [period], 'L', 0, '')
185
+ end
186
+
187
+ # Returns the period as set by BrickletTemperatureIR#set_object_temperature_callback_period.
188
+ def get_object_temperature_callback_period
189
+ send_request(FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_PERIOD, [], '', 4, 'L')
190
+ end
191
+
192
+ # Sets the thresholds for the CALLBACK_AMBIENT_TEMPERATURE_REACHED callback.
193
+ #
194
+ # The following options are possible:
195
+ #
196
+ # "Option", "Description"
197
+ #
198
+ # "'x'", "Callback is turned off"
199
+ # "'o'", "Callback is triggered when the ambient temperature is *outside* the min and max values"
200
+ # "'i'", "Callback is triggered when the ambient temperature is *inside* the min and max values"
201
+ # "'<'", "Callback is triggered when the ambient temperature is smaller than the min value (max is ignored)"
202
+ # "'>'", "Callback is triggered when the ambient temperature is greater than the min value (max is ignored)"
203
+ #
204
+ # The default value is ('x', 0, 0).
205
+ def set_ambient_temperature_callback_threshold(option, min, max)
206
+ send_request(FUNCTION_SET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 0, '')
207
+ end
208
+
209
+ # Returns the threshold as set by BrickletTemperatureIR#set_ambient_temperature_callback_threshold.
210
+ def get_ambient_temperature_callback_threshold
211
+ send_request(FUNCTION_GET_AMBIENT_TEMPERATURE_CALLBACK_THRESHOLD, [], '', 5, 'k s s')
212
+ end
213
+
214
+ # Sets the thresholds for the CALLBACK_OBJECT_TEMPERATURE_REACHED callback.
215
+ #
216
+ # The following options are possible:
217
+ #
218
+ # "Option", "Description"
219
+ #
220
+ # "'x'", "Callback is turned off"
221
+ # "'o'", "Callback is triggered when the object temperature is *outside* the min and max values"
222
+ # "'i'", "Callback is triggered when the object temperature is *inside* the min and max values"
223
+ # "'<'", "Callback is triggered when the object temperature is smaller than the min value (max is ignored)"
224
+ # "'>'", "Callback is triggered when the object temperature is greater than the min value (max is ignored)"
225
+ #
226
+ # The default value is ('x', 0, 0).
227
+ def set_object_temperature_callback_threshold(option, min, max)
228
+ send_request(FUNCTION_SET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 0, '')
229
+ end
230
+
231
+ # Returns the threshold as set by BrickletTemperatureIR#set_object_temperature_callback_threshold.
232
+ def get_object_temperature_callback_threshold
233
+ send_request(FUNCTION_GET_OBJECT_TEMPERATURE_CALLBACK_THRESHOLD, [], '', 5, 'k s s')
234
+ end
235
+
236
+ # Sets the period in ms with which the threshold callbacks
237
+ #
238
+ # CALLBACK_AMBIENT_TEMPERATURE_REACHED, CALLBACK_OBJECT_TEMPERATURE_REACHED
239
+ #
240
+ # are triggered, if the thresholds
241
+ #
242
+ # BrickletTemperatureIR#set_ambient_temperature_callback_threshold, BrickletTemperatureIR#set_object_temperature_callback_threshold
243
+ #
244
+ # keep being reached.
245
+ #
246
+ # The default value is 100.
247
+ def set_debounce_period(debounce)
248
+ send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
249
+ end
250
+
251
+ # Returns the debounce period as set by BrickletTemperatureIR#set_debounce_period.
252
+ def get_debounce_period
253
+ send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
254
+ end
255
+
256
+ # Returns the UID, the UID where the Bricklet is connected to,
257
+ # the position, the hardware and firmware version as well as the
258
+ # device identifier.
259
+ #
260
+ # The position can be 'a', 'b', 'c' or 'd'.
261
+ #
262
+ # The device identifiers can be found :ref:`here <device_identifier>`.
263
+ #
264
+ # .. versionadded:: 2.0.0~(Plugin)
265
+ def get_identity
266
+ send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
267
+ end
268
+
269
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
270
+ def register_callback(id, &block)
271
+ callback = block
272
+ @registered_callbacks[id] = callback
273
+ end
274
+ end
275
+ end