tinkerforge 2.1.24 → 2.1.25

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 (142) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +155 -74
  3. data/lib/tinkerforge/brick_hat.rb +70 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +56 -22
  5. data/lib/tinkerforge/brick_imu.rb +184 -77
  6. data/lib/tinkerforge/brick_imu_v2.rb +208 -105
  7. data/lib/tinkerforge/brick_master.rb +484 -182
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +185 -101
  10. data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
  11. data/lib/tinkerforge/brick_stepper.rb +210 -98
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
  18. data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +66 -26
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -18
  27. data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +34 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
  30. data/lib/tinkerforge/bricklet_color.rb +69 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +78 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +58 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +58 -24
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
  37. data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
  39. data/lib/tinkerforge/bricklet_dmx.rb +88 -34
  40. data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
  46. data/lib/tinkerforge/bricklet_gps.rb +64 -26
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
  50. data/lib/tinkerforge/bricklet_humidity.rb +51 -21
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
  52. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
  53. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
  54. data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
  55. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
  57. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
  59. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
  62. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
  64. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
  65. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
  66. data/lib/tinkerforge/bricklet_io16.rb +55 -21
  67. data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
  68. data/lib/tinkerforge/bricklet_io4.rb +55 -23
  69. data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
  70. data/lib/tinkerforge/bricklet_isolator.rb +72 -28
  71. data/lib/tinkerforge/bricklet_joystick.rb +59 -25
  72. data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
  73. data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
  74. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
  75. data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
  76. data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
  77. data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
  78. data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
  79. data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
  80. data/lib/tinkerforge/bricklet_line.rb +34 -14
  81. data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
  82. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
  83. data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
  84. data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
  85. data/lib/tinkerforge/bricklet_moisture.rb +40 -16
  86. data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
  87. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
  88. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
  89. data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
  90. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
  91. data/lib/tinkerforge/bricklet_nfc.rb +123 -58
  92. data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
  93. data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
  94. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
  95. data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
  96. data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
  97. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
  98. data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
  99. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
  100. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
  101. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
  102. data/lib/tinkerforge/bricklet_ptc.rb +74 -42
  103. data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
  104. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
  105. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
  106. data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
  107. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
  108. data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
  109. data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
  110. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
  111. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
  112. data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
  113. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
  114. data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
  115. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
  116. data/lib/tinkerforge/bricklet_rs232.rb +90 -28
  117. data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
  118. data/lib/tinkerforge/bricklet_rs485.rb +223 -95
  119. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
  120. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
  121. data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
  122. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
  123. data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
  124. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
  125. data/lib/tinkerforge/bricklet_temperature.rb +40 -16
  126. data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
  127. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
  128. data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
  129. data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
  130. data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
  131. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
  132. data/lib/tinkerforge/bricklet_tilt.rb +24 -10
  133. data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
  134. data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
  135. data/lib/tinkerforge/bricklet_voltage.rb +52 -28
  136. data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
  137. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
  138. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
  139. data/lib/tinkerforge/device_display_names.rb +163 -0
  140. data/lib/tinkerforge/ip_connection.rb +151 -32
  141. data/lib/tinkerforge/version.rb +1 -1
  142. metadata +3 -2
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 power, DC voltage and DC current up to 720W/36V/20A
14
16
  class BrickletVoltageCurrent < Device
@@ -99,11 +101,19 @@ module Tinkerforge
99
101
  THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
100
102
  THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
101
103
  THRESHOLD_OPTION_GREATER = '>' # :nodoc:
104
+ CONVERSION_TIME_140US = 0 # :nodoc:
105
+ CONVERSION_TIME_204US = 1 # :nodoc:
106
+ CONVERSION_TIME_332US = 2 # :nodoc:
107
+ CONVERSION_TIME_588US = 3 # :nodoc:
108
+ CONVERSION_TIME_1_1MS = 4 # :nodoc:
109
+ CONVERSION_TIME_2_116MS = 5 # :nodoc:
110
+ CONVERSION_TIME_4_156MS = 6 # :nodoc:
111
+ CONVERSION_TIME_8_244MS = 7 # :nodoc:
102
112
 
103
113
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
104
114
  # the IP Connection <tt>ipcon</tt>.
