tinkerforge 2.1.24 → 2.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +69 -31
  4. data/lib/tinkerforge/brick_hat_zero.rb +55 -23
  5. data/lib/tinkerforge/brick_imu.rb +185 -78
  6. data/lib/tinkerforge/brick_imu_v2.rb +209 -106
  7. data/lib/tinkerforge/brick_master.rb +491 -183
  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 +247 -167
  11. data/lib/tinkerforge/brick_stepper.rb +211 -99
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
  18. data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +100 -27
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -19
  27. data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +33 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
  30. data/lib/tinkerforge/bricklet_color.rb +68 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +77 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +57 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +57 -24
  35. data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
  36. data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
  37. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
  38. data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
  39. data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
  40. data/lib/tinkerforge/bricklet_dmx.rb +87 -34
  41. data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
  42. data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
  43. data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
  44. data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
  45. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
  46. data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
  47. data/lib/tinkerforge/bricklet_gps.rb +63 -26
  48. data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
  49. data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
  50. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
  51. data/lib/tinkerforge/bricklet_humidity.rb +50 -21
  52. data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
  53. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  54. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
  55. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
  56. data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
  58. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
  60. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
  62. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
  65. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
  66. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
  67. data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
  68. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
  69. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
  70. data/lib/tinkerforge/bricklet_io16.rb +54 -21
  71. data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
  72. data/lib/tinkerforge/bricklet_io4.rb +54 -23
  73. data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
  74. data/lib/tinkerforge/bricklet_isolator.rb +72 -29
  75. data/lib/tinkerforge/bricklet_joystick.rb +58 -25
  76. data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
  77. data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
  78. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
  79. data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
  80. data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
  81. data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
  82. data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
  83. data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
  84. data/lib/tinkerforge/bricklet_line.rb +33 -14
  85. data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
  86. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
  87. data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
  88. data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
  89. data/lib/tinkerforge/bricklet_moisture.rb +39 -16
  90. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  91. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
  92. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
  93. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
  94. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
  95. data/lib/tinkerforge/bricklet_nfc.rb +126 -62
  96. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  97. data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
  98. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
  99. data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
  100. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  101. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
  102. data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
  103. data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
  104. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
  105. data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
  106. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
  107. data/lib/tinkerforge/bricklet_ptc.rb +73 -42
  108. data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
  109. data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
  110. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
  111. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  112. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  113. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  114. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  115. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  116. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  117. data/lib/tinkerforge/bricklet_rotary_encoder.rb +38 -19
  118. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
  119. data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
  120. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
  121. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  122. data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
  123. data/lib/tinkerforge/bricklet_rs485.rb +222 -95
  124. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  125. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
  126. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  127. data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
  128. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  129. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  130. data/lib/tinkerforge/bricklet_sound_intensity.rb +34 -18
  131. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
  132. data/lib/tinkerforge/bricklet_temperature.rb +39 -16
  133. data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
  134. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
  135. data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
  136. data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
  137. data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
  138. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
  139. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  140. data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
  141. data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
  142. data/lib/tinkerforge/bricklet_voltage.rb +51 -28
  143. data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
  144. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
  145. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
  146. data/lib/tinkerforge/device_display_names.rb +170 -0
  147. data/lib/tinkerforge/ip_connection.rb +153 -33
  148. data/lib/tinkerforge/version.rb +1 -1
  149. metadata +11 -3
@@ -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 2021-05-06. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.29 #
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
  # 59mm linear potentiometer
14
16
  class BrickletLinearPotiV2 < Device
@@ -61,7 +63,7 @@ module Tinkerforge
61
63
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
62
64
  # the IP Connection <tt>ipcon</tt>.
63
65
  def initialize(uid, ipcon)
64
- super uid, ipcon
66
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
65
67
 
66
68
  @api_version = [2, 0, 0]
67
69
 
@@ -81,8 +83,9 @@ module Tinkerforge
81
83
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
82
84
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
83
85
 
84
- @callback_formats[CALLBACK_POSITION] = 'C'
86
+ @callback_formats[CALLBACK_POSITION] = [9, 'C']
85
87
 
88
+ @ipcon.add_device self
86
89
  end
87
90
 
88
91
  # Returns the position of the linear potentiometer. The value is
@@ -93,7 +96,9 @@ module Tinkerforge
93
96
  # CALLBACK_POSITION callback. You can set the callback configuration
