tinkerforge 2.1.22 → 2.1.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +157 -76
  3. data/lib/tinkerforge/brick_hat.rb +115 -32
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +192 -87
  6. data/lib/tinkerforge/brick_imu_v2.rb +220 -119
  7. data/lib/tinkerforge/brick_master.rb +498 -198
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +187 -103
  10. data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
  11. data/lib/tinkerforge/brick_stepper.rb +214 -102
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
  14. data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
  18. data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
  21. data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
  24. data/lib/tinkerforge/bricklet_barometer.rb +108 -58
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
  26. data/lib/tinkerforge/bricklet_can.rb +84 -24
  27. data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
  28. data/lib/tinkerforge/bricklet_co2.rb +36 -25
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
  30. data/lib/tinkerforge/bricklet_color.rb +77 -49
  31. data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
  32. data/lib/tinkerforge/bricklet_compass.rb +397 -0
  33. data/lib/tinkerforge/bricklet_current12.rb +61 -40
  34. data/lib/tinkerforge/bricklet_current25.rb +61 -40
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
  37. data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
  39. data/lib/tinkerforge/bricklet_dmx.rb +92 -48
  40. data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
  46. data/lib/tinkerforge/bricklet_gps.rb +72 -48
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
  50. data/lib/tinkerforge/bricklet_humidity.rb +54 -38
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
  52. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  53. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
  54. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
  55. data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
  62. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  63. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
  65. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
  66. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
  67. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
  68. data/lib/tinkerforge/bricklet_io16.rb +57 -32
  69. data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
  70. data/lib/tinkerforge/bricklet_io4.rb +56 -31
  71. data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
  72. data/lib/tinkerforge/bricklet_isolator.rb +111 -35
  73. data/lib/tinkerforge/bricklet_joystick.rb +63 -42
  74. data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
  75. data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
  76. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
  78. data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
  79. data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
  80. data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
  81. data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
  82. data/lib/tinkerforge/bricklet_line.rb +35 -22
  83. data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
  84. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
  85. data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
  86. data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
  87. data/lib/tinkerforge/bricklet_moisture.rb +43 -30
  88. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  89. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
  90. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
  91. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
  92. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
  93. data/lib/tinkerforge/bricklet_nfc.rb +130 -80
  94. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  95. data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
  96. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
  97. data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
  98. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  99. data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
  100. data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
  101. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  102. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  103. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  104. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  105. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  106. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  107. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  108. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  109. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  110. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  111. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  112. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  113. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  114. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  115. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  116. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  117. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
  118. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  119. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  120. data/lib/tinkerforge/bricklet_rs485.rb +303 -207
  121. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  122. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  123. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  124. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  125. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  126. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  127. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  128. data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
  129. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
  130. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  131. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  132. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  133. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  134. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  135. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  136. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  137. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  138. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  139. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
  140. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
  141. data/lib/tinkerforge/device_display_names.rb +165 -0
  142. data/lib/tinkerforge/ip_connection.rb +155 -33
  143. data/lib/tinkerforge/version.rb +1 -1
  144. metadata +14 -4
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2020-11-02. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.27 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # Measures ambient temperature with 0.2°C accuracy
14
16
  class BrickletTemperatureV2 < Device
@@ -65,7 +67,7 @@ module Tinkerforge
65
67
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
66
68
  # the IP Connection <tt>ipcon</tt>.
67
69
  def initialize(uid, ipcon)
68
- super uid, ipcon
70
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
69
71
 
70
72
  @api_version = [2, 0, 0]
71
73
 
@@ -87,23 +89,24 @@ module Tinkerforge
87
89
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
88
90
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
89
91
 
90
- @callback_formats[CALLBACK_TEMPERATURE] = 's'
92
+ @callback_formats[CALLBACK_TEMPERATURE] = [10, 's']
91
93
 
94
+ @ipcon.add_device self
92
95
  end
93
96
 