105
115
  def initialize(uid, ipcon)
106
- super uid, ipcon
116
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
107
117
 
108
118
  @api_version = [2, 0, 0]
109
119
 
@@ -130,84 +140,63 @@ module Tinkerforge
130
140
  @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
131
141
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
132
142
 
133
- @callback_formats[CALLBACK_CURRENT] = 'l'
134
- @callback_formats[CALLBACK_VOLTAGE] = 'l'
135
- @callback_formats[CALLBACK_POWER] = 'l'
136
- @callback_formats[CALLBACK_CURRENT_REACHED] = 'l'
137
- @callback_formats[CALLBACK_VOLTAGE_REACHED] = 'l'
138
- @callback_formats[CALLBACK_POWER_REACHED] = 'l'
143
+ @callback_formats[CALLBACK_CURRENT] = [12, 'l']
144
+ @callback_formats[CALLBACK_VOLTAGE] = [12, 'l']
145
+ @callback_formats[CALLBACK_POWER] = [12, 'l']
146
+ @callback_formats[CALLBACK_CURRENT_REACHED] = [12, 'l']
147
+ @callback_formats[CALLBACK_VOLTAGE_REACHED] = [12, 'l']
148
+ @callback_formats[CALLBACK_POWER_REACHED] = [12, 'l']
139
149
 
150
+ @ipcon.add_device self
140
151
  end
141
152
 
142
- # Returns the current. The value is in mA
143
- # and between -20000mA and 20000mA.
153
+ # Returns the current.
144
154
  #
145
155
  # If you want to get the current periodically, it is recommended to use the
146
156
  # CALLBACK_CURRENT callback and set the period with
147
157
  # BrickletVoltageCurrent#set_current_callback_period.
148
158
  def get_current
149
- send_request FUNCTION_GET_CURRENT, [], '', 4, 'l'
159
+ check_validity
160
+
161
+ send_request FUNCTION_GET_CURRENT, [], '', 12, 'l'
150
162
  end
151
163
 
152
- # Returns the voltage. The value is in mV
153
- # and between 0mV and 36000mV.
164
+ # Returns the voltage.
154
165
  #
155
166
  # If you want to get the voltage periodically, it is recommended to use the
156
167
  # CALLBACK_VOLTAGE callback and set the period with
157
168
  # BrickletVoltageCurrent#set_voltage_callback_period.
158
169
  def get_voltage
159
- send_request FUNCTION_GET_VOLTAGE, [], '', 4, 'l'
170
+ check_validity
171
+
172
+ send_request FUNCTION_GET_VOLTAGE, [], '', 12, 'l'
160
173
  end
161
174
 
162
- # Returns the power. The value is in mW
163
- # and between 0mV and 720000mW.
175
+ # Returns the power.
164
176
  #
165
177
  # If you want to get the power periodically, it is recommended to use the
166
178
  # CALLBACK_POWER callback and set the period with
167
179
  # BrickletVoltageCurrent#set_power_callback_period.
168
180
  def get_power
169
- send_request FUNCTION_GET_POWER, [], '', 4, 'l'
181
+ check_validity
182
+
183
+ send_request FUNCTION_GET_POWER, [], '', 12, 'l'
170
184
  end
171
185
 
172
186
  # Sets the configuration of the Voltage/Current Bricklet. It is
173
187
  # possible to configure number of averages as well as
174
188
  # voltage and current conversion time.
175
- #
176
- # Averaging:
177
- #
178
- # "Value", "Number of Averages"
179
- #
180
- # "0", "1"
181
- # "1", "4"
182
- # "2", "16"
183
- # "3", "64"
184
- # "4", "128"
185
- # "5", "256"
186
- # "6", "512"
187
- # ">=7", "1024"
188
- #
189
- # Voltage/Current conversion:
190
- #
191
- # "Value", "Conversion time"
192
- #
193
- # "0", "140µs"
194
- # "1", "204µs"
195
- # "2", "332µs"
196
- # "3", "588µs"
197
- # "4", "1.1ms"
198
- # "5", "2.116ms"
199
- # "6", "4.156ms"
200
- # ">=7", "8.244ms"
201
- #
202
- # The default values are 3, 4 and 4 (64, 1.1ms, 1.1ms) for averaging, voltage
203
- # conversion and current conversion.
204
189
  def set_configuration(averaging, voltage_conversion_time, current_conversion_time)