94
97
  # with BrickletLinearPotiV2#set_position_callback_configuration.
95
98
  def get_position
96
- send_request FUNCTION_GET_POSITION, [], '', 1, 'C'
99
+ check_validity
100
+
101
+ send_request FUNCTION_GET_POSITION, [], '', 9, 'C'
97
102
  end
98
103
 
99
104
  # The period is the period with which the CALLBACK_POSITION callback is triggered
@@ -122,12 +127,16 @@ module Tinkerforge
122
127
  #
123
128
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
124
129
  def set_position_callback_configuration(period, value_has_to_change, option, min, max)
125
- send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k C C', 0, ''
130
+ check_validity
131
+
132
+ send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k C C', 8, ''
126
133
  end
127
134
 
128
135
  # Returns the callback configuration as set by BrickletLinearPotiV2#set_position_callback_configuration.
129
136
  def get_position_callback_configuration
130
- send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 8, 'L ? k C C'
137
+ check_validity
138
+
139
+ send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 16, 'L ? k C C'
131
140
  end
132
141
 
133
142
  # Returns the error count for the communication between Brick and Bricklet.
@@ -142,7 +151,9 @@ module Tinkerforge
142
151
  # The errors counts are for errors that occur on the Bricklet side. All
143
152
  # Bricks have a similar function that returns the errors on the Brick side.
144
153
  def get_spitfp_error_count
145
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
154
+ check_validity
155
+
156
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
146
157
  end
147
158
 
148
159
  # Sets the bootloader mode and returns the status after the requested
@@ -155,12 +166,16 @@ module Tinkerforge
155
166
  # This function is used by Brick Viewer during flashing. It should not be
156
167
  # necessary to call it in a normal user program.
157
168
  def set_bootloader_mode(mode)
158
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
169
+ check_validity
170
+
171
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
159
172
  end
160
173
 
161
174
  # Returns the current bootloader mode, see BrickletLinearPotiV2#set_bootloader_mode.
162
175
  def get_bootloader_mode
163
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
176
+ check_validity
177
+
178
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
164
179
  end
165
180
 
166
181
  # Sets the firmware pointer for BrickletLinearPotiV2#write_firmware. The pointer has
@@ -170,7 +185,9 @@ module Tinkerforge
170
185
  # This function is used by Brick Viewer during flashing. It should not be
171
186
  # necessary to call it in a normal user program.
172
187
  def set_write_firmware_pointer(pointer)
173
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
188
+ check_validity
189
+
190
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
174
191
  end
175
192
 
176
193
  # Writes 64 Bytes of firmware at the position as written by
@@ -182,7 +199,9 @@ module Tinkerforge
182
199
  # This function is used by Brick Viewer during flashing. It should not be
183
200
  # necessary to call it in a normal user program.
184
201
  def write_firmware(data)
185
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
202
+ check_validity
203
+
204
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
186
205
  end
187
206
 
188
207
  # Sets the status LED configuration. By default the LED shows
@@ -193,22 +212,28 @@ module Tinkerforge
193
212
  #
194
213
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
195
214
  def set_status_led_config(config)
196
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
215
+ check_validity
216
+
217
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
197
218
  end
198
219
 
199
220
  # Returns the configuration as set by BrickletLinearPotiV2#set_status_led_config
200
221
  def get_status_led_config
201
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
222
+ check_validity
223
+
224
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
202
225
  end
203
226
 
204
- # Returns the temperature in °C as measured inside the microcontroller. The
227
+ # Returns the temperature as measured inside the microcontroller. The
205
228
  # value returned is not the ambient temperature!
206
229
  #
207
230
  # The temperature is only proportional to the real temperature and it has bad
208
231
  # accuracy. Practically it is only useful as an indicator for
209
232
  # temperature changes.
210
233
  def get_chip_temperature
211
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
234
+ check_validity
235
+
236
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
212
237
  end
213
238
 
214
239
  # Calling this function will reset the Bricklet. All configurations
@@ -218,7 +243,9 @@ module Tinkerforge
218
243
  # calling functions on the existing ones will result in
219
244
  # undefined behavior!
220
245
  def reset
221
- send_request FUNCTION_RESET, [], '', 0, ''
246
+ check_validity
247
+
248
+ send_request FUNCTION_RESET, [], '', 8, ''
222
249
  end
223
250
 
224
251
  # Writes a new UID into flash. If you want to set a new UID
