tinkerforge 2.1.23 → 2.1.28

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 (146) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +109 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +191 -86
  6. data/lib/tinkerforge/brick_imu_v2.rb +219 -118
  7. data/lib/tinkerforge/brick_master.rb +495 -195
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +186 -102
  10. data/lib/tinkerforge/brick_silent_stepper.rb +248 -168
  11. data/lib/tinkerforge/brick_stepper.rb +212 -100
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +107 -63
  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 +75 -47
  31. data/lib/tinkerforge/bricklet_color_v2.rb +91 -47
  32. data/lib/tinkerforge/bricklet_compass.rb +81 -40
  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 +68 -33
  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 +81 -40
  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 +99 -51
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +219 -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 +76 -39
  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 +75 -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_performance_dc.rb +676 -0
  102. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  103. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  104. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  105. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  106. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  107. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  108. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  109. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  110. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  111. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  112. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  113. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  114. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  115. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  116. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  117. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  118. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -26
  119. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  120. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  121. data/lib/tinkerforge/bricklet_rs485.rb +250 -164
  122. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  123. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  124. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  125. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  126. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  127. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  128. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  129. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  130. data/lib/tinkerforge/bricklet_temperature_ir.rb +61 -47
  131. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +74 -44
  132. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  133. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  134. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  135. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  136. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  137. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  138. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  139. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  140. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  141. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +92 -77
  142. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +81 -36
  143. data/lib/tinkerforge/device_display_names.rb +167 -0
  144. data/lib/tinkerforge/ip_connection.rb +156 -33
  145. data/lib/tinkerforge/version.rb +1 -1
  146. metadata +8 -3
@@ -1,16 +1,18 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
5
+ # Ruby Bindings Version 2.1.28 #
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
- # 3-axis compass with 0.1mG (milli Gauss) and 0.1° resolution
15
+ # 3-axis compass with 10 nanotesla and 0.1° resolution
14
16
  class BrickletCompass < Device
15
17
  DEVICE_IDENTIFIER = 2153 # :nodoc:
16
18
  DEVICE_DISPLAY_NAME = 'Compass Bricklet' # :nodoc:
@@ -78,7 +80,7 @@ module Tinkerforge
78
80
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
79
81
  # the IP Connection <tt>ipcon</tt>.
80
82
  def initialize(uid, ipcon)
81
- super uid, ipcon
83
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
82
84
 
83
85
  @api_version = [2, 0, 0]
84
86
 
@@ -105,12 +107,13 @@ module Tinkerforge
105
107
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
106
108
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
107
109
 
108
- @callback_formats[CALLBACK_HEADING] = 's'
109
- @callback_formats[CALLBACK_MAGNETIC_FLUX_DENSITY] = 'l l l'
110
+ @callback_formats[CALLBACK_HEADING] = [10, 's']
111
+ @callback_formats[CALLBACK_MAGNETIC_FLUX_DENSITY] = [20, 'l l l']
110
112
 
113
+ @ipcon.add_device self
111
114
  end
112
115
 
113
- # Returns the heading in 1/10 degree (north = 0 degree, east = 90 degree).
116
+ # Returns the heading (north = 0 degree, east = 90 degree).
114
117
  #
115
118
  # Alternatively you can use BrickletCompass#get_magnetic_flux_density and calculate the
116
119
  # heading with ``heading = atan2(y, x) * 180 / PI``.
@@ -120,10 +123,12 @@ module Tinkerforge
120
123
  # CALLBACK_HEADING callback. You can set the callback configuration
121
124
  # with BrickletCompass#set_heading_callback_configuration.
122
125
  def get_heading
123
- send_request FUNCTION_GET_HEADING, [], '', 2, 's'
126
+ check_validity
127
+
128
+ send_request FUNCTION_GET_HEADING, [], '', 10, 's'
124
129
  end
125
130
 
126
- # The period in ms is the period with which the CALLBACK_HEADING callback is triggered
131
+ # The period is the period with which the CALLBACK_HEADING callback is triggered
127
132
  # periodically. A value of 0 turns the callback off.
128
133
  #
129
134
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -148,28 +153,32 @@ module Tinkerforge
148
153
  # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
149
154
  #