94
- # Returns the temperature measured by the sensor. The value
95
- # has a range of -4500 to 13000 and is given in °C/100,
96
- # i.e. a value of 3200 means that a temperature of 32.00 °C is measured.
97
+ # Returns the temperature measured by the sensor.
97
98
  #
98
99
  #
99
100
  # If you want to get the value periodically, it is recommended to use the
100
101
  # CALLBACK_TEMPERATURE callback. You can set the callback configuration
101
102
  # with BrickletTemperatureV2#set_temperature_callback_configuration.
102
103
  def get_temperature
103
- send_request FUNCTION_GET_TEMPERATURE, [], '', 2, 's'
104
+ check_validity
105
+
106
+ send_request FUNCTION_GET_TEMPERATURE, [], '', 10, 's'
104
107
  end
105
108
 
106
- # The period in ms is the period with which the CALLBACK_TEMPERATURE callback is triggered
109
+ # The period is the period with which the CALLBACK_TEMPERATURE callback is triggered
107
110
  # periodically. A value of 0 turns the callback off.
108
111
  #
109
112
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -128,27 +131,31 @@ module Tinkerforge
128
131
  # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
129
132
  #
130
133
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
131
- #
132
- # The default value is (0, false, 'x', 0, 0).
133
134
  def set_temperature_callback_configuration(period, value_has_to_change, option, min, max)
134
- send_request FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 0, ''
135
+ check_validity
136
+
137
+ send_request FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 8, ''
135
138
  end
136
139
 
137
140
  # Returns the callback configuration as set by BrickletTemperatureV2#set_temperature_callback_configuration.
138
141
  def get_temperature_callback_configuration
139
- send_request FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k s s'
142
+ check_validity
143
+
144
+ send_request FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k s s'
140
145
  end
141
146
 
142
147
  # Enables/disables the heater. The heater can be used to test the sensor.
143
- #
144
- # By default the heater is disabled.
145
148
  def set_heater_configuration(heater_config)
146
- send_request FUNCTION_SET_HEATER_CONFIGURATION, [heater_config], 'C', 0, ''
149
+ check_validity
150
+
151
+ send_request FUNCTION_SET_HEATER_CONFIGURATION, [heater_config], 'C', 8, ''
147
152
  end
148
153
 
149
154
  # Returns the heater configuration as set by BrickletTemperatureV2#set_heater_configuration.
150
155
  def get_heater_configuration
151
- send_request FUNCTION_GET_HEATER_CONFIGURATION, [], '', 1, 'C'
156
+ check_validity
157
+
158
+ send_request FUNCTION_GET_HEATER_CONFIGURATION, [], '', 9, 'C'
152
159
  end
153
160
 
154
161
  # Returns the error count for the communication between Brick and Bricklet.
@@ -163,7 +170,9 @@ module Tinkerforge
163
170
  # The errors counts are for errors that occur on the Bricklet side. All
164
171
  # Bricks have a similar function that returns the errors on the Brick side.
165
172
  def get_spitfp_error_count
166
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
173
+ check_validity
174
+
175
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
167
176
  end
168
177
 
169
178
  # Sets the bootloader mode and returns the status after the requested
@@ -176,12 +185,16 @@ module Tinkerforge
176
185
  # This function is used by Brick Viewer during flashing. It should not be
177
186
  # necessary to call it in a normal user program.
178
187
  def set_bootloader_mode(mode)
179
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
188
+ check_validity
189
+
190
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
180
191
  end
181
192
 
182
193
  # Returns the current bootloader mode, see BrickletTemperatureV2#set_bootloader_mode.
183
194
  def get_bootloader_mode
184
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
195
+ check_validity
196
+
197
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
185
198
  end
186
199
 
187
200
  # Sets the firmware pointer for BrickletTemperatureV2#write_firmware. The pointer has
@@ -191,7 +204,9 @@ module Tinkerforge
191
204
  # This function is used by Brick Viewer during flashing. It should not be