@@ -227,25 +254,31 @@ module Tinkerforge
227
254
  #
228
255
  # We recommend that you use Brick Viewer to change the UID.
229
256
  def write_uid(uid)
230
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
257
+ check_validity
258
+
259
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
231
260
  end
232
261
 
233
262
  # Returns the current UID as an integer. Encode as
234
263
  # Base58 to get the usual string version.
235
264
  def read_uid
236
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
265
+ check_validity
266
+
267
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
237
268
  end
238
269
 
239
270
  # Returns the UID, the UID where the Bricklet is connected to,
240
271
  # the position, the hardware and firmware version as well as the
241
272
  # device identifier.
242
273
  #
243
- # The position can be 'a', 'b', 'c' or 'd'.
274
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
275
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
276
+ # position 'z'.
244
277
  #
245
278
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
246
279
  # |device_identifier_constant|
247
280
  def get_identity
248
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
281
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
249
282
  end
250
283
 
251
284
  # 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 2021-05-06. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.29 #
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 weight with a load cell
14
16
  class BrickletLoadCell < Device
@@ -63,7 +65,7 @@ module Tinkerforge
63
65
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
64
66
  # the IP Connection <tt>ipcon</tt>.
65
67
  def initialize(uid, ipcon)
66
- super uid, ipcon
68
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
67
69
 
68
70
  @api_version = [2, 0, 0]
69
71
 
@@ -85,9 +87,10 @@ module Tinkerforge
85
87
  @response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
86
88
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
87
89
 
88
- @callback_formats[CALLBACK_WEIGHT] = 'l'
89
- @callback_formats[CALLBACK_WEIGHT_REACHED] = 'l'
90
+ @callback_formats[CALLBACK_WEIGHT] = [12, 'l']
91
+ @callback_formats[CALLBACK_WEIGHT_REACHED] = [12, 'l']
90
92
 
93
+ @ipcon.add_device self
91
94
  end
92
95
 
93
96
  # Returns the currently measured weight.
@@ -96,7 +99,9 @@ module Tinkerforge
96
99
  # to use the CALLBACK_WEIGHT callback and set the period with
97
100
  # BrickletLoadCell#set_weight_callback_period.
98
101
  def get_weight
99
- send_request FUNCTION_GET_WEIGHT, [], '', 4, 'l'
102
+ check_validity
103
+
104
+ send_request FUNCTION_GET_WEIGHT, [], '', 12, 'l'
100
105
  end
101
106
 
102
107
  # Sets the period with which the CALLBACK_WEIGHT callback is triggered
@@ -105,12 +110,16 @@ module Tinkerforge
105
110
  # The CALLBACK_WEIGHT callback is only triggered if the weight has changed since the
106
111
  # last triggering.
107
112
  def set_weight_callback_period(period)
108
- send_request FUNCTION_SET_WEIGHT_CALLBACK_PERIOD, [period], 'L', 0, ''
113
+ check_validity
114
+
115
+ send_request FUNCTION_SET_WEIGHT_CALLBACK_PERIOD, [period], 'L', 8, ''
109
116
  end
110
117
 
111
118
  # Returns the period as set by BrickletLoadCell#set_weight_callback_period.
112
119
  def get_weight_callback_period
113
- send_request FUNCTION_GET_WEIGHT_CALLBACK_PERIOD, [], '', 4, 'L'
120
+ check_validity
121
+
122
+ send_request FUNCTION_GET_WEIGHT_CALLBACK_PERIOD, [], '', 12, 'L'
114
123
  end
115
124
 
116
125
  # Sets the thresholds for the CALLBACK_WEIGHT_REACHED callback.
@@ -125,12 +134,16 @@ module Tinkerforge
125
134
  # "'<'", "Callback is triggered when the weight is smaller than the min value (max is ignored)"
126
135
  # "'>'", "Callback is triggered when the weight is greater than the min value (max is ignored)"
127
136
  def set_weight_callback_threshold(option, min, max)
128
- send_request FUNCTION_SET_WEIGHT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, ''
137
+ check_validity
138
+
139
+ send_request FUNCTION_SET_WEIGHT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
129
140
  end
130
141
 
131
142
  # Returns the threshold as set by BrickletLoadCell#set_weight_callback_threshold.
132
143
  def get_weight_callback_threshold