150
155
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
151
- #
152
- # The default value is (0, false, 'x', 0, 0).
153
156
  def set_heading_callback_configuration(period, value_has_to_change, option, min, max)
154
- send_request FUNCTION_SET_HEADING_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 0, ''
157
+ check_validity
158
+
159
+ send_request FUNCTION_SET_HEADING_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 8, ''
155
160
  end
156
161
 
157
162
  # Returns the callback configuration as set by BrickletCompass#set_heading_callback_configuration.
158
163
  def get_heading_callback_configuration
159
- send_request FUNCTION_GET_HEADING_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k s s'
164
+ check_validity
165
+
166
+ send_request FUNCTION_GET_HEADING_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k s s'
160
167
  end
161
168
 
162
169
  # Returns the `magnetic flux density (magnetic induction) <https://en.wikipedia.org/wiki/Magnetic_flux>`__
163
- # for all three axis in 1/10 `mG (milli Gauss) <https://en.wikipedia.org/wiki/Gauss_(unit)>`__.
170
+ # for all three axis.
164
171
  #
165
172
  # If you want to get the value periodically, it is recommended to use the
166
173
  # CALLBACK_MAGNETIC_FLUX_DENSITY callback. You can set the callback configuration
167
174
  # with BrickletCompass#set_magnetic_flux_density_callback_configuration.
168
175
  def get_magnetic_flux_density
169
- send_request FUNCTION_GET_MAGNETIC_FLUX_DENSITY, [], '', 12, 'l l l'
176
+ check_validity
177
+
178
+ send_request FUNCTION_GET_MAGNETIC_FLUX_DENSITY, [], '', 20, 'l l l'
170
179
  end
171
180
 
172
- # The period in ms is the period with which the CALLBACK_MAGNETIC_FLUX_DENSITY callback
181
+ # The period is the period with which the CALLBACK_MAGNETIC_FLUX_DENSITY callback
173
182
  # is triggered periodically. A value of 0 turns the callback off.
174
183
  #
175
184
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -178,16 +187,18 @@ module Tinkerforge
178
187
  #
179
188
  # If it is set to false, the callback is continuously triggered with the period,
180
189
  # independent of the value.
181
- #
182
- # The default value is (0, false).
183
190
  def set_magnetic_flux_density_callback_configuration(period, value_has_to_change)
184
- send_request FUNCTION_SET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
191
+ check_validity
192
+
193
+ send_request FUNCTION_SET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
185
194
  end
186
195
 
187
196
  # Returns the callback configuration as set by
188
197
  # BrickletCompass#set_magnetic_flux_density_callback_configuration.
189
198
  def get_magnetic_flux_density_callback_configuration
190
- send_request FUNCTION_GET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
199
+ check_validity
200
+
201
+ send_request FUNCTION_GET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
191
202
  end
192
203
 
193
204
  # Configures the data rate and background calibration.
@@ -202,15 +213,17 @@ module Tinkerforge
202
213
  # you will not get new data for a period of 20ms. We highly recommend that
203
214
  # you keep the background calibration enabled and only disable it if the 20ms
204
215
  # off-time is a problem in your application.
205
- #
206
- # Default values: Data rate of 100Hz and background calibration enabled.
207
216
  def set_configuration(data_rate, background_calibration)
208
- send_request FUNCTION_SET_CONFIGURATION, [data_rate, background_calibration], 'C ?', 0, ''
217
+ check_validity
218
+
219
+ send_request FUNCTION_SET_CONFIGURATION, [data_rate, background_calibration], 'C ?', 8, ''
209
220
  end
210
221
 
211
222
  # Returns the configuration as set by BrickletCompass#set_configuration.
212
223
  def get_configuration
213
- send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C ?'
224
+ check_validity
225
+
226
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C ?'
214
227
  end
215
228
 
216
229
  # Sets offset and gain for each of the three axes.
@@ -221,12 +234,16 @@ module Tinkerforge
221
234
  # The calibration is saved in non-volatile memory and only has to be
222
235
  # done once.
223
236
  def set_calibration(offset, gain)
224
- send_request FUNCTION_SET_CALIBRATION, [offset, gain], 's3 s3', 0, ''
237
+ check_validity
238
+
239
+ send_request FUNCTION_SET_CALIBRATION, [offset, gain], 's3 s3', 8, ''
225
240
  end