205
- send_request FUNCTION_SET_CONFIGURATION, [averaging, voltage_conversion_time, current_conversion_time], 'C C C', 0, ''
190
+ check_validity
191
+
192
+ send_request FUNCTION_SET_CONFIGURATION, [averaging, voltage_conversion_time, current_conversion_time], 'C C C', 8, ''
206
193
  end
207
194
 
208
195
  # Returns the configuration as set by BrickletVoltageCurrent#set_configuration.
209
196
  def get_configuration
210
- send_request FUNCTION_GET_CONFIGURATION, [], '', 3, 'C C C'
197
+ check_validity
198
+
199
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 11, 'C C C'
211
200
  end
212
201
 
213
202
  # Since the shunt resistor that is used to measure the current is not
@@ -218,12 +207,16 @@ module Tinkerforge
218
207
  # are measuring 1023mA, you can calibrate the Voltage/Current Bricklet
219
208
  # by setting the multiplier to 1000 and the divisor to 1023.
220
209
  def set_calibration(gain_multiplier, gain_divisor)
221
- send_request FUNCTION_SET_CALIBRATION, [gain_multiplier, gain_divisor], 'S S', 0, ''
210
+ check_validity
211
+
212
+ send_request FUNCTION_SET_CALIBRATION, [gain_multiplier, gain_divisor], 'S S', 8, ''
222
213
  end
223
214
 
224
215
  # Returns the calibration as set by BrickletVoltageCurrent#set_calibration.
225
216
  def get_calibration
226
- send_request FUNCTION_GET_CALIBRATION, [], '', 4, 'S S'
217
+ check_validity
218
+
219
+ send_request FUNCTION_GET_CALIBRATION, [], '', 12, 'S S'
227
220
  end
228
221
 
229
222
  # Sets the period with which the CALLBACK_CURRENT callback is triggered
@@ -232,12 +225,16 @@ module Tinkerforge
232
225
  # The CALLBACK_CURRENT callback is only triggered if the current has changed since
233
226
  # the last triggering.
234
227
  def set_current_callback_period(period)
235
- send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 0, ''
228
+ check_validity
229
+
230
+ send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 8, ''
236
231
  end
237
232
 
238
233
  # Returns the period as set by BrickletVoltageCurrent#set_current_callback_period.
239
234
  def get_current_callback_period
240
- send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 4, 'L'
235
+ check_validity
236
+
237
+ send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 12, 'L'
241
238
  end
242
239
 
243
240
  # Sets the period with which the CALLBACK_VOLTAGE callback is triggered
@@ -246,12 +243,16 @@ module Tinkerforge
246
243
  # The CALLBACK_VOLTAGE callback is only triggered if the voltage has changed since
247
244
  # the last triggering.
248
245
  def set_voltage_callback_period(period)
249
- send_request FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 0, ''
246
+ check_validity
247
+
248
+ send_request FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 8, ''
250
249
  end
251
250
 
252
251
  # Returns the period as set by BrickletVoltageCurrent#set_voltage_callback_period.
253
252
  def get_voltage_callback_period
254
- send_request FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [], '', 4, 'L'
253
+ check_validity
254
+
255
+ send_request FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [], '', 12, 'L'
255
256
  end
256
257
 
257
258
  # Sets the period with which the CALLBACK_POWER callback is triggered
@@ -260,12 +261,16 @@ module Tinkerforge
260
261
  # The CALLBACK_POWER callback is only triggered if the power has changed since the
261
262
  # last triggering.
262
263
  def set_power_callback_period(period)
263
- send_request FUNCTION_SET_POWER_CALLBACK_PERIOD, [period], 'L', 0, ''
264
+ check_validity
265
+
266
+ send_request FUNCTION_SET_POWER_CALLBACK_PERIOD, [period], 'L', 8, ''
264
267
  end
265
268
 
266
269
  # Returns the period as set by BrickletVoltageCurrent#get_power_callback_period.
267
270
  def get_power_callback_period