133
- send_request FUNCTION_GET_WEIGHT_CALLBACK_THRESHOLD, [], '', 9, 'k l l'
144
+ check_validity
145
+
146
+ send_request FUNCTION_GET_WEIGHT_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
134
147
  end
135
148
 
136
149
  # Sets the period with which the threshold callback
@@ -143,12 +156,16 @@ module Tinkerforge
143
156
  #
144
157
  # keeps being reached.
145
158
  def set_debounce_period(debounce)
146
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
159
+ check_validity
160
+
161
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
147
162
  end
148
163
 
149
164
  # Returns the debounce period as set by BrickletLoadCell#set_debounce_period.
150
165
  def get_debounce_period
151
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
166
+ check_validity
167
+
168
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
152
169
  end
153
170
 
154
171
  # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
@@ -157,27 +174,37 @@ module Tinkerforge
157
174
  # Setting the length to 1 will turn the averaging off. With less
158
175
  # averaging, there is more noise on the data.
159
176
  def set_moving_average(average)
160
- send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 0, ''
177
+ check_validity
178
+
179
+ send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 8, ''
161
180
  end
162
181
 
163
182
  # Returns the length moving average as set by BrickletLoadCell#set_moving_average.
164
183
  def get_moving_average
165
- send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 1, 'C'
184
+ check_validity
185
+
186
+ send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 9, 'C'
166
187
  end
167
188
 
168
189
  # Turns the LED on.
169
190
  def led_on
170
- send_request FUNCTION_LED_ON, [], '', 0, ''
191
+ check_validity
192
+
193
+ send_request FUNCTION_LED_ON, [], '', 8, ''
171
194
  end
172
195
 
173
196
  # Turns the LED off.
174
197
  def led_off
175
- send_request FUNCTION_LED_OFF, [], '', 0, ''
198
+ check_validity
199
+
200
+ send_request FUNCTION_LED_OFF, [], '', 8, ''
176
201
  end
177
202
 
178
203
  # Returns *true* if the led is on, *false* otherwise.
179
204
  def is_led_on
180
- send_request FUNCTION_IS_LED_ON, [], '', 1, '?'
205
+ check_validity
206
+
207
+ send_request FUNCTION_IS_LED_ON, [], '', 9, '?'
181
208
  end
182
209
 
183
210
  # To calibrate your Load Cell Bricklet you have to
@@ -191,12 +218,16 @@ module Tinkerforge
191
218
  # We recommend to use the Brick Viewer for calibration, you don't need
192
219
  # to call this function in your source code.
193
220
  def calibrate(weight)
194
- send_request FUNCTION_CALIBRATE, [weight], 'L', 0, ''
221
+ check_validity
222
+
223
+ send_request FUNCTION_CALIBRATE, [weight], 'L', 8, ''
195
224
  end
196
225
 
197
226
  # Sets the currently measured weight as tare weight.
198
227
  def tare
199
- send_request FUNCTION_TARE, [], '', 0, ''
228
+ check_validity
229
+
230
+ send_request FUNCTION_TARE, [], '', 8, ''
200
231
  end
201
232
 
202
233
  # The measurement rate and gain are configurable.
@@ -218,24 +249,30 @@ module Tinkerforge
218
249
  # We recommend to use the Brick Viewer for configuration, you don't need
219
250
  # to call this function in your source code.
220
251
  def set_configuration(rate, gain)
221
- send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 0, ''
252
+ check_validity
253
+
254
+ send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 8, ''
222
255
  end
223
256
 
224
257
  # Returns the configuration as set by BrickletLoadCell#set_configuration.
225
258
  def get_configuration
226
- send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C'
259
+ check_validity
260
+
261
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
227
262
  end
228
263
 
229
264
  # Returns the UID, the UID where the Bricklet is connected to,
230
265
  # the position, the hardware and firmware version as well as the
231
266
  # device identifier.
232
267
  #
233
- # The position can be 'a', 'b', 'c' or 'd'.
268
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
269
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
270
+ # position 'z'.
234
271
  #
235
272
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
236
273
  # |device_identifier_constant|
237
274
  def get_identity
238
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
275
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
239
276
  end
240
277
 
241
278
  # 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 2021-05-06. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.29 #
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 weight with a load cell
14
16
  class BrickletLoadCellV2 < Device
@@ -77,7 +79,7 @@ module Tinkerforge
77
79
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
78
80
  # the IP Connection <tt>ipcon</tt>.
79
81
  def initialize(uid, ipcon)