226
241
 
227
242
  # Returns the calibration parameters as set by BrickletCompass#set_calibration.
228
243
  def get_calibration
229
- send_request FUNCTION_GET_CALIBRATION, [], '', 12, 's3 s3'
244
+ check_validity
245
+
246
+ send_request FUNCTION_GET_CALIBRATION, [], '', 20, 's3 s3'
230
247
  end
231
248
 
232
249
  # Returns the error count for the communication between Brick and Bricklet.
@@ -241,7 +258,9 @@ module Tinkerforge
241
258
  # The errors counts are for errors that occur on the Bricklet side. All
242
259
  # Bricks have a similar function that returns the errors on the Brick side.
243
260
  def get_spitfp_error_count
244
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
261
+ check_validity
262
+
263
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
245
264
  end
246
265
 
247
266
  # Sets the bootloader mode and returns the status after the requested
@@ -254,12 +273,16 @@ module Tinkerforge
254
273
  # This function is used by Brick Viewer during flashing. It should not be
255
274
  # necessary to call it in a normal user program.
256
275
  def set_bootloader_mode(mode)
257
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
276
+ check_validity
277
+
278
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
258
279
  end
259
280
 
260
281
  # Returns the current bootloader mode, see BrickletCompass#set_bootloader_mode.
261
282
  def get_bootloader_mode
262
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
283
+ check_validity
284
+
285
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
263
286
  end
264
287
 
265
288
  # Sets the firmware pointer for BrickletCompass#write_firmware. The pointer has
@@ -269,7 +292,9 @@ module Tinkerforge
269
292
  # This function is used by Brick Viewer during flashing. It should not be
270
293
  # necessary to call it in a normal user program.
271
294
  def set_write_firmware_pointer(pointer)
272
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
295
+ check_validity
296
+
297
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
273
298
  end
274
299
 
275
300
  # Writes 64 Bytes of firmware at the position as written by
@@ -281,7 +306,9 @@ module Tinkerforge
281
306
  # This function is used by Brick Viewer during flashing. It should not be
282
307
  # necessary to call it in a normal user program.
283
308
  def write_firmware(data)
284
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
309
+ check_validity
310
+
311
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
285
312
  end
286
313
 
287
314
  # Sets the status LED configuration. By default the LED shows
@@ -292,22 +319,28 @@ module Tinkerforge
292
319
  #
293
320
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
294
321
  def set_status_led_config(config)
295
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
322
+ check_validity
323
+
324
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
296
325
  end
297
326
 
298
327
  # Returns the configuration as set by BrickletCompass#set_status_led_config
299
328
  def get_status_led_config
300
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
329
+ check_validity
330
+
331
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
301
332
  end
302
333
 
303
- # Returns the temperature in °C as measured inside the microcontroller. The
334
+ # Returns the temperature as measured inside the microcontroller. The
304
335
  # value returned is not the ambient temperature!
305
336
  #
306
337
  # The temperature is only proportional to the real temperature and it has bad
307
338
  # accuracy. Practically it is only useful as an indicator for
308
339
  # temperature changes.
309
340
  def get_chip_temperature
310
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
341
+ check_validity
342
+
343
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
311
344
  end
312
345
 
313
346
  # Calling this function will reset the Bricklet. All configurations
@@ -317,7 +350,9 @@ module Tinkerforge
317
350
  # calling functions on the existing ones will result in
318
351
  # undefined behavior!
319
352
  def reset
320
- send_request FUNCTION_RESET, [], '', 0, ''
353
+ check_validity
354
+
355
+ send_request FUNCTION_RESET, [], '', 8, ''
321
356
  end
322
357
 
323
358
  # Writes a new UID into flash. If you want to set a new UID
@@ -326,25 +361,31 @@ module Tinkerforge
326
361
  #
327
362
  # We recommend that you use Brick Viewer to change the UID.
328
363
  def write_uid(uid)
329
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
364
+ check_validity
365
+
366
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
330
367
  end
331
368
 
332
369
  # Returns the current UID as an integer. Encode as
333
370
  # Base58 to get the usual string version.
334
371
  def read_uid
335
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
372
+ check_validity
373
+
374
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
336
375
  end