268
- send_request FUNCTION_GET_POWER_CALLBACK_PERIOD, [], '', 4, 'L'
271
+ check_validity
272
+
273
+ send_request FUNCTION_GET_POWER_CALLBACK_PERIOD, [], '', 12, 'L'
269
274
  end
270
275
 
271
276
  # Sets the thresholds for the CALLBACK_CURRENT_REACHED callback.
@@ -279,15 +284,17 @@ module Tinkerforge
279
284
  # "'i'", "Callback is triggered when the current is *inside* the min and max values"
280
285
  # "'<'", "Callback is triggered when the current is smaller than the min value (max is ignored)"
281
286
  # "'>'", "Callback is triggered when the current is greater than the min value (max is ignored)"
282
- #
283
- # The default value is ('x', 0, 0).
284
287
  def set_current_callback_threshold(option, min, max)
285
- send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, ''
288
+ check_validity
289
+
290
+ send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
286
291
  end
287
292
 
288
293
  # Returns the threshold as set by BrickletVoltageCurrent#set_current_callback_threshold.
289
294
  def get_current_callback_threshold
290
- send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 9, 'k l l'
295
+ check_validity
296
+
297
+ send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
291
298
  end
292
299
 
293
300
  # Sets the thresholds for the CALLBACK_VOLTAGE_REACHED callback.
@@ -301,15 +308,17 @@ module Tinkerforge
301
308
  # "'i'", "Callback is triggered when the voltage is *inside* the min and max values"
302
309
  # "'<'", "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
303
310
  # "'>'", "Callback is triggered when the voltage is greater than the min value (max is ignored)"
304
- #
305
- # The default value is ('x', 0, 0).
306
311
  def set_voltage_callback_threshold(option, min, max)
307
- send_request FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, ''
312
+ check_validity
313
+
314
+ send_request FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
308
315
  end
309
316
 
310
317
  # Returns the threshold as set by BrickletVoltageCurrent#set_voltage_callback_threshold.
311
318
  def get_voltage_callback_threshold
312
- send_request FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 9, 'k l l'
319
+ check_validity
320
+
321
+ send_request FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
313
322
  end
314
323
 
315
324
  # Sets the thresholds for the CALLBACK_POWER_REACHED callback.
@@ -323,15 +332,17 @@ module Tinkerforge
323
332
  # "'i'", "Callback is triggered when the power is *inside* the min and max values"
324
333
  # "'<'", "Callback is triggered when the power is smaller than the min value (max is ignored)"
325
334
  # "'>'", "Callback is triggered when the power is greater than the min value (max is ignored)"
326
- #
327
- # The default value is ('x', 0, 0).
328
335
  def set_power_callback_threshold(option, min, max)
329
- send_request FUNCTION_SET_POWER_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, ''
336
+ check_validity
337
+
338
+ send_request FUNCTION_SET_POWER_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
330
339
  end
331
340
 
332
341
  # Returns the threshold as set by BrickletVoltageCurrent#set_power_callback_threshold.
333
342
  def get_power_callback_threshold
334
- send_request FUNCTION_GET_POWER_CALLBACK_THRESHOLD, [], '', 9, 'k l l'
343
+ check_validity
344
+
345
+ send_request FUNCTION_GET_POWER_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
335
346
  end
336
347
 
337
348
  # Sets the period with which the threshold callbacks
@@ -348,24 +359,31 @@ module Tinkerforge
348
359
  #
349
360
  # keep being reached.
350
361
  def set_debounce_period(debounce)
351
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
362
+ check_validity
363
+
364
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
352
365
  end
353
366
 
354
367
  # Returns the debounce period as set by BrickletVoltageCurrent#set_debounce_period.
355
368
  def get_debounce_period
356
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
369
+ check_validity
370
+
371
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
357
372
  end
358
373
 
359
374
  # Returns the UID, the UID where the Bricklet is connected to,
360
375
  # the position, the hardware and firmware version as well as the
361
376
  # device identifier.
362
377
  #
363
- # The position can be 'a', 'b', 'c' or 'd'.
378
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
379
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
380
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
381
+ # position 'z'.
364
382
  #
365
383
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
366
384
  # |device_identifier_constant|
367
385
  def get_identity
368
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
386
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
369
387
  end
370
388
 
371
389
  # 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-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 power, DC voltage and DC current up to 720W/36V/20A