80
- super uid, ipcon
82
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
81
83
 
82
84
  @api_version = [2, 0, 0]
83
85
 
@@ -105,18 +107,21 @@ 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_WEIGHT] = 'l'
110
+ @callback_formats[CALLBACK_WEIGHT] = [12, 'l']
109
111
 
112
+ @ipcon.add_device self
110
113
  end
111
114
 
112
- # Returns the currently measured weight in grams.
115
+ # Returns the currently measured weight.
113
116
  #
114
117
  #
115
118
  # If you want to get the value periodically, it is recommended to use the
116
119
  # CALLBACK_WEIGHT callback. You can set the callback configuration
117
120
  # with BrickletLoadCellV2#set_weight_callback_configuration.
118
121
  def get_weight
119
- send_request FUNCTION_GET_WEIGHT, [], '', 4, 'l'
122
+ check_validity
123
+
124
+ send_request FUNCTION_GET_WEIGHT, [], '', 12, 'l'
120
125
  end
121
126
 
122
127
  # The period is the period with which the CALLBACK_WEIGHT callback is triggered
@@ -145,12 +150,16 @@ module Tinkerforge
145
150
  #
146
151
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
147
152
  def set_weight_callback_configuration(period, value_has_to_change, option, min, max)
148
- send_request FUNCTION_SET_WEIGHT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
153
+ check_validity
154
+
155
+ send_request FUNCTION_SET_WEIGHT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
149
156
  end
150
157
 
151
158
  # Returns the callback configuration as set by BrickletLoadCellV2#set_weight_callback_configuration.
152
159
  def get_weight_callback_configuration
153
- send_request FUNCTION_GET_WEIGHT_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
160
+ check_validity
161
+
162
+ send_request FUNCTION_GET_WEIGHT_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
154
163
  end
155
164
 
156
165
  # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
@@ -159,23 +168,31 @@ module Tinkerforge
159
168
  # Setting the length to 1 will turn the averaging off. With less
160
169
  # averaging, there is more noise on the data.
161
170
  def set_moving_average(average)
162
- send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'S', 0, ''
171
+ check_validity
172
+
173
+ send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'S', 8, ''
163
174
  end
164
175
 
165
176
  # Returns the length moving average as set by BrickletLoadCellV2#set_moving_average.
166
177
  def get_moving_average
167
- send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 2, 'S'
178
+ check_validity
179
+
180
+ send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 10, 'S'
168
181
  end
169
182
 
170
183
  # Configures the info LED to be either turned off, turned on, or blink in
171
184
  # heartbeat mode.
172
185
  def set_info_led_config(config)
173
- send_request FUNCTION_SET_INFO_LED_CONFIG, [config], 'C', 0, ''
186
+ check_validity
187
+
188
+ send_request FUNCTION_SET_INFO_LED_CONFIG, [config], 'C', 8, ''
174
189
  end
175
190
 
176
191
  # Returns the LED configuration as set by BrickletLoadCellV2#set_info_led_config
177
192
  def get_info_led_config
178
- send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 1, 'C'
193
+ check_validity
194
+
195
+ send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 9, 'C'
179
196
  end
180
197
 
181
198
  # To calibrate your Load Cell Bricklet 2.0 you have to
@@ -189,12 +206,16 @@ module Tinkerforge
189
206
  # We recommend to use the Brick Viewer for calibration, you don't need
190
207
  # to call this function in your source code.
191
208
  def calibrate(weight)
192
- send_request FUNCTION_CALIBRATE, [weight], 'L', 0, ''
209
+ check_validity
210
+
211
+ send_request FUNCTION_CALIBRATE, [weight], 'L', 8, ''
193
212
  end
194
213
 
195
214
  # Sets the currently measured weight as tare weight.
196
215
  def tare
197
- send_request FUNCTION_TARE, [], '', 0, ''
216
+ check_validity
217
+
218
+ send_request FUNCTION_TARE, [], '', 8, ''
198
219
  end
199
220
 
200
221
  # The measurement rate and gain are configurable.
@@ -210,12 +231,16 @@ module Tinkerforge
210
231
  # is best). If you don't know what all of this means you should keep it at
211
232
  # 128x, it will most likely be correct.
212
233
  def set_configuration(rate, gain)
213
- send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 0, ''
234
+ check_validity
235
+
236
+ send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 8, ''
214
237
  end
215
238
 
216
239
  # Returns the configuration as set by BrickletLoadCellV2#set_configuration.