337
376
 
338
377
  # Returns the UID, the UID where the Bricklet is connected to,
339
378
  # the position, the hardware and firmware version as well as the
340
379
  # device identifier.
341
380
  #
342
- # The position can be 'a', 'b', 'c' or 'd'.
381
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
382
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
383
+ # position 'z'.
343
384
  #
344
385
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
345
386
  # |device_identifier_constant|
346
387
  def get_identity
347
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
388
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
348
389
  end
349
390
 
350
391
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
5
+ # Ruby Bindings Version 2.1.28 #
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 AC/DC current between -12.5A and +12.5A
14
16
  class BrickletCurrent12 < Device
@@ -76,7 +78,7 @@ module Tinkerforge
76
78
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
77
79
  # the IP Connection <tt>ipcon</tt>.
78
80
  def initialize(uid, ipcon)
79
- super uid, ipcon
81
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
80
82
 
81
83
  @api_version = [2, 0, 0]
82
84
 
@@ -96,22 +98,24 @@ module Tinkerforge
96
98
  @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
97
99
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
98
100
 
99
- @callback_formats[CALLBACK_CURRENT] = 's'
100
- @callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
101
- @callback_formats[CALLBACK_CURRENT_REACHED] = 's'
102
- @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
103
- @callback_formats[CALLBACK_OVER_CURRENT] = ''
101
+ @callback_formats[CALLBACK_CURRENT] = [10, 's']
102
+ @callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
103
+ @callback_formats[CALLBACK_CURRENT_REACHED] = [10, 's']
104
+ @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
105
+ @callback_formats[CALLBACK_OVER_CURRENT] = [8, '']
104
106
 
107
+ @ipcon.add_device self
105
108
  end
106
109
 
107
- # Returns the current of the sensor. The value is in mA
108
- # and between -12500mA and 12500mA.
110
+ # Returns the current of the sensor.
109
111
  #
110
112
  # If you want to get the current periodically, it is recommended to use the
111
113
  # CALLBACK_CURRENT callback and set the period with
112
114
  # BrickletCurrent12#set_current_callback_period.
113
115
  def get_current
114
- send_request FUNCTION_GET_CURRENT, [], '', 2, 's'
116
+ check_validity
117
+
118
+ send_request FUNCTION_GET_CURRENT, [], '', 10, 's'
115
119
  end
116
120
 
117
121
  # Calibrates the 0 value of the sensor. You have to call this function
@@ -126,7 +130,9 @@ module Tinkerforge
126
130
  # The resulting calibration will be saved on the EEPROM of the Current
127
131
  # Bricklet.
128
132
  def calibrate
129
- send_request FUNCTION_CALIBRATE, [], '', 0, ''
133
+ check_validity
134
+
135
+ send_request FUNCTION_CALIBRATE, [], '', 8, ''
130
136
  end
131
137
 
132
138
  # Returns *true* if more than 12.5A were measured.
@@ -134,11 +140,12 @@ module Tinkerforge
134
140
  # .. note::
135
141
  # To reset this value you have to power cycle the Bricklet.
136
142
  def is_over_current
137
- send_request FUNCTION_IS_OVER_CURRENT, [], '', 1, '?'
143
+ check_validity
144
+
145
+ send_request FUNCTION_IS_OVER_CURRENT, [], '', 9, '?'
138
146
  end
139
147
 
140
148
  # Returns the value as read by a 12-bit analog-to-digital converter.
141
- # The value is between 0 and 4095.
142
149
  #
143
150
  # .. note::
144
151
  # The value returned by BrickletCurrent12#get_current is averaged over several samples
@@ -150,39 +157,45 @@ module Tinkerforge
150
157
  # CALLBACK_ANALOG_VALUE callback and set the period with
151
158
  # BrickletCurrent12#set_analog_value_callback_period.
152
159
  def get_analog_value
153
- send_request FUNCTION_GET_ANALOG_VALUE, [], '', 2, 'S'
160
+ check_validity
161
+
162
+ send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
154
163
  end
155
164
 
156
- # Sets the period in ms with which the CALLBACK_CURRENT callback is triggered
165
+ # Sets the period with which the CALLBACK_CURRENT callback is triggered
157
166
  # periodically. A value of 0 turns the callback off.