192
205
  # necessary to call it in a normal user program.
193
206
  def set_write_firmware_pointer(pointer)
194
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
207
+ check_validity
208
+
209
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
195
210
  end
196
211
 
197
212
  # Writes 64 Bytes of firmware at the position as written by
@@ -203,7 +218,9 @@ module Tinkerforge
203
218
  # This function is used by Brick Viewer during flashing. It should not be
204
219
  # necessary to call it in a normal user program.
205
220
  def write_firmware(data)
206
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
221
+ check_validity
222
+
223
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
207
224
  end
208
225
 
209
226
  # Sets the status LED configuration. By default the LED shows
@@ -214,22 +231,28 @@ module Tinkerforge
214
231
  #
215
232
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
216
233
  def set_status_led_config(config)
217
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
234
+ check_validity
235
+
236
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
218
237
  end
219
238
 
220
239
  # Returns the configuration as set by BrickletTemperatureV2#set_status_led_config
221
240
  def get_status_led_config
222
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
241
+ check_validity
242
+
243
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
223
244
  end
224
245
 
225
- # Returns the temperature in °C as measured inside the microcontroller. The
246
+ # Returns the temperature as measured inside the microcontroller. The
226
247
  # value returned is not the ambient temperature!
227
248
  #
228
249
  # The temperature is only proportional to the real temperature and it has bad
229
250
  # accuracy. Practically it is only useful as an indicator for
230
251
  # temperature changes.
231
252
  def get_chip_temperature
232
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
253
+ check_validity
254
+
255
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
233
256
  end
234
257
 
235
258
  # Calling this function will reset the Bricklet. All configurations
@@ -239,7 +262,9 @@ module Tinkerforge
239
262
  # calling functions on the existing ones will result in
240
263
  # undefined behavior!
241
264
  def reset
242
- send_request FUNCTION_RESET, [], '', 0, ''
265
+ check_validity
266
+
267
+ send_request FUNCTION_RESET, [], '', 8, ''
243
268
  end
244
269
 
245
270
  # Writes a new UID into flash. If you want to set a new UID
@@ -248,25 +273,31 @@ module Tinkerforge
248
273
  #
249
274
  # We recommend that you use Brick Viewer to change the UID.
250
275
  def write_uid(uid)
251
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
276
+ check_validity
277
+
278
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
252
279
  end
253
280
 
254
281
  # Returns the current UID as an integer. Encode as
255
282
  # Base58 to get the usual string version.
256
283
  def read_uid
257
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
284
+ check_validity
285
+
286
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
258
287
  end
259
288
 
260
289
  # Returns the UID, the UID where the Bricklet is connected to,
261
290
  # the position, the hardware and firmware version as well as the
262
291
  # device identifier.
263
292
  #
264
- # The position can be 'a', 'b', 'c' or 'd'.
293
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
294
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
295
+ # position 'z'.
265
296
  #
266
297
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
267
298
  # |device_identifier_constant|
268
299
  def get_identity
269
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
300
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
270
301
  end
271
302
 
272
303
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
@@ -1,40 +1,26 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2020-11-02. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.27 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # 80x60 pixel thermal imaging camera
14
16
  class BrickletThermalImaging < Device
15
17
  DEVICE_IDENTIFIER = 278 # :nodoc:
16
18
  DEVICE_DISPLAY_NAME = 'Thermal Imaging Bricklet' # :nodoc:
17
19
 
18
- # This callback is triggered with every new high contrast image if the transfer image
19
- # config is configured for high contrast callback (see BrickletThermalImaging#set_image_transfer_config).
20
- #
21
- # The data is organized as a 8-bit value 80x60 pixel matrix linearized in
22
- # a one-dimensional array. The data is arranged line by line from top left to
23
- # bottom right.
24
- #
25
- # Each 8-bit value represents one gray-scale image pixel that can directly be
26
- # shown to a user on a display.
20
+ # See CALLBACK_HIGH_CONTRAST_IMAGE
27
21
  CALLBACK_HIGH_CONTRAST_IMAGE_LOW_LEVEL = 12