217
240
  def get_configuration
218
- send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C'
241
+ check_validity
242
+
243
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
219
244
  end
220
245
 
221
246
  # Returns the error count for the communication between Brick and Bricklet.
@@ -230,7 +255,9 @@ module Tinkerforge
230
255
  # The errors counts are for errors that occur on the Bricklet side. All
231
256
  # Bricks have a similar function that returns the errors on the Brick side.
232
257
  def get_spitfp_error_count
233
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
258
+ check_validity
259
+
260
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
234
261
  end
235
262
 
236
263
  # Sets the bootloader mode and returns the status after the requested
@@ -243,12 +270,16 @@ module Tinkerforge
243
270
  # This function is used by Brick Viewer during flashing. It should not be
244
271
  # necessary to call it in a normal user program.
245
272
  def set_bootloader_mode(mode)
246
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
273
+ check_validity
274
+
275
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
247
276
  end
248
277
 
249
278
  # Returns the current bootloader mode, see BrickletLoadCellV2#set_bootloader_mode.
250
279
  def get_bootloader_mode
251
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
280
+ check_validity
281
+
282
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
252
283
  end
253
284
 
254
285
  # Sets the firmware pointer for BrickletLoadCellV2#write_firmware. The pointer has
@@ -258,7 +289,9 @@ module Tinkerforge
258
289
  # This function is used by Brick Viewer during flashing. It should not be
259
290
  # necessary to call it in a normal user program.
260
291
  def set_write_firmware_pointer(pointer)
261
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
292
+ check_validity
293
+
294
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
262
295
  end
263
296
 
264
297
  # Writes 64 Bytes of firmware at the position as written by
@@ -270,7 +303,9 @@ module Tinkerforge
270
303
  # This function is used by Brick Viewer during flashing. It should not be
271
304
  # necessary to call it in a normal user program.
272
305
  def write_firmware(data)
273
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
306
+ check_validity
307
+
308
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
274
309
  end
275
310
 
276
311
  # Sets the status LED configuration. By default the LED shows
@@ -281,22 +316,28 @@ module Tinkerforge
281
316
  #
282
317
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
283
318
  def set_status_led_config(config)
284
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
319
+ check_validity
320
+
321
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
285
322
  end
286
323
 
287
324
  # Returns the configuration as set by BrickletLoadCellV2#set_status_led_config
288
325
  def get_status_led_config
289
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
326
+ check_validity
327
+
328
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
290
329
  end
291
330
 
292
- # Returns the temperature in °C as measured inside the microcontroller. The
331
+ # Returns the temperature as measured inside the microcontroller. The
293
332
  # value returned is not the ambient temperature!
294
333
  #
295
334
  # The temperature is only proportional to the real temperature and it has bad
296
335
  # accuracy. Practically it is only useful as an indicator for
297
336
  # temperature changes.
298
337
  def get_chip_temperature
299
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
338
+ check_validity
339
+
340
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
300
341
  end
301
342
 
302
343
  # Calling this function will reset the Bricklet. All configurations
@@ -306,7 +347,9 @@ module Tinkerforge
306
347
  # calling functions on the existing ones will result in
307
348
  # undefined behavior!
308
349
  def reset
309
- send_request FUNCTION_RESET, [], '', 0, ''
350
+ check_validity
351
+
352
+ send_request FUNCTION_RESET, [], '', 8, ''
310
353
  end
311
354
 
312
355
  # Writes a new UID into flash. If you want to set a new UID
@@ -315,25 +358,31 @@ module Tinkerforge
315
358
  #
316
359
  # We recommend that you use Brick Viewer to change the UID.
317
360
  def write_uid(uid)
318
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
361
+ check_validity
362
+
363
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
319
364
  end
320
365
 
321
366
  # Returns the current UID as an integer. Encode as
322
367
  # Base58 to get the usual string version.
323
368
  def read_uid
324
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
369
+ check_validity
370
+
371
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
325
372
  end
326
373
 
327
374
  # Returns the UID, the UID where the Bricklet is connected to,
328
375
  # the position, the hardware and firmware version as well as the
329
376
  # device identifier.
330
377
  #
331
- # 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
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
380
+ # position 'z'.
332
381
  #
333
382
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
334
383
  # |device_identifier_constant|
335
384
  def get_identity
336
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
385
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
337
386
  end
338
387
 
339
388
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.