158
167
  #
159
168
  # The CALLBACK_CURRENT callback is only triggered if the current has changed since
160
169
  # the last triggering.
161
- #
162
- # The default value is 0.
163
170
  def set_current_callback_period(period)
164
- send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 0, ''
171
+ check_validity
172
+
173
+ send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 8, ''
165
174
  end
166
175
 
167
176
  # Returns the period as set by BrickletCurrent12#set_current_callback_period.
168
177
  def get_current_callback_period
169
- send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 4, 'L'
178
+ check_validity
179
+
180
+ send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 12, 'L'
170
181
  end
171
182
 
172
- # Sets the period in ms with which the CALLBACK_ANALOG_VALUE callback is triggered
183
+ # Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
173
184
  # periodically. A value of 0 turns the callback off.
174
185
  #
175
186
  # The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
176
187
  # changed since the last triggering.
177
- #
178
- # The default value is 0.
179
188
  def set_analog_value_callback_period(period)
180
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 0, ''
189
+ check_validity
190
+
191
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
181
192
  end
182
193
 
183
194
  # Returns the period as set by BrickletCurrent12#set_analog_value_callback_period.
184
195
  def get_analog_value_callback_period
185
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 4, 'L'
196
+ check_validity
197
+
198
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
186
199
  end
187
200
 
188
201
  # Sets the thresholds for the CALLBACK_CURRENT_REACHED callback.
@@ -196,15 +209,17 @@ module Tinkerforge
196
209
  # "'i'", "Callback is triggered when the current is *inside* the min and max values"
197
210
  # "'<'", "Callback is triggered when the current is smaller than the min value (max is ignored)"
198
211
  # "'>'", "Callback is triggered when the current is greater than the min value (max is ignored)"
199
- #
200
- # The default value is ('x', 0, 0).
201
212
  def set_current_callback_threshold(option, min, max)
202
- send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 0, ''
213
+ check_validity
214
+
215
+ send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, ''
203
216
  end
204
217
 
205
218
  # Returns the threshold as set by BrickletCurrent12#set_current_callback_threshold.
206
219
  def get_current_callback_threshold
207
- send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 5, 'k s s'
220
+ check_validity
221
+
222
+ send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
208
223
  end
209
224
 
210
225
  # Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
@@ -218,18 +233,20 @@ module Tinkerforge
218
233
  # "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
219
234
  # "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
220
235
  # "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
221
- #
222
- # The default value is ('x', 0, 0).
223
236
  def set_analog_value_callback_threshold(option, min, max)
224
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, ''
237
+ check_validity
238
+
239
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
225
240
  end
226
241
 
227
242
  # Returns the threshold as set by BrickletCurrent12#set_analog_value_callback_threshold.
228
243
  def get_analog_value_callback_threshold
229
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 5, 'k S S'
244
+ check_validity
245
+
246
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
230
247
  end
231
248
 
232
- # Sets the period in ms with which the threshold callbacks
249
+ # Sets the period with which the threshold callbacks
233
250
  #
234
251
  # * CALLBACK_CURRENT_REACHED,
235
252
  # * CALLBACK_ANALOG_VALUE_REACHED
@@ -240,27 +257,31 @@ module Tinkerforge
240
257
  # * BrickletCurrent12#set_analog_value_callback_threshold
241
258
  #
242
259
  # keep being reached.
243
- #
244
- # The default value is 100.
245
260
  def set_debounce_period(debounce)
246
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
261
+ check_validity
262
+
263
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
247
264
  end
248
265
 
249
266
  # Returns the debounce period as set by BrickletCurrent12#set_debounce_period.
250
267
  def get_debounce_period
251
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
268
+ check_validity
269
+
270
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
252
271
  end
253
272
 
254
273
  # Returns the UID, the UID where the Bricklet is connected to,
255
274
  # the position, the hardware and firmware version as well as the
256
275
  # device identifier.
257
276
  #
258
- # The position can be 'a', 'b', 'c' or 'd'.
277
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
278
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
279
+ # position 'z'.
259
280
  #
260
281
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
261
282
  # |device_identifier_constant|
262
283
  def get_identity
263
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
284
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
264
285
  end
265
286
 
266
287
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.