28
22
 
29
- # This callback is triggered with every new temperature image if the transfer image
30
- # config is configured for temperature callback (see BrickletThermalImaging#set_image_transfer_config).
31
- #
32
- # The data is organized as a 16-bit value 80x60 pixel matrix linearized in
33
- # a one-dimensional array. The data is arranged line by line from top left to
34
- # bottom right.
35
- #
36
- # Each 16-bit value represents one temperature measurement in either
37
- # Kelvin/10 or Kelvin/100 (depending on the resolution set with BrickletThermalImaging#set_resolution).
23
+ # See CALLBACK_TEMPERATURE_IMAGE
38
24
  CALLBACK_TEMPERATURE_IMAGE_LOW_LEVEL = 13
39
25
 
40
26
  # This callback is triggered with every new high contrast image if the transfer image
@@ -46,6 +32,9 @@ module Tinkerforge
46
32
  #
47
33
  # Each 8-bit value represents one gray-scale image pixel that can directly be
48
34
  # shown to a user on a display.
35
+ #
36
+ # .. note::
37
+ # If reconstructing the value fails, the callback is triggered with nil for image.
49
38
  CALLBACK_HIGH_CONTRAST_IMAGE = -12
50
39
 
51
40
  # This callback is triggered with every new temperature image if the transfer image
@@ -57,6 +46,9 @@ module Tinkerforge
57
46
  #
58
47
  # Each 16-bit value represents one temperature measurement in either
59
48
  # Kelvin/10 or Kelvin/100 (depending on the resolution set with BrickletThermalImaging#set_resolution).
49
+ #
50
+ # .. note::
51
+ # If reconstructing the value fails, the callback is triggered with nil for image.
60
52
  CALLBACK_TEMPERATURE_IMAGE = -13
61
53
 
62
54
  FUNCTION_GET_HIGH_CONTRAST_IMAGE_LOW_LEVEL = 1 # :nodoc:
@@ -70,6 +62,8 @@ module Tinkerforge
70
62
  FUNCTION_GET_HIGH_CONTRAST_CONFIG = 9 # :nodoc:
71
63
  FUNCTION_SET_IMAGE_TRANSFER_CONFIG = 10 # :nodoc:
72
64
  FUNCTION_GET_IMAGE_TRANSFER_CONFIG = 11 # :nodoc:
65
+ FUNCTION_SET_FLUX_LINEAR_PARAMETERS = 14 # :nodoc:
66
+ FUNCTION_GET_FLUX_LINEAR_PARAMETERS = 15 # :nodoc:
73
67
  FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
74
68
  FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
75
69
  FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
@@ -112,9 +106,9 @@ module Tinkerforge
112
106
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
113
107
  # the IP Connection <tt>ipcon</tt>.
114
108
  def initialize(uid, ipcon)
115
- super uid, ipcon
109
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
116
110
 
117
- @api_version = [2, 0, 0]
111
+ @api_version = [2, 0, 1]
118
112
 