14
16
  class BrickletVoltageCurrentV2 < Device
@@ -99,7 +101,7 @@ module Tinkerforge
99
101
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
100
102
  # the IP Connection <tt>ipcon</tt>.
101
103
  def initialize(uid, ipcon)
102
- super uid, ipcon
104
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
103
105
 
104
106
  @api_version = [2, 0, 0]
105
107
 
@@ -129,21 +131,23 @@ module Tinkerforge
129
131
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
130
132
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
131
133
 
132
- @callback_formats[CALLBACK_CURRENT] = 'l'
133
- @callback_formats[CALLBACK_VOLTAGE] = 'l'
134
- @callback_formats[CALLBACK_POWER] = 'l'
134
+ @callback_formats[CALLBACK_CURRENT] = [12, 'l']
135
+ @callback_formats[CALLBACK_VOLTAGE] = [12, 'l']
136
+ @callback_formats[CALLBACK_POWER] = [12, 'l']
135
137
 
138
+ @ipcon.add_device self
136
139
  end
137
140
 
138
- # Returns the current. The value is in mA
139
- # and between -20000mA and 20000mA.
141
+ # Returns the current.
140
142
  #
141
143
  #
142
144
  # If you want to get the value periodically, it is recommended to use the
143
145
  # CALLBACK_CURRENT callback. You can set the callback configuration
144
146
  # with BrickletVoltageCurrentV2#set_current_callback_configuration.
145
147
  def get_current
146
- send_request FUNCTION_GET_CURRENT, [], '', 4, 'l'
148
+ check_validity
149
+
150
+ send_request FUNCTION_GET_CURRENT, [], '', 12, 'l'
147
151
  end
148
152
 
149
153
  # The period is the period with which the CALLBACK_CURRENT callback is triggered
@@ -172,23 +176,28 @@ module Tinkerforge
172
176
  #
173
177
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
174
178
  def set_current_callback_configuration(period, value_has_to_change, option, min, max)
175
- send_request FUNCTION_SET_CURRENT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
179
+ check_validity
180
+
181
+ send_request FUNCTION_SET_CURRENT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
176
182
  end
177
183
 
178
184
  # Returns the callback configuration as set by BrickletVoltageCurrentV2#set_current_callback_configuration.
179
185
  def get_current_callback_configuration
180
- send_request FUNCTION_GET_CURRENT_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
186
+ check_validity
187
+
188
+ send_request FUNCTION_GET_CURRENT_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
181
189
  end
182
190
 
183
- # Returns the voltage. The value is in mV
184
- # and between 0mV and 36000mV.
191
+ # Returns the voltage.
185
192
  #
186
193
  #
187
194
  # If you want to get the value periodically, it is recommended to use the
188
195
  # CALLBACK_VOLTAGE callback. You can set the callback configuration
189
196
  # with BrickletVoltageCurrentV2#set_voltage_callback_configuration.
190
197
  def get_voltage
191
- send_request FUNCTION_GET_VOLTAGE, [], '', 4, 'l'
198
+ check_validity
199
+
200
+ send_request FUNCTION_GET_VOLTAGE, [], '', 12, 'l'
192
201
  end
193
202
 
194
203
  # The period is the period with which the CALLBACK_VOLTAGE callback is triggered
@@ -217,23 +226,28 @@ module Tinkerforge
217
226
  #
218
227
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
219
228
  def set_voltage_callback_configuration(period, value_has_to_change, option, min, max)
220
- send_request FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
229
+ check_validity
230
+
231
+ send_request FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
221
232
  end
222
233
 
223
234
  # Returns the callback configuration as set by BrickletVoltageCurrentV2#set_voltage_callback_configuration.
224
235
  def get_voltage_callback_configuration
225
- send_request FUNCTION_GET_VOLTAGE_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
236
+ check_validity
237
+
238
+ send_request FUNCTION_GET_VOLTAGE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
226
239
  end
227
240
 
228
- # Returns the power. The value is in mW
229
- # and between 0mV and 720000mW.
241
+ # Returns the power.
230
242
  #
231
243
  #
232
244
  # If you want to get the value periodically, it is recommended to use the
233
245
  # CALLBACK_POWER callback. You can set the callback configuration
234
246
  # with BrickletVoltageCurrentV2#set_power_callback_configuration.
235
247
  def get_power
236
- send_request FUNCTION_GET_POWER, [], '', 4, 'l'
248
+ check_validity
249
+
250
+ send_request FUNCTION_GET_POWER, [], '', 12, 'l'
237
251
  end
238
252
 
239
253
  # The period is the period with which the CALLBACK_POWER callback is triggered
@@ -262,53 +276,32 @@ module Tinkerforge
262
276
  #
263
277
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
264
278
  def set_power_callback_configuration(period, value_has_to_change, option, min, max)
265
- send_request FUNCTION_SET_POWER_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
279
+ check_validity
280
+
281
+ send_request FUNCTION_SET_POWER_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
266
282
  end
267
283
 
268
284
  # Returns the callback configuration as set by BrickletVoltageCurrentV2#set_power_callback_configuration.
269
285
  def get_power_callback_configuration
270
- send_request FUNCTION_GET_POWER_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
286
+ check_validity
287
+
288
+ send_request FUNCTION_GET_POWER_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
271
289
  end
272
290
 
273
291
  # Sets the configuration of the Voltage/Current Bricklet 2.0. It is
274
292
  # possible to configure number of averages as well as
275
293
  # voltage and current conversion time.
276
- #
277
- # Averaging:
278
- #
279
- # "Value", "Number of Averages"
280
- #
281
- # "0", "1"
282
- # "1", "4"
283
- # "2", "16"
284
- # "3", "64"
285
- # "4", "128"
286
- # "5", "256"
287
- # "6", "512"
288
- # ">=7", "1024"
289
- #
290
- # Voltage/Current conversion:
291
- #
292
- # "Value", "Conversion time"
293
- #
294
- # "0", "140µs"
295
- # "1", "204µs"
296
- # "2", "332µs"
297
- # "3", "588µs"
298
- # "4", "1.1ms"
299
- # "5", "2.116ms"
300
- # "6", "4.156ms"
301
- # ">=7", "8.244ms"
302
- #
303
- # The default values are 3, 4 and 4 (64, 1.1ms, 1.1ms) for averaging, voltage
304
- # conversion and current conversion.
305
294
  def set_configuration(averaging, voltage_conversion_time, current_conversion_time)
306
- send_request FUNCTION_SET_CONFIGURATION, [averaging, voltage_conversion_time, current_conversion_time], 'C C C', 0, ''
295
+ check_validity
296
+
297
+ send_request FUNCTION_SET_CONFIGURATION, [averaging, voltage_conversion_time, current_conversion_time], 'C C C', 8, ''
307
298
  end
308
299
 
309
300
  # Returns the configuration as set by BrickletVoltageCurrentV2#set_configuration.
310
301
  def get_configuration
311
- send_request FUNCTION_GET_CONFIGURATION, [], '', 3, 'C C C'
302
+ check_validity
303
+
304
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 11, 'C C C'
312
305
  end
313
306
 
314
307
  # Since the ADC and the shunt resistor used for the measurements
@@ -323,12 +316,16 @@ module Tinkerforge
323
316
  # The calibration will be saved on the EEPROM of the Voltage/Current
324
317
  # Bricklet and only needs to be done once.
325
318
  def set_calibration(voltage_multiplier, voltage_divisor, current_multiplier, current_divisor)
326
- send_request FUNCTION_SET_CALIBRATION, [voltage_multiplier, voltage_divisor, current_multiplier, current_divisor], 'S S S S', 0, ''
319
+ check_validity
320
+
321
+ send_request FUNCTION_SET_CALIBRATION, [voltage_multiplier, voltage_divisor, current_multiplier, current_divisor], 'S S S S', 8, ''
327
322
  end
328
323
 
329
324
  # Returns the calibration as set by BrickletVoltageCurrentV2#set_calibration.
330
325
  def get_calibration
331
- send_request FUNCTION_GET_CALIBRATION, [], '', 8, 'S S S S'
326
+ check_validity
327
+
328
+ send_request FUNCTION_GET_CALIBRATION, [], '', 16, 'S S S S'
332
329
  end
333
330
 
334
331
  # Returns the error count for the communication between Brick and Bricklet.