119
113
  @response_expected[FUNCTION_GET_HIGH_CONTRAST_IMAGE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
120
114
  @response_expected[FUNCTION_GET_TEMPERATURE_IMAGE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -127,6 +121,8 @@ module Tinkerforge
127
121
  @response_expected[FUNCTION_GET_HIGH_CONTRAST_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
128
122
  @response_expected[FUNCTION_SET_IMAGE_TRANSFER_CONFIG] = RESPONSE_EXPECTED_TRUE
129
123
  @response_expected[FUNCTION_GET_IMAGE_TRANSFER_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
124
+ @response_expected[FUNCTION_SET_FLUX_LINEAR_PARAMETERS] = RESPONSE_EXPECTED_FALSE
125
+ @response_expected[FUNCTION_GET_FLUX_LINEAR_PARAMETERS] = RESPONSE_EXPECTED_ALWAYS_TRUE
130
126
  @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
131
127
  @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
132
128
  @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -140,11 +136,12 @@ module Tinkerforge
140
136
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
141
137
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
142
138
 
143
- @callback_formats[CALLBACK_HIGH_CONTRAST_IMAGE_LOW_LEVEL] = 'S C62'
144
- @callback_formats[CALLBACK_TEMPERATURE_IMAGE_LOW_LEVEL] = 'S S31'
139
+ @callback_formats[CALLBACK_HIGH_CONTRAST_IMAGE_LOW_LEVEL] = [72, 'S C62']
140
+ @callback_formats[CALLBACK_TEMPERATURE_IMAGE_LOW_LEVEL] = [72, 'S S31']
145
141
 
146
142
  @high_level_callbacks[CALLBACK_HIGH_CONTRAST_IMAGE] = [['stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => 4800, 'single_chunk' => false}, nil]
147
143
  @high_level_callbacks[CALLBACK_TEMPERATURE_IMAGE] = [['stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => 4800, 'single_chunk' => false}, nil]
144
+ @ipcon.add_device self
148
145
  end
149
146
 
150
147
  # Returns the current high contrast image. See `here <https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Thermal_Imaging.html#high-contrast-image-vs-temperature-image>`__
@@ -162,7 +159,9 @@ module Tinkerforge
162
159
  # Before you can use this function you have to enable it with
163
160
  # BrickletThermalImaging#set_image_transfer_config.
164
161
  def get_high_contrast_image_low_level
165
- send_request FUNCTION_GET_HIGH_CONTRAST_IMAGE_LOW_LEVEL, [], '', 64, 'S C62'
162
+ check_validity
163
+
164
+ send_request FUNCTION_GET_HIGH_CONTRAST_IMAGE_LOW_LEVEL, [], '', 72, 'S C62'
166
165
  end
167
166
 
168
167
  # Returns the current temperature image. See `here <https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Thermal_Imaging.html#high-contrast-image-vs-temperature-image>`__
@@ -179,7 +178,9 @@ module Tinkerforge
179
178
  # Before you can use this function you have to enable it with
180
179
  # BrickletThermalImaging#set_image_transfer_config.
181
180
  def get_temperature_image_low_level
182
- send_request FUNCTION_GET_TEMPERATURE_IMAGE_LOW_LEVEL, [], '', 64, 'S S31'
181
+ check_validity
182
+
183
+ send_request FUNCTION_GET_TEMPERATURE_IMAGE_LOW_LEVEL, [], '', 72, 'S S31'
183
184
  end
184
185
 
185
186
  # Returns the spotmeter statistics, various temperatures, current resolution and status bits.
@@ -213,7 +214,9 @@ module Tinkerforge
213
214
  # * Index 0: Shutter lockout (if true shutter is locked out because temperature is outside -10°C to +65°C)
214
215
  # * Index 1: Overtemperature shut down imminent (goes true 10 seconds before shutdown)
215
216
  def get_statistics
216
- send_request FUNCTION_GET_STATISTICS, [], '', 20, 'S4 S4 C C ?2'
217
+ check_validity
218
+
219
+ send_request FUNCTION_GET_STATISTICS, [], '', 27, 'S4 S4 C C ?2'
217
220
  end
218
221
 
219
222
  # Sets the resolution. The Thermal Imaging Bricklet can either measure
@@ -223,15 +226,17 @@ module Tinkerforge
223
226
  #
224
227
  # The accuracy is specified for -10°C to 450°C in the
225
228
  # first range and -10°C and 140°C in the second range.
226
- #
227
- # The default value is 0 to 655 Kelvin.
228
229
  def set_resolution(resolution)
229
- send_request FUNCTION_SET_RESOLUTION, [resolution], 'C', 0, ''
230
+ check_validity
231
+
232
+ send_request FUNCTION_SET_RESOLUTION, [resolution], 'C', 8, ''
230
233
  end
231
234
 
232
235
  # Returns the resolution as set by BrickletThermalImaging#set_resolution.
233
236
  def get_resolution
234
- send_request FUNCTION_GET_RESOLUTION, [], '', 1, 'C'
237
+ check_validity
238
+
239
+ send_request FUNCTION_GET_RESOLUTION, [], '', 9, 'C'
235
240
  end
236
241
 
237
242
  # Sets the spotmeter region of interest. The 4 values are
@@ -242,15 +247,17 @@ module Tinkerforge
242
247
  # * Index 3: Row end (has to be smaller then 60).
243
248
  #
244
249
  # The spotmeter statistics can be read out with BrickletThermalImaging#get_statistics.
245
- #
246
- # The default region of interest is (39, 29, 40, 30).
247
250
  def set_spotmeter_config(region_of_interest)
248
- send_request FUNCTION_SET_SPOTMETER_CONFIG, [region_of_interest], 'C4', 0, ''
251
+ check_validity
252
+
253
+ send_request FUNCTION_SET_SPOTMETER_CONFIG, [region_of_interest], 'C4', 8, ''
249
254
  end
250
255
 
251
256
  # Returns the spotmeter config as set by BrickletThermalImaging#set_spotmeter_config.
252
257
  def get_spotmeter_config
253
- send_request FUNCTION_GET_SPOTMETER_CONFIG, [], '', 4, 'C4'
258
+ check_validity
259
+
260
+ send_request FUNCTION_GET_SPOTMETER_CONFIG, [], '', 12, 'C4'
254
261
  end
255
262
 
256
263
  # Sets the high contrast region of interest, dampening factor, clip limit and empty counts.
@@ -276,35 +283,32 @@ module Tinkerforge
276
283
  # lower the value of N the higher the influence of the current video frame whereas
277
284
  # the higher the value of N the more influence the previous damped transfer function has.
278
285
  #
279
- # Clip Limit Index 0 (AGC HEQ Clip Limit Low): This parameter defines an artificial population that is added to
286
+ # Clip Limit Index 0 (AGC HEQ Clip Limit High): This parameter defines the maximum number of pixels allowed
287
+ # to accumulate in any given histogram bin. Any additional pixels in a given bin are clipped.
288
+ # The effect of this parameter is to limit the influence of highly-populated bins on the
289
+ # resulting HEQ transformation function.
290
+ #
291
+ # Clip Limit Index 1 (AGC HEQ Clip Limit Low): This parameter defines an artificial population that is added to
280
292
  # every non-empty histogram bin. In other words, if the Clip Limit Low is set to L, a bin
281
293
  # with an actual population of X will have an effective population of L + X. Any empty bin
282
294
  # that is nearby a populated bin will be given an artificial population of L. The effect of
283
295
  # higher values is to provide a more linear transfer function; lower values provide a more
284
296
  # non-linear (equalized) transfer function.
285
297
  #
286
- # Clip Limit Index 1 (AGC HEQ Clip Limit High): This parameter defines the maximum number of pixels allowed
287
- # to accumulate in any given histogram bin. Any additional pixels in a given bin are clipped.
288
- # The effect of this parameter is to limit the influence of highly-populated bins on the
289
- # resulting HEQ transformation function.
290
- #
291
298
  # Empty Counts: This parameter specifies the maximum number of pixels in a bin that will be
292
299
  # interpreted as an empty bin. Histogram bins with this number of pixels or less will be
293
300
  # processed as an empty bin.
294
- #
295
- # The default values are
296
- #
297
- # * Region Of Interest = (0, 0, 79, 59),
298
- # * Dampening Factor = 64,
299
- # * Clip Limit = (4800, 512) and
300
- # * Empty Counts = 2.
301
301
  def set_high_contrast_config(region_of_interest, dampening_factor, clip_limit, empty_counts)
302
- send_request FUNCTION_SET_HIGH_CONTRAST_CONFIG, [region_of_interest, dampening_factor, clip_limit, empty_counts], 'C4 S S2 S', 0, ''
302
+ check_validity
303
+
304
+ send_request FUNCTION_SET_HIGH_CONTRAST_CONFIG, [region_of_interest, dampening_factor, clip_limit, empty_counts], 'C4 S S2 S', 8, ''
303
305
  end
304
306
 
305
307
  # Returns the high contrast config as set by BrickletThermalImaging#set_high_contrast_config.
306
308
  def get_high_contrast_config
307
- send_request FUNCTION_GET_HIGH_CONTRAST_CONFIG, [], '', 12, 'C4 S S2 S'
309
+ check_validity
310
+
311
+ send_request FUNCTION_GET_HIGH_CONTRAST_CONFIG, [], '', 20, 'C4 S S2 S'
308
312
  end
309
313
 
310
314
  # The necessary bandwidth of this Bricklet is too high to use getter/callback or
@@ -317,15 +321,37 @@ module Tinkerforge
317
321
  # * Manual Temperature Image: BrickletThermalImaging#get_temperature_image.
318
322
  # * Callback High Contrast Image: CALLBACK_HIGH_CONTRAST_IMAGE callback.
319
323
  # * Callback Temperature Image: CALLBACK_TEMPERATURE_IMAGE callback.
320
- #
321
- # The default is Manual High Contrast Image (0).
322
324
  def set_image_transfer_config(config)
323
- send_request FUNCTION_SET_IMAGE_TRANSFER_CONFIG, [config], 'C', 0, ''
325
+ check_validity
326
+
327
+ send_request FUNCTION_SET_IMAGE_TRANSFER_CONFIG, [config], 'C', 8, ''
324
328
  end
325
329
 
326
330
  # Returns the image transfer config, as set by BrickletThermalImaging#set_image_transfer_config.
327
331
  def get_image_transfer_config
328
- send_request FUNCTION_GET_IMAGE_TRANSFER_CONFIG, [], '', 1, 'C'
332
+ check_validity
333
+
334
+ send_request FUNCTION_GET_IMAGE_TRANSFER_CONFIG, [], '', 9, 'C'
335
+ end
336
+
337
+ # Sets the flux linear parameters that can be used for radiometry calibration.
338
+ #
339
+ # See FLIR document 102-PS245-100-01 for more details.
340
+ #
341
+ # .. versionadded:: 2.0.5$nbsp;(Plugin)
342
+ def set_flux_linear_parameters(scene_emissivity, temperature_background, tau_window, temperatur_window, tau_atmosphere, temperature_atmosphere, reflection_window, temperature_reflection)
343
+ check_validity
344
+
345
+ send_request FUNCTION_SET_FLUX_LINEAR_PARAMETERS, [scene_emissivity, temperature_background, tau_window, temperatur_window, tau_atmosphere, temperature_atmosphere, reflection_window, temperature_reflection], 'S S S S S S S S', 8, ''
346
+ end
347
+
348
+ # Returns the flux linear parameters, as set by BrickletThermalImaging#set_flux_linear_parameters.
349
+ #
350
+ # .. versionadded:: 2.0.5$nbsp;(Plugin)
351
+ def get_flux_linear_parameters
352
+ check_validity
353
+
354
+ send_request FUNCTION_GET_FLUX_LINEAR_PARAMETERS, [], '', 24, 'S S S S S S S S'
329
355
  end
330
356
 
331
357
  # Returns the error count for the communication between Brick and Bricklet.
@@ -340,7 +366,9 @@ module Tinkerforge
340
366
  # The errors counts are for errors that occur on the Bricklet side. All
341
367
  # Bricks have a similar function that returns the errors on the Brick side.
342
368
  def get_spitfp_error_count
343
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
369
+ check_validity
370
+
371
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
344
372
  end
345
373
 
346
374
  # Sets the bootloader mode and returns the status after the requested
@@ -353,12 +381,16 @@ module Tinkerforge
353
381
  # This function is used by Brick Viewer during flashing. It should not be
354
382
  # necessary to call it in a normal user program.
355
383
  def set_bootloader_mode(mode)
356
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
384
+ check_validity
385
+
386
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
357
387
  end
358
388
 
359
389
  # Returns the current bootloader mode, see BrickletThermalImaging#set_bootloader_mode.
360
390
  def get_bootloader_mode
361
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
391
+ check_validity
392
+
393
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
362
394
  end
363
395
 
364
396
  # Sets the firmware pointer for BrickletThermalImaging#write_firmware. The pointer has
@@ -368,7 +400,9 @@ module Tinkerforge
368
400
  # This function is used by Brick Viewer during flashing. It should not be
369
401
  # necessary to call it in a normal user program.
370
402
  def set_write_firmware_pointer(pointer)
371
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
403
+ check_validity
404
+
405
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
372
406
  end
373
407
 
374
408
  # Writes 64 Bytes of firmware at the position as written by
@@ -380,7 +414,9 @@ module Tinkerforge
380
414
  # This function is used by Brick Viewer during flashing. It should not be
381
415
  # necessary to call it in a normal user program.
382
416
  def write_firmware(data)
383
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
417
+ check_validity
418
+
419
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
384
420
  end
385
421
 
386
422
  # Sets the status LED configuration. By default the LED shows
@@ -391,22 +427,28 @@ module Tinkerforge
391
427
  #
392
428
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
393
429
  def set_status_led_config(config)
394
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
430
+ check_validity
431
+
432
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
395
433
  end
396
434
 
397
435
  # Returns the configuration as set by BrickletThermalImaging#set_status_led_config
398
436
  def get_status_led_config
399
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
437
+ check_validity
438
+
439
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
400
440
  end
401
441
 
402
- # Returns the temperature in °C as measured inside the microcontroller. The
442
+ # Returns the temperature as measured inside the microcontroller. The
403
443
  # value returned is not the ambient temperature!
404
444
  #
405
445
  # The temperature is only proportional to the real temperature and it has bad
406
446
  # accuracy. Practically it is only useful as an indicator for
407
447
  # temperature changes.
408
448
  def get_chip_temperature
409
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
449
+ check_validity
450
+
451
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
410
452
  end
411
453
 
412
454
  # Calling this function will reset the Bricklet. All configurations
@@ -416,7 +458,9 @@ module Tinkerforge
416
458
  # calling functions on the existing ones will result in
417
459
  # undefined behavior!
418
460
  def reset
419
- send_request FUNCTION_RESET, [], '', 0, ''
461
+ check_validity
462
+
463
+ send_request FUNCTION_RESET, [], '', 8, ''
420
464
  end
421
465
 
422
466
  # Writes a new UID into flash. If you want to set a new UID
@@ -425,25 +469,31 @@ module Tinkerforge
425
469
  #
426
470
  # We recommend that you use Brick Viewer to change the UID.
427
471
  def write_uid(uid)
428
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
472
+ check_validity
473
+
474
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
429
475
  end
430
476
 
431
477
  # Returns the current UID as an integer. Encode as
432
478
  # Base58 to get the usual string version.
433
479
  def read_uid
434
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
480
+ check_validity
481
+
482
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
435
483
  end
436
484
 
437
485
  # Returns the UID, the UID where the Bricklet is connected to,
438
486
  # the position, the hardware and firmware version as well as the
439
487
  # device identifier.
440
488
  #
441
- # The position can be 'a', 'b', 'c' or 'd'.
489
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
490
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
491
+ # position 'z'.
442
492
  #
443
493
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
444
494
  # |device_identifier_constant|
445
495
  def get_identity
446
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
496
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
447
497
  end
448
498
 
449
499
  # Returns the current high contrast image. See `here <https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Thermal_Imaging.html#high-contrast-image-vs-temperature-image>`__