@@ -343,7 +340,9 @@ module Tinkerforge
343
340
  # The errors counts are for errors that occur on the Bricklet side. All
344
341
  # Bricks have a similar function that returns the errors on the Brick side.
345
342
  def get_spitfp_error_count
346
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
343
+ check_validity
344
+
345
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
347
346
  end
348
347
 
349
348
  # Sets the bootloader mode and returns the status after the requested
@@ -356,12 +355,16 @@ module Tinkerforge
356
355
  # This function is used by Brick Viewer during flashing. It should not be
357
356
  # necessary to call it in a normal user program.
358
357
  def set_bootloader_mode(mode)
359
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
358
+ check_validity
359
+
360
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
360
361
  end
361
362
 
362
363
  # Returns the current bootloader mode, see BrickletVoltageCurrentV2#set_bootloader_mode.
363
364
  def get_bootloader_mode
364
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
365
+ check_validity
366
+
367
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
365
368
  end
366
369
 
367
370
  # Sets the firmware pointer for BrickletVoltageCurrentV2#write_firmware. The pointer has
@@ -371,7 +374,9 @@ module Tinkerforge
371
374
  # This function is used by Brick Viewer during flashing. It should not be
372
375
  # necessary to call it in a normal user program.
373
376
  def set_write_firmware_pointer(pointer)
374
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
377
+ check_validity
378
+
379
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
375
380
  end
376
381
 
377
382
  # Writes 64 Bytes of firmware at the position as written by
@@ -383,7 +388,9 @@ module Tinkerforge
383
388
  # This function is used by Brick Viewer during flashing. It should not be
384
389
  # necessary to call it in a normal user program.
385
390
  def write_firmware(data)
386
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
391
+ check_validity
392
+
393
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
387
394
  end
388
395
 
389
396
  # Sets the status LED configuration. By default the LED shows
@@ -394,22 +401,28 @@ module Tinkerforge
394
401
  #
395
402
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
396
403
  def set_status_led_config(config)
397
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
404
+ check_validity
405
+
406
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
398
407
  end
399
408
 
400
409
  # Returns the configuration as set by BrickletVoltageCurrentV2#set_status_led_config
401
410
  def get_status_led_config
402
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
411
+ check_validity
412
+
413
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
403
414
  end
404
415
 
405
- # Returns the temperature in °C as measured inside the microcontroller. The
416
+ # Returns the temperature as measured inside the microcontroller. The
406
417
  # value returned is not the ambient temperature!
407
418
  #
408
419
  # The temperature is only proportional to the real temperature and it has bad
409
420
  # accuracy. Practically it is only useful as an indicator for
410
421
  # temperature changes.
411
422
  def get_chip_temperature
412
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
423
+ check_validity
424
+
425
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
413
426
  end
414
427
 
415
428
  # Calling this function will reset the Bricklet. All configurations
@@ -419,7 +432,9 @@ module Tinkerforge
419
432
  # calling functions on the existing ones will result in
420
433
  # undefined behavior!
421
434
  def reset
422
- send_request FUNCTION_RESET, [], '', 0, ''
435
+ check_validity
436
+
437
+ send_request FUNCTION_RESET, [], '', 8, ''
423
438
  end
424
439
 
425
440
  # Writes a new UID into flash. If you want to set a new UID
@@ -428,25 +443,32 @@ module Tinkerforge
428
443
  #
429
444
  # We recommend that you use Brick Viewer to change the UID.
430
445
  def write_uid(uid)
431
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
446
+ check_validity
447
+
448
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
432
449
  end
433
450
 
434
451
  # Returns the current UID as an integer. Encode as
435
452
  # Base58 to get the usual string version.
436
453
  def read_uid
437
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
454
+ check_validity
455
+
456
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
438
457
  end
439
458
 
440
459
  # Returns the UID, the UID where the Bricklet is connected to,
441
460
  # the position, the hardware and firmware version as well as the
442
461
  # device identifier.
443
462
  #
444
- # The position can be 'a', 'b', 'c' or 'd'.
463
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
464
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
465
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
466
+ # position 'z'.
445
467
  #
446
468
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
447
469
  # |device_identifier_constant|
448
470
  def get_identity
449
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
471
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
450
472
  end
451
473
 
452
474
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.